3 * view permission should be required on the underlying object...
8 * args: ontable request
9 * ontable (req) tablename.
12 * as (serve as a type) = eg. mimetype.
15 * as :(serve as a type) = eg. mimetype.
17 * Images/{ID}/fullname.xxxx
19 * (valid thumbs 200, 400)...?
20 * Images/Thumb/200/{ID}/fullname.xxxx
23 require_once 'Pman.php';
24 class Pman_Images extends Pman
28 parent::getAuth(); // load company!
30 $au = $this->getAuthUser();
34 $this->authUser = $au;
39 function get($s) // determin what to serve!!!!
41 $this->as_mimetype = empty($_REQUEST['as']) ? '' : $_REQUEST['as'];
43 $bits= explode('/', $s);
45 // without id as first part...
46 if (!empty($bits[0]) && $bits[0] == 'Thumb') {
48 $this->as_mimetype = 'image/jpeg';
49 $this->size = empty($bits[1]) ? '0x0' : $bits[1];
50 $id = empty($bits[2]) ? 0 : $bits[2];
52 } else if (!empty($bits[0]) && $bits[0] == 'Download') {
53 $this->method = 'attachment';
54 $id = empty($bits[1]) ? 0 : $bits[1];
56 } else if (!empty($bits[1]) && $bits[1] == 'Thumb') { // with id as first part.
58 $this->as_mimetype = 'image/jpeg';
59 $this->size = empty($bits[2]) ? '0x0' : $bits[2];
60 $id = empty($bits[3]) ? 0 : $bits[3];
63 $id = empty($bits[0]) ? 0 : $bits[0];
66 if (strpos($id,':') > 0) { // id format tablename:id:-imgtype
67 $onbits = explode(':', $id);
68 if ((count($onbits) < 2) || empty($onbits[1]) || !is_numeric($onbits[1]) || !strlen($onbits[0])) {
71 $img = DB_DataObjecT::factory('Images');
72 $img->ontable = $onbits[0];
73 $img->onid = $onbits[1];
74 if (isset($onbits[2])) {
75 $img->imgtype = $onbits[2];
78 if (!$img->find(true)) {
88 // depreciated - should use ontable:onid:type here...
89 if (!empty($_REQUEST['ontable'])) {
91 //DB_DataObjecT::debugLevel(1);
92 $img = DB_DataObjecT::factory('Images');
93 $img->setFrom($_REQUEST);
95 // if (!empty($_REQUEST['query']['filename'])){
96 // $img->whereAdd("filename LIKE '". $img->escape($_REQUEST['query']['filename']).".%'");
101 if (!$img->find(true)) {
102 die("No file exists");
110 $img = DB_DataObjecT::factory('Images');
111 if (!$id || !$img->get($id)) {
112 die("image has been removed or deleted.");
118 var $asmimetype = false;
119 var $method = 'inline';
122 require_once 'File/Convert.php';
123 $x = new File_Convert($img->getStoreName(), $img->mimetype);
124 if (empty($this->as_mimetype)) {
125 $this->as_mimetype = $img->mimetype;
128 $x->convert( $this->as_mimetype);
129 $x->serve($this->method);
133 $this->validateSize();
134 $x->convert( $this->as_mimetype, $this->size);
142 function validateSize()
144 if (!in_array($this->size, array(
153 die("invalid scale");