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
00041 $myConfig = $this->getConfig();
00042 if ( !$myConfig->getConfigParam( 'bl_perfLoadCurrency' ) ) {
00043
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
00057 $myConfig->setActShopCurrency( $iCur );
00058
00059
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
00070 if ( !isset( $oBasket ) ) {
00071 $oBasket = $this->getSession()->getBasket();
00072 }
00073 $oBasket->setBasketCurrency( $this->_oActCur );
00074
00075 $oUrlUtils = oxUtilsUrl::getInstance();
00076 $sUrl = $oUrlUtils->cleanUrl( $this->getParent()->getLink(), array( "cur" ) );
00077 reset( $this->aCurrencies );
00078 while ( list( , $oItem ) = each( $this->aCurrencies ) ) {
00079 $oItem->link = $oUrlUtils->processUrl( $sUrl, true, array( "cur" => $oItem->id ) );
00080 }
00081
00082 parent::init();
00083 }
00084
00094 public function render()
00095 {
00096 parent::render();
00097 $oParentView = $this->getParent();
00098 $oParentView->setActCurrency( $this->_oActCur );
00099
00100 $oParentView->addTplParam( 'currency', $oParentView->getActCurrency() );
00101 return $this->aCurrencies;
00102 }
00103 }