energine
[ class tree: energine ] [ index: energine ] [ all elements ]

Source for file ManufacturerList.class.php

Documentation is available at ManufacturerList.class.php

  1. <?php
  2.  
  3. /**
  4.  * Содержит класс ManufacturerList
  5.  *
  6.  * @package energine
  7.  * @subpackage core
  8.  * @author dr.Pavka
  9.  * @copyright ColoCall 2007
  10.  * @version $Id$
  11.  */
  12.  
  13. //require_once('core/modules/share/components/DataSet.class.php');
  14.  
  15. /**
  16.  * Класс выводящий список производителей для раздела каталога
  17.  *
  18.  * @package energine
  19.  * @subpackage core
  20.  * @author dr.Pavka
  21.  */
  22. class ManufacturerList extends DataSet {
  23.     /**
  24.      * Конструктор класса
  25.      *
  26.      * @param string $name 
  27.      * @param string $module 
  28.      * @param Document $document 
  29.      * @param array $params 
  30.      * @access public
  31.      */
  32.     public function __construct($name$moduleDocument $document,  array $params null{
  33.         parent::__construct($name$module$document,  $params);
  34.         $this->setType(self::COMPONENT_TYPE_LIST);
  35.         $this->addTranslation('FIELD_PRODUCER');
  36.     }
  37.  
  38.     /**
  39.      * Перечень полей
  40.      *
  41.      * @return DataDescription 
  42.      * @access protected
  43.      */
  44.  
  45.     protected function createDataDescription({
  46.         $result new DataDescription();
  47.         $fd new FieldDescription('producer_id');
  48.         $fd ->setType(FieldDescription::FIELD_TYPE_INT);
  49.         $fd->setProperty('key'true);
  50.         $result->addFieldDescription($fd);
  51.  
  52.         $fd new FieldDescription('producer_name');
  53.         $fd ->setType(FieldDescription::FIELD_TYPE_STRING);
  54.         $result->addFieldDescription($fd);
  55.  
  56.         $fd new FieldDescription('producer_segment');
  57.         $fd ->setType(FieldDescription::FIELD_TYPE_STRING);
  58.         $result->addFieldDescription($fd);
  59.  
  60.         return $result;
  61.     }
  62.  
  63.     /**
  64.       * Загрузка данных
  65.       *
  66.       * @return array 
  67.       * @access protected
  68.       */
  69.  
  70.     protected function loadData({
  71.         $sitemap Sitemap::getInstance();
  72.         $smapID $this->document->getID();
  73.         $descendants Sitemap::getInstance()->getTree()->getNodeById($smapID)->getDescendants()->asList(false);
  74.  
  75.         $id implode(','array_merge(array($smapID)$descendants));
  76.  
  77.         $result $this->dbh->selectRequest('SELECT DISTINCT producer.producer_id, producer.producer_name, producer_segment '.
  78.         'FROM shop_products product '.
  79.         'LEFT JOIN shop_producers producer ON producer.producer_id = product.producer_id '.
  80.         'WHERE product.smap_id in('.$id.')');
  81.         $url  $sitemap->getURLByID($smapID);
  82.  
  83.         if (is_array($result)) {
  84.             foreach ($result as $key => $value{
  85.                 $result[$key]['producer_segment'$url.'manufacturer-'.$value['producer_segment'].'/';
  86.             }
  87.         }
  88.         return $result;
  89.  
  90.     }
  91. }
В создании документации нам помог: phpDocumentor