Images.php
[Pman.Core] / Images.php
index 438db09..34bc7be 100644 (file)
@@ -57,6 +57,7 @@ class Pman_Core_Images extends Pman
     
     function get($s) // determin what to serve!!!!
     {
+        print_r('test');exit;
         // for testing only.
         //if (!empty($_GET['_post'])) {
         //   return $this->post();
@@ -107,7 +108,7 @@ class Pman_Core_Images extends Pman
             if (empty($_REQUEST['anytype'])) {
                 $img->whereAdd("mimetype like 'image/%'");
             }
-            
+            $img->orderBy('title ASC'); /// spurious ordering... (curretnly used by shipping project)
             if (isset($onbits[2])) {
                 $img->imgtype = $onbits[2];
             }
@@ -221,6 +222,7 @@ class Pman_Core_Images extends Pman
  
     function serve($img)
     {
+        print_f("test??");exit;
         $this->sessionState(0); // turn off session... - locking...
         
         require_once 'File/Convert.php';
@@ -232,9 +234,10 @@ class Pman_Core_Images extends Pman
         }
 //        print_r($img);exit;
         $x = $img->toFileConvert();
-        if (empty($this->as_mimetype)) {
+        if (empty($this->as_mimetype) || $img->mimetype == 'image/gif') {
             $this->as_mimetype  = $img->mimetype;
         }
+        
         if (!$this->thumb) {
             $x->convert( $this->as_mimetype);
             $x->serve($this->method);
@@ -243,7 +246,11 @@ class Pman_Core_Images extends Pman
         //echo "SKALING?  $this->size";
         // acutally if we generated the image, then we do not need to validate the size..
         
+        require_once 'File/MimeType.php';
+        $y = new File_MimeType();
+        $ext = $y->toExt(trim((string) $this->as_mimetype ));
         
+        print_r($ext);exit;
         
         // if the mimetype is not converted..
         // then the filename should be original.{size}.jpeg
@@ -257,8 +264,7 @@ class Pman_Core_Images extends Pman
             }
         }
         
-        if (!file_exists($fn)) {            
-            
+        if (!file_exists($fn)) {    
             $this->validateSize();
         }
         
@@ -272,11 +278,12 @@ class Pman_Core_Images extends Pman
     }
     function validateSize()
     {
-        if (($this->authUser && $this->authUser->company_id && $this->authUser->company()->comptype=='OWNER') || $_SERVER['SERVER_ADDR'] == $_SERVER['REMOTE_ADDR']) {
+        if (($this->authUser && !empty($this->authUser->company_id) && $this->authUser->company()->comptype=='OWNER') || $_SERVER['SERVER_ADDR'] == $_SERVER['REMOTE_ADDR']) {
             return true;
         }
         
-        // DEFAULT allowed - override with Pman_Core_Images[sizes] => array();
+        
+        $ff = HTML_FlexyFramework::get();
         
         $sizes = array(
                 '100', 
@@ -287,26 +294,28 @@ class Pman_Core_Images extends Pman
                 '200x0',
                 '200x200',  
                 '400x0',
-                '300x100', // logo on login.
+                '300x100',
                 '500'
             );
         
-        // this should be configurable...
-        $ff = HTML_FlexyFramework::get();
-        
-        
         $cfg = isset($ff->Pman_Images) ? $ff->Pman_Images :
                 (isset($ff->Pman_Core_Images) ? $ff->Pman_Core_Images : array());
         
-        
-        
         if (!empty($cfg['sizes'])) {
             $sizes = array_merge($sizes , $cfg['sizes']);
         }
         
+        $project = $ff->project;
+        
+        require_once $ff->project . '.php';
+        
+        $project = new $ff->project();
+        
+        if(isset($project::$Pman_Core_Images_Size)){
+            $sizes = $project::$Pman_Core_Images_Size;
+        }
         
         if (!in_array($this->size, $sizes)) {
-            print_r($sizes);
             die("invalid scale - ".$this->size);
         }
     }
@@ -358,7 +367,7 @@ class Pman_Core_Images extends Pman
                 $html = self::replaceImgUrl($html, $baseURL, $img, $attr,  'src' );
                 continue;
             }
-            if (false !== strpos($attr['src'], '//')) {
+            if (false !== strpos($attr['src'], '//') && false === strpos($attr['src'], $baseURL)) {
                 // contains an absolute path.. that is probably not us...
                 continue;
             }
@@ -366,8 +375,6 @@ class Pman_Core_Images extends Pman
             
             $html = self::replaceImgUrl($html, $baseURL, $img, $attr,  'src' );
             
-            
-            
         }