リビジョン | 297 (tree) |
---|---|
日時 | 2010-10-20 07:34:44 |
作者 | kmorimatsu |
1) The new class, tables, contains mime() and language() methods.
2) media::gd()
3) _CONF_THUMBNAIL_SIZE etc
@@ -23,7 +23,7 @@ | ||
23 | 23 | self::member_id($mid); |
24 | 24 | self::$accepted=preg_split('/[^a-zA-Z0-9]+/',strtolower(_CONF_ALLOW_FILE_TYPES),-1,PREG_SPLIT_NO_EMPTY); |
25 | 25 | // Thumbnail |
26 | - if (!defined('_CONF_THUMBNAIL_SIZE')) define('_CONF_THUMBNAIL_SIZE',64); | |
26 | + if (!defined('_CONF_THUMBNAIL_VIEW_SIZE')) define('_CONF_THUMBNAIL_ADMIN_SIZE',80); | |
27 | 27 | } |
28 | 28 | static private function member_id($set=false){ |
29 | 29 | static $mid; |
@@ -65,10 +65,10 @@ | ||
65 | 65 | return error::note('_ADMIN_MEDIA_INVALID_FILENAME'); |
66 | 66 | } |
67 | 67 | // Get image information and thumbnail if possible |
68 | - $mime=self::mime($m[2]); | |
68 | + $mime=tables::mime($m[2]); | |
69 | 69 | $xml=new SimpleXMLElement(_XML_BLANC); |
70 | 70 | if (preg_match('#^image/#i',$mime)) { |
71 | - $gd=self::gd($file['tmp_name'],$mime); | |
71 | + $gd=media::gd($file['tmp_name'],$mime); | |
72 | 72 | if ($gd) { |
73 | 73 | $thumbnail=$gd[2]; |
74 | 74 | } else { |
@@ -108,75 +108,6 @@ | ||
108 | 108 | error::note('_ADMIN_MEDIA_UPLOAD_FAILED'); |
109 | 109 | } |
110 | 110 | } |
111 | - static public function gd($file,$mime){ | |
112 | - // Check if GD is available. | |
113 | - switch ($mime) { | |
114 | - case 'image/gif': | |
115 | - $func='imagecreatefromgif'; | |
116 | - break; | |
117 | - case 'image/jpeg': | |
118 | - $func='imagecreatefromjpeg'; | |
119 | - break; | |
120 | - case 'image/png': | |
121 | - $func='imagecreatefrompng'; | |
122 | - break; | |
123 | - case 'image/bmp': | |
124 | - $func='imagecreatefromwbmp'; | |
125 | - break; | |
126 | - case 'image/x-xbitmap': | |
127 | - $func='imagecreatefromxbm'; | |
128 | - break; | |
129 | - case 'image/x-xpixmap': | |
130 | - $func='imagecreatefromxpm'; | |
131 | - break; | |
132 | - default: | |
133 | - return false; | |
134 | - } | |
135 | - if (!function_exists($func)) return false; | |
136 | - $image=call_user_func_array($func,array($file)); | |
137 | - if (!$image) return false; | |
138 | - // Determine the size. | |
139 | - $width=imagesx($image); | |
140 | - $height=imagesy($image); | |
141 | - // Decide the new size. | |
142 | - if ($width>$height) { | |
143 | - $new_width=intval(_CONF_THUMBNAIL_SIZE); | |
144 | - $new_height=intval($height * _CONF_THUMBNAIL_SIZE / $width); | |
145 | - } else { | |
146 | - $new_width=intval($width * _CONF_THUMBNAIL_SIZE / $height); | |
147 | - $new_height=intval(_CONF_THUMBNAIL_SIZE); | |
148 | - } | |
149 | - // Create new image. | |
150 | - $new_image = ImageCreateTrueColor($new_width, $new_height); | |
151 | - ImageCopyResampled($new_image,$image,0,0,0,0,$new_width,$new_height,$width,$height); | |
152 | - $types=imagetypes(); | |
153 | - if ($types & IMG_PNG) { | |
154 | - $thumbnail=array( | |
155 | - 'mime'=>'image/png', | |
156 | - 'width'=>$new_width, | |
157 | - 'height'=>$new_height, | |
158 | - 'file'=>self::gd_image('imagepng',$new_image)); | |
159 | - } elseif ($types & IMG_JPG) { | |
160 | - $thumbnail=array( | |
161 | - 'mime'=>'image/png', | |
162 | - 'width'=>$new_width, | |
163 | - 'height'=>$new_height, | |
164 | - 'file'=>self::gd_image('imagejpeg',$new_image)); | |
165 | - } elseif ($types & IMG_GIF) { | |
166 | - $thumbnail=array( | |
167 | - 'mime'=>'image/png', | |
168 | - 'width'=>$new_width, | |
169 | - 'height'=>$new_height, | |
170 | - 'file'=>self::gd_image('imagegif',$new_image)); | |
171 | - } else $thumbnail=false; | |
172 | - // Return original size and thumbnail. | |
173 | - return array($width,$height,$thumbnail); | |
174 | - } | |
175 | - static public function gd_image($func,&$res){ | |
176 | - ob_start(); | |
177 | - call_user_func_array($func,array($res)); | |
178 | - return ob_get_clean(); | |
179 | - } | |
180 | 111 | static public function uploaded_file($info=false){ |
181 | 112 | static $cache; |
182 | 113 | if (!isset($cache)) { |
@@ -206,180 +137,22 @@ | ||
206 | 137 | if (substr($row['mime'],0,6)=='image/') { |
207 | 138 | $row['type']='image'; |
208 | 139 | if (empty($row['twidth'])) { |
209 | - if ($row['width']<$row['height']) { | |
210 | - $row['twidth']=intval($row['width'] * _CONF_THUMBNAIL_SIZE / $row['height']); | |
211 | - $row['theight']=intval(_CONF_THUMBNAIL_SIZE); | |
212 | - } else { | |
213 | - $row['theight']=intval($row['height'] * _CONF_THUMBNAIL_SIZE / $row['width']); | |
214 | - $row['twidth']=intval(_CONF_THUMBNAIL_SIZE); | |
215 | - } | |
216 | - | |
140 | + $width=$row['width']; | |
141 | + $height=$row['height']; | |
142 | + } else { | |
143 | + $width=$row['twidth']; | |
144 | + $height=$row['theight']; | |
217 | 145 | } |
146 | + if ($width<$height) { | |
147 | + $row['twidth']=intval($width * _CONF_THUMBNAIL_ADMIN_SIZE / $height); | |
148 | + $row['theight']=intval(_CONF_THUMBNAIL_ADMIN_SIZE); | |
149 | + } else { | |
150 | + $row['theight']=intval($height * _CONF_THUMBNAIL_ADMIN_SIZE / $width); | |
151 | + $width=intval(_CONF_THUMBNAIL_ADMIN_SIZE); | |
152 | + } | |
218 | 153 | $row['thumbnail']='?action=media.thumbnail&file='.$row['file']; |
219 | 154 | } else { |
220 | 155 | $row['type']='media'; |
221 | - | |
222 | 156 | } |
223 | 157 | } |
224 | - static public function mime($extension){ | |
225 | - static $cache=array ( | |
226 | - 'ez' => 'application/andrew-inset', | |
227 | - 'atom' => 'application/atom+xml', | |
228 | - 'hqx' => 'application/mac-binhex40', | |
229 | - 'cpt' => 'application/mac-compactpro', | |
230 | - 'mathml' => 'application/mathml+xml', | |
231 | - 'doc' => 'application/msword', | |
232 | - 'bin' => 'application/octet-stream', | |
233 | - 'dms' => 'application/octet-stream', | |
234 | - 'lha' => 'application/octet-stream', | |
235 | - 'lzh' => 'application/octet-stream', | |
236 | - 'exe' => 'application/octet-stream', | |
237 | - 'class' => 'application/octet-stream', | |
238 | - 'so' => 'application/octet-stream', | |
239 | - 'dll' => 'application/octet-stream', | |
240 | - 'dmg' => 'application/octet-stream', | |
241 | - 'oda' => 'application/oda', | |
242 | - 'ogg' => 'application/ogg', | |
243 | - 'pdf' => 'application/pdf', | |
244 | - 'ai' => 'application/postscript', | |
245 | - 'eps' => 'application/postscript', | |
246 | - 'ps' => 'application/postscript', | |
247 | - 'rdf' => 'application/rdf+xml', | |
248 | - 'smi' => 'application/smil', | |
249 | - 'smil' => 'application/smil', | |
250 | - 'gram' => 'application/srgs', | |
251 | - 'grxml' => 'application/srgs+xml', | |
252 | - 'mif' => 'application/vnd.mif', | |
253 | - 'xul' => 'application/vnd.mozilla.xul+xml', | |
254 | - 'xls' => 'application/vnd.ms-excel', | |
255 | - 'ppt' => 'application/vnd.ms-powerpoint', | |
256 | - 'wbxml' => 'application/vnd.wap.wbxml', | |
257 | - 'wmlc' => 'application/vnd.wap.wmlc', | |
258 | - 'wmlsc' => 'application/vnd.wap.wmlscriptc', | |
259 | - 'vxml' => 'application/voicexml+xml', | |
260 | - 'bcpio' => 'application/x-bcpio', | |
261 | - 'vcd' => 'application/x-cdlink', | |
262 | - 'pgn' => 'application/x-chess-pgn', | |
263 | - 'cpio' => 'application/x-cpio', | |
264 | - 'csh' => 'application/x-csh', | |
265 | - 'dcr' => 'application/x-director', | |
266 | - 'dir' => 'application/x-director', | |
267 | - 'dxr' => 'application/x-director', | |
268 | - 'dvi' => 'application/x-dvi', | |
269 | - 'spl' => 'application/x-futuresplash', | |
270 | - 'gtar' => 'application/x-gtar', | |
271 | - 'hdf' => 'application/x-hdf', | |
272 | - 'js' => 'application/x-javascript', | |
273 | - 'skp' => 'application/x-koan', | |
274 | - 'skd' => 'application/x-koan', | |
275 | - 'skt' => 'application/x-koan', | |
276 | - 'skm' => 'application/x-koan', | |
277 | - 'latex' => 'application/x-latex', | |
278 | - 'nc' => 'application/x-netcdf', | |
279 | - 'cdf' => 'application/x-netcdf', | |
280 | - 'sh' => 'application/x-sh', | |
281 | - 'shar' => 'application/x-shar', | |
282 | - 'swf' => 'application/x-shockwave-flash', | |
283 | - 'sit' => 'application/x-stuffit', | |
284 | - 'sv4cpio' => 'application/x-sv4cpio', | |
285 | - 'sv4crc' => 'application/x-sv4crc', | |
286 | - 'tar' => 'application/x-tar', | |
287 | - 'tcl' => 'application/x-tcl', | |
288 | - 'tex' => 'application/x-tex', | |
289 | - 'texinfo' => 'application/x-texinfo', | |
290 | - 'texi' => 'application/x-texinfo', | |
291 | - 't' => 'application/x-troff', | |
292 | - 'tr' => 'application/x-troff', | |
293 | - 'roff' => 'application/x-troff', | |
294 | - 'man' => 'application/x-troff-man', | |
295 | - 'me' => 'application/x-troff-me', | |
296 | - 'ms' => 'application/x-troff-ms', | |
297 | - 'ustar' => 'application/x-ustar', | |
298 | - 'src' => 'application/x-wais-source', | |
299 | - 'xhtml' => 'application/xhtml+xml', | |
300 | - 'xht' => 'application/xhtml+xml', | |
301 | - 'xslt' => 'application/xslt+xml', | |
302 | - 'xml' => 'application/xml', | |
303 | - 'xsl' => 'application/xml', | |
304 | - 'dtd' => 'application/xml-dtd', | |
305 | - 'zip' => 'application/zip', | |
306 | - 'au' => 'audio/basic', | |
307 | - 'snd' => 'audio/basic', | |
308 | - 'mid' => 'audio/midi', | |
309 | - 'midi' => 'audio/midi', | |
310 | - 'kar' => 'audio/midi', | |
311 | - 'mpga' => 'audio/mpeg', | |
312 | - 'mp2' => 'audio/mpeg', | |
313 | - 'mp3' => 'audio/mpeg', | |
314 | - 'aif' => 'audio/x-aiff', | |
315 | - 'aiff' => 'audio/x-aiff', | |
316 | - 'aifc' => 'audio/x-aiff', | |
317 | - 'm3u' => 'audio/x-mpegurl', | |
318 | - 'ram' => 'audio/x-pn-realaudio', | |
319 | - 'ra' => 'audio/x-pn-realaudio', | |
320 | - 'rm' => 'application/vnd.rn-realmedia', | |
321 | - 'wav' => 'audio/x-wav', | |
322 | - 'pdb' => 'chemical/x-pdb', | |
323 | - 'xyz' => 'chemical/x-xyz', | |
324 | - 'bmp' => 'image/bmp', | |
325 | - 'cgm' => 'image/cgm', | |
326 | - 'gif' => 'image/gif', | |
327 | - 'ief' => 'image/ief', | |
328 | - 'jpeg' => 'image/jpeg', | |
329 | - 'jpg' => 'image/jpeg', | |
330 | - 'jpe' => 'image/jpeg', | |
331 | - 'png' => 'image/png', | |
332 | - 'svg' => 'image/svg+xml', | |
333 | - 'tiff' => 'image/tiff', | |
334 | - 'tif' => 'image/tiff', | |
335 | - 'djvu' => 'image/vnd.djvu', | |
336 | - 'djv' => 'image/vnd.djvu', | |
337 | - 'wbmp' => 'image/vnd.wap.wbmp', | |
338 | - 'ras' => 'image/x-cmu-raster', | |
339 | - 'ico' => 'image/x-icon', | |
340 | - 'pnm' => 'image/x-portable-anymap', | |
341 | - 'pbm' => 'image/x-portable-bitmap', | |
342 | - 'pgm' => 'image/x-portable-graymap', | |
343 | - 'ppm' => 'image/x-portable-pixmap', | |
344 | - 'rgb' => 'image/x-rgb', | |
345 | - 'xbm' => 'image/x-xbitmap', | |
346 | - 'xpm' => 'image/x-xpixmap', | |
347 | - 'xwd' => 'image/x-xwindowdump', | |
348 | - 'igs' => 'model/iges', | |
349 | - 'iges' => 'model/iges', | |
350 | - 'msh' => 'model/mesh', | |
351 | - 'mesh' => 'model/mesh', | |
352 | - 'silo' => 'model/mesh', | |
353 | - 'wrl' => 'model/vrml', | |
354 | - 'vrml' => 'model/vrml', | |
355 | - 'ics' => 'text/calendar', | |
356 | - 'ifb' => 'text/calendar', | |
357 | - 'css' => 'text/css', | |
358 | - 'html' => 'text/html', | |
359 | - 'htm' => 'text/html', | |
360 | - 'asc' => 'text/plain', | |
361 | - 'txt' => 'text/plain', | |
362 | - 'rtx' => 'text/richtext', | |
363 | - 'rtf' => 'text/rtf', | |
364 | - 'sgml' => 'text/sgml', | |
365 | - 'sgm' => 'text/sgml', | |
366 | - 'tsv' => 'text/tab-separated-values', | |
367 | - 'wml' => 'text/vnd.wap.wml', | |
368 | - 'wmls' => 'text/vnd.wap.wmlscript', | |
369 | - 'etx' => 'text/x-setext', | |
370 | - 'mpeg' => 'video/mpeg', | |
371 | - 'mpg' => 'video/mpeg', | |
372 | - 'mpe' => 'video/mpeg', | |
373 | - 'qt' => 'video/quicktime', | |
374 | - 'mov' => 'video/quicktime', | |
375 | - 'mxu' => 'video/vnd.mpegurl', | |
376 | - 'm4u' => 'video/vnd.mpegurl', | |
377 | - 'avi' => 'video/x-msvideo', | |
378 | - 'movie' => 'video/x-sgi-movie', | |
379 | - 'ice' => 'x-conference/x-cooltalk', | |
380 | - ); | |
381 | - $extension=strtolower($extension); | |
382 | - if (isset($cache[$extension])) return $cache[$extension]; | |
383 | - return 'application/unknown'; | |
384 | - } | |
385 | 158 | } |
\ No newline at end of file |
@@ -0,0 +1,329 @@ | ||
1 | +<?php | |
2 | +/* | |
3 | + * Jeans CMS (GPL license) | |
4 | + * $Id$ | |
5 | + */ | |
6 | + | |
7 | + | |
8 | +class tables extends jeans { | |
9 | + static public function language($shortname){ | |
10 | + switch(strtolower($shortname)){ | |
11 | + case 'af': return 'afrikaans'; | |
12 | + case 'sq': return 'albanian'; | |
13 | + case 'ar-dz': return 'arabic-dz'; | |
14 | + case 'ar-bh': return 'arabic-bh'; | |
15 | + case 'ar-eg': return 'arabic-eg'; | |
16 | + case 'ar-iq': return 'arabic-iq'; | |
17 | + case 'ar-jo': return 'arabic-jo'; | |
18 | + case 'ar-kw': return 'arabic-kw'; | |
19 | + case 'ar-lb': return 'arabic-lb'; | |
20 | + case 'ar-ly': return 'arabic-ly'; | |
21 | + case 'ar-ma': return 'arabic-ma'; | |
22 | + case 'ar-om': return 'arabic-om'; | |
23 | + case 'ar-qa': return 'arabic-qa'; | |
24 | + case 'ar-sa': return 'arabic-sa'; | |
25 | + case 'ar-sy': return 'arabic-sy'; | |
26 | + case 'ar-tn': return 'arabic-tn'; | |
27 | + case 'ar-ae': return 'arabic-ae'; | |
28 | + case 'ar-ye': return 'arabic-ye'; | |
29 | + case 'ar': return 'arabic'; | |
30 | + case 'hy': return 'armenian'; | |
31 | + case 'as': return 'assamese'; | |
32 | + case 'az': return 'azeri'; | |
33 | + case 'az': return 'azeri'; | |
34 | + case 'eu': return 'basque'; | |
35 | + case 'be': return 'belarusian'; | |
36 | + case 'bn': return 'bengali'; | |
37 | + case 'bg': return 'bulgarian'; | |
38 | + case 'ca': return 'catalan'; | |
39 | + case 'zh-cn': return 'chinese-cn'; | |
40 | + case 'zh-hk': return 'chinese-hk'; | |
41 | + case 'zh-mo': return 'chinese-mo'; | |
42 | + case 'zh-sg': return 'chinese-sg'; | |
43 | + case 'zh-tw': return 'chinese-tw'; | |
44 | + case 'zh': return 'chinese'; | |
45 | + case 'hr': return 'croatian'; | |
46 | + case 'cs': return 'chech'; | |
47 | + case 'da': return 'danish'; | |
48 | + case 'div': return 'divehi'; | |
49 | + case 'nl-be': return 'dutch-be'; | |
50 | + case 'nl': return 'dutch'; | |
51 | + case 'en-au': return 'english-au'; | |
52 | + case 'en-bz': return 'english-bz'; | |
53 | + case 'en-ca': return 'english-ca'; | |
54 | + case 'en-ie': return 'english-ie'; | |
55 | + case 'en-jm': return 'english-jm'; | |
56 | + case 'en-nz': return 'english-nz'; | |
57 | + case 'en-ph': return 'english-ph'; | |
58 | + case 'en-za': return 'english-za'; | |
59 | + case 'en-tt': return 'english-tt'; | |
60 | + case 'en-gb': return 'english-gb'; | |
61 | + case 'en-us': return 'english-us'; | |
62 | + case 'en-zw': return 'english-zw'; | |
63 | + case 'en': return 'english'; | |
64 | + case 'et': return 'estonian'; | |
65 | + case 'fo': return 'faeroese'; | |
66 | + case 'fa': return 'farsi'; | |
67 | + case 'fi': return 'finnish'; | |
68 | + case 'fr-be': return 'french-be'; | |
69 | + case 'fr-ca': return 'french-ca'; | |
70 | + case 'fr': return 'french'; | |
71 | + case 'fr-lu': return 'french-lu'; | |
72 | + case 'fr-mc': return 'french-mc'; | |
73 | + case 'fr-ch': return 'french-ch'; | |
74 | + case 'mk': return 'fyro'; | |
75 | + case 'gd': return 'gaelic'; | |
76 | + case 'ka': return 'georgian'; | |
77 | + case 'de-at': return 'german-at'; | |
78 | + case 'de': return 'german'; | |
79 | + case 'de-li': return 'german-li'; | |
80 | + case 'de-lu': return 'german-lu'; | |
81 | + case 'de-ch': return 'german-ch'; | |
82 | + case 'el': return 'greek'; | |
83 | + case 'gu': return 'gujarati'; | |
84 | + case 'he': return 'hebrew'; | |
85 | + case 'hi': return 'hindi'; | |
86 | + case 'hu': return 'hungarian'; | |
87 | + case 'is': return 'icelandic'; | |
88 | + case 'id': return 'indonesian'; | |
89 | + case 'it': return 'italian'; | |
90 | + case 'it-ch': return 'italian-ch'; | |
91 | + case 'ja': return 'japanese'; | |
92 | + case 'kn': return 'kannada'; | |
93 | + case 'kk': return 'kazakh'; | |
94 | + case 'kok': return 'konkani'; | |
95 | + case 'ko': return 'korean'; | |
96 | + case 'kz': return 'kyrgyz'; | |
97 | + case 'lv': return 'latvian'; | |
98 | + case 'lt': return 'lithuanian'; | |
99 | + case 'ms': return 'malay'; | |
100 | + case 'ms': return 'malay'; | |
101 | + case 'ml': return 'malayalam'; | |
102 | + case 'mt': return 'maltese'; | |
103 | + case 'mr': return 'marathi'; | |
104 | + case 'mn': return 'mongolian'; | |
105 | + case 'ne': return 'nepali'; | |
106 | + case 'nb-no': return 'norwegian-nb'; | |
107 | + case 'no': return 'norwegian'; | |
108 | + case 'nn-no': return 'norwegian-nn'; | |
109 | + case 'or': return 'oriya'; | |
110 | + case 'pl': return 'polish'; | |
111 | + case 'pt-br': return 'portuguese-br'; | |
112 | + case 'pt': return 'portuguese'; | |
113 | + case 'pa': return 'punjabi'; | |
114 | + case 'rm': return 'rhaeto'; | |
115 | + case 'ro-md': return 'romanian-md'; | |
116 | + case 'ro': return 'romanian'; | |
117 | + case 'ru-md': return 'russian-md'; | |
118 | + case 'ru': return 'russian'; | |
119 | + case 'sa': return 'sanskrit'; | |
120 | + case 'sr': return 'serbian'; | |
121 | + case 'sr': return 'serbian'; | |
122 | + case 'sk': return 'slovak'; | |
123 | + case 'ls': return 'slovenian'; | |
124 | + case 'sb': return 'sorbian'; | |
125 | + case 'es-ar': return 'spanish-ar'; | |
126 | + case 'es-bo': return 'spanish-bo'; | |
127 | + case 'es-cl': return 'spanish-cl'; | |
128 | + case 'es-co': return 'spanish-co'; | |
129 | + case 'es-cr': return 'spanish-cr'; | |
130 | + case 'es-do': return 'spanish-do'; | |
131 | + case 'es-ec': return 'spanish-ec'; | |
132 | + case 'es-sv': return 'spanish-sv'; | |
133 | + case 'es-gt': return 'spanish-gt'; | |
134 | + case 'es-hn': return 'spanish-hn'; | |
135 | + case 'es': return 'spanish'; | |
136 | + case 'es-mx': return 'spanish-mx'; | |
137 | + case 'es-ni': return 'spanish-ni'; | |
138 | + case 'es-pa': return 'spanish-pa'; | |
139 | + case 'es-py': return 'spanish-py'; | |
140 | + case 'es-pe': return 'spanish-pe'; | |
141 | + case 'es-pr': return 'spanish-pr'; | |
142 | + case 'es': return 'spanish'; | |
143 | + case 'es-us': return 'spanish-us'; | |
144 | + case 'es-uy': return 'spanish-uy'; | |
145 | + case 'es-ve': return 'spanish-ve'; | |
146 | + case 'sx': return 'sutu'; | |
147 | + case 'sw': return 'swahili'; | |
148 | + case 'sv-fi': return 'swedish-fi'; | |
149 | + case 'sv': return 'swedish'; | |
150 | + case 'syr': return 'syriac'; | |
151 | + case 'ta': return 'tamil'; | |
152 | + case 'tt': return 'tatar'; | |
153 | + case 'te': return 'telugu'; | |
154 | + case 'th': return 'thai'; | |
155 | + case 'ts': return 'tsonga'; | |
156 | + case 'tn': return 'tswana'; | |
157 | + case 'tr': return 'turkish'; | |
158 | + case 'uk': return 'ukrainian'; | |
159 | + case 'ur': return 'urdu'; | |
160 | + case 'uz': return 'uzbek'; | |
161 | + case 'uz': return 'uzbek'; | |
162 | + case 'vi': return 'vietnamese'; | |
163 | + case 'xh': return 'xhosa'; | |
164 | + case 'yi': return 'yiddish'; | |
165 | + default: return false; | |
166 | + } | |
167 | + } | |
168 | + static public function mime($extension){ | |
169 | + static $cache=array ( | |
170 | + 'ez' => 'application/andrew-inset', | |
171 | + 'atom' => 'application/atom+xml', | |
172 | + 'hqx' => 'application/mac-binhex40', | |
173 | + 'cpt' => 'application/mac-compactpro', | |
174 | + 'mathml' => 'application/mathml+xml', | |
175 | + 'doc' => 'application/msword', | |
176 | + 'bin' => 'application/octet-stream', | |
177 | + 'dms' => 'application/octet-stream', | |
178 | + 'lha' => 'application/octet-stream', | |
179 | + 'lzh' => 'application/octet-stream', | |
180 | + 'exe' => 'application/octet-stream', | |
181 | + 'class' => 'application/octet-stream', | |
182 | + 'so' => 'application/octet-stream', | |
183 | + 'dll' => 'application/octet-stream', | |
184 | + 'dmg' => 'application/octet-stream', | |
185 | + 'oda' => 'application/oda', | |
186 | + 'ogg' => 'application/ogg', | |
187 | + 'pdf' => 'application/pdf', | |
188 | + 'ai' => 'application/postscript', | |
189 | + 'eps' => 'application/postscript', | |
190 | + 'ps' => 'application/postscript', | |
191 | + 'rdf' => 'application/rdf+xml', | |
192 | + 'smi' => 'application/smil', | |
193 | + 'smil' => 'application/smil', | |
194 | + 'gram' => 'application/srgs', | |
195 | + 'grxml' => 'application/srgs+xml', | |
196 | + 'mif' => 'application/vnd.mif', | |
197 | + 'xul' => 'application/vnd.mozilla.xul+xml', | |
198 | + 'xls' => 'application/vnd.ms-excel', | |
199 | + 'ppt' => 'application/vnd.ms-powerpoint', | |
200 | + 'wbxml' => 'application/vnd.wap.wbxml', | |
201 | + 'wmlc' => 'application/vnd.wap.wmlc', | |
202 | + 'wmlsc' => 'application/vnd.wap.wmlscriptc', | |
203 | + 'vxml' => 'application/voicexml+xml', | |
204 | + 'bcpio' => 'application/x-bcpio', | |
205 | + 'vcd' => 'application/x-cdlink', | |
206 | + 'pgn' => 'application/x-chess-pgn', | |
207 | + 'cpio' => 'application/x-cpio', | |
208 | + 'csh' => 'application/x-csh', | |
209 | + 'dcr' => 'application/x-director', | |
210 | + 'dir' => 'application/x-director', | |
211 | + 'dxr' => 'application/x-director', | |
212 | + 'dvi' => 'application/x-dvi', | |
213 | + 'spl' => 'application/x-futuresplash', | |
214 | + 'gtar' => 'application/x-gtar', | |
215 | + 'hdf' => 'application/x-hdf', | |
216 | + 'js' => 'application/x-javascript', | |
217 | + 'skp' => 'application/x-koan', | |
218 | + 'skd' => 'application/x-koan', | |
219 | + 'skt' => 'application/x-koan', | |
220 | + 'skm' => 'application/x-koan', | |
221 | + 'latex' => 'application/x-latex', | |
222 | + 'nc' => 'application/x-netcdf', | |
223 | + 'cdf' => 'application/x-netcdf', | |
224 | + 'sh' => 'application/x-sh', | |
225 | + 'shar' => 'application/x-shar', | |
226 | + 'swf' => 'application/x-shockwave-flash', | |
227 | + 'sit' => 'application/x-stuffit', | |
228 | + 'sv4cpio' => 'application/x-sv4cpio', | |
229 | + 'sv4crc' => 'application/x-sv4crc', | |
230 | + 'tar' => 'application/x-tar', | |
231 | + 'tcl' => 'application/x-tcl', | |
232 | + 'tex' => 'application/x-tex', | |
233 | + 'texinfo' => 'application/x-texinfo', | |
234 | + 'texi' => 'application/x-texinfo', | |
235 | + 't' => 'application/x-troff', | |
236 | + 'tr' => 'application/x-troff', | |
237 | + 'roff' => 'application/x-troff', | |
238 | + 'man' => 'application/x-troff-man', | |
239 | + 'me' => 'application/x-troff-me', | |
240 | + 'ms' => 'application/x-troff-ms', | |
241 | + 'ustar' => 'application/x-ustar', | |
242 | + 'src' => 'application/x-wais-source', | |
243 | + 'xhtml' => 'application/xhtml+xml', | |
244 | + 'xht' => 'application/xhtml+xml', | |
245 | + 'xslt' => 'application/xslt+xml', | |
246 | + 'xml' => 'application/xml', | |
247 | + 'xsl' => 'application/xml', | |
248 | + 'dtd' => 'application/xml-dtd', | |
249 | + 'zip' => 'application/zip', | |
250 | + 'au' => 'audio/basic', | |
251 | + 'snd' => 'audio/basic', | |
252 | + 'mid' => 'audio/midi', | |
253 | + 'midi' => 'audio/midi', | |
254 | + 'kar' => 'audio/midi', | |
255 | + 'mpga' => 'audio/mpeg', | |
256 | + 'mp2' => 'audio/mpeg', | |
257 | + 'mp3' => 'audio/mpeg', | |
258 | + 'aif' => 'audio/x-aiff', | |
259 | + 'aiff' => 'audio/x-aiff', | |
260 | + 'aifc' => 'audio/x-aiff', | |
261 | + 'm3u' => 'audio/x-mpegurl', | |
262 | + 'ram' => 'audio/x-pn-realaudio', | |
263 | + 'ra' => 'audio/x-pn-realaudio', | |
264 | + 'rm' => 'application/vnd.rn-realmedia', | |
265 | + 'wav' => 'audio/x-wav', | |
266 | + 'pdb' => 'chemical/x-pdb', | |
267 | + 'xyz' => 'chemical/x-xyz', | |
268 | + 'bmp' => 'image/bmp', | |
269 | + 'cgm' => 'image/cgm', | |
270 | + 'gif' => 'image/gif', | |
271 | + 'ief' => 'image/ief', | |
272 | + 'jpeg' => 'image/jpeg', | |
273 | + 'jpg' => 'image/jpeg', | |
274 | + 'jpe' => 'image/jpeg', | |
275 | + 'png' => 'image/png', | |
276 | + 'svg' => 'image/svg+xml', | |
277 | + 'tiff' => 'image/tiff', | |
278 | + 'tif' => 'image/tiff', | |
279 | + 'djvu' => 'image/vnd.djvu', | |
280 | + 'djv' => 'image/vnd.djvu', | |
281 | + 'wbmp' => 'image/vnd.wap.wbmp', | |
282 | + 'ras' => 'image/x-cmu-raster', | |
283 | + 'ico' => 'image/x-icon', | |
284 | + 'pnm' => 'image/x-portable-anymap', | |
285 | + 'pbm' => 'image/x-portable-bitmap', | |
286 | + 'pgm' => 'image/x-portable-graymap', | |
287 | + 'ppm' => 'image/x-portable-pixmap', | |
288 | + 'rgb' => 'image/x-rgb', | |
289 | + 'xbm' => 'image/x-xbitmap', | |
290 | + 'xpm' => 'image/x-xpixmap', | |
291 | + 'xwd' => 'image/x-xwindowdump', | |
292 | + 'igs' => 'model/iges', | |
293 | + 'iges' => 'model/iges', | |
294 | + 'msh' => 'model/mesh', | |
295 | + 'mesh' => 'model/mesh', | |
296 | + 'silo' => 'model/mesh', | |
297 | + 'wrl' => 'model/vrml', | |
298 | + 'vrml' => 'model/vrml', | |
299 | + 'ics' => 'text/calendar', | |
300 | + 'ifb' => 'text/calendar', | |
301 | + 'css' => 'text/css', | |
302 | + 'html' => 'text/html', | |
303 | + 'htm' => 'text/html', | |
304 | + 'asc' => 'text/plain', | |
305 | + 'txt' => 'text/plain', | |
306 | + 'rtx' => 'text/richtext', | |
307 | + 'rtf' => 'text/rtf', | |
308 | + 'sgml' => 'text/sgml', | |
309 | + 'sgm' => 'text/sgml', | |
310 | + 'tsv' => 'text/tab-separated-values', | |
311 | + 'wml' => 'text/vnd.wap.wml', | |
312 | + 'wmls' => 'text/vnd.wap.wmlscript', | |
313 | + 'etx' => 'text/x-setext', | |
314 | + 'mpeg' => 'video/mpeg', | |
315 | + 'mpg' => 'video/mpeg', | |
316 | + 'mpe' => 'video/mpeg', | |
317 | + 'qt' => 'video/quicktime', | |
318 | + 'mov' => 'video/quicktime', | |
319 | + 'mxu' => 'video/vnd.mpegurl', | |
320 | + 'm4u' => 'video/vnd.mpegurl', | |
321 | + 'avi' => 'video/x-msvideo', | |
322 | + 'movie' => 'video/x-sgi-movie', | |
323 | + 'ice' => 'x-conference/x-cooltalk', | |
324 | + ); | |
325 | + $extension=strtolower($extension); | |
326 | + if (isset($cache[$extension])) return $cache[$extension]; | |
327 | + return 'application/unknown'; | |
328 | + } | |
329 | +} | |
\ No newline at end of file |
@@ -16,6 +16,7 @@ | ||
16 | 16 | break; |
17 | 17 | } |
18 | 18 | } |
19 | + if (!defined('_CONF_THUMBNAIL_SIZE')) define('_CONF_THUMBNAIL_SIZE',240); | |
19 | 20 | } |
20 | 21 | static public function action_get_skin(){ |
21 | 22 | if (isset($_GET['file_path'])) { |
@@ -105,7 +106,7 @@ | ||
105 | 106 | } |
106 | 107 | } |
107 | 108 | /* |
108 | - * Following method is public. | |
109 | + * Following method are public. | |
109 | 110 | * You can use it from any class. |
110 | 111 | */ |
111 | 112 | static public function send_media(&$image,$mime,$time=false,$name=false,$mode='view'){ |
@@ -121,4 +122,74 @@ | ||
121 | 122 | echo $image; |
122 | 123 | exit; |
123 | 124 | } |
125 | + static public function gd($file,$mime,$size=false){ | |
126 | + // Check if GD is available. | |
127 | + switch ($mime) { | |
128 | + case 'image/gif': | |
129 | + $func='imagecreatefromgif'; | |
130 | + break; | |
131 | + case 'image/jpeg': | |
132 | + $func='imagecreatefromjpeg'; | |
133 | + break; | |
134 | + case 'image/png': | |
135 | + $func='imagecreatefrompng'; | |
136 | + break; | |
137 | + case 'image/bmp': | |
138 | + $func='imagecreatefromwbmp'; | |
139 | + break; | |
140 | + case 'image/x-xbitmap': | |
141 | + $func='imagecreatefromxbm'; | |
142 | + break; | |
143 | + case 'image/x-xpixmap': | |
144 | + $func='imagecreatefromxpm'; | |
145 | + break; | |
146 | + default: | |
147 | + return false; | |
148 | + } | |
149 | + if (!function_exists($func)) return false; | |
150 | + $image=call_user_func_array($func,array($file)); | |
151 | + if (!$image) return false; | |
152 | + // Determine the size. | |
153 | + if (!$size) $size=_CONF_THUMBNAIL_SIZE; | |
154 | + $width=imagesx($image); | |
155 | + $height=imagesy($image); | |
156 | + // Decide the new size. | |
157 | + if ($width>$height) { | |
158 | + $new_width=intval($size); | |
159 | + $new_height=intval($height * $size / $width); | |
160 | + } else { | |
161 | + $new_width=intval($width * $size / $height); | |
162 | + $new_height=intval($size); | |
163 | + } | |
164 | + // Create new image. | |
165 | + $new_image = ImageCreateTrueColor($new_width, $new_height); | |
166 | + ImageCopyResampled($new_image,$image,0,0,0,0,$new_width,$new_height,$width,$height); | |
167 | + $types=imagetypes(); | |
168 | + if ($types & IMG_PNG) { | |
169 | + $thumbnail=array( | |
170 | + 'mime'=>'image/png', | |
171 | + 'width'=>$new_width, | |
172 | + 'height'=>$new_height, | |
173 | + 'file'=>self::gd_image('imagepng',$new_image)); | |
174 | + } elseif ($types & IMG_JPG) { | |
175 | + $thumbnail=array( | |
176 | + 'mime'=>'image/jpeg', | |
177 | + 'width'=>$new_width, | |
178 | + 'height'=>$new_height, | |
179 | + 'file'=>self::gd_image('imagejpeg',$new_image)); | |
180 | + } elseif ($types & IMG_GIF) { | |
181 | + $thumbnail=array( | |
182 | + 'mime'=>'image/gif', | |
183 | + 'width'=>$new_width, | |
184 | + 'height'=>$new_height, | |
185 | + 'file'=>self::gd_image('imagegif',$new_image)); | |
186 | + } else $thumbnail=false; | |
187 | + // Return original size and thumbnail. | |
188 | + return array($width,$height,$thumbnail); | |
189 | + } | |
190 | + static private function gd_image($func,&$res){ | |
191 | + ob_start(); | |
192 | + call_user_func_array($func,array($res)); | |
193 | + return ob_get_clean(); | |
194 | + } | |
124 | 195 | } |
@@ -21,7 +21,7 @@ | ||
21 | 21 | // Detemine user's default language from header from browser. |
22 | 22 | if (preg_match_all('/[a-z\-]+/i',$_SERVER['HTTP_ACCEPT_LANGUAGE'],$matches,PREG_SET_ORDER)) { |
23 | 23 | foreach($matches as $m){ |
24 | - $lang=self::language($m[0]); | |
24 | + $lang=tables::language($m[0]); | |
25 | 25 | if (!in_array($lang,self::$language)) continue; |
26 | 26 | self::$default=$lang; |
27 | 27 | break; |
@@ -149,163 +149,4 @@ | ||
149 | 149 | return false; |
150 | 150 | } |
151 | 151 | } |
152 | - static private function language($shortname){ | |
153 | - switch(strtolower($shortname)){ | |
154 | - case 'af': return 'afrikaans'; | |
155 | - case 'sq': return 'albanian'; | |
156 | - case 'ar-dz': return 'arabic-dz'; | |
157 | - case 'ar-bh': return 'arabic-bh'; | |
158 | - case 'ar-eg': return 'arabic-eg'; | |
159 | - case 'ar-iq': return 'arabic-iq'; | |
160 | - case 'ar-jo': return 'arabic-jo'; | |
161 | - case 'ar-kw': return 'arabic-kw'; | |
162 | - case 'ar-lb': return 'arabic-lb'; | |
163 | - case 'ar-ly': return 'arabic-ly'; | |
164 | - case 'ar-ma': return 'arabic-ma'; | |
165 | - case 'ar-om': return 'arabic-om'; | |
166 | - case 'ar-qa': return 'arabic-qa'; | |
167 | - case 'ar-sa': return 'arabic-sa'; | |
168 | - case 'ar-sy': return 'arabic-sy'; | |
169 | - case 'ar-tn': return 'arabic-tn'; | |
170 | - case 'ar-ae': return 'arabic-ae'; | |
171 | - case 'ar-ye': return 'arabic-ye'; | |
172 | - case 'ar': return 'arabic'; | |
173 | - case 'hy': return 'armenian'; | |
174 | - case 'as': return 'assamese'; | |
175 | - case 'az': return 'azeri'; | |
176 | - case 'az': return 'azeri'; | |
177 | - case 'eu': return 'basque'; | |
178 | - case 'be': return 'belarusian'; | |
179 | - case 'bn': return 'bengali'; | |
180 | - case 'bg': return 'bulgarian'; | |
181 | - case 'ca': return 'catalan'; | |
182 | - case 'zh-cn': return 'chinese-cn'; | |
183 | - case 'zh-hk': return 'chinese-hk'; | |
184 | - case 'zh-mo': return 'chinese-mo'; | |
185 | - case 'zh-sg': return 'chinese-sg'; | |
186 | - case 'zh-tw': return 'chinese-tw'; | |
187 | - case 'zh': return 'chinese'; | |
188 | - case 'hr': return 'croatian'; | |
189 | - case 'cs': return 'chech'; | |
190 | - case 'da': return 'danish'; | |
191 | - case 'div': return 'divehi'; | |
192 | - case 'nl-be': return 'dutch-be'; | |
193 | - case 'nl': return 'dutch'; | |
194 | - case 'en-au': return 'english-au'; | |
195 | - case 'en-bz': return 'english-bz'; | |
196 | - case 'en-ca': return 'english-ca'; | |
197 | - case 'en-ie': return 'english-ie'; | |
198 | - case 'en-jm': return 'english-jm'; | |
199 | - case 'en-nz': return 'english-nz'; | |
200 | - case 'en-ph': return 'english-ph'; | |
201 | - case 'en-za': return 'english-za'; | |
202 | - case 'en-tt': return 'english-tt'; | |
203 | - case 'en-gb': return 'english-gb'; | |
204 | - case 'en-us': return 'english-us'; | |
205 | - case 'en-zw': return 'english-zw'; | |
206 | - case 'en': return 'english'; | |
207 | - case 'et': return 'estonian'; | |
208 | - case 'fo': return 'faeroese'; | |
209 | - case 'fa': return 'farsi'; | |
210 | - case 'fi': return 'finnish'; | |
211 | - case 'fr-be': return 'french-be'; | |
212 | - case 'fr-ca': return 'french-ca'; | |
213 | - case 'fr': return 'french'; | |
214 | - case 'fr-lu': return 'french-lu'; | |
215 | - case 'fr-mc': return 'french-mc'; | |
216 | - case 'fr-ch': return 'french-ch'; | |
217 | - case 'mk': return 'fyro'; | |
218 | - case 'gd': return 'gaelic'; | |
219 | - case 'ka': return 'georgian'; | |
220 | - case 'de-at': return 'german-at'; | |
221 | - case 'de': return 'german'; | |
222 | - case 'de-li': return 'german-li'; | |
223 | - case 'de-lu': return 'german-lu'; | |
224 | - case 'de-ch': return 'german-ch'; | |
225 | - case 'el': return 'greek'; | |
226 | - case 'gu': return 'gujarati'; | |
227 | - case 'he': return 'hebrew'; | |
228 | - case 'hi': return 'hindi'; | |
229 | - case 'hu': return 'hungarian'; | |
230 | - case 'is': return 'icelandic'; | |
231 | - case 'id': return 'indonesian'; | |
232 | - case 'it': return 'italian'; | |
233 | - case 'it-ch': return 'italian-ch'; | |
234 | - case 'ja': return 'japanese'; | |
235 | - case 'kn': return 'kannada'; | |
236 | - case 'kk': return 'kazakh'; | |
237 | - case 'kok': return 'konkani'; | |
238 | - case 'ko': return 'korean'; | |
239 | - case 'kz': return 'kyrgyz'; | |
240 | - case 'lv': return 'latvian'; | |
241 | - case 'lt': return 'lithuanian'; | |
242 | - case 'ms': return 'malay'; | |
243 | - case 'ms': return 'malay'; | |
244 | - case 'ml': return 'malayalam'; | |
245 | - case 'mt': return 'maltese'; | |
246 | - case 'mr': return 'marathi'; | |
247 | - case 'mn': return 'mongolian'; | |
248 | - case 'ne': return 'nepali'; | |
249 | - case 'nb-no': return 'norwegian-nb'; | |
250 | - case 'no': return 'norwegian'; | |
251 | - case 'nn-no': return 'norwegian-nn'; | |
252 | - case 'or': return 'oriya'; | |
253 | - case 'pl': return 'polish'; | |
254 | - case 'pt-br': return 'portuguese-br'; | |
255 | - case 'pt': return 'portuguese'; | |
256 | - case 'pa': return 'punjabi'; | |
257 | - case 'rm': return 'rhaeto'; | |
258 | - case 'ro-md': return 'romanian-md'; | |
259 | - case 'ro': return 'romanian'; | |
260 | - case 'ru-md': return 'russian-md'; | |
261 | - case 'ru': return 'russian'; | |
262 | - case 'sa': return 'sanskrit'; | |
263 | - case 'sr': return 'serbian'; | |
264 | - case 'sr': return 'serbian'; | |
265 | - case 'sk': return 'slovak'; | |
266 | - case 'ls': return 'slovenian'; | |
267 | - case 'sb': return 'sorbian'; | |
268 | - case 'es-ar': return 'spanish-ar'; | |
269 | - case 'es-bo': return 'spanish-bo'; | |
270 | - case 'es-cl': return 'spanish-cl'; | |
271 | - case 'es-co': return 'spanish-co'; | |
272 | - case 'es-cr': return 'spanish-cr'; | |
273 | - case 'es-do': return 'spanish-do'; | |
274 | - case 'es-ec': return 'spanish-ec'; | |
275 | - case 'es-sv': return 'spanish-sv'; | |
276 | - case 'es-gt': return 'spanish-gt'; | |
277 | - case 'es-hn': return 'spanish-hn'; | |
278 | - case 'es': return 'spanish'; | |
279 | - case 'es-mx': return 'spanish-mx'; | |
280 | - case 'es-ni': return 'spanish-ni'; | |
281 | - case 'es-pa': return 'spanish-pa'; | |
282 | - case 'es-py': return 'spanish-py'; | |
283 | - case 'es-pe': return 'spanish-pe'; | |
284 | - case 'es-pr': return 'spanish-pr'; | |
285 | - case 'es': return 'spanish'; | |
286 | - case 'es-us': return 'spanish-us'; | |
287 | - case 'es-uy': return 'spanish-uy'; | |
288 | - case 'es-ve': return 'spanish-ve'; | |
289 | - case 'sx': return 'sutu'; | |
290 | - case 'sw': return 'swahili'; | |
291 | - case 'sv-fi': return 'swedish-fi'; | |
292 | - case 'sv': return 'swedish'; | |
293 | - case 'syr': return 'syriac'; | |
294 | - case 'ta': return 'tamil'; | |
295 | - case 'tt': return 'tatar'; | |
296 | - case 'te': return 'telugu'; | |
297 | - case 'th': return 'thai'; | |
298 | - case 'ts': return 'tsonga'; | |
299 | - case 'tn': return 'tswana'; | |
300 | - case 'tr': return 'turkish'; | |
301 | - case 'uk': return 'ukrainian'; | |
302 | - case 'ur': return 'urdu'; | |
303 | - case 'uz': return 'uzbek'; | |
304 | - case 'uz': return 'uzbek'; | |
305 | - case 'vi': return 'vietnamese'; | |
306 | - case 'xh': return 'xhosa'; | |
307 | - case 'yi': return 'yiddish'; | |
308 | - default: return false; | |
309 | - } | |
310 | - } | |
311 | 152 | } |
\ No newline at end of file |
@@ -199,6 +199,7 @@ | ||
199 | 199 | define('_ADMIN_BATCH_DELETEPLUGIN_FAILED','Deletion of plugin failed'); |
200 | 200 | define('_ADMIN_BATCH_MOVEPLUGINS_UP','Plugin(s) moved up.'); |
201 | 201 | define('_ADMIN_BATCH_MOVEPLUGINS_DOWN','Plugin(s) moved down.'); |
202 | +define('_ADMIN_BATCH_DELETEMEDIA','Following media will be deleted.'); | |
202 | 203 | define('_ADMIN_BATCH_DELETEMEDIA_DONE','Media was(were) deleted.'); |
203 | 204 | define('_ADMIN_BATCH_DELETEMEDIA_FAILED','Deletion of Media failed.'); |
204 | 205 |
@@ -199,6 +199,7 @@ | ||
199 | 199 | define('_ADMIN_BATCH_DELETEPLUGIN_FAILED','プラグインの消去に失敗'); |
200 | 200 | define('_ADMIN_BATCH_MOVEPLUGINS_UP','プラグインを上に移動しました。'); |
201 | 201 | define('_ADMIN_BATCH_MOVEPLUGINS_DOWN','プラグインを下に移動しました。'); |
202 | +define('_ADMIN_BATCH_DELETEMEDIA','次のメディアを削除します。'); | |
202 | 203 | define('_ADMIN_BATCH_DELETEMEDIA_DONE','メディアを削除しました'); |
203 | 204 | define('_ADMIN_BATCH_DELETEMEDIA_FAILED','メディアの削除に失敗しました'); |
204 | 205 |