<?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;
}
}