Merge branch 'master' into wip_leon_T7754_fix_download_upload_for_admin
[Pman.Core] / Images.php
index eff84f5..2f2ae0c 100644 (file)
@@ -78,6 +78,8 @@ class Pman_Core_Images extends Pman
     var $method = 'inline';
     var $page = false;
     var $is_local = false;
+    var $size;
+    
     
     function get($s, $opts=array()) // determin what to serve!!!!
     {
@@ -126,7 +128,7 @@ class Pman_Core_Images extends Pman
         }
         
         if (strpos($id,':') > 0) {  // id format  tablename:id:-imgtype
-            
+            //DB_DataObject::debugLevel(1);
             if (!$this->authUser) {
                 $this->imgErr("not-authenticated-using-colon-format",$s);
                 
@@ -184,6 +186,7 @@ class Pman_Core_Images extends Pman
         $img = DB_DataObjecT::factory('Images');
          
         if (!$id || !$img->get($id) || !$img->exists()) {
+           //print_r($img);           die("HERE");
             $this->imgErr("image has been removed or deleted.",$s);
         }
         
@@ -217,8 +220,9 @@ class Pman_Core_Images extends Pman
     }
     
     function imgErr($reason,$path) {
-        header('Location: ' . $this->rootURL . '/Pman/templates/images/file-broken.png?reason=' .
-            urlencode($reason) .'&path='.urlencode($path));
+        header('Location: ' . $this->rootURL . '/Pman/templates/images/file-broken.png?reason=' . urlencode($reason) );
+        header('X-Error: ' . $reason . ':' . $path);
+        echo $reason . ':' . $path;
         exit;
     }
     
@@ -284,11 +288,9 @@ class Pman_Core_Images extends Pman
     {
         $this->sessionState(0); // turn off session... - locking...
         require_once 'File/Convert.php';
-        if (!file_exists($img->getStoreName())) {
-//            print_r($img);exit;
-            header('Location: ' . $this->rootURL . '/Pman/templates/images/file-broken.png?reason=' .
-                urlencode("Original file was missing : " . $img->getStoreName()));
-    
+        if (!$img->exists()) {
+            $this->imgErr("serve = missing-image", $img->getStoreName());
+             
         }
 //        print_r($img);exit;
         $x = $img->toFileConvert();
@@ -297,11 +299,11 @@ class Pman_Core_Images extends Pman
         }
         if (!$this->thumb) {
             if ($x->mimetype == $this->as_mimetype) {
-                $x->serveOnly($this->method);
+                $x->serveOnly($this->method, $img->filename);
                 exit;
             }
             $x->convert( $this->as_mimetype);
-            $x->serve($this->method);
+            $x->serve($this->method, $img->filename);
             exit;
         }
         //echo "SKALING?  $this->size";
@@ -663,4 +665,8 @@ class Pman_Core_Images extends Pman
         }
     }
     
+     
+        
+        
+         
 }