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

Source for file CurrencyEditor.class.php

Documentation is available at CurrencyEditor.class.php

  1. <?php
  2. /**
  3.  * Содержит класс CurrencyEditor
  4.  *
  5.  * @package energine
  6.  * @subpackage shop
  7.  * @author dr.Pavka
  8.  * @copyright ColoCall 2006
  9.  * @version $Id$
  10.  */
  11.  
  12. //require_once('core/modules/share/components/Grid.class.php');
  13.  
  14. /**
  15.  * Класс предназначен для редактирования перечня валюты
  16.  *
  17.  * @package energine
  18.  * @subpackage shop
  19.  * @author dr.Pavka
  20.  */
  21. class CurrencyEditor extends Grid {
  22.     /**
  23.      * Конструктор класса
  24.      *
  25.      * @param string $name 
  26.      * @param string $module 
  27.      * @param Document $document 
  28.      * @param array $params 
  29.      * @access public
  30.      */
  31.     public function __construct($name$moduleDocument $document,  array $params null{
  32.         parent::__construct($name$module$document,  $params);
  33.         $this->setTableName('shop_currency');
  34.         $this->setOrderColumn('curr_order_num');
  35.         $this->setOrder(array('curr_order_num'=>QAL::ASC));
  36.     }
  37.  
  38.     protected function createDataDescription({
  39.         $result parent::createDataDescription();
  40.         if (in_array($this->getAction()array('add''edit'))) {
  41.             $fd $result->getFieldDescriptionByName('curr_abbr');
  42.             $fd->setProperty('pattern''/[a-zA-Z]{3}/');
  43.             $fd->setProperty('message'$this->translate('MSG_BAD_CURR_ABBR'));
  44.             
  45.             $fd $result->getFieldDescriptionByName('curr_is_main')->removeProperty('nullable');
  46.         }
  47.         return $result;
  48.     }
  49.  
  50.     protected function edit(){
  51.         parent::edit();
  52.         if($this->getData()->getFieldByName('curr_is_main')->getRowData(0)){
  53.             $this->getDataDescription()->getFieldDescriptionByName('curr_is_main')->setMode(FieldDescription::FIELD_MODE_READ);
  54.         }
  55.          
  56.     }
  57.  
  58.     protected function saveData(){
  59.         if(isset($_POST[$this->getTableName()]['curr_abbr'])){
  60.             $_POST[$this->getTableName()]['curr_abbr'strtoupper($_POST[$this->getTableName()]['curr_abbr']);
  61.         }
  62.         
  63.         if($_POST[$this->getTableName()]['curr_is_main']){
  64.           $this->dbh->modifyRequest('UPDATE '.$this->getTableName().' SET curr_is_main = NULL');    
  65.         }
  66.         else {
  67.             $_POST[$this->getTableName()]['curr_is_main''';
  68.         }
  69.         
  70.         return parent::saveData();
  71.     }
  72. }
В создании документации нам помог: phpDocumentor