<?php
/**
* СодеÑÐ¶Ð¸Ñ ÐºÐ»Ð°ÑÑ ChildDivisions
*
* @package energine
* @author dr.Pavka
* @copyright ColoCall 2006
* @version $Id: ChildDivisions.class.php,v 1.11 2008/01/18 14:50:42 pavka Exp $
*/
//require_once('core/modules/share/components/DataSet.class.php');
/**
* ÐлаÑÑ Ð¿ÐµÑедназнаÑен Ð´Ð»Ñ Ð²Ñвода доÑеÑниÑ
Ñазделов ÑекÑÑего Ñаздела
*
* @package energine
* @subpackage share
*
*/
class ChildDivisions extends DataSet {
/**
* ÐонÑÑÑÑкÑÐ¾Ñ ÐºÐ»Ð°ÑÑа
*
* @return void
*/
public function __construct($name, $module, Document $document, array $params = null) {
parent::__construct($name, $module, $document, $params);
$this->setType(self::COMPONENT_TYPE_LIST);
if ($this->getParam('id')) {
$this->setParam('active', false);
$this->setParam('recordsPerPage', false);
}
}
/**
* Ðобавлен паÑамеÑÑ id - иденÑиÑикаÑÐ¾Ñ ÑÑÑаниÑÑ
*
* @return int
* @access protected
*/
protected function defineParams() {
$result = array_merge(parent::defineParams(),
array(
'id'=>false,
'showFinal' => false,
'active' => true
));
return $result;
}
/**
* УÑÑанавливаем пеÑеÑÐµÐ½Ñ Ð¿Ð¾Ð»ÐµÐ¹
*
* @return DataDescription
* @access protected
*/
protected function createDataDescription() {
$result = new DataDescription();
$field = new FieldDescription('Id');
$field->setType(FieldDescription::FIELD_TYPE_INT);
$field->addProperty('key', true);
$result->addFieldDescription($field);
$field = new FieldDescription('Name');
$field->setType(FieldDescription::FIELD_TYPE_STRING);
$result->addFieldDescription($field);
$field = new FieldDescription('Segment');
$field->setType(FieldDescription::FIELD_TYPE_STRING);
$result->addFieldDescription($field);
$field = new FieldDescription('DescriptionRtf');
$field->setType(FieldDescription::FIELD_TYPE_TEXT);
$result->addFieldDescription($field);
return $result;
}
/**
* ÐеÑеопÑеделеннÑй меÑод загÑÑзки даннÑÑ
*
* @return mixed
* @access protected
*/
protected function loadData() {
$sitemap = Sitemap::getInstance();
$this->setTitle($this->translate('TXT_CHILD_DIVISIONS'));
if (!$this->getParam('id')) {
$id = $this->document->getID();
}
else {
$id = $this->getParam('id');
}
$data = $sitemap->getChilds($id);
$data = (empty($data))?false:$data;
if(is_array($data)) {
if ($this->getParam('recordsPerPage')) {
if ($this->pager->getCurrentPage()>1) {
$this->document->componentManager->getComponentByName('breadCrumbs')->addCrumb();
}
$this->pager->setRecordsCount(sizeof($data));
$limit = $this->pager->getLimit();
$data = array_slice($data, $limit[0], $limit[1], true);
}
foreach ($data as $id => $current) {
$data[$id] = array(
'Id' => $id,
'Segment' => $current['Segment'],
'Name' => $current['Name'],
'DescriptionRtf' => $current['DescriptionRtf']
);
}
}
return $data;
}
}