- <?php
-
-
- /**
- * Menu class file.
- *
- * @license http://opensource.org/licenses/mozilla1.1.php Mozilla Public License
- * @copyright 2005, diemeisterei GmbH. All rights reserved.
- * @author $Author: schmunk $
- * @version $Revision: 246 $ $Date: 2006-06-01 17:11:24 +0200 (Do, 01 Jun 2006) $
- * @package Lithron.LVirtualNodes
- * @subpackage WebControls
- */
-
- /**
- * Displays and manages the CSS menu (sitemap tree)
- *
- * @package System.Web.UI.WebControls
- */
-
- class LPageMenu extends TTemplateControl
- {
- #private $_nodes;
- private $_horizontal;
-
-
- /**
- * @param boolean: show menu horizontal / vertical
- */
- function setHorizontal($value)
- {
- $this->_horizontal = $value;
- }
- /**
- * @return Menu orientation settings,
- */
- function getHorizontal()
- {
- return $this->_horizontal;
- }
-
- /**
- * Maps nodes from LPageService
- */
- function onLoad($param)
- {
- $this->CssMenu->setHorizontal($this->getHorizontal());
- parent :: onLoad($param);
- }
-
- /**
- * Adds automatic menu init
- */
- function onPreRender($param)
- {
- if ($this->Service->areNodesAvailable() && $this->findControl("MenuPlaceholder") !== null)
- $this->initMenu($this->MenuPlaceholder);
- else
- Prado :: trace("Can not render menu (node tree status:".$this->Service->areNodesAvailable().")", 'Lithron.LPageMenu');
- parent :: onPreRender($param);
- }
-
- /**
- * Builds menu with data from sitemap tree and implements caching
- */
- function initMenu($parent)
- {
-
- if ($cache = $this->Application->Cache)
- {
- $menu = $cache->get("LPageMenu:".$this->getUniqueID());
- }
-
- if (is_object($menu))
- {
- Prado :: trace("Using cached menu", 'Lithron.LPageMenu');
- } else
- {
- $menu = new TControl;
- $_nodes = $this->Service->getNodes();
- $this->renderMenu($menu, $_nodes, "");
- if ($cache)
- $cache->set("LPageMenu:".$this->getUniqueID(), $menu, $this->Application->getGlobalState("LVirtualNodes:cachingTime", 0));
- Prado :: trace("Menu rendered", 'Lithron.LPageMenu');
- }
-
- $parent->Controls[] = $menu;
- }
-
- /**
- * Recursive function for walk through sitemap tree
- *
- * @todo
- */
- function renderMenu($parent, $nodeTree, $uri)
- {
- $child = $nodeTree->getFirstChildNode();
- while ($child)
- {
- $menuNode = Prado :: createComponent('LCssDropDownMenuNode');
- $parent->Controls[] = $menuNode;
-
- $name = $child->getAlias();
- $menuNode->setText($name); // TODO
-
- #$uri_part = str_replace(" ", "+", $name);
- #$new_uri = $uri.$uri_part."/";
- $new_uri = "";
- #$this->Request->constructUrl($new_uri));
-
- $menuNode->setLinkId(LPageService::NODE_PREFIX.$child->getId());
- $menuNode->setLinkUrl($this->Service->constructUrl(LPageService::NODE_PREFIX.$child->getId()));
-
- // render childs
- $this->renderMenu($menuNode, $child, $new_uri);
-
- // inlcude dynamic menus
- $dclass = $child->getDynmenuClass();
- $dmethod = $child->getDynmenuMethod();
- if ($dclass && $dmethod)
- {
- $sn = $this->Application->singleton($dclass);
- $sn-> $dmethod ($menuNode, $child, $new_uri);
- }
-
- $child = $child->getSiblingNode();
- }
- }
- }
- ?>