move mime_magic class to Api\MimeMagic

This commit is contained in:
Ralf Becker 2016-03-05 12:33:37 +00:00
parent a24c1121a2
commit 7989d702dd
6 changed files with 2256 additions and 2231 deletions

2239
api/src/MimeMagic.php Normal file

File diff suppressed because it is too large Load Diff

View File

@ -14,7 +14,6 @@
namespace EGroupware\Api; namespace EGroupware\Api;
// explicitly import old phpgwapi classes used: // explicitly import old phpgwapi classes used:
use mime_magic;
use common; use common;
use html; use html;
use HTTP_WebDAV_Server; use HTTP_WebDAV_Server;
@ -1213,8 +1212,8 @@ class Vfs extends Vfs\StreamWrapper
if (!($img=common::image('etemplate',$icon='mime'.$size.'_'.$mime_full)) && if (!($img=common::image('etemplate',$icon='mime'.$size.'_'.$mime_full)) &&
// check mime-alias-map before falling back to more generic icons // check mime-alias-map before falling back to more generic icons
!(isset(mime_magic::$mime_alias_map[$mime_type]) && !(isset(MimeMagic::$mime_alias_map[$mime_type]) &&
($img=common::image('etemplate',$icon='mime'.$size.'_'.str_replace('/','_',mime_magic::$mime_alias_map[$mime_full])))) && ($img=common::image('etemplate',$icon='mime'.$size.'_'.str_replace('/','_',MimeMagic::$mime_alias_map[$mime_full])))) &&
!($img=common::image('etemplate',$icon='mime'.$size.'_'.$mime_part))) !($img=common::image('etemplate',$icon='mime'.$size.'_'.$mime_part)))
{ {
$img = common::image('etemplate',$icon='mime'.$size.'_unknown'); $img = common::image('etemplate',$icon='mime'.$size.'_unknown');
@ -1227,7 +1226,7 @@ class Vfs extends Vfs\StreamWrapper
{ {
return 'etemplate/'.$icon; return 'etemplate/'.$icon;
} }
return html::image('etemplate',$icon,mime_magic::mime2label($mime_type)); return html::image('etemplate',$icon,MimeMagic::mime2label($mime_type));
} }
/** /**

View File

@ -16,10 +16,6 @@ namespace EGroupware\Api\Vfs\Sqlfs;
use EGroupware\Api\Vfs; use EGroupware\Api\Vfs;
use EGroupware\Api; use EGroupware\Api;
// explicitly import old phpgwapi classes used:
use mime_magic;
/** /**
* EGroupware API: VFS - new DB based VFS stream wrapper * EGroupware API: VFS - new DB based VFS stream wrapper
* *
@ -359,7 +355,7 @@ class StreamWrapper implements Vfs\StreamWrapperIface
$values = array( $values = array(
'fs_size' => $this->stream_tell(), 'fs_size' => $this->stream_tell(),
// todo: analyse the file for the mime-type // todo: analyse the file for the mime-type
'fs_mime' => mime_magic::filename2mime($this->opened_path), 'fs_mime' => Api\MimeMagic::filename2mime($this->opened_path),
'fs_id' => $this->opened_fs_id, 'fs_id' => $this->opened_fs_id,
'fs_modifier' => Vfs::$user, 'fs_modifier' => Vfs::$user,
'fs_modified' => self::_pdo_timestamp(time()), 'fs_modified' => self::_pdo_timestamp(time()),

View File

@ -14,9 +14,7 @@
namespace EGroupware\Api\Vfs\Sqlfs; namespace EGroupware\Api\Vfs\Sqlfs;
use EGroupware\Api\Vfs; use EGroupware\Api\Vfs;
use EGroupware\Api;
// explicitly import old phpgwapi classes used:
use mime_magic;
/** /**
* sqlfs stream wrapper utilities: migration db-fs, fsck * sqlfs stream wrapper utilities: migration db-fs, fsck
@ -317,7 +315,7 @@ class Utils extends StreamWrapper
if ($check_only) if ($check_only)
{ {
$msgs[] = lang('Found unconnected %1 %2!', $msgs[] = lang('Found unconnected %1 %2!',
mime_magic::mime2label($row['fs_mime']), Api\MimeMagic::mime2label($row['fs_mime']),
Vfs::decodePath($row['fs_name']).' (#'.$row['fs_id'].')'); Vfs::decodePath($row['fs_name']).' (#'.$row['fs_id'].')');
continue; continue;
} }
@ -349,14 +347,14 @@ class Utils extends StreamWrapper
))) )))
{ {
$msgs[] = lang('Moved unconnected %1 %2 to %3.', $msgs[] = lang('Moved unconnected %1 %2 to %3.',
mime_magic::mime2label($row['fs_mime']), Api\MimeMagic::mime2label($row['fs_mime']),
Vfs::decodePath($row['fs_name']).' (#'.$row['fs_id'].')', Vfs::decodePath($row['fs_name']).' (#'.$row['fs_id'].')',
self::LOST_N_FOUND); self::LOST_N_FOUND);
} }
else else
{ {
$msgs[] = lang('Failed to move unconnected %1 %2 to %3!', $msgs[] = lang('Failed to move unconnected %1 %2 to %3!',
mime_magic::mime2label($row['fs_mime']), Vfs::decodePath($row['fs_name']), self::LOST_N_FOUND); Api\MimeMagic::mime2label($row['fs_mime']), Vfs::decodePath($row['fs_name']), self::LOST_N_FOUND);
} }
} }
if ($check_only && $msgs) if ($check_only && $msgs)

View File

@ -14,9 +14,7 @@
namespace EGroupware\Api\Vfs; namespace EGroupware\Api\Vfs;
use EGroupware\Api\Vfs; use EGroupware\Api\Vfs;
use EGroupware\Api;
// explicitly import old phpgwapi classes used:
use mime_magic;
/** /**
* eGroupWare API: VFS - stream wrapper interface * eGroupWare API: VFS - stream wrapper interface
@ -848,7 +846,7 @@ class StreamWrapper implements StreamWrapperIface
// using EGw's own mime magic (currently only checking the extension!) // using EGw's own mime magic (currently only checking the extension!)
if (!$mime) if (!$mime)
{ {
$mime = mime_magic::filename2mime(self::parse_url($url,PHP_URL_PATH)); $mime = Api\MimeMagic::filename2mime(self::parse_url($url,PHP_URL_PATH));
} }
//error_log(__METHOD__."($path,$recheck) mime=$mime"); //error_log(__METHOD__."($path,$recheck) mime=$mime");
return $mime; return $mime;

File diff suppressed because it is too large Load Diff