A Qcodo based CMS/ecommerce framework
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.

167 lines
7.8 KiB

13 years ago
  1. <?php
  2. if(!defined('QUASICMS') ) die("No quasi.");
  3. if (!defined("PAGEVIEW.CLASS.PHP")){
  4. define("PAGEVIEW.CLASS.PHP",1);
  5. /**
  6. * PageView - handles the content block placement for a single page in Quasi.
  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 Quasi 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 <erikwinnmail@yahoo.com>
  25. *
  26. *
  27. * $Id: PageView.class.php 197 2008-09-19 22:11:27Z erikwinn $
  28. *@version 0.1
  29. *
  30. *@copyright (C) 2008 by Erik Winn
  31. *@license GPL v.2
  32. This program is free software; you can redistribute it and/or modify
  33. it under the terms of the GNU General Public License as published by
  34. the Free Software Foundation; either version 2 of the License, or
  35. (at your option) any later version.
  36. This program is distributed in the hope that it will be useful,
  37. but WITHOUT ANY WARRANTY; without even the implied warranty of
  38. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  39. GNU General Public License for more details.
  40. You should have received a copy of the GNU General Public License
  41. along with this program; if not, write to the Free Software
  42. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
  43. *
  44. * @package Quasi
  45. * @subpackage Views
  46. */
  47. class PageView extends QPanel
  48. {
  49. protected $objParentObject;
  50. protected $objPage;
  51. public $aryHeaderContentBlocks;
  52. public $aryRightPanelContentBlocks;
  53. public $aryCenterPanelContentBlocks;
  54. public $aryLeftPanelContentBlocks;
  55. public $aryFooterContentBlocks;
  56. public $aryExtraContentBlocks;
  57. public function __construct($objParentObject, $objPage)
  58. {
  59. ///@todo We should have an ErrorPage in the page table with an Error ContentBlock and
  60. // ContentItem attached! quasidb.sql should insert these by default on install.
  61. // Thought: just redirect to a static page here, or we need a class ErrorPage .. but, this
  62. // is an unlikely scenario anyway as IndexPage should handle this - I am really thinking
  63. // of new developers using this class wrongly, for now just go home ..
  64. if(! $objPage )
  65. $this->objPage = $this->objPage = Page::LoadByName('Home');
  66. else
  67. $this->objPage = $objPage;
  68. //To have any actions, Parent must be a QForm - QuasiCMS uses class IndexPage
  69. // as the master page (index.php) that takes all requests and instantiates pages
  70. $this->objParentObject = $objParentObject;
  71. try {
  72. parent::__construct($this->objParentObject);
  73. } catch (QCallerException $objExc) {
  74. $objExc->IncrementOffset();
  75. throw $objExc;
  76. }
  77. if( $this->objPage)
  78. foreach ( $this->objPage->GetContentBlockArray(
  79. QQ::Clause (QQ::OrderBy(QQN::ContentBlock()->SortOrder) )
  80. ) as $objContentBlock )
  81. {
  82. if(! $objContentBlock)
  83. continue;
  84. $strLocation = $objContentBlock->Location;
  85. $strCssId = $strLocation . preg_replace('/\s/', '',$objContentBlock->Name);
  86. $strCssClass = $strLocation . 'ContentBlock';
  87. switch ($strLocation)
  88. {
  89. case 'PageHeader':
  90. $objContentBlockView = new ContentBlockView( $this, $objContentBlock, $strCssId);
  91. $this->aryHeaderContentBlocks[] = $objContentBlockView;
  92. break;
  93. case 'RightPanel':
  94. $objContentBlockView = new ContentBlockView( $this, $objContentBlock, $strCssId);
  95. $this->aryRightPanelContentBlocks[] = $objContentBlockView;
  96. break;
  97. case 'LeftPanel':
  98. $objContentBlockView = new ContentBlockView( $this, $objContentBlock, $strCssId);
  99. $this->aryLeftPanelContentBlocks[] = $objContentBlockView;
  100. break;
  101. case 'CenterPanel':
  102. $objContentBlockView = new ContentBlockView( $this, $objContentBlock, $strCssId);
  103. $this->aryCenterPanelContentBlocks[] = $objContentBlockView;
  104. break;
  105. case 'PageFooter':
  106. $objContentBlockView = new ContentBlockView( $this, $objContentBlock, $strCssId);
  107. $this->aryFooterContentBlocks[] = $objContentBlockView;
  108. break;
  109. default:
  110. $objContentBlockView = new ContentBlockView( $this, $objContentBlock, $strCssId);
  111. $this->aryExtraContentBlocks[] = $objContentBlockView;
  112. break;
  113. }
  114. $objContentBlockView->CssClass = $strCssClass;
  115. $objContentBlockView->Visible = true;
  116. }
  117. $this->Template = __QUASI_CORE_TEMPLATES__ . '/PageView.tpl.php';
  118. }
  119. public function __get($strName)
  120. {
  121. switch ($strName)
  122. {
  123. case 'HeaderContentBlocks':
  124. return $this->aryHeaderContentBlocks ;
  125. case 'LeftPanelContentBlocks':
  126. return $this->aryLeftPanelContentBlocks ;
  127. case 'CenterPanelContentBlocks':
  128. return $this->aryCenterPanelContentBlocks ;
  129. case 'RightPanelContentBlocks':
  130. return $this->aryRightPanelContentBlocks ;
  131. case 'FooterContentBlocks':
  132. return $this->aryFooterContentBlocks ;
  133. case 'ExtraContentBlocks':
  134. return $this->aryExtraContentBlocks ;
  135. case 'HasHeader':
  136. return $this->objPage->HasHeader ;
  137. case 'HasLeftColumn':
  138. return $this->objPage->HasLeftColumn ;
  139. case 'HasRightColumn':
  140. return $this->objPage->HasRightColumn ;
  141. case 'HasFooter':
  142. return $this->objPage->HasFooter ;
  143. default:
  144. try {
  145. return parent::__get($strName);
  146. } catch (QCallerException $objExc) {
  147. $objExc->IncrementOffset();
  148. throw $objExc;
  149. }
  150. }
  151. }
  152. }//end class
  153. }//end define
  154. ?>