1 | <?php |
||
2 | /** |
||
3 | * Simple Machines Forum (SMF) |
||
4 | * |
||
5 | * @package SMF |
||
6 | * @author Simple Machines https://www.simplemachines.org |
||
7 | * @copyright 2022 Simple Machines and individual contributors |
||
8 | * @license https://www.simplemachines.org/about/smf/license.php BSD |
||
9 | * |
||
10 | * @version 2.1.0 |
||
11 | */ |
||
12 | |||
13 | /** |
||
14 | * This contains the HTML for the menu bar at the top of the admin center. |
||
15 | */ |
||
16 | function template_generic_menu_dropdown_above() |
||
17 | { |
||
18 | global $context, $txt; |
||
19 | |||
20 | // Which menu are we rendering? |
||
21 | $context['cur_menu_id'] = isset($context['cur_menu_id']) ? $context['cur_menu_id'] + 1 : 1; |
||
22 | $menu_context = &$context['menu_data_' . $context['cur_menu_id']]; |
||
23 | $menu_label = isset($context['admin_menu_name']) ? $txt['admin_center'] : (isset($context['moderation_menu_name']) ? $txt['moderation_center'] : ''); |
||
24 | |||
25 | // Load the menu |
||
26 | // Add mobile menu as well |
||
27 | echo ' |
||
28 | <a class="mobile_generic_menu_', $context['cur_menu_id'], '"> |
||
29 | <span class="menu_icon"></span> |
||
30 | <span class="text_menu">', sprintf($txt['mobile_generic_menu'], $menu_label), '</span> |
||
31 | </a> |
||
32 | <div id="genericmenu"> |
||
33 | <div id="mobile_generic_menu_', $context['cur_menu_id'], '" class="popup_container"> |
||
34 | <div class="popup_window description"> |
||
35 | <div class="popup_heading"> |
||
36 | ', sprintf($txt['mobile_generic_menu'], $menu_label), ' |
||
37 | <a href="javascript:void(0);" class="main_icons hide_popup"></a> |
||
38 | </div> |
||
39 | ', template_generic_menu($menu_context), ' |
||
0 ignored issues
–
show
|
|||
40 | </div> |
||
41 | </div> |
||
42 | </div> |
||
43 | <script> |
||
44 | $( ".mobile_generic_menu_', $context['cur_menu_id'], '" ).click(function() { |
||
45 | $( "#mobile_generic_menu_', $context['cur_menu_id'], '" ).show(); |
||
46 | }); |
||
47 | $( ".hide_popup" ).click(function() { |
||
48 | $( "#mobile_generic_menu_', $context['cur_menu_id'], '" ).hide(); |
||
49 | }); |
||
50 | </script>'; |
||
51 | |||
52 | // This is the main table - we need it so we can keep the content to the right of it. |
||
53 | echo ' |
||
54 | <div id="admin_content">'; |
||
55 | |||
56 | // It's possible that some pages have their own tabs they wanna force... |
||
57 | // if (!empty($context['tabs'])) |
||
58 | template_generic_menu_tabs($menu_context); |
||
59 | } |
||
60 | |||
61 | /** |
||
62 | * Part of the admin layer - used with generic_menu_dropdown_above to close the admin content div. |
||
63 | */ |
||
64 | function template_generic_menu_dropdown_below() |
||
65 | { |
||
66 | echo ' |
||
67 | </div><!-- #admin_content -->'; |
||
68 | } |
||
69 | |||
70 | /** |
||
71 | * The template for displaying a menu |
||
72 | * |
||
73 | * @param array $menu_context An array of menu information |
||
74 | */ |
||
75 | function template_generic_menu(&$menu_context) |
||
76 | { |
||
77 | global $context; |
||
78 | |||
79 | echo ' |
||
80 | <div class="generic_menu"> |
||
81 | <ul class="dropmenu dropdown_menu_', $context['cur_menu_id'], '">'; |
||
82 | |||
83 | // Main areas first. |
||
84 | foreach ($menu_context['sections'] as $section) |
||
85 | { |
||
86 | echo ' |
||
87 | <li ', !empty($section['areas']) ? 'class="subsections"' : '', '><a class="', !empty($section['selected']) ? 'active ' : '', '" href="', $section['url'], $menu_context['extra_parameters'], '">', $section['title'], !empty($section['amt']) ? ' <span class="amt">' . $section['amt'] . '</span>' : '', '</a> |
||
88 | <ul>'; |
||
89 | |||
90 | // For every area of this section show a link to that area (bold if it's currently selected.) |
||
91 | // @todo Code for additional_items class was deprecated and has been removed. Suggest following up in Sources if required. |
||
92 | foreach ($section['areas'] as $i => $area) |
||
93 | { |
||
94 | // Not supposed to be printed? |
||
95 | if (empty($area['label'])) |
||
96 | continue; |
||
97 | |||
98 | echo ' |
||
99 | <li', !empty($area['subsections']) && empty($area['hide_subsections']) ? ' class="subsections"' : '', '> |
||
100 | <a class="', $area['icon_class'], !empty($area['selected']) ? ' chosen ' : '', '" href="', (isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $i), $menu_context['extra_parameters'], '">', $area['icon'], $area['label'], !empty($area['amt']) ? ' <span class="amt">' . $area['amt'] . '</span>' : '', '</a>'; |
||
101 | |||
102 | // Is this the current area, or just some area? |
||
103 | if (!empty($area['selected']) && empty($context['tabs'])) |
||
104 | $context['tabs'] = isset($area['subsections']) ? $area['subsections'] : array(); |
||
105 | |||
106 | // Are there any subsections? |
||
107 | if (!empty($area['subsections']) && empty($area['hide_subsections'])) |
||
108 | { |
||
109 | echo ' |
||
110 | <ul>'; |
||
111 | |||
112 | foreach ($area['subsections'] as $sa => $sub) |
||
113 | { |
||
114 | if (!empty($sub['disabled'])) |
||
115 | continue; |
||
116 | |||
117 | $url = isset($sub['url']) ? $sub['url'] : (isset($area['url']) ? $area['url'] : $menu_context['base_url'] . ';area=' . $i) . ';sa=' . $sa; |
||
118 | |||
119 | echo ' |
||
120 | <li> |
||
121 | <a ', !empty($sub['selected']) ? 'class="chosen" ' : '', ' href="', $url, $menu_context['extra_parameters'], '">', $sub['label'], !empty($sub['amt']) ? ' <span class="amt">' . $sub['amt'] . '</span>' : '', '</a> |
||
122 | </li>'; |
||
123 | } |
||
124 | |||
125 | echo ' |
||
126 | </ul>'; |
||
127 | } |
||
128 | |||
129 | echo ' |
||
130 | </li>'; |
||
131 | } |
||
132 | echo ' |
||
133 | </ul> |
||
134 | </li>'; |
||
135 | } |
||
136 | |||
137 | echo ' |
||
138 | </ul><!-- .dropmenu --> |
||
139 | </div><!-- .generic_menu -->'; |
||
140 | } |
||
141 | |||
142 | /** |
||
143 | * The code for displaying the menu |
||
144 | * |
||
145 | * @param array $menu_context An array of menu context data |
||
146 | */ |
||
147 | function template_generic_menu_tabs(&$menu_context) |
||
148 | { |
||
149 | global $context, $settings, $scripturl, $txt; |
||
150 | |||
151 | // Handy shortcut. |
||
152 | $tab_context = &$menu_context['tab_data']; |
||
153 | |||
154 | if (!empty($tab_context['title'])) |
||
155 | { |
||
156 | echo ' |
||
157 | <div class="cat_bar">'; |
||
158 | |||
159 | // The function is in Admin.template.php, but since this template is used elsewhere too better check if the function is available |
||
160 | if (function_exists('template_admin_quick_search')) |
||
161 | template_admin_quick_search(); |
||
162 | |||
163 | echo ' |
||
164 | <h3 class="catbg">'; |
||
165 | |||
166 | // Exactly how many tabs do we have? |
||
167 | if (!empty($context['tabs'])) |
||
168 | { |
||
169 | foreach ($context['tabs'] as $id => $tab) |
||
170 | { |
||
171 | // Can this not be accessed? |
||
172 | if (!empty($tab['disabled'])) |
||
173 | { |
||
174 | $tab_context['tabs'][$id]['disabled'] = true; |
||
175 | continue; |
||
176 | } |
||
177 | |||
178 | // Did this not even exist - or do we not have a label? |
||
179 | if (!isset($tab_context['tabs'][$id])) |
||
180 | $tab_context['tabs'][$id] = array('label' => $tab['label']); |
||
181 | elseif (!isset($tab_context['tabs'][$id]['label'])) |
||
182 | $tab_context['tabs'][$id]['label'] = $tab['label']; |
||
183 | |||
184 | // Has a custom URL defined in the main admin structure? |
||
185 | if (isset($tab['url']) && !isset($tab_context['tabs'][$id]['url'])) |
||
186 | $tab_context['tabs'][$id]['url'] = $tab['url']; |
||
187 | |||
188 | // Any additional parameters for the url? |
||
189 | if (isset($tab['add_params']) && !isset($tab_context['tabs'][$id]['add_params'])) |
||
190 | $tab_context['tabs'][$id]['add_params'] = $tab['add_params']; |
||
191 | |||
192 | // Has it been deemed selected? |
||
193 | if (!empty($tab['is_selected'])) |
||
194 | $tab_context['tabs'][$id]['is_selected'] = true; |
||
195 | |||
196 | // Does it have its own help? |
||
197 | if (!empty($tab['help'])) |
||
198 | $tab_context['tabs'][$id]['help'] = $tab['help']; |
||
199 | |||
200 | // Is this the last one? |
||
201 | if (!empty($tab['is_last']) && !isset($tab_context['override_last'])) |
||
202 | $tab_context['tabs'][$id]['is_last'] = true; |
||
203 | } |
||
204 | |||
205 | // Find the selected tab |
||
206 | foreach ($tab_context['tabs'] as $sa => $tab) |
||
207 | { |
||
208 | if (!empty($tab['is_selected']) || (isset($menu_context['current_subsection']) && $menu_context['current_subsection'] == $sa)) |
||
209 | { |
||
210 | $selected_tab = $tab; |
||
211 | $tab_context['tabs'][$sa]['is_selected'] = true; |
||
212 | } |
||
213 | } |
||
214 | } |
||
215 | |||
216 | // Show an icon and/or a help item? |
||
217 | if (!empty($selected_tab['icon_class']) || !empty($tab_context['icon_class']) || !empty($selected_tab['icon']) || !empty($tab_context['icon']) || !empty($selected_tab['help']) || !empty($tab_context['help'])) |
||
218 | { |
||
219 | if (!empty($selected_tab['icon_class']) || !empty($tab_context['icon_class'])) |
||
220 | echo ' |
||
221 | <span class="', !empty($selected_tab['icon_class']) ? $selected_tab['icon_class'] : $tab_context['icon_class'], ' icon"></span>'; |
||
222 | elseif (!empty($selected_tab['icon']) || !empty($tab_context['icon'])) |
||
223 | echo ' |
||
224 | <img src="', $settings['images_url'], '/icons/', !empty($selected_tab['icon']) ? $selected_tab['icon'] : $tab_context['icon'], '" alt="" class="icon">'; |
||
225 | |||
226 | if (!empty($selected_tab['help']) || !empty($tab_context['help'])) |
||
227 | echo ' |
||
228 | <a href="', $scripturl, '?action=helpadmin;help=', !empty($selected_tab['help']) ? $selected_tab['help'] : $tab_context['help'], '" onclick="return reqOverlayDiv(this.href);" class="help"><span class="main_icons help" title="', $txt['help'], '"></span></a>'; |
||
229 | |||
230 | echo $tab_context['title']; |
||
231 | } |
||
232 | else |
||
233 | echo ' |
||
234 | ', $tab_context['title']; |
||
235 | |||
236 | echo ' |
||
237 | </h3> |
||
238 | </div><!-- .cat_bar -->'; |
||
239 | } |
||
240 | |||
241 | // Shall we use the tabs? Yes, it's the only known way! |
||
242 | if (!empty($selected_tab['description']) || !empty($tab_context['description'])) |
||
243 | echo ' |
||
244 | <p class="information"> |
||
245 | ', !empty($selected_tab['description']) ? $selected_tab['description'] : $tab_context['description'], ' |
||
246 | </p>'; |
||
247 | |||
248 | // Print out all the items in this tab (if any). |
||
249 | if (!empty($context['tabs'])) |
||
250 | { |
||
251 | // The admin tabs. |
||
252 | echo ' |
||
253 | <a class="mobile_generic_menu_', $context['cur_menu_id'], '_tabs"> |
||
254 | <span class="menu_icon"></span> |
||
255 | <span class="text_menu">', sprintf($txt['mobile_generic_menu'], $tab_context['title']), '</span> |
||
256 | </a> |
||
257 | <div id="adm_submenus"> |
||
258 | <div id="mobile_generic_menu_', $context['cur_menu_id'], '_tabs" class="popup_container"> |
||
259 | <div class="popup_window description"> |
||
260 | <div class="popup_heading"> |
||
261 | ', sprintf($txt['mobile_generic_menu'], $tab_context['title']), ' |
||
262 | <a href="javascript:void(0);" class="main_icons hide_popup"></a> |
||
263 | </div>'; |
||
264 | |||
265 | echo ' |
||
266 | <div class="generic_menu"> |
||
267 | <ul class="dropmenu dropdown_menu_', $context['cur_menu_id'], '_tabs">'; |
||
268 | |||
269 | foreach ($tab_context['tabs'] as $sa => $tab) |
||
270 | { |
||
271 | if (!empty($tab['disabled'])) |
||
272 | continue; |
||
273 | |||
274 | if (!empty($tab['is_selected'])) |
||
275 | echo ' |
||
276 | <li> |
||
277 | <a class="active" href="', isset($tab['url']) ? $tab['url'] : $menu_context['base_url'] . ';area=' . $menu_context['current_area'] . ';sa=' . $sa, $menu_context['extra_parameters'], isset($tab['add_params']) ? $tab['add_params'] : '', '">', $tab['label'], '</a> |
||
278 | </li>'; |
||
279 | else |
||
280 | echo ' |
||
281 | <li> |
||
282 | <a href="', isset($tab['url']) ? $tab['url'] : $menu_context['base_url'] . ';area=' . $menu_context['current_area'] . ';sa=' . $sa, $menu_context['extra_parameters'], isset($tab['add_params']) ? $tab['add_params'] : '', '">', $tab['label'], '</a> |
||
283 | </li>'; |
||
284 | } |
||
285 | |||
286 | // The end of tabs |
||
287 | echo ' |
||
288 | </ul> |
||
289 | </div> |
||
290 | </div> |
||
291 | </div> |
||
292 | </div><!-- #adm_submenus --> |
||
293 | <script> |
||
294 | $( ".mobile_generic_menu_', $context['cur_menu_id'], '_tabs" ).click(function() { |
||
295 | $( "#mobile_generic_menu_', $context['cur_menu_id'], '_tabs" ).show(); |
||
296 | }); |
||
297 | $( ".hide_popup" ).click(function() { |
||
298 | $( "#mobile_generic_menu_', $context['cur_menu_id'], '_tabs" ).hide(); |
||
299 | }); |
||
300 | </script>'; |
||
301 | } |
||
302 | } |
||
303 | |||
304 | ?> |
This check looks for function or method calls that always return null and whose return value is used.
The method
getObject()
can return nothing but null, so it makes no sense to use the return value.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.