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

Source for file NewsFeed.class.php

Documentation is available at NewsFeed.class.php

  1. <?php
  2. /**
  3.  * Содержит класс NewsFeed
  4.  *
  5.  * @package energine
  6.  * @subpackage share
  7.  * @author dr.Pavka
  8.  * @copyright Energine 2007
  9.  * @version $Id$
  10.  */
  11.  
  12. //require_once('core/modules/share/components/DBDataSet.class.php');
  13.  
  14. /**
  15.  * Лента новостей
  16.  *
  17.  * @package energine
  18.  * @subpackage share
  19.  * @author dr.Pavka
  20.  */
  21. class NewsFeed extends Feed {
  22.     /**
  23.      * Конструктор класса
  24.      *
  25.      * @param string $name 
  26.      * @param string $module 
  27.      * @param Document $document 
  28.      * @param array $params 
  29.      * @access public
  30.      */
  31.     public function __construct($name$moduleDocument $documentarray $params null{
  32.         parent::__construct($name$module$document$params);
  33.         $this->setTableName('share_news');
  34.         $this->setOrder(array('news_date'=>QAL::DESC));
  35.     }
  36.  
  37.     /**
  38.      * Добавляем поле - флаг указывающий на то - существует ли текст новости
  39.      *
  40.      * @return void 
  41.      * @access protected
  42.      */
  43.  
  44.      protected function main({
  45.         parent::main();
  46.         /*
  47.         if($this->getData() && $newsID = $this->getData()->getFieldByName('news_id')){
  48.             $hasTextField = new FieldDescription('has_text');
  49.             $hasTextField->setType(FieldDescription::FIELD_TYPE_BOOL);
  50.             $this->getDataDescription()->addFieldDescription($hasTextField);
  51.  
  52.             $hasTextField = new Field('has_text');
  53.             foreach ($newsID as $id) {
  54.                 $hasTextField->addRowData(simplifyDBResult($this->dbh->select($this->getTranslationTableName(), array('news_text_rtf is not null as has_text'), array('news_id'=>$id)), 'has_text', true));
  55.             }
  56.             $this->getData()->addField($hasTextField);
  57.         }*/
  58.      }
  59.  
  60.     /**
  61.      * View
  62.      *
  63.      * @return type 
  64.      * @access protected
  65.      */
  66.  
  67.     protected function view({
  68.         $params $this->getActionParams();
  69.  
  70.         list($day$month$year$params;
  71.         $this->addFilterCondition(
  72.             array('news_date'=>sprintf('%s-%s-%s'$year$month$day))
  73.         );
  74.         $this->addFilterCondition(array('smap_id' => $this->document->getID()));
  75.  
  76.         $this->setType(self::COMPONENT_TYPE_FORM);
  77.         $this->setDataDescription($this->createDataDescription());
  78.         $this->setBuilder($this->createBuilder());
  79.         $this->createPager();
  80.         $data $this->createData();
  81.         if ($data instanceof Data{
  82.             $this->setData($data);
  83.             list($newsTitle$data->getFieldByName('news_title')->getData();
  84.             $this->document->componentManager->getComponentByName('breadCrumbs')->addCrumb(''$newsTitle);
  85.         }
  86.         else {
  87.             throw new SystemException('ERR_404'SystemException::ERR_404);
  88.         }
  89.         
  90.         $this->addToolbar($this->createToolbar());
  91.         
  92.         foreach ($this->getDataDescription()->getFieldDescriptions(as $fieldDescription{
  93.             $fieldDescription->setMode(FieldDescription::FIELD_MODE_READ);
  94.         }
  95.  
  96.     }
  97. }
В создании документации нам помог: phpDocumentor