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

Source for file MainMenu.class.php

Documentation is available at MainMenu.class.php

  1. <?php
  2.  
  3. /**
  4.  * Содержит класс MainMenu
  5.  *
  6.  * @package energine
  7.  * @subpackage share
  8.  * @author dr.Pavka
  9.  * @copyright Energine 2006
  10.  * @version $Id$
  11.  */
  12. //require_once('core/modules/share/components/DataSet.class.php');
  13.  
  14. /**
  15.  * Класс выводит главное меню(меню первого уровня)
  16.  *
  17.  * @package energine
  18.  * @subpackage share
  19.  * @author dr.Pavka
  20.  * @final
  21.  */
  22. final class MainMenu extends DataSet {
  23.     /**
  24.      * Конструктор класса
  25.      *
  26.      * @return void 
  27.      */
  28.     public function __construct($name$moduleDocument $document,  array $params null{
  29.         parent::__construct($name$module$document,  $params);
  30.         $this->setType(self::COMPONENT_TYPE_LIST);
  31.         $this->addTranslation('TXT_HOME');
  32.     }
  33.     /**
  34.      * Принудительно выставляем необходимый перечень полей
  35.      *
  36.      * @return DataDescription 
  37.      * @access protected
  38.      */
  39.  
  40.     protected function createDataDescription({
  41.         $result new DataDescription();
  42.  
  43.         $field new FieldDescription('Id');
  44.         $field->setType(FieldDescription::FIELD_TYPE_INT);
  45.         $field->setProperty('key'true);
  46.         $result->addFieldDescription($field);
  47.  
  48.         $field new FieldDescription('Name');
  49.         $field->setType(FieldDescription::FIELD_TYPE_STRING);
  50.         $result->addFieldDescription($field);
  51.  
  52.         $field new FieldDescription('Segment');
  53.         $field->setType(FieldDescription::FIELD_TYPE_STRING);
  54.         $result->addFieldDescription($field);
  55.  
  56.         return $result;
  57.     }
  58.     /**
  59.      * Переопределенный метод загрузки данных
  60.      *
  61.      * @return mixed 
  62.      * @access protected
  63.      */
  64.  
  65.     protected function loadData({
  66.         $sitemap Sitemap::getInstance();
  67.         $data $sitemap->getMainLevel();
  68.         if (empty($data)) {
  69.             $this->generateError(SystemException::ERR_WARNING'ERR_NO_DATA');
  70.         }
  71.         foreach ($data as $key => $value{
  72.             if($key == $sitemap->getDefault(|| $value['isFinal']{
  73.                 unset($data[$key]);
  74.             }
  75.             else {
  76.                 $data[$key]['Id'$key;
  77.                 $data[$key]['Segment'$value['Segment'];
  78.                 $data[$key]['Name'$value['Name'];
  79.             }
  80.         }
  81.         return $data;
  82.     }
  83. }
В создании документации нам помог: phpDocumentor