making whole mime_magic class static, for easier use and better caching by byte code caches

This commit is contained in:
Ralf Becker 2009-04-17 06:25:33 +00:00
parent 7233f87413
commit f12a0dc307
3 changed files with 945 additions and 837 deletions

File diff suppressed because it is too large Load Diff

View File

@ -304,16 +304,11 @@ class sqlfs_stream_wrapper implements iface_stream_wrapper
{ {
$this->stream_seek(0,SEEK_END); $this->stream_seek(0,SEEK_END);
static $mime_magic;
if (is_null($mime_magic))
{
$mime_magic = new mime_magic();
}
// we need to update the mime-type, size and content (if STORE2DB) // we need to update the mime-type, size and content (if STORE2DB)
$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' => mime_magic::filename2mime($this->opened_path),
'fs_id' => $this->opened_fs_id, 'fs_id' => $this->opened_fs_id,
'fs_modifier' => egw_vfs::$user, 'fs_modifier' => egw_vfs::$user,
'fs_modified' => self::_pdo_timestamp(time()), 'fs_modified' => self::_pdo_timestamp(time()),

View File

@ -617,15 +617,9 @@ class vfs_stream_wrapper implements iface_stream_wrapper
$mime = mime_content_type($path); $mime = mime_content_type($path);
} }
// using eGW's own mime magic // using eGW's own mime magic
// ToDo: rework mime_magic as all methods cound be static!
if (!$mime) if (!$mime)
{ {
static $mime_magic; $mime = mime_magic::filename2mime(parse_url($url,PHP_URL_PATH));
if (is_null($mime_magic))
{
$mime_magic = new mime_magic();
}
$mime = $mime_magic->filename2mime(parse_url($url,PHP_URL_PATH));
} }
//error_log(__METHOD__."($path) mime=$mime"); //error_log(__METHOD__."($path) mime=$mime");
return $mime; return $mime;
@ -855,7 +849,7 @@ class vfs_stream_wrapper implements iface_stream_wrapper
* @param boolean $do_symlink=true is a direct match allowed, default yes (must be false for a lstat or readlink!) * @param boolean $do_symlink=true is a direct match allowed, default yes (must be false for a lstat or readlink!)
* @return string target or path, if path not found * @return string target or path, if path not found
*/ */
static protected function symlinkCache_resolve($path,$do_symlink=true) static public function symlinkCache_resolve($path,$do_symlink=true)
{ {
// remove vfs scheme, but no other schemes (eg. filesystem!) // remove vfs scheme, but no other schemes (eg. filesystem!)
if ($path[0] != '/' && parse_url($path,PHP_URL_SCHEME) == self::SCHEME) if ($path[0] != '/' && parse_url($path,PHP_URL_SCHEME) == self::SCHEME)