Source for file SimpleBuilder.class.php

Documentation is available at SimpleBuilder.class.php

  1. /**
  2.  * Класс SimpleBuilder.
  3.  *
  4.  * @package energine
  5.  * @subpackage core
  6.  * @author 1m.dm
  7.  * @copyright ColoCall 2006
  8.  * @version $Id: fsource_energine_core_frameworkSimpleBuilder.class.php.html,v 1.1 2007/09/17 14:32:34 pavka Exp $
  9.  */
  10.  
  11. require_once 'core/framework/Builder.class.php';
  12.  
  13. /**
  14.  * Построитель XML-документа.
  15.  *
  16.  * @package energine
  17.  * @subpackage core
  18.  */
  19. class SimpleBuilder extends Builder {
  20.  
  21.     /**
  22.      * Конструктор класса.
  23.      *
  24.      * @access public
  25.      * @return void 
  26.      */
  27.     public function __construct({
  28.         parent::__construct();
  29.     }
  30.  
  31.     /**
  32.      * Построение результата.
  33.      *
  34.      * @access protected
  35.      * @return void 
  36.      */
  37.     protected function run({
  38.         $dom_recordSet $this->result->createElement('recordset');
  39.         $this->result->appendChild($dom_recordSet);
  40.         if (!$this->data{
  41.             $dom_recordSet->setAttribute('empty''empty');
  42.         }
  43.         $rowCount 0;
  44.         $i 0;
  45.         do {
  46.             if ($this->data{
  47.                 $rowCount $this->data->getRowCount();
  48.             }
  49.  
  50.             $dom_record $this->result->createElement('record');
  51.  
  52.             foreach ($this->dataDescription->getFieldDescriptions(as $fieldName => $fieldInfo{
  53.                 $fieldProperties false;
  54.  
  55.                 // если тип поля предполагает выбор из нескольких значений - создаем соответствующие узлы
  56.                 if (in_array($fieldInfo->getType()array(FieldDescription::FIELD_TYPE_MULTIFieldDescription::FIELD_TYPE_SELECT))) {
  57.                     if ($this->data && $this->data->getFieldByName($fieldName)) {
  58.                         if ($fieldInfo->getType(== FieldDescription::FIELD_TYPE_SELECT{
  59.                             $data array($this->data->getFieldByName($fieldName)->getRowData($i));
  60.                         }
  61.                         else {
  62.                             $data $this->data->getFieldByName($fieldName)->getRowData($i);
  63.                         }
  64.                     }
  65.                     else {
  66.                         $data false;
  67.                     }
  68.                     $fieldValue $this->createOptions($fieldInfo$data);
  69.                 }
  70.                 elseif (!$this->data{
  71.                     $fieldValue false;
  72.                 }
  73.                 elseif ($this->data->getFieldByName($fieldName)) {
  74.                     $fieldProperties $this->data->getFieldByName($fieldName)->getRowProperties($i);
  75.                     $fieldValue $this->data->getFieldByName($fieldName)->getRowData($i);
  76.                 }
  77.                 else {
  78.                     $fieldValue false;
  79.                 }
  80.  
  81.                 $dom_field $this->createField($fieldName$fieldInfo$fieldValue$fieldProperties);
  82.                 $dom_record->appendChild($dom_field);
  83.             }
  84.  
  85.             $dom_recordSet->appendChild($dom_record);
  86.             $i++;
  87.         }
  88.         while ($i $rowCount);
  89.     }
  90. }

Documentation generated on Mon, 17 Sep 2007 13:31:51 +0300 by phpDocumentor 1.4.0a2