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.

185 lines
6.6 KiB

13 years ago
  1. <?php
  2. if(!defined('QUASICMS') ) die("No quasi.");
  3. /**
  4. * This is the View class for display functionality of the Menu class.
  5. * It provides a div based area for content with hierarchy, css id and class
  6. * and a relationship to the basic areas managed by ContentBlockView. It is to a
  7. * Menu that a MenuItem is assigned. This class will render any child Menus
  8. * and all associated Items.
  9. * These associations may configured via the QuasiCMS Dashboard interface and
  10. * will then automatically be reflected in the associated ContentBlockView display.
  11. *
  12. *@author Erik Winn <erikwinnmail@yahoo.com>
  13. *
  14. *
  15. * $Id: MenuView.class.php 294 2008-10-13 22:29:36Z erikwinn $
  16. *@version 0.1
  17. *
  18. *@copyright (C) 2008 by Erik Winn
  19. *@license GPL v.2
  20. This program is free software; you can redistribute it and/or modify
  21. it under the terms of the GNU General Public License as published by
  22. the Free Software Foundation; either version 2 of the License, or
  23. (at your option) any later version.
  24. This program is distributed in the hope that it will be useful,
  25. but WITHOUT ANY WARRANTY; without even the implied warranty of
  26. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  27. GNU General Public License for more details.
  28. You should have received a copy of the GNU General Public License
  29. along with this program; if not, write to the Free Software
  30. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111 USA
  31. *
  32. * @package Quasi
  33. * @subpackage Views
  34. *
  35. */
  36. class MenuView extends QPanel
  37. {
  38. // Local instances of the Parent object, Menu and MenuItems
  39. protected $objParentObject;
  40. protected $objMenu;
  41. public $aryMenuItemViews;
  42. protected $strTitle;
  43. protected $intLevel = 0;
  44. // This Menu block's CSS id
  45. protected $strCssId;
  46. protected $strCssclass;
  47. public function __construct($objParentObject, Menu $objMenu/*, $strCssId*/)
  48. {
  49. //Parent must always be a ContentBlock or a MenuView
  50. $this->objParentObject = $objParentObject;
  51. $this->strCssId = preg_replace('/\s/', '',$objMenu->Name);
  52. // $this->strCssId = $strCssId;
  53. try {
  54. parent::__construct($this->objParentObject, $this->strCssId);
  55. } catch (QCallerException $objExc) {
  56. $objExc->IncrementOffset();
  57. throw $objExc;
  58. }
  59. if( !$objMenu )
  60. throw new QCallerException(sprintf("Menu %s created without a MenuItem!", $strCssId) );
  61. else
  62. $this->objMenu = $objMenu;
  63. $this->strTitle = $this->objMenu->Title;
  64. if($objMenu->CssClass)
  65. $this->AddCssClass($objMenu->CssClass);
  66. $this->AddCssClass($objMenu->Type);
  67. $this->Template = __QUASI_CORE_TEMPLATES__ . '/MenuView.tpl.php';
  68. $aryMenuItems = $this->objMenu->GetMenuItemAsItemArray( QQ::Clause(
  69. QQ::OrderBy(QQN::MenuItem()->SortOrder)
  70. ));
  71. foreach($aryMenuItems as $objMenuItem )
  72. {
  73. $objMenuItemView = new MenuItemView( $this, $objMenuItem );
  74. //Note: this will increment
  75. $objMenuItemView->Level = $this->Level + 1;
  76. $this->aryMenuItemViews[] = $objMenuItemView;
  77. }
  78. /* if(!$this->mctMenu || !$this->objMenu )
  79. $this->Template = 'BasicMenu.tpl.php';
  80. else
  81. switch( $this->objMenu->Type )
  82. {
  83. case 'Menu':
  84. $this->Template = 'MenuMenu.tpl.php';
  85. break;
  86. case 'MenuItem':
  87. $this->Template = 'MenuItemMenu.tpl.php';
  88. break;
  89. case 'Header':
  90. $this->Template = 'HeaderMenu.tpl.php';
  91. break;
  92. case 'RightPanel':
  93. $this->Template = 'RightPanelMenu.tpl.php';
  94. break;
  95. case 'LeftPanel':
  96. $this->Template = 'LeftPanelMenu.tpl.php';
  97. break;
  98. case 'CenterPanel':
  99. $this->Template = 'CenterPanelMenu.tpl.php';
  100. break;
  101. case 'Footer':
  102. $this->Template = 'FooterMenu.tpl.php';
  103. break;
  104. case 'BlockHeader':
  105. $this->Template = 'BlockHeaderMenu.tpl.php';
  106. break;
  107. case 'BlockFooter':
  108. $this->Template = 'BlockFooterMenu.tpl.php';
  109. break;
  110. default:
  111. $this->Template = 'BasicMenu.tpl.php';
  112. }*/
  113. }
  114. protected function init()
  115. {
  116. }
  117. public function __get($strName)
  118. {
  119. switch ($strName)
  120. {
  121. case 'Level':
  122. return $this->intLevel ;
  123. case 'CssId':
  124. return $this->strCssId ;
  125. case 'Title':
  126. return $this->strTitle ;
  127. case 'ShowTitle':
  128. return $this->objMenu->ShowTitle ;
  129. case 'Name':
  130. return $this->objMenu->Name ;
  131. case 'MenuItemViews':
  132. return $this->aryMenuItemViews ;
  133. default:
  134. try {
  135. return parent::__get($strName);
  136. } catch (QCallerException $objExc) {
  137. $objExc->IncrementOffset();
  138. throw $objExc;
  139. }
  140. }
  141. }
  142. public function __set($strName, $mixValue)
  143. {
  144. switch ($strName)
  145. {
  146. case 'Level':
  147. try {
  148. return ($this->intLevel = QType::Cast($mixValue, QType::Integer));
  149. } catch (QInvalidCastException $objExc) {
  150. $objExc->IncrementOffset();
  151. throw $objExc;
  152. }
  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. ?>