1 | <?php |
||
14 | class display |
||
15 | { |
||
16 | /** @var \phpbb\auth\auth */ |
||
17 | protected $auth; |
||
18 | |||
19 | /** @var \phpbb\config\config */ |
||
20 | protected $config; |
||
21 | |||
22 | /** @var ContainerInterface */ |
||
23 | protected $phpbb_container; |
||
24 | |||
25 | /** @var \phpbb\request\request_interface */ |
||
26 | protected $request; |
||
27 | |||
28 | /** @var \phpbb\template\template */ |
||
29 | protected $template; |
||
30 | |||
31 | /** @var \phpbb\language\language */ |
||
32 | protected $translator; |
||
33 | |||
34 | /** @var \phpbb\user */ |
||
35 | protected $user; |
||
36 | |||
37 | /** @var bool */ |
||
38 | private $is_subpage; |
||
39 | |||
40 | /** @var string */ |
||
41 | public $route; |
||
42 | |||
43 | const SHOW_BLOCK_BOTH = 0; |
||
44 | const SHOW_BLOCK_LANDING = 1; |
||
45 | const SHOW_BLOCK_SUBPAGE = 2; |
||
46 | |||
47 | /** |
||
48 | * Constructor |
||
49 | * |
||
50 | * @param \phpbb\auth\auth $auth Auth object |
||
51 | * @param \phpbb\config\config $config Config object |
||
52 | * @param ContainerInterface $phpbb_container Service container |
||
53 | * @param \phpbb\request\request_interface $request Request object |
||
54 | * @param \phpbb\template\template $template Template object |
||
55 | * @param \phpbb\language\language $translator Language object |
||
56 | * @param \phpbb\user $user User object |
||
57 | */ |
||
58 | 6 | public function __construct(\phpbb\auth\auth $auth, \phpbb\config\config $config, ContainerInterface $phpbb_container, \phpbb\request\request_interface $request, \phpbb\template\template $template, \phpbb\language\language $translator, \phpbb\user $user) |
|
68 | |||
69 | /** |
||
70 | * Show blocks |
||
71 | */ |
||
72 | 6 | public function show() |
|
73 | { |
||
74 | 6 | $this->template->assign_var('L_INDEX', $this->translator->lang('HOME')); |
|
75 | |||
76 | 6 | if ($this->page_can_have_blocks()) |
|
77 | 6 | { |
|
78 | 4 | $style_id = $this->get_style_id(); |
|
79 | 4 | $edit_mode = $this->toggle_edit_mode(); |
|
80 | 4 | $display_modes = $this->get_display_modes(); |
|
81 | 4 | $u_edit_mode = $this->get_edit_mode_url($edit_mode, $display_modes); |
|
82 | |||
83 | 4 | $this->show_blocks($style_id, $edit_mode, $display_modes); |
|
84 | |||
85 | 4 | $this->template->assign_vars(array( |
|
86 | 4 | 'S_SITEMAKER' => true, |
|
87 | 4 | 'S_LAYOUT' => $this->get_layout($style_id), |
|
88 | 4 | 'U_EDIT_MODE' => $u_edit_mode, |
|
89 | 4 | )); |
|
90 | 4 | } |
|
91 | 6 | } |
|
92 | |||
93 | /** |
||
94 | * Set current route |
||
95 | */ |
||
96 | 4 | public function set_route() |
|
97 | { |
||
98 | 4 | $this->route = $this->user->page['page_name']; |
|
99 | 4 | $this->is_subpage = ($this->user->page['query_string']) ? true : false; |
|
100 | 4 | } |
|
101 | |||
102 | /** |
||
103 | * Get style id |
||
104 | * @return int |
||
105 | */ |
||
106 | 4 | public function get_style_id() |
|
117 | |||
118 | /** |
||
119 | * @return bool |
||
120 | */ |
||
121 | 6 | protected function page_can_have_blocks() |
|
126 | |||
127 | /** |
||
128 | * @param bool $edit_mode |
||
129 | * @param array $route_info |
||
130 | */ |
||
131 | 4 | protected function show_admin_bar($edit_mode, array $route_info) |
|
138 | |||
139 | /** |
||
140 | * @return bool |
||
141 | */ |
||
142 | 4 | protected function toggle_edit_mode() |
|
154 | |||
155 | /** |
||
156 | * @return array |
||
157 | */ |
||
158 | 4 | protected function get_display_modes() |
|
181 | |||
182 | /** |
||
183 | * @param bool $edit_mode |
||
184 | * @param array $modes |
||
185 | * @return string |
||
186 | */ |
||
187 | 4 | protected function get_edit_mode_url(&$edit_mode, array &$modes) |
|
210 | |||
211 | /** |
||
212 | * @param int $style_id |
||
213 | * @return string |
||
214 | */ |
||
215 | 4 | protected function get_layout($style_id) |
|
222 | |||
223 | /** |
||
224 | * @param int $style_id |
||
225 | * @param bool $edit_mode |
||
226 | * @param array $display_modes |
||
227 | */ |
||
228 | 4 | protected function show_blocks($style_id, $edit_mode, array $display_modes) |
|
238 | } |
||
239 |