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

Source for file Feed.class.php

Documentation is available at Feed.class.php

  1. <?php
  2. /**
  3.  * Содержит класс Feed
  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 Feed extends DBDataSet {
  20.     /**
  21.      * Конструктор класса
  22.      *
  23.      * @param string $name 
  24.      * @param string $module 
  25.      * @param Document $document 
  26.      * @param array $params 
  27.      * @access public
  28.      */
  29.     public function __construct($name$moduleDocument $documentarray $params null{
  30.         parent::__construct($name$module$document$params);
  31.         $this->setProperty('title'$this->translate('TXT_'.strtoupper($this->getName())));
  32.         $this->setProperty('exttype''feed');
  33.         $this->setParam('onlyCurrentLang'true);
  34.     }
  35.     /**
  36.      * Убираем smap_id
  37.      *
  38.      * @access protected
  39.      * @return DataDescription 
  40.      */
  41.     protected function createDataDescription({
  42.         $result parent::createDataDescription();
  43.         if($smapField $result->getFieldDescriptionByName('smap_id')){
  44.             $result->removeFieldDescription($smapField);
  45.         }
  46.  
  47.         return $result;
  48.     }
  49.     /**
  50.      * Фильтруем по разделам
  51.      *
  52.      * @return void 
  53.      * @access protected
  54.      */
  55.  
  56.     protected function main({
  57.  
  58.         if(!($id $this->getParam('id'))){
  59.             $id $this->document->getID();
  60.         }
  61.  
  62.         if ($this->getParam('showAll')) {
  63.                $descendants array_keys(
  64.                    Sitemap::getInstance()->getTree()->getNodeById($id)->getDescendants()->asList(false)
  65.                );
  66.             $id array_merge(array($id)$descendants);
  67.         }
  68.         $this->addFilterCondition(array('smap_id'=>$id));
  69.         if ($limit $this->getParam('limit')){
  70.             $this->setLimit(array(0,$limit));
  71.             $this->setParam('recordsPerPage'false);
  72.         }
  73.  
  74.         parent::main();
  75.     }
  76.  
  77.     /**
  78.      * Добавляем крошку
  79.      *
  80.      * @return void 
  81.      * @access protected
  82.      */
  83.  
  84.      protected function view({
  85.         parent::view();
  86.         $this->addFilterCondition(array('smap_id' => $this->document->getID()));
  87.         $this->document->componentManager->getComponentByName('breadCrumbs')->addCrumb();
  88.      }
  89.     /**
  90.      * Делаем компонент активным
  91.      *
  92.      * @return type 
  93.      * @access protected
  94.      */
  95.  
  96.     protected function defineParams({
  97.         return array_merge(
  98.         parent::defineParams(),
  99.         array(
  100.         'active' => true,
  101.         'showAll' =>false,
  102.         'id' => false,
  103.         'limit' => false
  104.         )
  105.         );
  106.     }
  107. }
В создании документации нам помог: phpDocumentor