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.

159 lines
5.8 KiB

13 years ago
  1. <?php
  2. if(!defined('QUASICMS') ) die("No quasi.");
  3. if (!defined("BLOGMODULE.CLASS.PHP")){
  4. define("BLOGMODULE.CLASS.PHP",1);
  5. /**
  6. * Class BlogModule - provides module that loads content items of type "BlogPost"
  7. *
  8. * To use this module, assign it to a content block and create content items that have the
  9. * content type set to BlogPost. This module will display the most recent 10 posts sorted
  10. * by date descending.
  11. *
  12. * This class can also be used independently by instantiating the class. It accepts optional
  13. * parameters for the type of content item to display and the number of items.
  14. *
  15. *@author Erik Winn <erikwinnmail@yahoo.com>
  16. *
  17. * $Id: BlogModule.class.php 517 2009-03-24 17:59:23Z erikwinn $
  18. *@version 0.1
  19. *
  20. *@copyright (C) 2008 by Erik Winn
  21. *@license GPL v.2
  22. This program is free software; you can redistribute it and/or modify
  23. it under the terms of the GNU General Public License as published by
  24. the Free Software Foundation; either version 2 of the License, or
  25. (at your option) any later version.
  26. This program is distributed in the hope that it will be useful,
  27. but WITHOUT ANY WARRANTY; without even the implied warranty of
  28. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  29. GNU General Public License for more details.
  30. You should have received a copy of the GNU General Public License
  31. along with this program; if not, write to the Free Software
  32. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
  33. *
  34. *@package Quasi
  35. * @subpackage Modules
  36. */
  37. class BlogModule extends QPanel
  38. {
  39. /**
  40. * @var ContentBlockView objContentBlock - the content block to which this module is assigned
  41. */
  42. protected $objContentBlock;
  43. /**
  44. * @var array aryContentItems ContentItems to be displayed
  45. */
  46. protected $aryContentItems;
  47. /**
  48. * @var array aryContentItemViews ContentItemViews to be displayed
  49. */
  50. public $aryContentItemViews;
  51. /**
  52. * Module constructor
  53. * NOTE: When loaded as a module registered in the database, the parameters will be
  54. * a reference to the Module ORM object.
  55. *@param ContentBlock - parent controller object.
  56. *@param mixed - extra parameters for the displayed module
  57. *@param integer - optional content type to display
  58. *@param integer - optional number of posts to display
  59. */
  60. public function __construct( ContentBlockView $objContentBlock,
  61. $mixParameters = null,
  62. $intContentType=ContentType::BlogPost,
  63. $intLimit=10)
  64. {
  65. //Parent should always be a ContentBlockView
  66. $this->objContentBlock =& $objContentBlock;
  67. try {
  68. parent::__construct($this->objContentBlock);
  69. } catch (QCallerException $objExc) {
  70. $objExc->IncrementOffset();
  71. throw $objExc;
  72. }
  73. $this->strTemplate = __QUASI_CORE_TEMPLATES__ . '/BlogModule.tpl.php';
  74. $objConditions = QQ::AndCondition(
  75. QQ::Equal(QQN::ContentItem()->TypeId, $intContentType),
  76. QQ::Equal(QQN::ContentItem()->StatusId, ContentStatusType::Published)
  77. );
  78. $aryClauses = QQ::Clause(
  79. QQ::OrderBy(QQN::ContentItem()->CreationDate, false),
  80. QQ::LimitInfo($intLimit));
  81. $this->aryContentItems = ContentItem::QueryArray($objConditions, $aryClauses);
  82. foreach ( $this->aryContentItems as $objContentItem )
  83. {
  84. $objContentItemView = new ContentItemView( $this, $objContentItem );
  85. $objContentItemView->AddCssClass($objContentItem->Type);
  86. $this->aryContentItemViews[] = $objContentItemView;
  87. }
  88. }
  89. /**
  90. * This Function is called when any input is sent - on failure the
  91. * fields are redrawn with optional error messages.
  92. */
  93. public function Validate()
  94. {
  95. $blnToReturn = true;
  96. // validate input here
  97. return $blnToReturn;
  98. }
  99. /**
  100. * Event Handling
  101. */
  102. public function btnDoSomething_Click($strFormId, $strControlId, $strParameter)
  103. {
  104. Quasi::Redirect(__QUASI_SUBDIRECTORY__ . '/index.php/Home');
  105. }
  106. public function __get($strName)
  107. {
  108. switch ($strName)
  109. {
  110. /* case 'SomeClass':
  111. return $this->objSomeClass ;*/
  112. default:
  113. try {
  114. return parent::__get($strName);
  115. } catch (QCallerException $objExc) {
  116. $objExc->IncrementOffset();
  117. throw $objExc;
  118. }
  119. }
  120. }
  121. public function __set($strName, $mixValue)
  122. {
  123. switch ($strName)
  124. {
  125. // case 'SomeClass':
  126. // try {
  127. // return ($this->objSomeClass = QType::Cast($mixValue, 'SomeClass' ));
  128. // } catch (QInvalidCastException $objExc) {
  129. // $objExc->IncrementOffset();
  130. // throw $objExc;
  131. // }
  132. default:
  133. try {
  134. return (parent::__set($strName, $mixValue));
  135. } catch (QCallerException $objExc) {
  136. $objExc->IncrementOffset();
  137. throw $objExc;
  138. }
  139. }
  140. }
  141. }//end class
  142. }//end define
  143. ?>