page= loadPage($name); */ function loadPage($prefix, $name, $default = false) { //var_dump($name, $default); $oo = HTML_FlexyFramework::get()->Pman_Cms; $template_prefix = isset($oo['template_prefix']) ? $oo['template_prefix'] : ''; // used to load sub elements. of a site.. if ($default === false && preg_match('/\*$/', $name)) { $x = DB_DataObject::factory("cms_page"); $x->whereAdd("page_link like '" . $x->escape(substr($name,0,-1)) ."%'"); foreach($x->fetchAll('page_link') as $pl) { $this->loadPage($pl, false); } return; } if ($default != false) { $x = DB_DataObject::factory("cms_page"); $x->autoJoin(); $x->is_element = 0; $x->is_draft = 0; $x->language = 'en'; //$this->bootLoader->locale; if (!$x->get("page_link", $prefix .'/'. $default)) { die("default page '$default' does not exist"); } // load the home page blocks.. $blocks = $x->children(array( 'type'=>'named_blocks', 'language' => $this->bootLoader->locale, )); foreach($blocks as $k=>$b) { $this->block[$k] = $b; } $this->defaultPage = $x->inLanguage($this->bootLoader->locale); $this->defaultPage_en = $x; if ($this->defaultPage_en->id != $this->defaultPage->id) { $blocks =$this->defaultPage->children(array( 'type'=>'named_blocks', 'language' => $this->bootLoader->locale )); foreach($blocks as $k=>$b) { $this->block[$k] = $b; } } } if (empty($name)) { $this->page = $this->defaultPage; $this->page_en = $this->defaultPage_en; } else { $x = DB_DataObject::factory("cms_page"); $x->autoJoin(); $x->is_element = 0; $x->is_draft = 0; $x->language = 'en'; if (!$x->get("page_link", $prefix .'/'. $name)) { $this->err(404, "$name not found"); } $blocks = $x->children(array( 'type'=>'named_blocks', 'language' => $this->bootLoader->locale, )); foreach($blocks as $k=>$b) { $this->block[$k] = $b; } $this->page_en = $x; $this->page = $x->inLanguage($this->bootLoader->locale); if ($this->page_en->id != $this->page->id) { $blocks = $this->page->children(array( 'type'=>'named_blocks', 'language' => $this->bootLoader->locale )); foreach($blocks as $k=>$b) { $this->block[$k] = $b; } } } // load all the blocks.. $this->assignMeta(); $this->template = $this->page_en->template()->template; //var_dump($this->template); // menus???? } function assignMeta() { foreach(array($this->page ,$this->defaultPage) as $argsItem) { if(empty($this->title) && !empty($argsItem->content->title)){ $this->title = ' - ' . $argsItem->title; } if(empty($this->keywords) && !empty($argsItem->keywords)){ $this->keywords = $argsItem->keywords; } if(empty($this->descriptions) && !empty($argsItem->descriptions)){ $this->descriptions = $argsItem->descriptions; } } } /* function herr( $error_name, $args = array(), $redirect=false ) { if($redirect !== false){ $args['errors'][$error_name] = 1; return HTML_FlexyFramework::run($redirect, $args); } $this->errors[$error_name] = 1; $this->elements = HTML_Template_Flexy_Factory::fromArray($_REQUEST, $this->elements); $this->addEvent('FRONTEND:'.$error_name, (empty($args['error_on'])) ? false : $args['error_on'], $error_name); return true; } */ function err($n, $msg = false) { header("HTTP/1.0 $n Not Found"); $this->template = 'error.html'; $this->msg = $msg; $this->output(); // should we log the referer!! exit; } function errmsg($str) { $this->errors[$str] = 1; return $this->get(''); } function redirect($loc) { header('Location: '. $this->baseURL . $loc); exit; } function ellipsis($input, $length) { //no need to trim, already shorter than trim length if (strlen($input) <= $length) { return $input; } //find last space within length $last_space = strrpos(substr($input, 0, $length), ' '); $trimmed_text = substr($input, 0, $last_space); //add ellipses (...) $trimmed_text .= '...'; return $trimmed_text; } function eq($a,$b){ return $a == $b; } function checkIsAdmin() { if(!$this->authUser){ return false; } $x = DB_DataObject::factory('core_company'); if($x->get($this->authUser->company_id)){ if($x->comptype == 'OWNER'){ return true; } return false; } return false; } function templateClass() { return preg_replace('/[^a-z]+/', '-', preg_replace('/\.html$/', '', strtolower($this->template))); } }