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

Source for file LSitenodeParameters.php

Documentation is available at LSitenodeParameters.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: 444 $  $Date: 2006-12-14 23:34:02 +0100 (Thu, 14 Dec 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 LSitenodeParameters extends TTemplateControl
  23. {
  24.     private $np_changed false;
  25.  
  26.     public function getNodePath()
  27.     {
  28.         return $this->getViewState("NodePath""1");
  29.     }
  30.  
  31.     public function setNodePath($value)
  32.     {
  33.         if ($value != $this->getNodePath())
  34.         {
  35.             $this->np_changed true;
  36.             $this->setViewState("NodePath"$value"1");
  37.         }
  38.     }
  39.  
  40.     public function getMode()
  41.     {
  42.         return $this->getViewState("Mode""Edit");
  43.     }
  44.  
  45.     public function setMode($value)
  46.     {
  47.         $this->setViewState("Mode"TPropertyValue::ensureEnum($valuearray("Edit""New"))"Edit");
  48.     }
  49.  
  50.     public function onReloadPage($param)
  51.     {
  52.         $this->raiseEvent('OnReloadPage'$this$param);
  53.     }
  54.  
  55.     public function onPreRender($param)
  56.     {
  57.         parent::onPreRender($param);
  58.         if (!$this->Page->IsPostBack || $this->np_changed)
  59.         {
  60.             $p explode("."$this->getNodePath());
  61.             $node $this->Service->getNodes();
  62.             for ($i 1$i count($p)$i++)
  63.                 $node $node->getChildNodeAt($p[$i]);
  64.  
  65.             if ($this->Mode == "Edit")
  66.             {
  67.                 $this->RightsPanel->setRecord($node);
  68.                 if ($this->Page->IsCallBack)
  69.                 {
  70.                     $cb $this->Page->CallbackClient;
  71.                     $cb->setValue($this->Alias$node->getAlias());
  72.                     $cb->setValue($this->DescriptiveName$node->getDescriptiveName());
  73.                     $cb->setValue($this->PageTypetrim($node->getPage()));
  74.                     $cb->update($this->RightsContainer$this->RightsPanel);
  75.                 }
  76.                 else
  77.                 {
  78.                     $this->Alias->Text $node->getAlias();
  79.                     $this->DescriptiveName->Text $node->getDescriptiveName();
  80.                     try {
  81.                         $this->PageType->SelectedValue trim($node->getPage());
  82.                     }
  83.                     catch (Exception $e{};
  84.                 }
  85.             }
  86.         }
  87.     }
  88.  
  89.     public function applyProps($sender$param)
  90.     {
  91.         $conn $this->Application->getModule("database")->getConnection("l_virtual_nodes""propel");
  92.         $path $this->NodePath;
  93.         //echo "renaming page ".$path." to ".$name."<br>";
  94.  
  95.         $p explode("."$path);
  96.         $node $this->Service->getNodes();
  97.         for ($i 1$i count($p)$i++)
  98.             $node $node->getChildNodeAt($p[$i]);
  99.  
  100.         $node->setAlias($this->Alias->Text);
  101.         $node->setDescriptiveName($this->DescriptiveName->Text);
  102.         $node->setPage(trim($this->PageType->SelectedValue));
  103.         $node->save($conn);
  104.  
  105.         $this->onReloadPage(array("selectedNode" => $path));
  106.     }
  107.  
  108.     public function applyRights($sender$param)
  109.     {
  110.         $conn $this->Application->getModule("database")->getConnection("l_virtual_nodes""propel");
  111.         $path $this->NodePath;
  112.         //echo "setting rights for page ".$path."<br>";
  113.  
  114.         $p explode("."$path);
  115.         $node $this->Service->getNodes();
  116.         for ($i 1$i count($p)$i++)
  117.             $node $node->getChildNodeAt($p[$i]);
  118.  
  119.         LRightsManager::setRights($node$this->RightsPanel);
  120.         $node->save($conn);
  121.  
  122.         $this->onReloadPage(array("selectedNode" => $path));
  123.     }
  124.  
  125.     public function deletePage($sender$param)
  126.     {
  127.         $conn $this->Application->getModule("database")->getConnection("l_virtual_nodes""propel");
  128.         $path $this->NodePath;
  129.         if ($path == "1")
  130.         {
  131.             throw new Exception("Do not touch the root node!");
  132.             return;
  133.         }
  134.         #echo "deleting page ".$path."<br>";exit;
  135.  
  136.         $p explode("."$path);
  137.         $node $this->Service->getNodes();
  138.         for ($i 1$i count($p)-1$i++)
  139.             $node $node->getChildNodeAt($p[$i]);
  140.  
  141.         /*
  142.         try
  143.         {
  144.         */
  145.             $node->deleteChildNodeAt($p[count($p)-1]$conn);
  146.         /*
  147.         }
  148.         catch (Exception $e) {};
  149.         */
  150.  
  151.         $this->onReloadPage(array());
  152.     }
  153.  
  154.     public function createPage($sender$param)
  155.     {
  156.         $conn $this->Application->getModule("database")->getConnection("l_virtual_nodes""propel");
  157.         $path $this->NodePath;
  158.         //echo "adding page at ".$path."<br>";
  159.  
  160.         $p explode("."$path);
  161.         $node $this->Service->getNodes();
  162.         for ($i 1$i count($p)-1$i++)
  163.             $node $node->getChildNodeAt($p[$i]);
  164.  
  165.         $newpage new LVirtualNodesSiteNode();
  166.         $newpage->setAlias($this->Alias->Text);
  167.         $newpage->setDescriptiveName($this->DescriptiveName->Text);
  168.         $newpage->setPage(trim($this->PageType->SelectedValue));
  169.         LRightsManager::setRights($newpage$this->RightsPanel);
  170.  
  171.         $node->insertNewNodeAt($p[count($p)-1]$newpage$conn);
  172.  
  173.         $this->onReloadPage(array());
  174.     }
  175.  
  176. }
  177. ?>

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