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.

178 lines
5.9 KiB

  1. <?php
  2. if(!defined('QUINTACMS') ) die("No quinta.");
  3. /**
  4. * Class ContentItemController - provids display of a content item
  5. * This class provides display of a ContentItem from the database - it is rendered
  6. * by a ContentBlockController 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 <sidewalksoftware@gmail.com>
  14. *
  15. *@version 0.3
  16. *
  17. * @package Quinta
  18. * @subpackage Controllers
  19. */
  20. class ContentItemController extends QPanel{
  21. // Local instances of the ContentItemMetaControl, Parent object, child ContentItems and ContentItems
  22. protected $objParentObject;
  23. protected $objContentItem;
  24. ///NOTE: in future, i want to implement an edit mode to allow inline editing, hence the
  25. /// meta control here ..
  26. protected $mctContentItem;
  27. // Panels for ContentItem's individual data fields
  28. protected $pnlTitle;
  29. protected $pnlDescription;
  30. protected $pnlText;
  31. protected $pnlCreator;
  32. protected $pnlCreationDate;
  33. protected $pnlLastModification;
  34. // This blocks CSS - note that Cssclass has a lower case c to avoid conflict with QCodo core ..
  35. protected $strCssId;
  36. protected $strCssclass;
  37. public function __construct($objParentObject, $objContentItem )
  38. {
  39. //Parent must always be a child of QForm or Qcontrol
  40. $this->objParentObject = $objParentObject;
  41. try {
  42. parent::__construct($this->objParentObject, $this->strCssId);
  43. } catch (QCallerException $objExc) {
  44. $objExc->IncrementOffset();
  45. throw $objExc;
  46. }
  47. if( $objContentItem ){
  48. $this->mctContentItem = new ContentItemMetaControl($this, $objContentItem);
  49. $this->objContentItem = $objContentItem;
  50. }else { ///@todo just in case, make _something_ ... todo, error out?
  51. $this->mctContentItem = ContentItemMetaControl::Create($this);
  52. $this->objContentItem = $this->mctContentItem->ContentItem;
  53. }
  54. $this->strCssId = preg_replace('/\s/', '',$objContentItem->Name);
  55. $this->AddCssClass($objContentItem->Cssclass);
  56. $this->pnlTitle = $this->mctContentItem->pnlTitle_Create($this->CssId );
  57. $this->pnlTitle->CssClass = "ContentItemTitle";
  58. $this->pnlDescription = $this->mctContentItem->pnlDescription_Create($this->CssId);
  59. $this->pnlDescription->CssClass = "ContentItemDescription";
  60. $this->pnlText = $this->mctContentItem->pnlText_Create($this->CssId );
  61. $this->pnlText->CssClass = "ContentItemText";
  62. $this->pnlCreator = $this->mctContentItem->pnlCreatorId_Create($this->CssId);
  63. $this->pnlCreator->Name = "Written by:";
  64. $this->pnlCreator->CssClass = "ContentItemCreator";
  65. $this->pnlCreationDate = $this->mctContentItem->pnlCreationDate_Create($this->CssId);
  66. $this->pnlCreationDate->Name = "Created On:";
  67. $this->pnlCreationDate->CssClass = "ContentItemCreationDate";
  68. $this->pnlLastModification = $this->mctContentItem->pnlLastModification_Create($this->CssId);
  69. $this->pnlLastModification->Name = "Last Modification:";
  70. $this->pnlLastModification->CssClass = "ContentItemLastModification";
  71. // Setup the Template
  72. $this->Template = __QUINTA_CORE_VIEWS__ . '/ContentItemView.tpl.php';
  73. /* just thinking here ..
  74. if(!$this->mctContentItem || !$this->objContentItem )
  75. $this->Template = 'BasicContentItem.tpl.php';
  76. else
  77. switch( $this->objContentItem->Type )
  78. {
  79. case 'Menu':
  80. $this->Template = 'MenuContentItem.tpl.php';
  81. break;
  82. case 'MenuItem':
  83. $this->Template = 'MenuItemContentItem.tpl.php';
  84. break;
  85. case 'Header':
  86. $this->Template = 'HeaderContentItem.tpl.php';
  87. break;
  88. case 'RightPanel':
  89. $this->Template = 'RightPanelContentItem.tpl.php';
  90. break;
  91. case 'LeftPanel':
  92. $this->Template = 'LeftPanelContentItem.tpl.php';
  93. break;
  94. case 'CenterPanel':
  95. $this->Template = 'CenterPanelContentItem.tpl.php';
  96. break;
  97. case 'Footer':
  98. $this->Template = 'FooterContentItem.tpl.php';
  99. break;
  100. case 'BlockHeader':
  101. $this->Template = 'BlockHeaderContentItem.tpl.php';
  102. break;
  103. case 'BlockFooter':
  104. $this->Template = 'BlockFooterContentItem.tpl.php';
  105. break;
  106. default:
  107. $this->Template = 'BasicContentItem.tpl.php';
  108. }*/
  109. // $this->AutoRenderChildren = false;
  110. }
  111. ///@todo provide defualt contstruction or errors for these
  112. public function __get($strName){
  113. switch ($strName){
  114. case 'CssId':
  115. return $this->strCssId ;
  116. case 'Cssclass':
  117. return $this->strCssclass ;
  118. case 'Title':
  119. return $this->pnlTitle ;
  120. case 'Description':
  121. return $this->pnlDescription ;
  122. case 'Text':
  123. return $this->pnlText ;
  124. case 'Creator':
  125. return $this->pnlCreator ;
  126. case 'CreationDate':
  127. return $this->pnlCreationDate ;
  128. case 'LastModification':
  129. return $this->pnlLastModification ;
  130. case 'ContentItem':
  131. return $this->objContentItem;
  132. case 'ShowTitle':
  133. return $this->objContentItem->ShowTitle ;
  134. case 'ShowDescription':
  135. return $this->objContentItem->ShowDescription ;
  136. case 'ShowCreator':
  137. return $this->objContentItem->ShowCreator ;
  138. case 'ShowCreationDate':
  139. return $this->objContentItem->ShowCreationDate ;
  140. case 'ShowLastModification':
  141. return $this->objContentItem->ShowLastModification ;
  142. default:
  143. try {
  144. return parent::__get($strName);
  145. } catch (QCallerException $objExc) {
  146. $objExc->IncrementOffset();
  147. throw $objExc;
  148. }
  149. }
  150. }
  151. public function __set($strName, $mixValue){
  152. switch ($strName){
  153. default:
  154. try {
  155. return (parent::__set($strName, $mixValue));
  156. } catch (QCallerException $objExc) {
  157. $objExc->IncrementOffset();
  158. throw $objExc;
  159. }
  160. }
  161. }
  162. }
  163. ?>