1: | <?php
2: | namespace Opencart\Catalog\Controller\Common;
3: | /**
4: | * Class Language
5: | *
6: | * @package Opencart\Catalog\Controller\Common
7: | */
8: | class Language extends \Opencart\System\Engine\Controller {
9: | /**
10: | * @return string
11: | */
12: | public function index(): string {
13: | $this->load->language('common/language');
14: |
15: | $url_data = $this->request->get;
16: |
17: | if (isset($url_data['route'])) {
18: | $route = $url_data['route'];
19: | } else {
20: | $route = $this->config->get('action_default');
21: | }
22: |
23: | unset($url_data['route']);
24: | unset($url_data['_route_']);
25: | unset($url_data['language']);
26: |
27: | $url = '';
28: |
29: | if ($url_data) {
30: | $url .= '&' . urldecode(http_build_query($url_data));
31: | }
32: |
33: | // Added so the correct SEO language URL is used.
34: | $language_id = $this->config->get('config_language_id');
35: |
36: | $data['languages'] = [];
37: |
38: | $this->load->model('localisation/language');
39: |
40: | $results = $this->model_localisation_language->getLanguages();
41: |
42: | foreach ($results as $result) {
43: | $this->config->set('config_language_id', $result['language_id']);
44: |
45: | $data['languages'][] = [
46: | 'name' => $result['name'],
47: | 'code' => $result['code'],
48: | 'image' => $result['image'],
49: | 'href' => $this->url->link($route, 'language=' . $result['code'] . $url, true)
50: | ];
51: | }
52: |
53: | $this->config->set('config_language_id', $language_id);
54: |
55: | $data['code'] = $this->config->get('config_language');
56: |
57: | return $this->load->view('common/language', $data);
58: | }
59: | }
60: |

OpenCart API API documentation generated by ApiGen dev-master