|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @package Cadmium\System\Frames\Admin |
|
5
|
|
|
* @author Anton Romanov |
|
6
|
|
|
* @copyright Copyright (c) 2015-2017, Anton Romanov |
|
7
|
|
|
* @link http://cadmium-cms.com |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
namespace Frames\Admin\View { |
|
11
|
|
|
|
|
12
|
|
|
use Frames, Modules\Auth, Modules\Extend, Utils\Messages, Utils\Popup, DB, Debug, Language, Template; |
|
13
|
|
|
|
|
14
|
|
|
class Panel extends Frames\Admin\View { |
|
15
|
|
|
|
|
16
|
|
|
protected $view = 'Panel', $status = STATUS_CODE_200; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Get a layout block |
|
20
|
|
|
*/ |
|
21
|
|
|
|
|
22
|
|
|
private function getLayout(Template\Block $contents) : Template\Block { |
|
23
|
|
|
|
|
24
|
|
|
$layout = self::get('Layouts/Panel'); |
|
25
|
|
|
|
|
26
|
|
|
# Set menu and user |
|
27
|
|
|
|
|
28
|
|
|
if (Auth::check()) { |
|
29
|
|
|
|
|
30
|
|
|
$layout->menu = self::get('Blocks/Utils/Menu'); |
|
31
|
|
|
|
|
32
|
|
|
$layout->getBlock('user')->gravatar = Auth::user()->gravatar; |
|
33
|
|
|
|
|
34
|
|
|
$layout->getBlock('user')->name = Auth::user()->name; |
|
35
|
|
|
|
|
36
|
|
|
$layout->getBlock('user')->id = Auth::user()->id; |
|
37
|
|
|
} |
|
38
|
|
|
|
|
39
|
|
|
# Set title |
|
40
|
|
|
|
|
41
|
|
|
$layout->title = Language::get($this->title); |
|
42
|
|
|
|
|
43
|
|
|
# Set messages |
|
44
|
|
|
|
|
45
|
|
|
$layout->messages = Messages::block(); |
|
46
|
|
|
|
|
47
|
|
|
# Set popup |
|
48
|
|
|
|
|
49
|
|
|
$layout->popup = Popup::block(); |
|
50
|
|
|
|
|
51
|
|
|
# Set contents |
|
52
|
|
|
|
|
53
|
|
|
$layout->contents = $contents; |
|
54
|
|
|
|
|
55
|
|
|
# Set language |
|
56
|
|
|
|
|
57
|
|
|
$layout->getBlock('language')->country = Extend\Languages::data('country'); |
|
58
|
|
|
|
|
59
|
|
|
$layout->getBlock('language')->title = Extend\Languages::data('title'); |
|
60
|
|
|
|
|
61
|
|
|
# Set report |
|
62
|
|
|
|
|
63
|
|
|
$layout->getBlock('report')->script_time = Debug::getTime(); |
|
64
|
|
|
|
|
65
|
|
|
$layout->getBlock('report')->db_time = DB::getTime(); |
|
66
|
|
|
|
|
67
|
|
|
# ------------------------ |
|
68
|
|
|
|
|
69
|
|
|
return $layout; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
/** |
|
73
|
|
|
* Get a layout dynamic data |
|
74
|
|
|
*/ |
|
75
|
|
|
|
|
76
|
|
|
private function getLayoutData(Template\Block $contents) : array { |
|
77
|
|
|
|
|
78
|
|
|
$layout = []; |
|
79
|
|
|
|
|
80
|
|
|
# Set title |
|
81
|
|
|
|
|
82
|
|
|
$layout['title'] = Language::get($this->title); |
|
83
|
|
|
|
|
84
|
|
|
# Set messages |
|
85
|
|
|
|
|
86
|
|
|
$layout['messages'] = Messages::block()->getContents(); |
|
87
|
|
|
|
|
88
|
|
|
# Set popup |
|
89
|
|
|
|
|
90
|
|
|
$layout['popup'] = Popup::block()->getContents(); |
|
91
|
|
|
|
|
92
|
|
|
# Set contents |
|
93
|
|
|
|
|
94
|
|
|
$layout['contents'] = $contents->getContents(); |
|
95
|
|
|
|
|
96
|
|
|
# ------------------------ |
|
97
|
|
|
|
|
98
|
|
|
return $layout; |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
/** |
|
102
|
|
|
* Output the page contents |
|
103
|
|
|
*/ |
|
104
|
|
|
|
|
105
|
|
|
public function display(Template\Block $contents) { |
|
106
|
|
|
|
|
107
|
|
|
$this->_display($this->getLayout($contents)); |
|
108
|
|
|
} |
|
109
|
|
|
|
|
110
|
|
|
/** |
|
111
|
|
|
* Output the page dynamic data as json |
|
112
|
|
|
*/ |
|
113
|
|
|
|
|
114
|
|
|
public function navigate(Template\Block $contents) { |
|
115
|
|
|
|
|
116
|
|
|
$this->_navigate($this->getLayoutData($contents)); |
|
117
|
|
|
} |
|
118
|
|
|
} |
|
119
|
|
|
} |
|
120
|
|
|
|