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 
00062             $oBasket->onUpdate();
00063         }
00064 
00065         $iActCur = $myConfig->getShopCurrency();
00066         $this->aCurrencies = $myConfig->getCurrencyArray( $iActCur );
00067 
00068         $this->_oActCur     = $this->aCurrencies[$iActCur];
00069 
00070         //setting basket currency (M:825)
00071         if ( !isset( $oBasket ) ) {
00072             $oBasket = $this->getSession()->getBasket();
00073         }
00074 
00075         $oBasket->setBasketCurrency( $this->_oActCur );
00076 
00077         $sClass = $this->getConfig()->getActiveView()->getClassName();
00078         $sURL  = $myConfig->getShopCurrentURL();
00079         $sURL .= "cl={$sClass}";
00080 
00081         // #921 S
00082         // name of function
00083         $sVal = oxConfig::getParameter( 'fnc' );
00084         $aFnc = array( 'tobasket', 'login_noredirect', 'addVoucher' );
00085         if ( $sVal && in_array( $sVal, $aFnc ) ) {
00086             $sVal = '';
00087         }
00088 
00089         if ( $sVal ) {
00090             $sURL .= "&amp;fnc={$sVal}";
00091         }
00092 
00093         // active category
00094         if ( $sVal = oxConfig::getParameter( 'cnid' ) ) {
00095             $sURL .= "&amp;cnid={$sVal}";
00096         }
00097 
00098         // active article
00099         if ( $sVal= oxConfig::getParameter( 'anid' ) ) {
00100             $sURL .= "&amp;anid={$sVal}";
00101         }
00102 
00103         // active template
00104         if ( $sVal = basename( oxConfig::getParameter( 'tpl' ) ) ) {
00105             $sURL .= "&amp;tpl={$sVal}";
00106         }
00107 
00108         // number of active page
00109         $iPgNr = ( int ) oxConfig::getParameter( 'pgNr' );
00110         if ( $iPgNr > 0 ) {
00111             $sURL .= "&amp;pgNr={$iPgNr}";
00112         }
00113 
00114         // #1184M - specialchar search
00115         // search parameter
00116         if ( $sVal = rawurlencode( oxConfig::getParameter( 'searchparam', true ) ) ) {
00117             $sURL .= "&amp;searchparam={$sVal}";
00118         }
00119 
00120         // search category
00121         if ( $sVal = oxConfig::getParameter( 'searchcnid' ) ) {
00122             $sURL .= "&amp;searchcnid={$sVal}";
00123         }
00124 
00125         // search vendor
00126         if ( $sVal = oxConfig::getParameter( 'searchvendor' ) ) {
00127             $sURL .= "&amp;searchvendor={$sVal}";
00128         }
00129 
00130         // search manufacturer
00131         if ( $sVal = oxConfig::getParameter( 'searchmanufacturer' ) ) {
00132             $sURL .= "&amp;searchmanufacturer={$sVal}";
00133         }
00134 
00135         reset( $this->aCurrencies );
00136         while ( list( , $oItem ) = each( $this->aCurrencies ) ) {
00137             $oItem->link = "{$sURL}&amp;cur={$oItem->id}";
00138         }
00139 
00140         parent::init();
00141     }
00142 
00152     public function render()
00153     {
00154         parent::render();
00155         $this->_oParent->setActCurrency( $this->_oActCur );
00156         // Passing to view. Left for compatibility reasons for a while. Will be removed in future
00157         $this->_oParent->addTplParam( 'currency', $this->_oParent->getActCurrency() );
00158         return $this->aCurrencies;
00159     }
00160 }

Generated on Mon Oct 26 20:07:20 2009 for OXID eShop CE by  doxygen 1.5.5