energine
[ class tree: energine ] [ index: energine ] [ all elements ]

Source for file FeedEditor.class.php

Documentation is available at FeedEditor.class.php

  1. <?php
  2. /**
  3.  * Содержит класс FeedEditor
  4.  *
  5.  * @package energine
  6.  * @subpackage share
  7.  * @author dr.Pavka
  8.  * @copyright Energine 2007
  9.  * @version $Id$
  10.  */
  11.  
  12. /**
  13.  * Класс для построения редакторов управляющихся из панели управления
  14.  *
  15.  * @package energine
  16.  * @subpackage share
  17.  * @author dr.Pavka
  18.  */
  19. class FeedEditor extends Grid {
  20.     /**
  21.      * Включен ли режим редактировани
  22.      *
  23.      * @var boolean 
  24.      * @access private
  25.      */
  26.     private $isEditable;
  27.  
  28.     /**
  29.      * Конструктор класса
  30.      *
  31.      * @param string $name 
  32.      * @param string $module 
  33.      * @param Document $document 
  34.      * @param array $params 
  35.      * @access public
  36.      */
  37.     public function __construct($name$moduleDocument $documentarray $params null{
  38.         parent::__construct($name$module$document$params);
  39.         $this->isEditable = $this->document->isEditable();
  40.         $this->setProperty('exttype''feededitor');
  41.     }
  42.  
  43.     /**
  44.      * Добавляем параметр  - имя связанного компонента
  45.      *
  46.      * @return array 
  47.      * @access protected
  48.      */
  49.  
  50.     protected function defineParams({
  51.         return array_merge(
  52.         parent::defineParams(),
  53.         array(
  54.         'linkTo' => false
  55.         )
  56.         );
  57.     }
  58.  
  59.     /**
  60.      * Для форм поле smap_id віводим как string
  61.      *
  62.      * @return DataDescription 
  63.      * @access protected
  64.      */
  65.  
  66.     protected function createDataDescription({
  67.         $result parent::createDataDescription();
  68.         if (in_array($this->getType()array(self::COMPONENT_TYPE_FORM_ADDself::COMPONENT_TYPE_FORM_ALTER))) {
  69.             $field $result->getFieldDescriptionByName('smap_id');
  70.             $field->setType(FieldDescription::FIELD_TYPE_STRING);
  71.             $field->setMode(FieldDescription::FIELD_MODE_READ);
  72.         }
  73.         return $result;
  74.     }
  75.  
  76.     /**
  77.      * Определяем данные для smap_id
  78.      *
  79.      * @return Data 
  80.      * @access protected
  81.      */
  82.  
  83.     protected function createData({
  84.  
  85.         $result parent::createData();
  86.         if (in_array($this->getType()array(self::COMPONENT_TYPE_FORM_ADDself::COMPONENT_TYPE_FORM_ALTER))) {
  87.             $info Sitemap::getInstance()->getDocumentInfo($this->document->getID());
  88.             $field $result->getFieldByName('smap_id');
  89.             for($i=0$i<sizeof(Language::getInstance()->getLanguages())$i++{
  90.                 $field->setRowProperty($i'segment'Sitemap::getInstance()->getURLByID($this->document->getID()));
  91.                 $field->setRowData($i$info['Name']);
  92.             }
  93.         }
  94.         return $result;
  95.     }
  96.  
  97.     /**
  98.      * Убираем все лишнее
  99.      *
  100.      * @return void 
  101.      * @access protected
  102.      */
  103.  
  104.     protected function main({
  105.         $_SESSION['feed_smap_id'=
  106.         $this->document->componentManager->getComponentByName(
  107.         $this->getParam('linkTo')
  108.         )->getFilter();
  109.         $this->addToolbar($this->createToolbar());
  110.         $this->js $this->buildJS();
  111.     }
  112.  
  113.     protected function changeOrder($direction){
  114.         $this->setFilter($_SESSION['feed_smap_id']);
  115.         //unset($_SESSION['feed_smap_id']);
  116.  
  117.         return parent::changeOrder($direction);
  118.     }
  119.  
  120.     /**
  121.      * Для метода main убираем вызов построителя
  122.      *
  123.      * @return DOMDocument 
  124.      * @access public
  125.      */
  126.  
  127.     public function build({
  128.         if ($this->getAction(== 'main'{
  129.             if ($param $this->getParam('linkTo')) {
  130.                 $this->setProperty('linkedComponent'$param);
  131.             }
  132.             $result Component::build();
  133.             if (($component $this->document->componentManager->getComponentByName($param)) && ($component->getAction(!= 'view'&& $this->isEditable{
  134.                 if ($this->js{
  135.                     $result->documentElement->appendChild($result->importNode($this->jstrue));
  136.                 }
  137.                 $result->documentElement->appendChild($result->createElement('recordset'));
  138.                 if (($tbs $this->getToolbar()) && (!empty($tbs))) {
  139.                     foreach($tbs as $tb)
  140.                     if($toolbar $tb->build()) {
  141.                         $result->documentElement->appendChild($result->importNode($toolbartrue));
  142.                     }
  143.                 }
  144.                  
  145.             }
  146.         }
  147.         else {
  148.             if ($this->getType(!== self::COMPONENT_TYPE_LIST {
  149.                 $this->setProperty('exttype''grid');
  150.             }
  151.             $result parent::build();
  152.         }
  153.  
  154.         return $result;
  155.     }
  156.  
  157.  
  158.     /**
  159.      * Выставляем smap_id в текущее значение
  160.      *
  161.      * @return mixed 
  162.      * @access protected
  163.      */
  164.  
  165.     protected function saveData({
  166.         $_POST[$this->getTableName()]['smap_id'$this->document->getID();
  167.         $result parent::saveData();
  168.         return $result;
  169.     }
  170.  
  171. }
В создании документации нам помог: phpDocumentor