Location: PHPKode > projects > Energine > energine-2.2/core2a/modules/share/components/NewsList.class.php
<?php
/**
 * Содержит класс NewsList
 *
 * @package energine
 * @subpackage share
 * @author dr.Pavka
 * @copyright ColoCall 2007
 * @version $Id: NewsList.class.php,v 1.1 2008/03/27 11:08:25 pavka Exp $
 */

/**
 * Выводит список новостей
 *
 * @package energine
 * @subpackage share
 */
class NewsList extends DBDataSet {
    /**
     * Конструктор класса
     *
     * @param string $name
     * @param string $module
     * @param Document $document
     * @param array $params
     * @access public
     */
    public function __construct($name, $module, Document $document, array $params = null) {
        parent::__construct($name, $module, $document, $params);
        $this->setParam('onlyCurrentLang', true);
        $this->setTableName('share_news');
        $this->setParam('recordsPerPage', false);
        $this->setOrder(array('news_date'=>QAL::DESC));
        if ($limit = $this->getParam('limit')) {
            $this->setLimit(array(0, $limit));
        }
    }

    /**
     * Добавляем параметр limit
     *
     * @return type
     * @access protected
     */

    protected function defineParams() {
        return array_merge(
        parent::defineParams(),
        array(
        'limit' =>false
        )
        );
    }

    /**
     * Исправляем вывод smap_id
     *
     * @return DataDescription
     * @access protected
     */

    protected function createDataDescription() {
        $result = parent::createDataDescription();
        if ($smpaIDFD = $result->getFieldDescriptionByName('smap_id')) {
        	$smpaIDFD->setType(FieldDescription::FIELD_TYPE_STRING);
        }
        return $result;
    }

    /**
     * Добавляем данные к smap_id
     *
     * @return Data
     * @access protected
     */

     protected function createData() {
        $result = parent::createData();
        if ($smapIDF = $result->getFieldByName('smap_id')) {
            for ($i=0; $i<$smapIDF->getRowCount(); $i++){
                $smapID = $smapIDF->getRowData($i);
                $smapIDF->setRowProperty($i, 'url', Sitemap::getInstance()->getURLByID($smapID));
                $smapInfo = Sitemap::getInstance()->getDocumentInfo($smapID);
                $smapIDF->setRowProperty($i, 'category', $smapInfo['Name']);
            }
        }
        return $result;
     }
}
Return current item: Energine