A QCodo powered CMS
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

144 lines
5.6 KiB

  1. <?php
  2. if(!defined('QUINTACMS') ) die("No quinta.");
  3. if (!defined("PAGECONTROLLER.CLASS.PHP")){
  4. define("PAGECONTROLLER.CLASS.PHP",1);
  5. /**
  6. * PageController - handles the content block placement for a single page in Quinta.
  7. *
  8. * This class is the manager for placing content blocks associated with a Page.
  9. * It sets up the ContentBlocks according to some default areas as defined in the
  10. * block_location_type table in the database, These are currently hard coded to offer
  11. * a default generic layout with a header, two side bars, a center content area and
  12. * a footer. Extra divs are also provided for extra flexibility. All divs loaded by this
  13. * class are contained within the master container div (see the template).
  14. *
  15. * You can modify the default layout via the style sheet associated with each Page
  16. * - the style sheet to use for a page can be set via the Quinta CMS administrative interface.
  17. * It is also not difficult to change the default areas - simply edit the template and ensure
  18. * that the associated div CSS id names are in the block_location_type table and then
  19. * you can associate ContentBlocks with those areas (again through the admin interface).
  20. *
  21. *NOTE: One course of development would be to subclass this for page types. This
  22. * is already in the database, but it is not used yet - an architectural decision to be made ...
  23. *
  24. *@author Erik Winn <sidewalksoftware@gmail.com>
  25. *
  26. *@version 0.3
  27. *
  28. * @package Quinta
  29. * @subpackage Controllers
  30. */
  31. class PageController extends QPanel{
  32. protected $objParentObject;
  33. protected $objPage;
  34. public $aryHeaderContentBlocks;
  35. public $aryRightPanelContentBlocks;
  36. public $aryCenterPanelContentBlocks;
  37. public $aryLeftPanelContentBlocks;
  38. public $aryFooterContentBlocks;
  39. public $aryExtraContentBlocks;
  40. public function __construct($objParentObject, $objPage){
  41. ///@todo We should have an ErrorPage in the page table with an Error ContentBlock and
  42. // ContentItem attached! quintadb.sql should insert these by default on install.
  43. // Thought: just redirect to a static page here, or we need a class ErrorPage .. but, this
  44. // is an unlikely scenario anyway as IndexPage should handle this - I am really thinking
  45. // of new developers using this class wrongly, for now just go home ..
  46. if(! $objPage )
  47. $this->objPage = $this->objPage = Page::LoadByName('Home');
  48. else
  49. $this->objPage = $objPage;
  50. //To have any actions, Parent must be a QForm - QuintaCMS uses class IndexPage
  51. // as the master page (index.php) that takes all requests and instantiates pages
  52. $this->objParentObject = $objParentObject;
  53. try {
  54. parent::__construct($this->objParentObject);
  55. } catch (QCallerException $objExc) {
  56. $objExc->IncrementOffset();
  57. throw $objExc;
  58. }
  59. if( $this->objPage)
  60. foreach ( $this->objPage->GetContentBlockArray(
  61. QQ::Clause (QQ::OrderBy(QQN::ContentBlock()->SortOrder) )
  62. ) as $objContentBlock )
  63. {
  64. if(! $objContentBlock)
  65. continue;
  66. $strLocation = $objContentBlock->Location;
  67. $strCssId = $strLocation . preg_replace('/\s/', '',$objContentBlock->Name);
  68. $strCssClass = $strLocation . 'ContentBlock';
  69. switch ($strLocation)
  70. {
  71. case 'PageHeader':
  72. $objContentBlockController = new ContentBlockController( $this, $objContentBlock, $strCssId);
  73. $this->aryHeaderContentBlocks[] = $objContentBlockController;
  74. break;
  75. case 'RightPanel':
  76. $objContentBlockController = new ContentBlockController( $this, $objContentBlock, $strCssId);
  77. $this->aryRightPanelContentBlocks[] = $objContentBlockController;
  78. break;
  79. case 'LeftPanel':
  80. $objContentBlockController = new ContentBlockController( $this, $objContentBlock, $strCssId);
  81. $this->aryLeftPanelContentBlocks[] = $objContentBlockController;
  82. break;
  83. case 'CenterPanel':
  84. $objContentBlockController = new ContentBlockController( $this, $objContentBlock, $strCssId);
  85. $this->aryCenterPanelContentBlocks[] = $objContentBlockController;
  86. break;
  87. case 'PageFooter':
  88. $objContentBlockController = new ContentBlockController( $this, $objContentBlock, $strCssId);
  89. $this->aryFooterContentBlocks[] = $objContentBlockController;
  90. break;
  91. default:
  92. $objContentBlockController = new ContentBlockController( $this, $objContentBlock, $strCssId);
  93. $this->aryExtraContentBlocks[] = $objContentBlockController;
  94. break;
  95. }
  96. $objContentBlockController->CssClass = $strCssClass;
  97. $objContentBlockController->Visible = true;
  98. }
  99. $this->Template = __QUINTA_CORE_VIEWS__ . '/PageView.tpl.php';
  100. }
  101. public function __get($strName){
  102. switch ($strName){
  103. case 'HeaderContentBlocks':
  104. return $this->aryHeaderContentBlocks ;
  105. case 'LeftPanelContentBlocks':
  106. return $this->aryLeftPanelContentBlocks ;
  107. case 'CenterPanelContentBlocks':
  108. return $this->aryCenterPanelContentBlocks ;
  109. case 'RightPanelContentBlocks':
  110. return $this->aryRightPanelContentBlocks ;
  111. case 'FooterContentBlocks':
  112. return $this->aryFooterContentBlocks ;
  113. case 'ExtraContentBlocks':
  114. return $this->aryExtraContentBlocks ;
  115. case 'HasHeader':
  116. return $this->objPage->HasHeader ;
  117. case 'HasLeftColumn':
  118. return $this->objPage->HasLeftColumn ;
  119. case 'HasRightColumn':
  120. return $this->objPage->HasRightColumn ;
  121. case 'HasFooter':
  122. return $this->objPage->HasFooter ;
  123. default:
  124. try {
  125. return parent::__get($strName);
  126. } catch (QCallerException $objExc) {
  127. $objExc->IncrementOffset();
  128. throw $objExc;
  129. }
  130. }
  131. }
  132. }//end class
  133. }//end define
  134. ?>