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

Source for file CurrencySwitcher.class.php

Documentation is available at CurrencySwitcher.class.php

  1.  
  2. /**
  3.  * Содержит класс CurrencySwitcher
  4.  *
  5.  * @package energine
  6.  * @subpackage shop
  7.  * @author dr.Pavka
  8.  * @copyright ColoCall 2007
  9.  * @version $Id$
  10.  */
  11.  
  12. //require_once('core/modules/share/components/DBDataSet.class.php');
  13. //require_once('core/modules/shop/components/CurrencyConverter.class.php');
  14.  
  15. /**
  16.  * Переключатель валют
  17.  *
  18.  * @package energine
  19.  * @subpackage shop
  20.  * @author dr.Pavka
  21.  */
  22. class CurrencySwitcher extends DBDataSet {
  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 $documentarray $params null{
  33.         parent::__construct($name$module$document$params);
  34.         $this->setTableName('shop_currency');
  35.         $this->setTitle($this->translate('TXT_CURRENT_CURRENCY'));
  36.         $this->setParam('recordsPerPage'false);
  37.         $this->setParam('onlyCurrentLang'true);
  38.         $this->setOrder(array('curr_order_num' => QAL::ASC));
  39.     }
  40.  
  41.     /**
  42.      * Добавлен параметр id - идентификатор страницы
  43.      *
  44.      * @return int 
  45.      * @access protected
  46.      */
  47.  
  48.     protected function defineParams({
  49.         $result = array_merge(parent::defineParams(),
  50.         array(
  51.         'active'=>false
  52.         ));
  53.         return $result;
  54.     }
  55.  
  56.     /**
  57.      * Method Description
  58.      *
  59.      * @return type 
  60.      * @access protected
  61.      */
  62.  
  63.      protected function main({
  64.         parent::main();
  65.         $currencyConverter CurrencyConverter::getInstance();
  66.         $currIDField $this->getData()->getFieldByName('curr_id')
  67.         $currRate $this->getData()->getFieldByName('curr_rate');
  68.         $currString new Field('curr_string');
  69.         $this->getData()->addField($currString);
  70.         foreach($currIDField as $rowID => $currencyRowData){
  71.             if($currencyRowData == $currencyConverter->getCurrent()){
  72.                 $currIDField->setRowProperty($rowID'current''current');
  73.             }
  74.             $currString->setRowData(
  75.                $rowID
  76.                $currencyConverter->format(
  77.                    $currencyConverter->convert(
  78.                        1,
  79.                        $currencyRowData
  80.                        $currencyConverter->getMain()
  81.                    )
  82.                    $currencyRowData
  83.                )
  84.             );
  85.         }
  86.         $this->addTranslation('MSG_SWITCHER_TIP');
  87.         $this->addTranslation('TXT_CURRENCY_RATE');
  88.      }
  89.  
  90. }
В создании документации нам помог: phpDocumentor