00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00024 class Diogenes_Icons
00025 {
00028 function Diogenes_Icons($theme = 'gartoon')
00029 {
00030 $this->theme = $theme;
00031 }
00032
00033
00036 function get_icon_themes()
00037 {
00038 $themes = array(
00039 'gartoon' => array(
00040 'action' => array(
00041 'add' => 'action-add.png',
00042 'delete' => 'action-delete.png',
00043 'edit' => 'action-edit.png',
00044 'properties' => 'action-properties.png',
00045 'plugins' => 'action-plugins.png',
00046 'revisions' => 'action-revisions.png',
00047 'rename' => 'action-rename.png',
00048 'remove' => 'action-remove.png',
00049 'update' => 'action-update.png',
00050 'view' => 'action-view.png',
00051 ),
00052 'barrel' => array(
00053 'home' => 'barrel-home.png',
00054 'directory' => 'barrel-directory.png'
00055 ),
00056 'mime' => array(
00057 'audio' => 'mime-audio.png',
00058 'deb' => 'mime-deb.png',
00059 'drm' => 'mime-drm.png',
00060 'excel' => 'mime-excel.png',
00061 'html' => 'mime-html.png',
00062 'lyx' => 'mime-lyx.png',
00063 'msword' => 'mime-msword.png',
00064 'postscript' => 'mime-postscript.png',
00065 'powerpoint' => 'mime-powerpoint.png',
00066 'pdf' => 'mime-pdf.png',
00067 'image' => 'mime-image.png',
00068 'text' => 'mime-text.png',
00069 'video' => 'mime-video.png',
00070 'compressed' => 'mime-compressed.png',
00071 'unknown' => 'mime-unknown.png',
00072 'xml' => 'mime-xml.png',
00073 ),
00074 'perm' => array(
00075 'public' => 'perm-public.png',
00076 'auth' => 'perm-auth.png',
00077 'user' => 'perm-user.png',
00078 'admin' => 'perm-admin.png',
00079 'forbidden' => 'perm-forbidden.png',
00080 )
00081 )
00082 );
00083
00084 return $themes;
00085 }
00086
00087
00093 function get_icon($category, $name)
00094 {
00095 global $globals;
00096 $maps = $this->get_icon_themes();
00097
00098 if (isset($maps[$this->theme][$category][$name])) {
00099 return $globals->rooturl . "images/".$maps[$this->theme][$category][$name];
00100 } else {
00101 trigger_error("could not find icon for '$name' in category '$category'", E_USER_WARNING);
00102 return false;
00103 }
00104 }
00105
00106
00111 function get_action_icon($action)
00112 {
00113 return $this->get_icon('action', $action);
00114 }
00115
00116
00121 function get_action_icons($actions)
00122 {
00123 $oactions = array();
00124 foreach ($actions as $action)
00125 {
00126 $oaction = $action;
00127 if (isset($action[2]))
00128 {
00129 $oaction[2] = $this->get_action_icon($action[2]);
00130 }
00131 array_push($oactions, $oaction);
00132 }
00133 return $oactions;
00134 }
00135
00136
00141 function get_mime_icon($filename)
00142 {
00143 global $globals;
00144
00145 $type = get_mime_type($filename);
00146
00147 if (preg_match('/^application\/msword$/', $type)) {
00148 $itype = 'msword';
00149 } elseif (preg_match('/^application\/vnd\.ms-powerpoint$/', $type)) {
00150 $itype = 'powerpoint';
00151 } elseif (preg_match('/^application\/vnd\.oma\.drm\.(content|message)$/', $type)) {
00152 $itype = 'drm';
00153 } elseif (preg_match('/^application\/(arj|x-bzip|x-bzip2|x-gzip|x-compressed|zip)$/', $type)) {
00154 $itype = 'compressed';
00155 } elseif (preg_match('/^application\/pdf$/', $type)) {
00156 $itype = 'pdf';
00157 } elseif (preg_match('/^application\/postscript$/', $type)) {
00158 $itype = 'postscript';
00159 } elseif (preg_match('/^application\/x-deb$/', $type)) {
00160 $itype = 'deb';
00161 } elseif (preg_match('/^audio\
00162 $itype = 'audio';
00163 } elseif (preg_match('/^application\/vnd\.ms-excel$/', $type)) {
00164 $itype = 'excel';
00165 } elseif (preg_match('/^image\
00166 $itype = 'image';
00167 } elseif (preg_match('/^text\/html$/', $type)) {
00168 $itype = 'html';
00169 } elseif (preg_match('/^text\/xml$/', $type)) {
00170 $itype = 'xml';
00171 } elseif (preg_match('/^text\/x-lyx$/', $type)) {
00172 $itype = 'lyx';
00173 } elseif (preg_match('/^text\
00174 $itype = 'text';
00175 } elseif (preg_match('/^video\
00176 $itype = 'video';
00177 } else {
00178 $itype = 'unknown';
00179 }
00180
00181 return $this->get_icon('mime', $itype);
00182 }
00183 }
00184
00185 ?>