3 * Copyright (C) 2003-2004 Polytechnique.org
4 * http://opensource.polytechnique.org/
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 /** This class describes Diogenes' icons.
26 /** Construct an object to manipulate Diogenes's icons.
28 function DiogenesIcons($theme = 'gartoon')
30 $this->theme
= $theme;
34 /** Return the available icon themes.
36 function get_icon_themes()
41 'add' => 'action-add.png',
42 'delete' => 'action-delete.png',
43 'edit' => 'action-edit.png',
44 'properties' => 'action-properties.png',
45 'plugins' => 'action-plugins.png',
46 'revisions' => 'action-revisions.png',
47 'rename' => 'action-rename.png',
48 'remove' => 'action-remove.png',
49 'update' => 'action-update.png',
50 'view' => 'action-view.png',
53 'home' => 'barrel-home.png',
54 'directory' => 'barrel-directory.png'
57 'audio' => 'mime-audio.png',
58 'deb' => 'mime-deb.png',
59 'drm' => 'mime-drm.png',
60 'excel' => 'mime-excel.png',
61 'html' => 'mime-html.png',
62 'lyx' => 'mime-lyx.png',
63 'msword' => 'mime-msword.png',
64 'postscript' => 'mime-postscript.png',
65 'powerpoint' => 'mime-powerpoint.png',
66 'pdf' => 'mime-pdf.png',
67 'image' => 'mime-image.png',
68 'text' => 'mime-text.png',
69 'video' => 'mime-video.png',
70 'compressed' => 'mime-compressed.png',
71 'unknown' => 'mime-unknown.png',
72 'xml' => 'mime-xml.png',
75 'public' => 'perm-public.png',
76 'auth' => 'perm-auth.png',
77 'user' => 'perm-user.png',
78 'admin' => 'perm-admin.png',
79 'forbidden' => 'perm-forbidden.png',
88 /** Return the icon associated with an action.
90 * @param $category the icon category
91 * @param $name the icon name
93 function get_icon($category, $name)
96 $maps = $this->get_icon_themes();
98 if (isset($maps[$this->theme
][$category][$name])) {
99 return $globals->rooturl
. "images/".$maps[$this->theme
][$category][$name];
101 trigger_error("could not find icon for '$name' in category '$category'", E_USER_WARNING
);
107 /** Return the icon associated with an action.
109 * @param $action the action we are describing
111 function get_action_icon($action)
113 return $this->get_icon('action', $action);
117 /** Return the icons associated with an array of actions
119 * @param $actions the actions we are describing
121 function get_action_icons($actions)
124 foreach ($actions as $action)
127 if (isset($action[2]))
129 $oaction[2] = $this->get_action_icon($action[2]);
131 array_push($oactions, $oaction);
137 /** Return the icon associated with a file's MIME content-type
139 * @param $filename the file we are describing
141 function get_mime_icon($filename)
145 $type = get_mime_type($filename);
147 if (preg_match('/^application\/msword$/', $type)) {
149 } elseif (preg_match('/^application\/vnd\.ms-powerpoint$/', $type)) {
150 $itype = 'powerpoint';
151 } elseif (preg_match('/^application\/vnd\.oma\.drm\.(content|message)$/', $type)) {
153 } elseif (preg_match('/^application\/(arj|x-bzip|x-bzip2|x-gzip|x-compressed|zip)$/', $type)) {
154 $itype = 'compressed';
155 } elseif (preg_match('/^application\/pdf$/', $type)) {
157 } elseif (preg_match('/^application\/postscript$/', $type)) {
158 $itype = 'postscript';
159 } elseif (preg_match('/^application\/x-deb$/', $type)) {
161 } elseif (preg_match('/^audio\//', $type)) {
163 } elseif (preg_match('/^application\/vnd\.ms-excel$/', $type)) {
165 } elseif (preg_match('/^image\//', $type)) {
167 } elseif (preg_match('/^text\/html$/', $type)) {
169 } elseif (preg_match('/^text\/xml$/', $type)) {
171 } elseif (preg_match('/^text\/x-lyx$/', $type)) {
173 } elseif (preg_match('/^text\//', $type)) {
175 } elseif (preg_match('/^video\//', $type)) {
181 return $this->get_icon('mime', $itype);