oxcmp_cur.php

Go to the documentation of this file.
00001 <?php
00002 
00007 class oxcmp_cur extends oxView
00008 {
00013     public $aCurrencies    = null;
00014 
00019     protected $_oActCur        = null;
00020 
00025     protected $_blIsComponent = true;
00026 
00038     public function init()
00039     {
00040         // Performance
00041         $myConfig = $this->getConfig();
00042         if ( !$myConfig->getConfigParam( 'bl_perfLoadCurrency' ) ) {
00043             //#861C -  show first currency
00044             $aCurrencies = $myConfig->getCurrencyArray();
00045             $this->_oActCur = current( $aCurrencies );
00046             return;
00047         }
00048 
00049         $iCur = oxConfig::getParameter( 'cur' );
00050         if ( isset( $iCur ) ) {
00051             $aCurrencies = $myConfig->getCurrencyArray();
00052             if (!isset( $aCurrencies[$iCur] ) ) {
00053                 $iCur = 0;
00054             }
00055 
00056             // set new currency
00057             $myConfig->setActShopCurrency( $iCur );
00058 
00059             // recalc basket
00060             $oBasket = $this->getSession()->getBasket();
00061             $oBasket->onUpdate();
00062         }
00063 
00064         $iActCur = $myConfig->getShopCurrency();
00065         $this->aCurrencies = $myConfig->getCurrencyArray( $iActCur );
00066 
00067         $this->_oActCur = $this->aCurrencies[$iActCur];
00068 
00069         //setting basket currency (M:825)
00070         if ( !isset( $oBasket ) ) {
00071             $oBasket = $this->getSession()->getBasket();
00072         }
00073         $oBasket->setBasketCurrency( $this->_oActCur );
00074         parent::init();
00075     }
00076 
00086     public function render()
00087     {
00088         parent::render();
00089         $oParentView = $this->getParent();
00090         $oParentView->setActCurrency( $this->_oActCur );
00091 
00092         $oUrlUtils = oxUtilsUrl::getInstance();
00093         $sUrl = $oUrlUtils->cleanUrl( $this->getParent()->getLink(), array( "cur" ) );
00094 
00095         if ( $this->getConfig()->getConfigParam( 'bl_perfLoadCurrency' ) ) {
00096             reset( $this->aCurrencies );
00097             while ( list( , $oItem ) = each( $this->aCurrencies ) ) {
00098                 $oItem->link = $oUrlUtils->processUrl( $sUrl, true, array( "cur" => $oItem->id ) );
00099             }
00100         }
00101 
00102         return $this->aCurrencies;
00103     }
00104 }