Documentation is available at absfileclass.php
1 <?php
2 /**
3 * @author Jan H. Andersen <jha@ipwsystems.dk>
4 * @author Martin R. Larsen <mrl@ipwsystems.dk>
5 * @copyright {@link http://www.ipwsystems.dk/ IPW Systems a.s}
6 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
7 * @package METAjour
8 * @subpackage core
9 * $Id: absfileclass.php,v 1.1 2005/02/07 09:56:20 jan Exp $
10 */
11 require_once('basicclass.php');
12
13 class absfile extends basic {
14
15 function absfile() {
16 $this->basic();
17 }
18
19 function geticon() {
20 switch ($this->elements[0]['mimetype']) {
21 case "image/bmp":
22 case "image/gif":
23 case "image/jpeg":
24 case "image/pjpeg":
25 case "image/png":
26 case "image/tiff":
27 return $this->userhandler->getSystemUrl().'image/mimetype/image.png';
28 default:
29 return $this->userhandler->getSystemUrl().'image/mimetype/document.png';
30 }
31 }
32
33 function getthumb($w=100,$h='') {
34 switch ($this->elements[0]['mimetype']) {
35 case "image/bmp":
36 case "image/gif":
37 case "image/jpeg":
38 case "image/pjpeg":
39 case "image/png":
40 case "image/tiff":
41 $ext = "_".$w."x".$h;
42 $cachedir = $this->userhandler->getDirBinfileCache();
43 $binfiledir = $this->getRoot();
44 $result = '';
45 if (!file_exists($cachedir)) {
46 if(!@mkdir($cachedir, 0755)) {
47 $this->errorcode = $this->ERR_CANNOTMAKEDIR;
48 return $this->errorcode;
49 }
50 }
51 $objectid = $this->elements[0]['objectid'];
52 if ( !file_exists($cachedir . $objectid.$ext) ||
53 filemtime($binfiledir . substr($objectid,-2).'/'.$objectid) > filemtime($cachedir . $objectid . $ext)) {
54 require_once($this->userhandler->getSystemPath().'core/util/class.imgresize.php');
55 $thumb = new imgresize($binfiledir.substr($objectid,-2).'/'.$objectid,$this->elements[0]['mimetype']);
56 if ($thumb->img['ok']) {
57 $thumb->size_width($w);
58 $thumb->jpeg_quality(50);
59 $thumb->save($cachedir . $objectid.$ext);
60 $result = $cachedir . $objectid.$ext;
61 }
62 } else {
63 $result = $cachedir . $objectid.$ext;
64 }
65 if ($this->elements[0]['mimetype'] == 'image/gif')
66 $result = $this->userhandler->getSystemUrl().'image/mimetype/image.png';
67 return $result;
68 break;
69
70 default:
71 return $this->userhandler->getSystemUrl().'image/mimetype/document.png';
72 }
73 }
74
75 }
Documentation generated on Thu, 9 Jun 2005 06:50:45 +0200 by phpDocumentor 1.2.3