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 $this->_oActCur = $this->aCurrencies[$iActCur];
00067
00068 $sClass = $this->getConfig()->getActiveView()->getClassName();
00069 $sURL = $myConfig->getShopCurrentURL();
00070 $sURL .= "cl={$sClass}";
00071
00072
00073
00074 $sVal = oxConfig::getParameter( 'fnc' );
00075 $aFnc = array( 'tobasket', 'login_noredirect', 'addVoucher' );
00076 if ( $sVal && in_array( $sVal, $aFnc ) ) {
00077 $sVal = '';
00078 }
00079
00080 if ( $sVal ) {
00081 $sURL .= "&fnc={$sVal}";
00082 }
00083
00084
00085 if ( $sVal = oxConfig::getParameter( 'cnid' ) ) {
00086 $sURL .= "&cnid={$sVal}";
00087 }
00088
00089
00090 if ( $sVal= oxConfig::getParameter( 'anid' ) ) {
00091 $sURL .= "&anid={$sVal}";
00092 }
00093
00094
00095 if ( $sVal = basename( oxConfig::getParameter( 'tpl' ) ) ) {
00096 $sURL .= "&tpl={$sVal}";
00097 }
00098
00099
00100 $iPgNr = ( int ) oxConfig::getParameter( 'pgNr' );
00101 if ( $iPgNr > 0 ) {
00102 $sURL .= "&pgNr={$iPgNr}";
00103 }
00104
00105
00106
00107 if ( $sVal = rawurlencode( oxConfig::getParameter( 'searchparam', true ) ) ) {
00108 $sURL .= "&searchparam={$sVal}";
00109 }
00110
00111
00112 if ( $sVal = oxConfig::getParameter( 'searchcnid' ) ) {
00113 $sURL .= "&searchcnid={$sVal}";
00114 }
00115
00116
00117 if ( $sVal = oxConfig::getParameter( 'searchvendor' ) ) {
00118 $sURL .= "&searchvendor={$sVal}";
00119 }
00120
00121 reset( $this->aCurrencies );
00122 while ( list( , $oItem ) = each( $this->aCurrencies ) ) {
00123 $oItem->link = "{$sURL}&cur={$oItem->id}";
00124 }
00125
00126 parent::init();
00127 }
00128
00138 public function render()
00139 {
00140 parent::render();
00141 $this->_oParent->setActCurrency( $this->_oActCur );
00142
00143 $this->_oParent->addTplParam( 'currency', $this->_oParent->getActCurrency() );
00144 return $this->aCurrencies;
00145 }
00146 }