* *@version 0.3 * * @package Quinta * @subpackage Controllers */ class PageController extends QPanel{ protected $objParentObject; protected $objPage; public $aryHeaderContentBlocks; public $aryRightPanelContentBlocks; public $aryCenterPanelContentBlocks; public $aryLeftPanelContentBlocks; public $aryFooterContentBlocks; public $aryExtraContentBlocks; public function __construct($objParentObject, $objPage){ ///@todo We should have an ErrorPage in the page table with an Error ContentBlock and // ContentItem attached! quintadb.sql should insert these by default on install. // Thought: just redirect to a static page here, or we need a class ErrorPage .. but, this // is an unlikely scenario anyway as IndexPage should handle this - I am really thinking // of new developers using this class wrongly, for now just go home .. if(! $objPage ) $this->objPage = $this->objPage = Page::LoadByName('Home'); else $this->objPage = $objPage; //To have any actions, Parent must be a QForm - QuintaCMS uses class IndexPage // as the master page (index.php) that takes all requests and instantiates pages $this->objParentObject = $objParentObject; try { parent::__construct($this->objParentObject); } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } if( $this->objPage) foreach ( $this->objPage->GetContentBlockArray( QQ::Clause (QQ::OrderBy(QQN::ContentBlock()->SortOrder) ) ) as $objContentBlock ) { if(! $objContentBlock) continue; $strLocation = $objContentBlock->Location; $strCssId = $strLocation . preg_replace('/\s/', '',$objContentBlock->Name); $strCssClass = $strLocation . 'ContentBlock'; switch ($strLocation) { case 'PageHeader': $objContentBlockController = new ContentBlockController( $this, $objContentBlock, $strCssId); $this->aryHeaderContentBlocks[] = $objContentBlockController; break; case 'RightPanel': $objContentBlockController = new ContentBlockController( $this, $objContentBlock, $strCssId); $this->aryRightPanelContentBlocks[] = $objContentBlockController; break; case 'LeftPanel': $objContentBlockController = new ContentBlockController( $this, $objContentBlock, $strCssId); $this->aryLeftPanelContentBlocks[] = $objContentBlockController; break; case 'CenterPanel': $objContentBlockController = new ContentBlockController( $this, $objContentBlock, $strCssId); $this->aryCenterPanelContentBlocks[] = $objContentBlockController; break; case 'PageFooter': $objContentBlockController = new ContentBlockController( $this, $objContentBlock, $strCssId); $this->aryFooterContentBlocks[] = $objContentBlockController; break; default: $objContentBlockController = new ContentBlockController( $this, $objContentBlock, $strCssId); $this->aryExtraContentBlocks[] = $objContentBlockController; break; } $objContentBlockController->CssClass = $strCssClass; $objContentBlockController->Visible = true; } $this->Template = __QUINTA_CORE_VIEWS__ . '/PageView.tpl.php'; } public function __get($strName){ switch ($strName){ case 'HeaderContentBlocks': return $this->aryHeaderContentBlocks ; case 'LeftPanelContentBlocks': return $this->aryLeftPanelContentBlocks ; case 'CenterPanelContentBlocks': return $this->aryCenterPanelContentBlocks ; case 'RightPanelContentBlocks': return $this->aryRightPanelContentBlocks ; case 'FooterContentBlocks': return $this->aryFooterContentBlocks ; case 'ExtraContentBlocks': return $this->aryExtraContentBlocks ; case 'HasHeader': return $this->objPage->HasHeader ; case 'HasLeftColumn': return $this->objPage->HasLeftColumn ; case 'HasRightColumn': return $this->objPage->HasRightColumn ; case 'HasFooter': return $this->objPage->HasFooter ; default: try { return parent::__get($strName); } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } } } }//end class }//end define ?>