Lithron.LVirtualNodes
[ class tree: Lithron.LVirtualNodes ] [ index: Lithron.LVirtualNodes ] [ all elements ]

Source for file LPageMenu.php

Documentation is available at LPageMenu.php

  1. <?php
  2.  
  3.  
  4. /**
  5. * Menu class file.
  6. *
  7. * @license http://opensource.org/licenses/mozilla1.1.php Mozilla Public License
  8. * @copyright 2005, diemeisterei GmbH. All rights reserved.
  9. * @author $Author: schmunk $
  10. * @version $Revision: 246 $ $Date: 2006-06-01 17:11:24 +0200 (Do, 01 Jun 2006) $
  11. * @package Lithron.LVirtualNodes
  12. * @subpackage WebControls
  13. */
  14.  
  15. /**
  16. * Displays and manages the CSS menu (sitemap tree)
  17. *
  18. * @package System.Web.UI.WebControls
  19. */
  20.  
  21. class LPageMenu extends TTemplateControl
  22. {
  23. #private $_nodes;
  24. private $_horizontal;
  25.  
  26.  
  27. /**
  28. * @param boolean: show menu horizontal / vertical
  29. */
  30. function setHorizontal($value)
  31. {
  32. $this->_horizontal = $value;
  33. }
  34. /**
  35. * @return Menu orientation settings,
  36. */
  37. function getHorizontal()
  38. {
  39. return $this->_horizontal;
  40. }
  41.  
  42. /**
  43. * Maps nodes from LPageService
  44. */
  45. function onLoad($param)
  46. {
  47. $this->CssMenu->setHorizontal($this->getHorizontal());
  48. parent :: onLoad($param);
  49. }
  50.  
  51. /**
  52. * Adds automatic menu init
  53. */
  54. function onPreRender($param)
  55. {
  56. if ($this->Service->areNodesAvailable() && $this->findControl("MenuPlaceholder") !== null)
  57. $this->initMenu($this->MenuPlaceholder);
  58. else
  59. Prado :: trace("Can not render menu (node tree status:".$this->Service->areNodesAvailable().")", 'Lithron.LPageMenu');
  60. parent :: onPreRender($param);
  61. }
  62.  
  63. /**
  64. * Builds menu with data from sitemap tree and implements caching
  65. */
  66. function initMenu($parent)
  67. {
  68.  
  69. if ($cache = $this->Application->Cache)
  70. {
  71. $menu = $cache->get("LPageMenu:".$this->getUniqueID());
  72. }
  73.  
  74. if (is_object($menu))
  75. {
  76. Prado :: trace("Using cached menu", 'Lithron.LPageMenu');
  77. } else
  78. {
  79. $menu = new TControl;
  80. $_nodes = $this->Service->getNodes();
  81. $this->renderMenu($menu, $_nodes, "");
  82. if ($cache)
  83. $cache->set("LPageMenu:".$this->getUniqueID(), $menu, $this->Application->getGlobalState("LVirtualNodes:cachingTime", 0));
  84. Prado :: trace("Menu rendered", 'Lithron.LPageMenu');
  85. }
  86.  
  87. $parent->Controls[] = $menu;
  88. }
  89.  
  90. /**
  91. * Recursive function for walk through sitemap tree
  92. *
  93. * @todo
  94. */
  95. function renderMenu($parent, $nodeTree, $uri)
  96. {
  97. $child = $nodeTree->getFirstChildNode();
  98. while ($child)
  99. {
  100. $menuNode = Prado :: createComponent('LCssDropDownMenuNode');
  101. $parent->Controls[] = $menuNode;
  102.  
  103. $name = $child->getAlias();
  104. $menuNode->setText($name); // TODO
  105.  
  106. #$uri_part = str_replace(" ", "+", $name);
  107. #$new_uri = $uri.$uri_part."/";
  108. $new_uri = "";
  109. #$this->Request->constructUrl($new_uri));
  110.  
  111. $menuNode->setLinkId(LPageService::NODE_PREFIX.$child->getId());
  112. $menuNode->setLinkUrl($this->Service->constructUrl(LPageService::NODE_PREFIX.$child->getId()));
  113.  
  114. // render childs
  115. $this->renderMenu($menuNode, $child, $new_uri);
  116.  
  117. // inlcude dynamic menus
  118. $dclass = $child->getDynmenuClass();
  119. $dmethod = $child->getDynmenuMethod();
  120. if ($dclass && $dmethod)
  121. {
  122. $sn = $this->Application->singleton($dclass);
  123. $sn-> $dmethod ($menuNode, $child, $new_uri);
  124. }
  125.  
  126. $child = $child->getSiblingNode();
  127. }
  128. }
  129. }
  130. ?>

Documentation generated on Tue, 20 Jun 2006 05:15:20 +0200 by phpDocumentor 1.3.0RC4