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

Source for file TemplateEditor.class.php

Documentation is available at TemplateEditor.class.php

  1. <?php
  2.  
  3. /**
  4.  * Содержит класс TemplateEditor
  5.  *
  6.  * @package energine
  7.  * @subpackage share
  8.  * @author dr.Pavka
  9.  * @copyright Energine 2006
  10.  * @version $Id$
  11.  */
  12.  
  13.  
  14. /**
  15.  * Редактор шаблонов
  16.  *
  17.  * @package energine
  18.  * @subpackage share
  19.  * @author dr.Pavka
  20.  */
  21. class TemplateEditor extends Grid {
  22.     const TMPL_CONTENT = 'content';
  23.     const TMPL_LAYOUT = 'layout';
  24.     
  25.     /**
  26.      * Конструктор класса
  27.      *
  28.      * @return void 
  29.      */
  30.     public function __construct($name$moduleDocument $document,  array $params null{
  31.         parent::__construct($name$module$document,  $params);
  32.         $this->setTableName('share_templates');
  33.         $this->setTitle($this->translate('TXT_TEMPLATE_EDITOR'));
  34.         $this->setOrderColumn('tmpl_order_num');
  35.         $this->setOrder(array('tmpl_order_num' =>QAL::ASC));
  36.     }
  37.     
  38.     protected function createDataDescription(){
  39.         $result parent::createDataDescription();
  40.         
  41.         if($f $result->getFieldDescriptionByName('tmpl_icon')){
  42.             $f->setType(FieldDescription::FIELD_TYPE_IMAGE);
  43.             if(in_array($this->getAction()array('add''edit'))){
  44.                 $f->setType(FieldDescription::FIELD_TYPE_SELECT);
  45.                 $f->loadAvailableValues(
  46.                 $this->loadIconsData(),            
  47.                 'key','value');                            
  48.             }
  49.         }
  50.         
  51.         foreach (array(self::TMPL_CONTENTself::TMPL_LAYOUTas $type)
  52.             if(($f $result->getFieldDescriptionByName('tmpl_'.$type)) && in_array($this->getAction()array('add''edit'))){
  53.                 $f->setType(FieldDescription::FIELD_TYPE_SELECT);
  54.                 $f->loadAvailableValues(
  55.                 $this->loadTemplateData($type),            
  56.                 'key','value');                         
  57.             }
  58.         
  59.         return $result;
  60.     }
  61.     
  62.     private function loadIconsData(){
  63.         $result array();
  64.         foreach(glob("templates/icons/*.icon.gif"as $path){
  65.             $result[array(
  66.                'key' => $path,
  67.                'value' => basename($path
  68.             );
  69.         }
  70.         return $result;
  71.     }
  72.     
  73.     private function loadTemplateData($type){
  74.         $result array();
  75.         foreach(glob("templates/".$type."/*.".$type.".xml"as $path){
  76.             $path basename($path);
  77.             $result[array(
  78.                'key' => $path,
  79.                'value' => $path 
  80.             );
  81.         }
  82.         return $result;        
  83.     }
  84.     
  85.     private function loadPreviewData(){
  86.         $result array();
  87.         foreach(glob("templates/icons/*.preview.gif"as $path){
  88.             $result[array(
  89.                'key' => $path,
  90.                'value' => basename($path
  91.             );
  92.         }
  93.         return $result;
  94.     }
  95. }
В создании документации нам помог: phpDocumentor