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

Source for file Administration.php

Documentation is available at Administration.php

  1. <?php
  2. /**
  3.  * class file.
  4.  *
  5.  * @license http://opensource.org/licenses/mozilla1.1.php Mozilla Public License
  6.  * @copyright 2005, diemeisterei GmbH. All rights reserved.
  7.  * @author $Author: schmunk $
  8.  * @version $Revision: 601 $  $Date: 2007-02-24 23:49:30 +0100 (Sa, 24 Feb 2007) $
  9.  * @package Phundament.Packages
  10.  * @subpackage LVirtualNodes
  11.  */
  12.  
  13. /**
  14.  * Displays LVirtualNodes configuration options (sitemap)
  15.  *
  16.  * @package Admin.Pages
  17.  * @subpackage LVirtualNodes
  18.  */
  19. class Administration extends TPage
  20. {
  21.     const DEFAULT_TAB "ModifyPage";
  22.     
  23.     public function getActiveTab()
  24.     {
  25.         return $this->getViewState("ActiveTab"self::DEFAULT_TAB);
  26.     }
  27.     
  28.     public function setActiveTab($value)
  29.     {
  30.         $this->MView->ActiveView $this->$value
  31.         $this->setViewState("ActiveTab"$valueself::DEFAULT_TAB);
  32.     }
  33.     
  34.     public function getTabCssClass($tab)
  35.     {
  36.         return $tab == $this->ActiveTab "TabButtonActive" "TabButton"
  37.     }
  38.     
  39.     public function changeView($sender$param)
  40.     {
  41.         $vname $param->CommandParameter;
  42.         $this->ActiveTab $vname;
  43.     }
  44.  
  45.     public function existingNodeSelected($sender$param)
  46.     {
  47.         $this->SNParamsExisting->NodePath $param;
  48.     }
  49.  
  50.     public function newNodeSelected($sender$param)
  51.     {
  52.         $this->SNParamsNew->NodePath $param;
  53.     }
  54.  
  55.     public function nodeAdminNeedsReload($sender$param)
  56.     {
  57.         $at $this->ActiveTab;
  58.         if ($at != self::DEFAULT_TAB$param["ActiveTab"$at;    
  59.         $url $this->Service->constructUrl($this->Service->getRequestedPagePath()$param);
  60.         $this->Response->redirect($url);
  61.     }
  62.  
  63.     public function onInit($param)
  64.     {
  65.         parent::onInit($param);
  66.         if (!$this->IsPostBack)
  67.         {
  68.             $value self::DEFAULT_TAB;
  69.             $this->MView->ActiveView $this->$value
  70.         }
  71.     }
  72.     
  73.     public function onLoad($param)
  74.     {
  75.         parent::onLoad($param);
  76.         if (!$this->IsPostBack && $this->Request->contains("ActiveTab"))
  77.             $this->ActiveTab $this->Request->itemAt("ActiveTab");
  78.     }
  79.     
  80.  
  81.  
  82.  
  83.  
  84.     function updateCachingTime($sender$param)
  85.     {
  86.         $this->Application->Cache->flush();
  87.         $time TPropertyValue :: ensureInteger($sender->getText());
  88.         $this->Application->setGlobalState("LVirtualNodes:cachingTime"$time);
  89.     }
  90.  
  91.     function checkVirtualNodes()
  92.     {
  93.         if ($this->Off->Checked || $this->Application->Service->areNodesAvailable(=== false)
  94.         {
  95.             $this->Application->setGlobalState("LVirtualNodes:available"false);
  96.         else
  97.         {
  98.             $this->Application->setGlobalState("LVirtualNodes:available"true);
  99.         }
  100.     }
  101.  
  102.     public function movePage($sender$param)
  103.     {
  104.         $src $this->SNSelectMoveSrc->SelectedValue;
  105.         $dst $this->SNSelectMoveDest->SelectedValue;
  106.  
  107.         Prado :: log("Trying to move page from $src to $dst..."TLogger::NOTICE"Lithron.LVirtualNodes");
  108.         if (strpos($dst$src=== && (strlen($dst== strlen($src|| $dst[strlen($src)== ".")) 
  109.         {
  110.             Prado :: log("Cannot move page onto any of it's children!"TLogger::ERROR"Lithron.LVirtualNodes");
  111.             return;
  112.         }
  113.  
  114.         $conn $this->Application->getModule("database")->getConnection("l_virtual_nodes""propel");
  115.  
  116.         // find srcnode and it's parent
  117.         $sp explode("."$src);
  118.         $nsrc $this->Service->getNodes();
  119.         for ($i 1$i count($sp)$i++)
  120.             $nsrc $nsrc->getChildNodeAt($sp[$i]);
  121.         $psrc $nsrc->getParentNode();
  122.         $srcIndex $nsrc->getNodeIndex();
  123.         
  124.         // find dstnode's parent
  125.         $dp explode("."$dst);
  126.         $pdst $this->Service->getNodes();
  127.         for ($i 1$i count($dp)-1$i++)
  128.             $pdst $pdst->getChildNodeAt($dp[$i]);
  129.         $dstIndex $dp[count($dp)-1];
  130.  
  131.         // if level is the same, and dst is behind src, we need to subtract one
  132.         if (count($sp== count($dp&& $dstIndex $srcIndex
  133.             $dstIndex--;
  134.  
  135.         // detach src node from in-memory tree
  136.         $psrc->detachChildNode($nsrc);
  137.         // move src to fake root node "2"
  138.         LVirtualNodesSiteNodePeer::moveNodeSubTree($src"2"$conn);
  139.         // shift src's following siblings up
  140.         $psrc->shiftChildNodes(-1$srcIndex+1$conn);
  141.         
  142.         // dst position may need to be updated
  143.         $dst $pdst->getNodePath().".".$dstIndex
  144.         
  145.         //create space at dst's position
  146.         $pdst->shiftChildNodes(1$dstIndex$conn);
  147.         // move fake root node "2" in place
  148.         LVirtualNodesSiteNodePeer::moveNodeSubTree("2"$dst$conn);
  149.         // adjust node-path of (in-memory) moved subtree objects
  150.         $nsrc->adjustNodePath($src$dst);
  151.         // attach src to in-memory tree again
  152.         $pdst->attachChildNode($nsrc);        
  153.         
  154.         $this->nodeAdminNeedsReload($thisarray());
  155.     }
  156.  
  157.     
  158.     
  159. }
  160. ?>

Documentation generated on Sun, 25 Feb 2007 16:09:26 +0100 by phpDocumentor 1.3.1