Phundament-Packages
[ class tree: Phundament-Packages ] [ index: Phundament-Packages ] [ all elements ]

Source for file LSitenodeSelection.php

Documentation is available at LSitenodeSelection.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: 128 $  $Date: 2006-04-25 15:50:26 +0000 (Di, 25 Apr 2006) $
  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 Admin
  20.  */
  21.  
  22. class LSitenodeSelection extends TPanel implements INamingContainer
  23. {
  24.     public function getMode()
  25.     {
  26.         return $this->getViewState("mode""select");
  27.     }
  28.  
  29.     public function setMode($mode)
  30.     {
  31.         $this->setViewState("mode"$mode"select");
  32.     }
  33.  
  34.     public function getSelectedValue()
  35.     {
  36.         return $this->getViewState("sel""1");
  37.     }
  38.  
  39.     public function setSelectedValue($sel)
  40.     {
  41.         $this->setViewState("sel"$sel"1");
  42.     }
  43.  
  44.     public function getBehaviour()
  45.     {
  46.         return $this->getViewState("beh""None");
  47.     }
  48.  
  49.     public function setBehaviour($sel)
  50.     {
  51.         $this->setViewState("beh"TPropertyValue::ensureEnum($selarray("None""Postback""Callback"))"None");
  52.     }
  53.  
  54.     private function onSelectionChanged($param)
  55.     {
  56.         $this->raiseEvent('OnSelectionChanged'$this$param);    
  57.     }
  58.  
  59.     function onLoad($param)
  60.     {
  61.         
  62.         parent :: onLoad($param);
  63.         if (!$this->Page->IsPostBack && $this->Request->contains("selectedNode"))
  64.         {
  65.             $this->setSelectedValue($this->Request->itemAt("selectedNode"));
  66.             $this->onSelectionChanged($this->getSelectedValue());            
  67.         }
  68.         $root$this->Service->getNodes();
  69.         $this->setStyle("font-family: Andale mono, Courier new, monospace; line-height: 1.4em; font-size: 1.1em");
  70.         $this->setCssClass("LSitenodeSelection");
  71.         $this->genTree($root);
  72.     }
  73.     
  74.     private function genRadioButton($cdata)
  75.     {
  76.         $b $this->getBehaviour();
  77.         $cname =  $b == "Callback" "TActiveRadioButton" "TRadioButton";
  78.         $rbPrado :: createComponent($cname);
  79.         $rb->setGroupName($this->getClientID(false));
  80.         $rb->setCustomData($cdata);
  81.         $rb->setAutoPostBack($b != "None");
  82.  
  83.         if ($b == "Callback")
  84.             $rb->OnCallback[]array (
  85.                 $this,
  86.                 "radioChanged"
  87.             );
  88.         else
  89.             $rb->OnCheckedChanged[]array (
  90.                 $this,
  91.                 "radioChanged"
  92.             );
  93.         return $rb;
  94.     
  95.  
  96.     private function genTree($node$level0$firsttrue)
  97.     {
  98.         if ((LRightsManager::getRights($node1))
  99.             {}
  100.         else
  101.             return;
  102.  
  103.         // generate tree-like prefix
  104.         $trace$node;
  105.         $prefix"";
  106.         for ($i0$i $level$i++)
  107.         {
  108.             $trace$trace->getParentNode();
  109.             if ($trace->getSiblingNode(|| $this->Mode == "insert")
  110.                 $prefix"|&nbsp;&nbsp;" $prefix;
  111.             else
  112.                 $prefix"&nbsp;&nbsp;&nbsp;" $prefix;
  113.         }
  114.         if ($level != 0)
  115.             $prefix .= ($node->getSiblingNode(|| $this->Mode == "insert" "|" "+""--";
  116.         $prefixsubstr($prefix$this->Mode == "insert" 13 18);
  117.  
  118.         // generate Insert-Before-Box
  119.         if ($this->Mode == "insert" && $level != 0
  120.             && $first
  121.             && LRightsManager::getRights($node->getParentNode()) LPermissions::CREATE)
  122.  
  123.         {
  124.             $rb $this->genRadioButton($node->getPath());
  125.             $this->Controls[]$prefix;
  126.             $this->Controls[]$rb;
  127.             $this->Controls[]"<br/>";
  128.             if (!$this->Page->IsPostBack)
  129.                 $rb->setChecked($node->getPath(== $this->getSelectedValue());
  130.         }
  131.  
  132.         // generate Current-Node-Box
  133.         if ($this->Mode != "select"# insert - mode
  134.         {
  135.             $string($node->getDescriptiveName()) $node->getDescriptiveName($node->getAlias();
  136.             $this->Controls[]$prefix ."<b>"$string."</b> ($level)";
  137.             $this->Controls[]"<br/>";
  138.         }
  139.         else # select - mode
  140.         {
  141.             $rb $this->genRadioButton($node->getPath());
  142.             if ($prefix)
  143.                 $this->Controls[]$prefix;
  144.  
  145.             if (LRightsManager::getRights($nodeLPermissions::EDIT)
  146.                 $this->Controls[]$rb;
  147.  
  148.             $this->Controls[]"<b>".TPropertyValue :: ensureString($node->getDescriptiveName())."</b>";
  149.             $this->Controls[]" (" $node->getAlias(")";
  150.             $this->Controls[]"<br/>";
  151.             if (!$this->Page->IsPostBack)
  152.                 $rb->setChecked($node->getPath(== $this->getSelectedValue());
  153.         }
  154.  
  155.         // generate Children
  156.         $subnode$node->getFirstChildNode();
  157.         if (!$subnode && $this->Mode == "insert"
  158.             && LRightsManager::getRights($nodeLPermissions::CREATE)
  159.         {
  160.             // generate Node-Child-Insertion-Box
  161.             $rb $this->genRadioButton($node->getPath(".1");
  162.             $otherprefixsubstr($prefix0strlen($prefix2);
  163.             $this->Controls[]$otherprefix "&nbsp;&nbsp;+--";
  164.             $this->Controls[]$rb;
  165.             $this->Controls[]"<br/>";
  166.         }
  167.         $isftrue;
  168.         // walk through child nodes
  169.         while ($subnode)
  170.         {
  171.             $this->genTree($subnode$level +1$isf);
  172.             $isffalse;
  173.             $subnode$subnode->getSiblingNode();
  174.         }
  175.  
  176.         // generate Insert-After-Box
  177.         if ($this->Mode == "insert" && $level != 0
  178.             && LRightsManager::getRights($node->getParentNode()) LPermissions::CREATE)
  179.         {
  180.             $parrexplode("."$node->getPath());
  181.             $parr[count($parr1]++;
  182.             $pimplode("."$parr);
  183.             if (!$node->getSiblingNode())
  184.                 $prefix[strlen($prefix3]"+";
  185.             $rb $this->genRadioButton($p);
  186.             $this->Controls[]$prefix;
  187.             $this->Controls[]$rb;
  188.             $this->Controls[]"<br/>";
  189.             if (!$this->Page->IsPostBack)
  190.                 $rb->setChecked($p == $this->getSelectedValue());
  191.         }
  192.     }
  193.  
  194.     public function radioChanged($sender$param)
  195.     {
  196.         $np $sender->CustomData;
  197.         $this->setSelectedValue($np);
  198.         $this->onSelectionChanged($np);
  199.     }                
  200.  
  201. }
  202. ?>

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