Source for file AdminTreeController.class.php

Documentation is available at AdminTreeController.class.php

  1. <?php
  2. lmb_require('limb/web_app/src/controller/lmbController.class.php');
  3. lmb_require('limb/cms/src/lmbCmsTreeBrowser.class.php');
  4.  
  5. {
  6.  function doCreateNode()
  7.   {
  8.     $this->useForm('node_form');
  9.     $this->setFormDatasource($this->request);
  10.  
  11.     if($this->request->hasPost())
  12.     {
  13.       $class_name $this->request->get('class_name'$this->request->get('class_name''lmbCmsNode';
  14.       $node new $class_name();
  15.  
  16.       $this->_importAndSave($node);
  17.     }
  18.     else
  19.       $this->request->set('class_name''lmbCmsNode');
  20.   }
  21.  
  22.   function doEditNode()
  23.   {
  24.     $node lmbActiveRecord :: findById('lmbCmsNode'$this->request->getInteger('id'));
  25.     $this->useForm('node_form');
  26.     $this->setFormDatasource($this->request);
  27.  
  28.     if($this->request->hasPost())
  29.       $this->_importAndSave($node);
  30.     else
  31.     {
  32.       $this->request->merge($node->export());
  33.       $this->request->set('controller_name'$node->getControllerName());
  34.     }
  35.   }
  36.  
  37.   protected function _importAndSave($node)
  38.   {
  39.     $node->import($this->request);
  40.  
  41.     $node->validate($this->error_list);
  42.  
  43.     if($this->error_list->isValid())
  44.     {
  45.       $node->saveSkipValidation();
  46.       $this->closePopup();
  47.     }
  48.   }
  49.  
  50.   function doDelete()
  51.   {
  52.     if($this->request->hasPost(&& $this->request->get('delete'))
  53.     {
  54.       foreach($this->request->getArray('ids'as $id)
  55.       {
  56.         $node lmbActiveRecord :: findById('lmbCmsNode'$id);
  57.         $node->destroy();
  58.       }
  59.       $this->closePopup();
  60.     }
  61.   }
  62.  
  63.   function doSavePriority()
  64.   {
  65.     $priority $this->request->get('priority');
  66.  
  67.     if(!is_array($priority|| !sizeof($priority))
  68.       throw new lmbException('"priority" request param should be an array!');
  69.  
  70.     foreach($priority as $id => $value)
  71.     {
  72.       $node new lmbCmsNode($id);
  73.       $node->setPriority($value);
  74.       $node->save();
  75.     }
  76.  
  77.     $this->closePopup();
  78.   }
  79.  
  80.   function doMove()
  81.   {
  82.     if($parent_id $this->request->getInteger('id'))
  83.     {
  84.       $parent_node new lmbCmsNode($parent_id);
  85.       $this->request->set('parent'$parent_node);
  86.     }
  87.  
  88.     $this->useForm('tree_form');
  89.     $this->setFormDatasource($this->request);
  90.  
  91.     if($this->request->hasPost(&& $this->request->get('move'))
  92.     {
  93.       $parent_id $this->request->get('parent_id');
  94.       foreach($this->request->getArray('ids'as $id)
  95.       {
  96.         $tree lmbToolkit :: instance()->getCmsTree();
  97.         $tree->moveNode($id$parent_id);
  98.       }
  99.       $this->closePopup();
  100.     }
  101.   }
  102.  
  103.   function doProcessCommand()
  104.   {
  105.     $resource_type $this->request->get('Type');
  106.     $current_folder $this->request->get('CurrentFolder');
  107.     $command $this->request->get('Command');
  108.  
  109.     $browser new lmbCmsTreeBrowser();
  110.     $browser->setCurrentFolderPath($current_folder);
  111.  
  112.     $this->_setXmlHeaders();
  113.  
  114.     $xml =     '<?xml version="1.0" encoding="utf-8" ?>';
  115.     $xml .= '<Connector command="' $command '" resourceType="' $resource_type '">' ;
  116.     $xml .= '<CurrentFolder path="' $current_folder '" url="/" />' ;
  117.  
  118.     $xml .= '<Folders>' $browser->renderFolders('</Folders>';
  119.     $xml .= '<Files></Files>';
  120.  
  121.     $xml .= '</Connector>';
  122.  
  123.     return $xml;
  124.   }
  125.  
  126.   protected function _setXmlHeaders()
  127.   {
  128.     $this->response->addHeader('Expires: Mon, 26 Jul 1997 05:00:00 GMT';
  129.     $this->response->addHeader('Last-Modified: ' gmdate('D, d M Y H:i:s'' GMT';
  130.     $this->response->addHeader('Cache-Control: no-store, no-cache, must-revalidate';
  131.     $this->response->addHeader('Cache-Control: post-check=0, pre-check=0'false;
  132.     $this->response->addHeader('Pragma: no-cache';
  133.     $this->response->addHeader'Content-Type:text/xml; charset=utf-8' ;
  134.   }
  135. }

Documentation generated on Wed, 07 Jan 2009 03:45:53 +0300 by phpDocumentor 1.3.2