Phundament-Packages
[ class tree: Phundament-Packages ] [ index: Phundament-Packages ] [ 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: 603 $  $Date: 2007-02-25 01:22:18 +0100 (So, 25 Feb 2007) $
  11.  * @package Phundament.Packages
  12.  * @subpackage LVirtualNodes
  13.  */
  14.  
  15. /**
  16.  * Displays and manages the CSS menu (sitemap tree)
  17.  *
  18.  * @package System.Web.UI.WebControls
  19.  * @subpackage Navigation
  20.  */
  21.  
  22. class LPageMenu extends TTemplateControl
  23. {
  24.     #private $_nodes;
  25.         private $_horizontal;
  26.     private $Level;
  27.  
  28.     /**
  29.      * @param boolean: show menu horizontal / vertical
  30.      */
  31.     function setHorizontal($value)
  32.     {
  33.         $this->_horizontal$value;
  34.     }
  35.     /**
  36.      * @return Menu orientation settings,
  37.      */
  38.     function getHorizontal()
  39.     {
  40.         return TPropertyValue :: ensureBoolean($this->_horizontal);
  41.     }
  42.  
  43.     /**
  44.      * @param 
  45.      */
  46.     function setRootNodeId($value)
  47.     {
  48.         $this->setViewState("RootNodeId"$value);
  49.     }
  50.     /**
  51.      * @return 
  52.      */
  53.     function getRootNodeId()
  54.     {
  55.         return $this->getViewState("RootNodeId"1);
  56.     }
  57.     /**
  58.      * @param 
  59.      */
  60.     function setRootNodeAlias($value)
  61.     {
  62.         $this->setViewState("RootNodeAlias"$value);
  63.     }
  64.     /**
  65.      * @return 
  66.      */
  67.     function getRootNodeAlias()
  68.     {
  69.         return $this->getViewState("RootNodeAlias"false);
  70.     }
  71.  
  72.     /**
  73.      * @param 
  74.      */
  75.     function setDescentLimit($value)
  76.     {
  77.         $this->setViewState("DescentLimit"$value);
  78.     }
  79.     /**
  80.      * @return 
  81.      */
  82.     function getDescentLimit()
  83.     {
  84.         return $this->getViewState("DescentLimit"null);
  85.     }
  86.  
  87.     /**
  88.      * @param 
  89.      */
  90.     function setEnableLocalization($value)
  91.     {
  92.         $this->setViewState("EnableLocalization"TPropertyValue :: ensureBoolean($value));
  93.     }
  94.     /**
  95.      * @return 
  96.      */
  97.     function getEnableLocalization()
  98.     {
  99.         return $this->getViewState("EnableLocalization"false);
  100.     }
  101.  
  102.     /**
  103.      * Maps nodes from LPageService
  104.      */
  105.     function onLoad($param)
  106.     {
  107.         parent :: onLoad($param);
  108.     }
  109.  
  110.     /**
  111.      * Adds automatic menu init
  112.      */
  113.     function onPreRender($param)
  114.     {
  115.         parent :: onPreRender($param);
  116.         $this->CssMenu->setHorizontal($this->getHorizontal());
  117.         if ($this->Service->areNodesAvailable(&& $this->findControl("MenuPlaceholder"!== null)
  118.             $this->initMenu($this->MenuPlaceholder);
  119.         else
  120.             Prado :: log("Can not render menu (node tree status:" $this->Service->areNodesAvailable(")"4'Lithron.LPageMenu');
  121.     }
  122.  
  123.     /**
  124.      * Builds menu with data from sitemap tree and implements caching
  125.      */
  126.     function initMenu($parent)
  127.     {
  128.         $menunew TControl;
  129.         $_nodes$this->Service->getNodeById($this->getRootNodeId());
  130.         if (!$_nodes instanceof LVirtualNodesSiteNode)
  131.             return;
  132.  
  133.         $this->renderMenu($menu$_nodes"");
  134.         Prado :: trace("Menu rendered"'Lithron.LPageMenu');
  135.  
  136.         $parent->Controls[]$menu;
  137.     }
  138.  
  139.     /**
  140.      * Recursive function for walk through sitemap tree
  141.      *
  142.      * @todo
  143.      */
  144.     function renderMenu($parent$nodeTree$uri)
  145.     {
  146.         #Prado :: trace("Creating menu node...", 'Lithron.LPageMenu');
  147.         $child$nodeTree->getFirstChildNode();
  148.         while ($child)
  149.         {
  150.             $menuNodePrado :: createComponent('LCssDropDownMenuNode');
  151.             $parent->Controls[]$menuNode;
  152.  
  153.             if ($this->Service->CurrentNode)
  154.             {
  155.                 $ancestors$this->Service->CurrentNode->getAncestors();
  156.                 foreach ($ancestors AS $ancestor)
  157.                 {
  158.                     if ($ancestor->getId(== $child->getId())
  159.                     {
  160.                         $menuNode->setSelectedPath(true);
  161.                     }
  162.                 }
  163.             }
  164.  
  165.             $_name$child->getDescriptiveName();
  166.             $_alias$child->getAlias();
  167.             $name(!empty ($_name)) $_name $_alias;
  168.  
  169.             if ($this->getEnableLocalization(== true)
  170.                 $namePrado :: localize($name);
  171.             $menuNode->setText($name)// TODO
  172.  
  173.             $new_uri"";
  174.             $menuNode->setLinkUrl($this->Service->constructUrl($child->getAlias()));
  175.  
  176.             // render childs
  177.             $levelsubstr_count($child->getPath()".");
  178.             if ($this->getDescentLimit(=== null || $this->getDescentLimit($level)
  179.                 $this->renderMenu($menuNode$child$new_uri);
  180.  
  181.             // inlcude dynamic menus
  182.             /* TEMP DISABLED TODO
  183.             $dclass = $child->getDynmenuClass();
  184.             $dmethod = $child->getDynmenuMethod();
  185.             if ($dclass && $dmethod)
  186.             {
  187.                 $sn = $this->Application->singleton($dclass);
  188.                 $sn-> $dmethod ($menuNode, $child, $new_uri);
  189.             }*/
  190.  
  191.             #Prado :: trace("Created menu node [$name]", 'Lithron.LPageMenu');
  192.  
  193.             $child$child->getSiblingNode();
  194.         }
  195.     }
  196. }
  197. ?>

Documentation generated on Sun, 25 Feb 2007 16:11:21 +0100 by phpDocumentor 1.3.1