DataObjects/Cms_page.php
[Pman.Cms] / PageThumb.php
index b65f568..db19d61 100644 (file)
@@ -4,20 +4,15 @@ require_once 'Pman.php';
 
 class Pman_Cms_PageThumb extends Pman
 {
-    function get($id)
+    function get($id = '',  $opts = array())
     {
         $cms_page = DB_DataObject::factory('cms_page');
         $cms_page->autoJoin();
         
-        $file = 'Pman/templates/images/file-broken.png';
-        
-        print_R(realpath($file));exit;
+        $file_broken = realpath('Pman/templates/images/file-broken.png');
         
         if(empty($id) || !$cms_page->get($id)){
-            
-            $this->jerr('Invalid Page');
-//            header('Location: ' . $this->rootURL . '/Pman/templates/images/file-broken.png?reason=' .
-//                urlencode("no images for that item: " . htmlspecialchars($id)));
+            $this->serve($file_broken);
         }
         
         if ($cms_page->page_type_id_name == 'element') {
@@ -25,13 +20,13 @@ class Pman_Cms_PageThumb extends Pman
         }
         
         if($cms_page->page_type_id_name != 'page'){
-            $this->jerr('Can not handle this type');
+            $this->serve($file_broken);
         }
         
         $opts = HTML_FlexyFramework::get()->Pman_Cms;
         
         if (!isset($opts['basePHP'])) {
-            $this->jerr(" Pman_Cms[basePHP] is not set ");
+            $this->serve($file_broken);
         }
         
         $basePHP = $opts['basePHP'];
@@ -48,7 +43,7 @@ class Pman_Cms_PageThumb extends Pman
                 }
             }
             if (!$matched) {
-                $this->jerr(" page link does not match any configured site.");
+                $this->serve($file_broken);
             }
         }
         
@@ -95,7 +90,7 @@ class Pman_Cms_PageThumb extends Pman
         exec($cmd);
         
         if(!file_exists($file)){
-            $this->jerr('Fail to make preview image');
+            $this->serve($file_broken);
         }
         
         $this->serve($file);
@@ -112,7 +107,7 @@ class Pman_Cms_PageThumb extends Pman
         
         $fc = new File_Convert($file, 'image/png');
         
-        $fc->convert('image/png', $this->size);
+        $fc->convert('image/png');
         
         $fc->serve('inline');