<?php
/**
* ÐлаÑÑ SimpleBuilder.
*
* @package energine
* @subpackage core
* @author 1m.dm
* @copyright ColoCall 2006
* @version $Id: SimpleBuilder.class.php,v 1.8 2008/02/06 10:06:17 pavka Exp $
*/
//require_once('core/framework/Builder.class.php');
/**
* ÐоÑÑÑоиÑÐµÐ»Ñ XML-докÑменÑа.
*
* @package energine
* @subpackage core
*/
class SimpleBuilder extends Builder {
/**
* Title
*
* @var string
* @access private
*/
private $title;
/**
* ÐонÑÑÑÑкÑÐ¾Ñ ÐºÐ»Ð°ÑÑа.
*
* @access public
* @return void
*/
public function __construct($title) {
parent::__construct();
$this->title = $title;
}
/**
* ÐоÑÑÑоение ÑезÑлÑÑаÑа.
*
* @access protected
* @return void
*/
protected function run() {
$dom_recordSet = $this->result->createElement('recordset');
$this->result->appendChild($dom_recordSet);
if (!$this->data || !$this->data->getRowCount()) {
$dom_recordSet->setAttribute('empty', 'empty');
}
$rowCount = 0;
$i = 0;
do {
if ($this->data) {
$rowCount = $this->data->getRowCount();
}
$dom_record = $this->result->createElement('record');
foreach ($this->dataDescription->getFieldDescriptions() as $fieldName => $fieldInfo) {
$fieldProperties = false;
if ($fieldInfo->getPropertyValue('tabName') === null) {
$fieldInfo->addProperty('tabName', $this->title);
}
// еÑли Ñип Ð¿Ð¾Ð»Ñ Ð¿ÑÐµÐ´Ð¿Ð¾Ð»Ð°Ð³Ð°ÐµÑ Ð²ÑÐ±Ð¾Ñ Ð¸Ð· неÑколÑкиÑ
знаÑений - Ñоздаем ÑооÑвеÑÑÑвÑÑÑие ÑзлÑ
if (in_array($fieldInfo->getType(), array(FieldDescription::FIELD_TYPE_MULTI, FieldDescription::FIELD_TYPE_SELECT))) {
if ($this->data && $this->data->getFieldByName($fieldName)) {
if ($fieldInfo->getType() == FieldDescription::FIELD_TYPE_SELECT) {
$data = array($this->data->getFieldByName($fieldName)->getRowData($i));
}
else {
$data = $this->data->getFieldByName($fieldName)->getRowData($i);
}
}
else {
$data = false;
}
$fieldValue = $this->createOptions($fieldInfo, $data);
}
elseif (!$this->data) {
$fieldValue = false;
}
elseif ($this->data->getFieldByName($fieldName)) {
$fieldProperties = $this->data->getFieldByName($fieldName)->getRowProperties($i);
$fieldValue = $this->data->getFieldByName($fieldName)->getRowData($i);
}
else {
$fieldValue = false;
}
$dom_field = $this->createField($fieldName, $fieldInfo, $fieldValue, $fieldProperties);
$dom_record->appendChild($dom_field);
}
$dom_recordSet->appendChild($dom_record);
$i++;
}
while ($i < $rowCount);
}
}