1: | <?php
2: | namespace Opencart\Admin\Controller\Common;
3: | /**
4: | * Class Dashboard
5: | *
6: | * @package Opencart\Admin\Controller\Common
7: | */
8: | class Dashboard extends \Opencart\System\Engine\Controller {
9: | /**
10: | * Index
11: | *
12: | * @return void
13: | */
14: | public function index(): void {
15: | $this->load->language('common/dashboard');
16: |
17: | $this->document->setTitle($this->language->get('heading_title'));
18: |
19: | $data['breadcrumbs'] = [];
20: |
21: | $data['breadcrumbs'][] = [
22: | 'text' => $this->language->get('text_home'),
23: | 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'])
24: | ];
25: |
26: | $data['breadcrumbs'][] = [
27: | 'text' => $this->language->get('heading_title'),
28: | 'href' => $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token'])
29: | ];
30: |
31: | // Dashboard Extensions
32: | $dashboards = [];
33: |
34: | $this->load->model('setting/extension');
35: |
36: | // Get a list of installed modules
37: | $extensions = $this->model_setting_extension->getExtensionsByType('dashboard');
38: |
39: | // Add all the modules which have multiple settings for each module
40: | foreach ($extensions as $extension) {
41: | if ($this->config->get('dashboard_' . $extension['code'] . '_status') && $this->user->hasPermission('access', 'extension/' . $extension['extension'] . '/dashboard/' . $extension['code'])) {
42: | $output = $this->load->controller('extension/' . $extension['extension'] . '/dashboard/' . $extension['code'] . '.dashboard');
43: |
44: | //if (!$output instanceof \Exception) {
45: | if ($output) {
46: | $dashboards[] = [
47: | 'code' => $extension['code'],
48: | 'width' => $this->config->get('dashboard_' . $extension['code'] . '_width'),
49: | 'sort_order' => $this->config->get('dashboard_' . $extension['code'] . '_sort_order'),
50: | 'output' => $output
51: | ];
52: | }
53: | }
54: | }
55: |
56: | $sort_order = [];
57: |
58: | foreach ($dashboards as $key => $value) {
59: | $sort_order[$key] = $value['sort_order'];
60: | }
61: |
62: | array_multisort($sort_order, SORT_ASC, $dashboards);
63: |
64: | // Split the array so the columns width is not more than 12 on each row.
65: | $width = 0;
66: | $column = [];
67: | $data['rows'] = [];
68: |
69: | foreach ($dashboards as $dashboard) {
70: | $column[] = $dashboard;
71: |
72: | $width = ($width + $dashboard['width']);
73: |
74: | if ($width >= 12) {
75: | $data['rows'][] = $column;
76: |
77: | $width = 0;
78: | $column = [];
79: | }
80: | }
81: |
82: | if ($column) {
83: | $data['rows'][] = $column;
84: | }
85: |
86: | if ($this->user->hasPermission('access', 'common/developer')) {
87: | $data['developer_status'] = true;
88: | } else {
89: | $data['developer_status'] = false;
90: | }
91: |
92: | $data['security'] = $this->load->controller('common/security');
93: |
94: | $data['user_token'] = $this->session->data['user_token'];
95: |
96: | $data['header'] = $this->load->controller('common/header');
97: | $data['column_left'] = $this->load->controller('common/column_left');
98: | $data['footer'] = $this->load->controller('common/footer');
99: |
100: | $this->response->setOutput($this->load->view('common/dashboard', $data));
101: | }
102: | }
103: |

OpenCart API API documentation generated by ApiGen dev-master