fix 'Optional parameter declared before required parameter is implicitly treated'
[Pman.Cms] / PageThumb.php
index 8dc5f40..4c7e3b9 100644 (file)
@@ -4,29 +4,29 @@ 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_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') {
             $cms_page = $cms_page->parent();
         }
         
-        if($cms_page->page_type_id_name != 'page'){
-            $this->jerr('Can not handle this type');
+        if(empty($cms_page->page_type_id_name) || $cms_page->page_type_id_name != 'page') {
+            $this->serve($file_broken);
         }
-        
-        $opts = HTML_FlexyFramework::get()->Pman_Cms;
+        $ff = HTML_FlexyFramework::get();
+        $opts = isset($ff->Pman_Cms) ? $ff->Pman_Cms : array();
         
         if (!isset($opts['basePHP'])) {
-            $this->jerr(" Pman_Cms[basePHP] is not set ");
+            $this->serve($file_broken);
         }
         
         $basePHP = $opts['basePHP'];
@@ -43,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);
             }
         }
         
@@ -90,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);
@@ -107,12 +107,11 @@ 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');
         
         exit;
         
-        
     }
 }
\ No newline at end of file