OXID eShop CE  4.9.6
 All Classes Files Functions Variables Pages
oxcmp_cur.php
Go to the documentation of this file.
1 <?php
2 
8 class oxcmp_cur extends oxView
9 {
10 
16  public $aCurrencies = null;
17 
23  protected $_oActCur = null;
24 
30  protected $_blIsComponent = true;
31 
43  public function init()
44  {
45  // Performance
46  $myConfig = $this->getConfig();
47  if (!$myConfig->getConfigParam('bl_perfLoadCurrency')) {
48  //#861C - show first currency
49  $aCurrencies = $myConfig->getCurrencyArray();
50  $this->_oActCur = current($aCurrencies);
51 
52  return;
53  }
54 
55  $iCur = oxRegistry::getConfig()->getRequestParameter('cur');
56  if (isset($iCur)) {
57  $aCurrencies = $myConfig->getCurrencyArray();
58  if (!isset($aCurrencies[$iCur])) {
59  $iCur = 0;
60  }
61 
62  // set new currency
63  $myConfig->setActShopCurrency($iCur);
64 
65  // recalc basket
66  $oBasket = $this->getSession()->getBasket();
67  $oBasket->onUpdate();
68  }
69 
70  $iActCur = $myConfig->getShopCurrency();
71  $this->aCurrencies = $myConfig->getCurrencyArray($iActCur);
72 
73  $this->_oActCur = $this->aCurrencies[$iActCur];
74 
75  //setting basket currency (M:825)
76  if (!isset($oBasket)) {
77  $oBasket = $this->getSession()->getBasket();
78  }
79  $oBasket->setBasketCurrency($this->_oActCur);
80  parent::init();
81  }
82 
92  public function render()
93  {
95  $oParentView = $this->getParent();
96  $oParentView->setActCurrency($this->_oActCur);
97 
98  $oUrlUtils = oxRegistry::get("oxUtilsUrl");
99  $sUrl = $oUrlUtils->cleanUrl($this->getConfig()->getTopActiveView()->getLink(), array("cur"));
100 
101  if ($this->getConfig()->getConfigParam('bl_perfLoadCurrency')) {
102  reset($this->aCurrencies);
103  while (list(, $oItem) = each($this->aCurrencies)) {
104  $oItem->link = $oUrlUtils->processUrl($sUrl, true, array("cur" => $oItem->id));
105  }
106  }
107 
108  return $this->aCurrencies;
109  }
110 }