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.

206 lines
8.5 KiB

13 years ago
  1. <?php
  2. if(!defined('QUASICMS') ) die("No quasi.");
  3. /**
  4. * Class ContentItemView - provids display of a content item
  5. * This class provides display of a ContentItem from the database - it is rendered
  6. * by a ContentBlockView template, which must always exist as a parent. The content
  7. * block view creates this with a reference to itself and a ContentItem ORM object drawn
  8. * from the content_item table. Here we instantiate the panels that display the content item
  9. * fields which are rendered in the template according to active flags. Title, Author, Description
  10. * and the other fields are optionally rendered - this behaviour can be configured from the
  11. * administrative interface.
  12. *
  13. *@author Erik Winn <erikwinnmail@yahoo.com>
  14. *
  15. *
  16. * $Id: ContentItemView.class.php 293 2008-10-13 19:02:28Z erikwinn $
  17. *@version 0.1
  18. *
  19. *@copyright (C) 2008 by Erik Winn
  20. *@license GPL v.2
  21. This program is free software; you can redistribute it and/or modify
  22. it under the terms of the GNU General Public License as published by
  23. the Free Software Foundation; either version 2 of the License, or
  24. (at your option) any later version.
  25. This program is distributed in the hope that it will be useful,
  26. but WITHOUT ANY WARRANTY; without even the implied warranty of
  27. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  28. GNU General Public License for more details.
  29. You should have received a copy of the GNU General Public License
  30. along with this program; if not, write to the Free Software
  31. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
  32. *
  33. * @package Quasi
  34. * @subpackage Views
  35. */
  36. class ContentItemView extends QPanel
  37. {
  38. // Local instances of the ContentItemMetaControl, Parent object, child ContentItems and ContentItems
  39. protected $objParentObject;
  40. protected $objContentItem;
  41. ///NOTE: in future, i want to implement an edit mode to allow inline editing, hence the
  42. /// meta control here ..
  43. protected $mctContentItem;
  44. // Panels for ContentItem's individual data fields
  45. protected $pnlTitle;
  46. protected $pnlDescription;
  47. protected $pnlText;
  48. protected $pnlCreator;
  49. protected $pnlCreationDate;
  50. protected $pnlLastModification;
  51. // This blocks CSS - note that Cssclass has a lower case c to avoid conflict with QCodo core ..
  52. protected $strCssId;
  53. protected $strCssclass;
  54. public function __construct($objParentObject, $objContentItem )
  55. {
  56. //Parent must always be a child of QForm or Qcontrol
  57. $this->objParentObject = $objParentObject;
  58. try {
  59. parent::__construct($this->objParentObject, $this->strCssId);
  60. } catch (QCallerException $objExc) {
  61. $objExc->IncrementOffset();
  62. throw $objExc;
  63. }
  64. if( $objContentItem )
  65. {
  66. $this->mctContentItem = new ContentItemMetaControl($this, $objContentItem);
  67. $this->objContentItem = $objContentItem;
  68. }
  69. else//just in case, make _something_ ... todo, error out?
  70. {
  71. $this->mctContentItem = ContentItemMetaControl::Create($this);
  72. $this->objContentItem = $this->mctContentItem->ContentItem;
  73. }
  74. $this->strCssId = preg_replace('/\s/', '',$objContentItem->Name);
  75. $this->AddCssClass($objContentItem->Cssclass);
  76. $this->pnlTitle = $this->mctContentItem->pnlTitle_Create($this->CssId );
  77. $this->pnlTitle->CssClass = "ContentItemTitle";
  78. $this->pnlDescription = $this->mctContentItem->pnlDescription_Create($this->CssId);
  79. $this->pnlDescription->CssClass = "ContentItemDescription";
  80. $this->pnlText = $this->mctContentItem->pnlText_Create($this->CssId );
  81. $this->pnlText->CssClass = "ContentItemText";
  82. $this->pnlCreator = $this->mctContentItem->pnlCreatorId_Create($this->CssId);
  83. $this->pnlCreator->Name = "Written by:";
  84. $this->pnlCreator->CssClass = "ContentItemCreator";
  85. $this->pnlCreationDate = $this->mctContentItem->pnlCreationDate_Create($this->CssId);
  86. $this->pnlCreationDate->Name = "Created On:";
  87. $this->pnlCreationDate->CssClass = "ContentItemCreationDate";
  88. $this->pnlLastModification = $this->mctContentItem->pnlLastModification_Create($this->CssId);
  89. $this->pnlLastModification->Name = "Last Modification:";
  90. $this->pnlLastModification->CssClass = "ContentItemLastModification";
  91. // Setup the Template
  92. $this->Template = __QUASI_CORE_TEMPLATES__ . '/ContentItemView.tpl.php';
  93. /* just thinking here ..
  94. if(!$this->mctContentItem || !$this->objContentItem )
  95. $this->Template = 'BasicContentItem.tpl.php';
  96. else
  97. switch( $this->objContentItem->Type )
  98. {
  99. case 'Menu':
  100. $this->Template = 'MenuContentItem.tpl.php';
  101. break;
  102. case 'MenuItem':
  103. $this->Template = 'MenuItemContentItem.tpl.php';
  104. break;
  105. case 'Header':
  106. $this->Template = 'HeaderContentItem.tpl.php';
  107. break;
  108. case 'RightPanel':
  109. $this->Template = 'RightPanelContentItem.tpl.php';
  110. break;
  111. case 'LeftPanel':
  112. $this->Template = 'LeftPanelContentItem.tpl.php';
  113. break;
  114. case 'CenterPanel':
  115. $this->Template = 'CenterPanelContentItem.tpl.php';
  116. break;
  117. case 'Footer':
  118. $this->Template = 'FooterContentItem.tpl.php';
  119. break;
  120. case 'BlockHeader':
  121. $this->Template = 'BlockHeaderContentItem.tpl.php';
  122. break;
  123. case 'BlockFooter':
  124. $this->Template = 'BlockFooterContentItem.tpl.php';
  125. break;
  126. default:
  127. $this->Template = 'BasicContentItem.tpl.php';
  128. }*/
  129. // $this->AutoRenderChildren = false;
  130. }
  131. //@todo provide defualt contstruction or errors for these
  132. public function __get($strName)
  133. {
  134. switch ($strName)
  135. {
  136. case 'CssId':
  137. return $this->strCssId ;
  138. case 'Cssclass':
  139. return $this->strCssclass ;
  140. case 'Title':
  141. return $this->pnlTitle ;
  142. case 'Description':
  143. return $this->pnlDescription ;
  144. case 'Text':
  145. return $this->pnlText ;
  146. case 'Creator':
  147. return $this->pnlCreator ;
  148. case 'CreationDate':
  149. return $this->pnlCreationDate ;
  150. case 'LastModification':
  151. return $this->pnlLastModification ;
  152. case 'ContentItem':
  153. return $this->objContentItem;
  154. case 'ShowTitle':
  155. return $this->objContentItem->ShowTitle ;
  156. case 'ShowDescription':
  157. return $this->objContentItem->ShowDescription ;
  158. case 'ShowCreator':
  159. return $this->objContentItem->ShowCreator ;
  160. case 'ShowCreationDate':
  161. return $this->objContentItem->ShowCreationDate ;
  162. case 'ShowLastModification':
  163. return $this->objContentItem->ShowLastModification ;
  164. default:
  165. try {
  166. return parent::__get($strName);
  167. } catch (QCallerException $objExc) {
  168. $objExc->IncrementOffset();
  169. throw $objExc;
  170. }
  171. }
  172. }
  173. public function __set($strName, $mixValue)
  174. {
  175. switch ($strName)
  176. {
  177. default:
  178. try {
  179. return (parent::__set($strName, $mixValue));
  180. } catch (QCallerException $objExc) {
  181. $objExc->IncrementOffset();
  182. throw $objExc;
  183. }
  184. }
  185. }
  186. }
  187. ?>