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

Source for file CurrencySwitcher.class.php

Documentation is available at CurrencySwitcher.class.php

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