Author: ralfbecker
New Revision: 26807
URL: http://www.egroupware.org/viewvc/egroupware?rev=3D26807&view=3Drev
Log:
method to create user friendly label for a mime type, eg. “PDF file (applic=
ation/pdf)”
Modified:
trunk/etemplate/inc/class.vfs_widget.inc.php
trunk/phpgwapi/inc/class.mime_magic.inc.php
Modified: trunk/etemplate/inc/class.vfs_widget.inc.php
URL: http://www.egroupware.org/viewvc/egroupware/trunk/etemplate/inc/class.=
vfs_widget.inc.php?rev=3D26807&r1=3D26806&r2=3D26807&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
— trunk/etemplate/inc/class.vfs_widget.inc.php (original)
+++ trunk/etemplate/inc/class.vfs_widget.inc.php Sat Apr 18 11:53:36 2009
@@ -212,14 +212,8 @@
}
//error_log(METHOD."() type=3Dvfs-mime: value=3D".array2string($va=
lue).": mime=3D$mime, path=3D$path");
$cell[‘type’] =3D ‘image’;
-
if ($mime =3D=3D egw_vfs::DIR_MIME_TYPE) -
{ -
$cell['label'] =3D lang('Directory'); -
} -
else -
{ -
$cell['label'] =3D lang('%1 file',strtoupper(mime_magic::mime2ext($mi=
me))).’ (’.$mime.’)’;
-
}
-
$cell['label'] =3D mime_magic::mime2label($mime); -
list($mime_main,$mime_sub) =3D explode('/',$mime); if ($mime_main =3D=3D 'egw') {
Modified: trunk/phpgwapi/inc/class.mime_magic.inc.php
URL: http://www.egroupware.org/viewvc/egroupware/trunk/phpgwapi/inc/class.m=
ime_magic.inc.php?rev=3D26807&r1=3D26806&r2=3D26807&view=3Ddiff
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D
— trunk/phpgwapi/inc/class.mime_magic.inc.php (original)
+++ trunk/phpgwapi/inc/class.mime_magic.inc.php Sat Apr 18 11:53:36 2009
@@ -27,6 +27,27 @@
class mime_magic
{
/**
-
- Get a user friendly label for a mime type: e.g. “PDF file (application=
/pdf)”
- Get a user friendly label for a mime type: e.g. “PDF file (application=
-
-
- @param string $mime
-
- @return string
- */
- public function mime2label($mime)
- {
-
$mime =3D strtolower($mime); -
if ($mime =3D=3D egw_vfs::DIR_MIME_TYPE) -
{ -
return lang('Directory'); -
} -
elseif (!($ext =3D self::mime2ext($mime))) -
{ -
return $mime; -
} -
return lang('%1 file',strtoupper($ext)).' ('.$mime.')'; - }
- /**
- Convert a file extension to a MIME type
- This is the simplest MIME type guessing function - rough but fast.
@@ -92,6 +113,7 @@
*/
public static function mime2ext($type)
{
-
$type =3D strtolower($type); $key =3D array_search($type, self::$mime_extension_map); if (empty($type) || $key =3D=3D=3D false) {
@@ -294,7 +316,7 @@
‘odt’ =3D> ‘application/vnd.oasis.opendocument.text’,
‘odp’ =3D> ‘application/vnd.oasis.opendocument.presentation’,
‘ods’ =3D> ‘application/vnd.oasis.opendocument.spreadsheet’,
-
'patch' =3D> 'text/diff',
-
'patch' =3D> 'text/x-diff', 'pbm' =3D> 'image/x-portable-bitmap', 'pdb' =3D> 'chemical/x-pdb', 'pdf' =3D> 'application/pdf',
Stay on top of everything new and different, both inside and
around Java ™ technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today.
Use priority code J9JMT32. http://p.sf.net/sfu/p
eGroupWare-cvs mailing list
eGroupWare-cvs@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/egroupware-cvs