currency.php (1744B)
1 <?php 2 class ControllerCommonCurrency extends Controller { 3 public function index() { 4 $this->load->language('common/currency'); 5 6 $data['action'] = $this->url->link('common/currency/currency', '', $this->request->server['HTTPS']); 7 8 $data['code'] = $this->session->data['currency']; 9 10 $this->load->model('localisation/currency'); 11 12 $data['currencies'] = array(); 13 14 $results = $this->model_localisation_currency->getCurrencies(); 15 16 foreach ($results as $result) { 17 if ($result['status']) { 18 $data['currencies'][] = array( 19 'title' => $result['title'], 20 'code' => $result['code'], 21 'symbol_left' => $result['symbol_left'], 22 'symbol_right' => $result['symbol_right'] 23 ); 24 } 25 } 26 27 if (!isset($this->request->get['route'])) { 28 $data['redirect'] = $this->url->link('common/home'); 29 } else { 30 $url_data = $this->request->get; 31 32 unset($url_data['_route_']); 33 34 $route = $url_data['route']; 35 36 unset($url_data['route']); 37 38 $url = ''; 39 40 if ($url_data) { 41 $url = '&' . urldecode(http_build_query($url_data, '', '&')); 42 } 43 44 $data['redirect'] = $this->url->link($route, $url, $this->request->server['HTTPS']); 45 } 46 47 return $this->load->view('common/currency', $data); 48 } 49 50 public function currency() { 51 if (isset($this->request->post['code'])) { 52 $this->session->data['currency'] = $this->request->post['code']; 53 54 unset($this->session->data['shipping_method']); 55 unset($this->session->data['shipping_methods']); 56 } 57 58 if (isset($this->request->post['redirect'])) { 59 $this->response->redirect($this->request->post['redirect']); 60 } else { 61 $this->response->redirect($this->url->link('common/home')); 62 } 63 } 64 }