OXID eShop CE  4.8.10
 All Classes Files Functions Variables Pages
oxcmp_cur.php
Go to the documentation of this file.
1 <?php
2 
7 class oxcmp_cur extends oxView
8 {
13  public $aCurrencies = null;
14 
19  protected $_oActCur = null;
20 
25  protected $_blIsComponent = true;
26 
38  public function init()
39  {
40  // Performance
41  $myConfig = $this->getConfig();
42  if ( !$myConfig->getConfigParam( 'bl_perfLoadCurrency' ) ) {
43  //#861C - show first currency
44  $aCurrencies = $myConfig->getCurrencyArray();
45  $this->_oActCur = current( $aCurrencies );
46  return;
47  }
48 
49  $iCur = oxConfig::getParameter( 'cur' );
50  if ( isset( $iCur ) ) {
51  $aCurrencies = $myConfig->getCurrencyArray();
52  if (!isset( $aCurrencies[$iCur] ) ) {
53  $iCur = 0;
54  }
55 
56  // set new currency
57  $myConfig->setActShopCurrency( $iCur );
58 
59  // recalc basket
60  $oBasket = $this->getSession()->getBasket();
61  $oBasket->onUpdate();
62  }
63 
64  $iActCur = $myConfig->getShopCurrency();
65  $this->aCurrencies = $myConfig->getCurrencyArray( $iActCur );
66 
67  $this->_oActCur = $this->aCurrencies[$iActCur];
68 
69  //setting basket currency (M:825)
70  if ( !isset( $oBasket ) ) {
71  $oBasket = $this->getSession()->getBasket();
72  }
73  $oBasket->setBasketCurrency( $this->_oActCur );
74  parent::init();
75  }
76 
86  public function render()
87  {
89  $oParentView = $this->getParent();
90  $oParentView->setActCurrency( $this->_oActCur );
91 
92  $oUrlUtils = oxRegistry::get("oxUtilsUrl");
93  $sUrl = $oUrlUtils->cleanUrl( $this->getConfig()->getTopActiveView()->getLink(), array( "cur" ) );
94 
95  if ( $this->getConfig()->getConfigParam( 'bl_perfLoadCurrency' ) ) {
96  reset( $this->aCurrencies );
97  while ( list( , $oItem ) = each( $this->aCurrencies ) ) {
98  $oItem->link = $oUrlUtils->processUrl( $sUrl, true, array( "cur" => $oItem->id ) );
99  }
100  }
101 
102  return $this->aCurrencies;
103  }
104 }