oxcmp_cur.php

Go to the documentation of this file.
00001 <?php
00002 
00008 class oxcmp_cur extends oxView
00009 {
00010 
00016     public $aCurrencies = null;
00017 
00023     protected $_oActCur = null;
00024 
00030     protected $_blIsComponent = true;
00031 
00043     public function init()
00044     {
00045         // Performance
00046         $myConfig = $this->getConfig();
00047         if (!$myConfig->getConfigParam('bl_perfLoadCurrency')) {
00048             //#861C -  show first currency
00049             $aCurrencies = $myConfig->getCurrencyArray();
00050             $this->_oActCur = current($aCurrencies);
00051 
00052             return;
00053         }
00054 
00055         $iCur = oxRegistry::getConfig()->getRequestParameter('cur');
00056         if (isset($iCur)) {
00057             $aCurrencies = $myConfig->getCurrencyArray();
00058             if (!isset($aCurrencies[$iCur])) {
00059                 $iCur = 0;
00060             }
00061 
00062             // set new currency
00063             $myConfig->setActShopCurrency($iCur);
00064 
00065             // recalc basket
00066             $oBasket = $this->getSession()->getBasket();
00067             $oBasket->onUpdate();
00068         }
00069 
00070         $iActCur = $myConfig->getShopCurrency();
00071         $this->aCurrencies = $myConfig->getCurrencyArray($iActCur);
00072 
00073         $this->_oActCur = $this->aCurrencies[$iActCur];
00074 
00075         //setting basket currency (M:825)
00076         if (!isset($oBasket)) {
00077             $oBasket = $this->getSession()->getBasket();
00078         }
00079         $oBasket->setBasketCurrency($this->_oActCur);
00080         parent::init();
00081     }
00082 
00092     public function render()
00093     {
00094         parent::render();
00095         $oParentView = $this->getParent();
00096         $oParentView->setActCurrency($this->_oActCur);
00097 
00098         $oUrlUtils = oxRegistry::get("oxUtilsUrl");
00099         $sUrl = $oUrlUtils->cleanUrl($this->getConfig()->getTopActiveView()->getLink(), array("cur"));
00100 
00101         if ($this->getConfig()->getConfigParam('bl_perfLoadCurrency')) {
00102             reset($this->aCurrencies);
00103             while (list(, $oItem) = each($this->aCurrencies)) {
00104                 $oItem->link = $oUrlUtils->processUrl($sUrl, true, array("cur" => $oItem->id));
00105             }
00106         }
00107 
00108         return $this->aCurrencies;
00109     }
00110 }