Back to Opencart

File admin\controller\common\header.php

docs/api/source-admin.controller.common.header.html

4.1.0.39.5 KB
Original Source

Namespaces

Classes

| 1: | <?php | | 2: | namespace Opencart\Admin\Controller\Common; | | 3: | /** | | 4: | * Class Header | | 5: | * | | 6: | * @package Opencart\Admin\Controller\Common | | 7: | */ | | 8: | class Header extends \Opencart\System\Engine\Controller { | | 9: | /** | | 10: | * Index | | 11: | * | | 12: | * @return string | | 13: | */ | | 14: | public function index(): string { | | 15: | $data['lang'] = $this->language->get('code'); | | 16: | $data['direction'] = $this->language->get('direction'); | | 17: | | | 18: | $data['title'] = $this->document->getTitle(); | | 19: | $data['base'] = HTTP_SERVER; | | 20: | $data['description'] = $this->document->getDescription(); | | 21: | $data['keywords'] = $this->document->getKeywords(); | | 22: | | | 23: | // Hard coding css so they can be replaced via the event's system. | | 24: | $data['bootstrap'] = 'view/stylesheet/bootstrap.css'; | | 25: | $data['icons'] = 'view/stylesheet/fonts/fontawesome/css/all.min.css'; | | 26: | $data['stylesheet'] = 'view/stylesheet/stylesheet.css'; | | 27: | | | 28: | // Hard coding scripts so they can be replaced via the event's system. | | 29: | $data['jquery'] = 'view/javascript/jquery/jquery-3.7.1.min.js'; | | 30: | | | 31: | $data['links'] = $this->document->getLinks(); | | 32: | $data['styles'] = $this->document->getStyles(); | | 33: | $data['scripts'] = $this->document->getScripts(); | | 34: | | | 35: | $this->load->language('common/header'); | | 36: | | | 37: | if (!isset($this->request->get['user_token']) || !isset($this->session->data['user_token']) || ($this->request->get['user_token'] != $this->session->data['user_token'])) { | | 38: | $data['logged'] = false; | | 39: | | | 40: | $data['home'] = $this->url->link('common/login'); | | 41: | } else { | | 42: | $data['logged'] = true; | | 43: | | | 44: | $data['home'] = $this->url->link('common/dashboard', 'user_token=' . $this->session->data['user_token']); | | 45: | | | 46: | $data['language'] = $this->load->controller('common/language'); | | 47: | | | 48: | // Notifications | | 49: | $filter_data = [ | | 50: | 'start' => 0, | | 51: | 'limit' => 5 | | 52: | ]; | | 53: | | | 54: | $data['notifications'] = []; | | 55: | | | 56: | $this->load->model('tool/notification'); | | 57: | | | 58: | $results = $this->model_tool_notification->getNotifications($filter_data); | | 59: | | | 60: | foreach ($results as $result) { | | 61: | $data['notifications'][] = [ | | 62: | 'title' => $result['title'], | | 63: | 'href' => $this->url->link('tool/notification.info', 'user_token=' . $this->session->data['user_token'] . '&notification_id=' . $result['notification_id']) | | 64: | ]; | | 65: | } | | 66: | | | 67: | $data['notification_all'] = $this->url->link('tool/notification', 'user_token=' . $this->session->data['user_token']); | | 68: | $data['notification_total'] = $this->model_tool_notification->getTotalNotifications(['filter_status' => 0]); | | 69: | | | 70: | $data['profile'] = $this->url->link('user/profile', 'user_token=' . $this->session->data['user_token']); | | 71: | | | 72: | $this->load->model('user/user'); | | 73: | | | 74: | $user_info = $this->model_user_user->getUser($this->user->getId()); | | 75: | | | 76: | if ($user_info) { | | 77: | $data['firstname'] = $user_info['firstname']; | | 78: | $data['lastname'] = $user_info['lastname']; | | 79: | } else { | | 80: | $data['firstname'] = ''; | | 81: | $data['lastname'] = ''; | | 82: | } | | 83: | | | 84: | $this->load->model('tool/image'); | | 85: | | | 86: | if ($user_info['image'] && is_file(DIR_IMAGE . html_entity_decode($user_info['image'], ENT_QUOTES, 'UTF-8'))) { | | 87: | $data['image'] = $this->model_tool_image->resize($user_info['image'], 45, 45); | | 88: | } else { | | 89: | $data['image'] = $this->model_tool_image->resize('profile.png', 45, 45); | | 90: | } | | 91: | | | 92: | // Stores | | 93: | $data['stores'] = []; | | 94: | | | 95: | $data['stores'][] = [ | | 96: | 'name' => $this->config->get('config_name'), | | 97: | 'href' => HTTP_CATALOG | | 98: | ]; | | 99: | | | 100: | $this->load->model('setting/store'); | | 101: | | | 102: | $results = $this->model_setting_store->getStores(); | | 103: | | | 104: | foreach ($results as $result) { | | 105: | $data['stores'][] = [ | | 106: | 'name' => $result['name'], | | 107: | 'href' => $result['url'] | | 108: | ]; | | 109: | } | | 110: | | | 111: | $data['logout'] = $this->url->link('common/logout', 'user_token=' . $this->session->data['user_token']); | | 112: | } | | 113: | | | 114: | return $this->load->view('common/header', $data); | | 115: | } | | 116: | } | | 117: | |

OpenCart API API documentation generated by ApiGen dev-master