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.2 |
||||||
11 | */ |
||||||
12 | |||||||
13 | /** |
||||||
14 | * This defines the XML for sending the body of a message |
||||||
15 | */ |
||||||
16 | function template_sendbody() |
||||||
17 | { |
||||||
18 | global $context; |
||||||
19 | |||||||
20 | echo '<', '?xml version="1.0" encoding="', $context['character_set'], '"?', '> |
||||||
21 | <smf> |
||||||
22 | <message view="', $context['view'], '">', cleanXml($context['message']), '</message> |
||||||
23 | </smf>'; |
||||||
24 | } |
||||||
25 | |||||||
26 | /** |
||||||
27 | * This defines the XML for the AJAX quote feature |
||||||
28 | */ |
||||||
29 | function template_quotefast() |
||||||
30 | { |
||||||
31 | global $context; |
||||||
32 | |||||||
33 | echo '<', '?xml version="1.0" encoding="', $context['character_set'], '"?', '> |
||||||
34 | <smf> |
||||||
35 | <quote>', cleanXml($context['quote']['xml']), '</quote> |
||||||
36 | </smf>'; |
||||||
37 | } |
||||||
38 | |||||||
39 | /** |
||||||
40 | * This defines the XML for the inline edit feature |
||||||
41 | */ |
||||||
42 | function template_modifyfast() |
||||||
43 | { |
||||||
44 | global $context; |
||||||
45 | |||||||
46 | echo '<', '?xml version="1.0" encoding="', $context['character_set'], '"?', '> |
||||||
47 | <smf> |
||||||
48 | <subject><![CDATA[', cleanXml($context['message']['subject']), ']]></subject> |
||||||
49 | <message id="msg_', $context['message']['id'], '"><![CDATA[', cleanXml($context['message']['body']), ']]></message> |
||||||
50 | <reason time="', $context['message']['reason']['time'], '" name="', $context['message']['reason']['name'], '"><![CDATA[', cleanXml($context['message']['reason']['text']), ']]></reason> |
||||||
51 | </smf>'; |
||||||
52 | |||||||
53 | } |
||||||
54 | |||||||
55 | /** |
||||||
56 | * The XML for handling things when you're done editing a post inline |
||||||
57 | */ |
||||||
58 | function template_modifydone() |
||||||
59 | { |
||||||
60 | global $context, $txt; |
||||||
61 | |||||||
62 | echo '<', '?xml version="1.0" encoding="', $context['character_set'], '"?', '> |
||||||
63 | <smf> |
||||||
64 | <message id="msg_', $context['message']['id'], '">'; |
||||||
65 | if (empty($context['message']['errors'])) |
||||||
66 | { |
||||||
67 | // Build our string of info about when and why it was modified |
||||||
68 | $modified = empty($context['message']['modified']['time']) ? '' : sprintf($txt['last_edit_by'], $context['message']['modified']['time'], $context['message']['modified']['name']); |
||||||
69 | $modified .= empty($context['message']['modified']['reason']) ? '' : ' ' . sprintf($txt['last_edit_reason'], $context['message']['modified']['reason']); |
||||||
70 | |||||||
71 | echo ' |
||||||
72 | <modified><![CDATA[', empty($modified) ? '' : cleanXml($modified), ']]></modified> |
||||||
73 | <subject is_first="', $context['message']['first_in_topic'] ? '1' : '0', '"><![CDATA[', cleanXml($context['message']['subject']), ']]></subject> |
||||||
74 | <body><![CDATA[', $context['message']['body'], ']]></body> |
||||||
75 | <success><![CDATA[', $txt['quick_modify_message'], ']]></success>'; |
||||||
76 | } |
||||||
77 | else |
||||||
78 | echo ' |
||||||
79 | <error in_subject="', $context['message']['error_in_subject'] ? '1' : '0', '" in_body="', cleanXml($context['message']['error_in_body']) ? '1' : '0', '"><![CDATA[', implode('<br />', $context['message']['errors']), ']]></error>'; |
||||||
80 | echo ' |
||||||
81 | </message> |
||||||
82 | </smf>'; |
||||||
83 | } |
||||||
84 | |||||||
85 | /** |
||||||
86 | * This handles things when editing a topic's subject from the messageindex. |
||||||
87 | */ |
||||||
88 | function template_modifytopicdone() |
||||||
89 | { |
||||||
90 | global $context, $txt; |
||||||
91 | |||||||
92 | echo '<', '?xml version="1.0" encoding="', $context['character_set'], '"?', '> |
||||||
93 | <smf> |
||||||
94 | <message id="msg_', $context['message']['id'], '">'; |
||||||
95 | if (empty($context['message']['errors'])) |
||||||
96 | { |
||||||
97 | // Build our string of info about when and why it was modified |
||||||
98 | $modified = empty($context['message']['modified']['time']) ? '' : sprintf($txt['last_edit_by'], $context['message']['modified']['time'], $context['message']['modified']['name']); |
||||||
99 | $modified .= empty($context['message']['modified']['reason']) ? '' : sprintf($txt['last_edit_reason'], $context['message']['modified']['reason']); |
||||||
100 | |||||||
101 | echo ' |
||||||
102 | <modified><![CDATA[', empty($modified) ? '' : cleanXml('<em>' . $modified . '</em>'), ']]></modified>'; |
||||||
103 | |||||||
104 | if (!empty($context['message']['subject'])) |
||||||
105 | echo ' |
||||||
106 | <subject><![CDATA[', cleanXml($context['message']['subject']), ']]></subject>'; |
||||||
107 | } |
||||||
108 | else |
||||||
109 | echo ' |
||||||
110 | <error in_subject="', $context['message']['error_in_subject'] ? '1' : '0', '"><![CDATA[', cleanXml(implode('<br />', $context['message']['errors'])), ']]></error>'; |
||||||
111 | echo ' |
||||||
112 | </message> |
||||||
113 | </smf>'; |
||||||
114 | } |
||||||
115 | |||||||
116 | /** |
||||||
117 | * The massive XML for previewing posts. |
||||||
118 | */ |
||||||
119 | function template_post() |
||||||
120 | { |
||||||
121 | global $context; |
||||||
122 | |||||||
123 | echo '<', '?xml version="1.0" encoding="', $context['character_set'], '"?', '> |
||||||
124 | <smf> |
||||||
125 | <preview> |
||||||
126 | <subject><![CDATA[', $context['preview_subject'], ']]></subject> |
||||||
127 | <body><![CDATA[', $context['preview_message'], ']]></body> |
||||||
128 | </preview> |
||||||
129 | <errors serious="', empty($context['error_type']) || $context['error_type'] != 'serious' ? '0' : '1', '" topic_locked="', $context['locked'] ? '1' : '0', '">'; |
||||||
130 | |||||||
131 | if (!empty($context['post_error'])) |
||||||
132 | foreach ($context['post_error'] as $message) |
||||||
133 | echo ' |
||||||
134 | <error><![CDATA[', cleanXml($message), ']]></error>'; |
||||||
135 | |||||||
136 | echo ' |
||||||
137 | <caption name="guestname" class="', isset($context['post_error']['long_name']) || isset($context['post_error']['no_name']) || isset($context['post_error']['bad_name']) ? 'error' : '', '" /> |
||||||
138 | <caption name="email" class="', isset($context['post_error']['no_email']) || isset($context['post_error']['bad_email']) ? 'error' : '', '" /> |
||||||
139 | <caption name="evtitle" class="', isset($context['post_error']['no_event']) ? 'error' : '', '" /> |
||||||
140 | <caption name="subject" class="', isset($context['post_error']['no_subject']) ? 'error' : '', '" /> |
||||||
141 | <caption name="question" class="', isset($context['post_error']['no_question']) ? 'error' : '', '" />', isset($context['post_error']['no_message']) || isset($context['post_error']['long_message']) ? ' |
||||||
142 | <post_error />' : '', ' |
||||||
143 | </errors> |
||||||
144 | <last_msg>', isset($context['topic_last_message']) ? $context['topic_last_message'] : '0', '</last_msg>'; |
||||||
145 | |||||||
146 | if (!empty($context['previous_posts'])) |
||||||
147 | { |
||||||
148 | echo ' |
||||||
149 | <new_posts>'; |
||||||
150 | |||||||
151 | foreach ($context['previous_posts'] as $post) |
||||||
152 | echo ' |
||||||
153 | <post id="', $post['id'], '"> |
||||||
154 | <time><![CDATA[', $post['time'], ']]></time> |
||||||
155 | <poster><![CDATA[', cleanXml($post['poster']), ']]></poster> |
||||||
156 | <message><![CDATA[', cleanXml($post['message']), ']]></message> |
||||||
157 | <is_ignored>', $post['is_ignored'] ? '1' : '0', '</is_ignored> |
||||||
158 | </post>'; |
||||||
159 | |||||||
160 | echo ' |
||||||
161 | </new_posts>'; |
||||||
162 | } |
||||||
163 | |||||||
164 | echo ' |
||||||
165 | </smf>'; |
||||||
166 | } |
||||||
167 | |||||||
168 | /** |
||||||
169 | * All the XML for previewing a PM |
||||||
170 | */ |
||||||
171 | function template_pm() |
||||||
172 | { |
||||||
173 | global $context, $txt; |
||||||
174 | |||||||
175 | // @todo something could be removed...otherwise it can be merged again with template_post |
||||||
176 | echo '<', '?xml version="1.0" encoding="', $context['character_set'], '"?', '> |
||||||
177 | <smf> |
||||||
178 | <preview> |
||||||
179 | <subject><![CDATA[', $txt['preview'], ' - ', !empty($context['preview_subject']) ? $context['preview_subject'] : $txt['no_subject'], ']]></subject> |
||||||
180 | <body><![CDATA[', $context['preview_message'], ']]></body> |
||||||
181 | </preview> |
||||||
182 | <errors serious="', empty($context['error_type']) || $context['error_type'] != 'serious' ? '0' : '1', '">'; |
||||||
183 | |||||||
184 | if (!empty($context['post_error']['messages'])) |
||||||
185 | foreach ($context['post_error']['messages'] as $message) |
||||||
186 | echo ' |
||||||
187 | <error><![CDATA[', cleanXml($message), ']]></error>'; |
||||||
188 | |||||||
189 | echo ' |
||||||
190 | <caption name="to" class="', isset($context['post_error']['no_to']) ? 'error' : '', '" /> |
||||||
191 | <caption name="bbc" class="', isset($context['post_error']['no_bbc']) ? 'error' : '', '" /> |
||||||
192 | <caption name="subject" class="', isset($context['post_error']['no_subject']) ? 'error' : '', '" /> |
||||||
193 | <caption name="question" class="', isset($context['post_error']['no_question']) ? 'error' : '', '" />', isset($context['post_error']['no_message']) || isset($context['post_error']['long_message']) ? ' |
||||||
194 | <post_error />' : '', ' |
||||||
195 | </errors>'; |
||||||
196 | |||||||
197 | echo ' |
||||||
198 | </smf>'; |
||||||
199 | } |
||||||
200 | |||||||
201 | /** |
||||||
202 | * The XML for previewing a warning |
||||||
203 | */ |
||||||
204 | function template_warning() |
||||||
205 | { |
||||||
206 | global $context; |
||||||
207 | |||||||
208 | // @todo something could be removed...otherwise it can be merged again with template_post |
||||||
209 | echo '<', '?xml version="1.0" encoding="', $context['character_set'], '"?', '> |
||||||
210 | <smf> |
||||||
211 | <preview> |
||||||
212 | <subject><![CDATA[', $context['preview_subject'], ']]></subject> |
||||||
213 | <body><![CDATA[', $context['preview_message'], ']]></body> |
||||||
214 | </preview> |
||||||
215 | <errors serious="', empty($context['error_type']) || $context['error_type'] != 'serious' ? '0' : '1', '">'; |
||||||
216 | |||||||
217 | if (!empty($context['post_error']['messages'])) |
||||||
218 | foreach ($context['post_error']['messages'] as $message) |
||||||
219 | echo ' |
||||||
220 | <error><![CDATA[', cleanXml($message), ']]></error>'; |
||||||
221 | |||||||
222 | echo ' |
||||||
223 | </errors>'; |
||||||
224 | |||||||
225 | echo ' |
||||||
226 | </smf>'; |
||||||
227 | } |
||||||
228 | |||||||
229 | /** |
||||||
230 | * The XML for hiding/showing stats sections via AJAX |
||||||
231 | */ |
||||||
232 | function template_stats() |
||||||
233 | { |
||||||
234 | global $context, $modSettings; |
||||||
235 | |||||||
236 | if (empty($context['yearly'])) |
||||||
237 | return; |
||||||
238 | |||||||
239 | echo '<', '?xml version="1.0" encoding="', $context['character_set'], '"?', '> |
||||||
240 | <smf>'; |
||||||
241 | foreach ($context['yearly'] as $year) |
||||||
242 | foreach ($year['months'] as $month) |
||||||
243 | { |
||||||
244 | echo ' |
||||||
245 | <month id="', $month['date']['year'], $month['date']['month'], '">'; |
||||||
246 | |||||||
247 | foreach ($month['days'] as $day) |
||||||
248 | echo ' |
||||||
249 | <day date="', $day['year'], '-', $day['month'], '-', $day['day'], '" new_topics="', $day['new_topics'], '" new_posts="', $day['new_posts'], '" new_members="', $day['new_members'], '" most_members_online="', $day['most_members_online'], '"', empty($modSettings['hitStats']) ? '' : ' hits="' . $day['hits'] . '"', ' />'; |
||||||
250 | |||||||
251 | echo ' |
||||||
252 | </month>'; |
||||||
253 | } |
||||||
254 | |||||||
255 | echo ' |
||||||
256 | </smf>'; |
||||||
257 | } |
||||||
258 | |||||||
259 | /** |
||||||
260 | * The XML for selecting items to split |
||||||
261 | */ |
||||||
262 | function template_split() |
||||||
263 | { |
||||||
264 | global $context; |
||||||
265 | |||||||
266 | echo '<', '?xml version="1.0" encoding="', $context['character_set'], '"?', '> |
||||||
267 | <smf> |
||||||
268 | <pageIndex section="not_selected" startFrom="', $context['not_selected']['start'], '"><![CDATA[', $context['not_selected']['page_index'], ']]></pageIndex> |
||||||
269 | <pageIndex section="selected" startFrom="', $context['selected']['start'], '"><![CDATA[', $context['selected']['page_index'], ']]></pageIndex>'; |
||||||
270 | foreach ($context['changes'] as $change) |
||||||
271 | { |
||||||
272 | if ($change['type'] == 'remove') |
||||||
273 | echo ' |
||||||
274 | <change id="', $change['id'], '" curAction="remove" section="', $change['section'], '" />'; |
||||||
275 | else |
||||||
276 | echo ' |
||||||
277 | <change id="', $change['id'], '" curAction="insert" section="', $change['section'], '"> |
||||||
278 | <subject><![CDATA[', cleanXml($change['insert_value']['subject']), ']]></subject> |
||||||
279 | <time><![CDATA[', cleanXml($change['insert_value']['time']), ']]></time> |
||||||
280 | <body><![CDATA[', cleanXml($change['insert_value']['body']), ']]></body> |
||||||
281 | <poster><![CDATA[', cleanXml($change['insert_value']['poster']), ']]></poster> |
||||||
282 | </change>'; |
||||||
283 | } |
||||||
284 | echo ' |
||||||
285 | </smf>'; |
||||||
286 | } |
||||||
287 | |||||||
288 | /** |
||||||
289 | * This is just to hold off some errors if people are stupid. |
||||||
290 | */ |
||||||
291 | if (!function_exists('template_button_strip')) |
||||||
292 | { |
||||||
293 | function template_button_strip($button_strip, $direction = 'top', $strip_options = array()) |
||||||
0 ignored issues
–
show
The parameter
$direction is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. ![]() The parameter
$strip_options is not used and could be removed.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for parameters that have been defined for a function or method, but which are not used in the method body. ![]() |
|||||||
294 | { |
||||||
295 | } |
||||||
296 | |||||||
297 | function template_menu() |
||||||
298 | { |
||||||
299 | } |
||||||
300 | |||||||
301 | function theme_linktree() |
||||||
302 | { |
||||||
303 | } |
||||||
304 | } |
||||||
305 | |||||||
306 | /** |
||||||
307 | * XML for search results |
||||||
308 | */ |
||||||
309 | function template_results() |
||||||
310 | { |
||||||
311 | global $context, $txt; |
||||||
312 | echo '<', '?xml version="1.0" encoding="', $context['character_set'], '"?', '> |
||||||
313 | <smf>'; |
||||||
314 | |||||||
315 | if (empty($context['topics'])) |
||||||
316 | echo ' |
||||||
317 | <noresults>', $txt['search_no_results'], '</noresults>'; |
||||||
318 | else |
||||||
319 | { |
||||||
320 | echo ' |
||||||
321 | <results>'; |
||||||
322 | |||||||
323 | while ($topic = $context['get_topics']()) |
||||||
324 | { |
||||||
325 | echo ' |
||||||
326 | <result> |
||||||
327 | <id>', $topic['id'], '</id> |
||||||
328 | <relevance>', $topic['relevance'], '</relevance> |
||||||
329 | <board> |
||||||
330 | <id>', $topic['board']['id'], '</id> |
||||||
331 | <name>', cleanXml($topic['board']['name']), '</name> |
||||||
332 | <href>', $topic['board']['href'], '</href> |
||||||
333 | </board> |
||||||
334 | <category> |
||||||
335 | <id>', $topic['category']['id'], '</id> |
||||||
336 | <name>', cleanXml($topic['category']['name']), '</name> |
||||||
337 | <href>', $topic['category']['href'], '</href> |
||||||
338 | </category> |
||||||
339 | <messages>'; |
||||||
340 | |||||||
341 | foreach ($topic['matches'] as $message) |
||||||
342 | { |
||||||
343 | echo ' |
||||||
344 | <message> |
||||||
345 | <id>', $message['id'], '</id> |
||||||
346 | <subject><![CDATA[', cleanXml($message['subject_highlighted'] != '' ? $message['subject_highlighted'] : $message['subject']), ']]></subject> |
||||||
347 | <body><![CDATA[', cleanXml($message['body_highlighted'] != '' ? $message['body_highlighted'] : $message['body']), ']]></body> |
||||||
348 | <time>', $message['time'], '</time> |
||||||
349 | <timestamp>', $message['timestamp'], '</timestamp> |
||||||
350 | <start>', $message['start'], '</start> |
||||||
351 | |||||||
352 | <author> |
||||||
353 | <id>', $message['member']['id'], '</id> |
||||||
354 | <name>', cleanXml($message['member']['name']), '</name> |
||||||
355 | <href>', $message['member']['href'], '</href> |
||||||
356 | </author> |
||||||
357 | </message>'; |
||||||
358 | } |
||||||
359 | echo ' |
||||||
360 | </messages> |
||||||
361 | </result>'; |
||||||
362 | } |
||||||
363 | |||||||
364 | echo ' |
||||||
365 | </results>'; |
||||||
366 | } |
||||||
367 | |||||||
368 | echo ' |
||||||
369 | </smf>'; |
||||||
370 | } |
||||||
371 | |||||||
372 | /** |
||||||
373 | * The XML for the Jump To box |
||||||
374 | */ |
||||||
375 | function template_jump_to() |
||||||
376 | { |
||||||
377 | global $context; |
||||||
378 | |||||||
379 | echo '<', '?xml version="1.0" encoding="', $context['character_set'], '"?', '> |
||||||
380 | <smf>'; |
||||||
381 | |||||||
382 | foreach ($context['jump_to'] as $category) |
||||||
383 | { |
||||||
384 | echo ' |
||||||
385 | <item type="category" id="', $category['id'], '"><![CDATA[', cleanXml($category['name']), ']]></item>'; |
||||||
386 | |||||||
387 | foreach ($category['boards'] as $board) |
||||||
388 | echo ' |
||||||
389 | <item type="board" id="', $board['id'], '" childlevel="', $board['child_level'], '" is_redirect="', (int) !empty($board['redirect']), '"><![CDATA[', cleanXml($board['name']), ']]></item>'; |
||||||
390 | } |
||||||
391 | echo ' |
||||||
392 | </smf>'; |
||||||
393 | } |
||||||
394 | |||||||
395 | /** |
||||||
396 | * The XML for displaying a column of message icons and selecting one via AJAX |
||||||
397 | */ |
||||||
398 | function template_message_icons() |
||||||
399 | { |
||||||
400 | global $context; |
||||||
401 | |||||||
402 | echo '<', '?xml version="1.0" encoding="', $context['character_set'], '"?', '> |
||||||
403 | <smf>'; |
||||||
404 | |||||||
405 | foreach ($context['icons'] as $icon) |
||||||
406 | echo ' |
||||||
407 | <icon value="', $icon['value'], '" url="', $icon['url'], '"><![CDATA[', cleanXml($icon['name']), ']]></icon>'; |
||||||
408 | |||||||
409 | echo ' |
||||||
410 | </smf>'; |
||||||
411 | } |
||||||
412 | |||||||
413 | /** |
||||||
414 | * The XML for instantly showing whether a username is valid on the registration page |
||||||
415 | */ |
||||||
416 | function template_check_username() |
||||||
417 | { |
||||||
418 | global $context; |
||||||
419 | |||||||
420 | echo '<', '?xml version="1.0" encoding="', $context['character_set'], '"?', '> |
||||||
421 | <smf> |
||||||
422 | <username valid="', $context['valid_username'] ? 1 : 0, '">', cleanXml($context['checked_username']), '</username> |
||||||
423 | </smf>'; |
||||||
424 | } |
||||||
425 | |||||||
426 | /** |
||||||
427 | * This prints XML in its most generic form. |
||||||
428 | */ |
||||||
429 | function template_generic_xml() |
||||||
430 | { |
||||||
431 | global $context; |
||||||
432 | |||||||
433 | echo '<', '?xml version="1.0" encoding="', $context['character_set'], '"?', '>'; |
||||||
434 | |||||||
435 | // Show the data. |
||||||
436 | template_generic_xml_recursive($context['xml_data'], 'smf', '', -1); |
||||||
437 | } |
||||||
438 | |||||||
439 | /** |
||||||
440 | * Recursive function for displaying generic XML data. |
||||||
441 | * |
||||||
442 | * @param array $xml_data An array of XML data |
||||||
443 | * @param string $parent_ident The parent tag |
||||||
444 | * @param string $child_ident The child tag |
||||||
445 | * @param int $level How many levels to indent the code |
||||||
446 | */ |
||||||
447 | function template_generic_xml_recursive($xml_data, $parent_ident, $child_ident, $level) |
||||||
448 | { |
||||||
449 | // This is simply for neat indentation. |
||||||
450 | $level++; |
||||||
451 | |||||||
452 | echo "\n" . str_repeat("\t", $level), '<', $parent_ident, '>'; |
||||||
453 | |||||||
454 | foreach ($xml_data as $key => $data) |
||||||
455 | { |
||||||
456 | // A group? |
||||||
457 | if (is_array($data) && isset($data['identifier'])) |
||||||
458 | template_generic_xml_recursive($data['children'], $key, $data['identifier'], $level); |
||||||
459 | // An item... |
||||||
460 | elseif (is_array($data) && isset($data['value'])) |
||||||
461 | { |
||||||
462 | echo "\n", str_repeat("\t", $level), '<', $child_ident; |
||||||
463 | |||||||
464 | if (!empty($data['attributes'])) |
||||||
465 | foreach ($data['attributes'] as $k => $v) |
||||||
466 | echo ' ' . $k . '="' . $v . '"'; |
||||||
467 | echo '><![CDATA[', cleanXml($data['value']), ']]></', $child_ident, '>'; |
||||||
468 | } |
||||||
469 | } |
||||||
470 | |||||||
471 | echo "\n", str_repeat("\t", $level), '</', $parent_ident, '>'; |
||||||
472 | } |
||||||
473 | |||||||
474 | ?> |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.