class Pman_Cms_PageThumb extends Pman
{
- function get($id)
+ function get($id = '', $opts = array())
{
- $this->jerr('Invalid Page');
$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'];
}
}
if (!$matched) {
- $this->jerr(" page link does not match any configured site.");
+ $this->serve($file_broken);
}
}
exec($cmd);
if(!file_exists($file)){
- $this->jerr('Fail to make preview image');
+ $this->serve($file_broken);
}
$this->serve($file);
$fc = new File_Convert($file, 'image/png');
- $fc->convert('image/png', $this->size);
+ $fc->convert('image/png');
$fc->serve('inline');