Mercurial > hg > vamp-website
comparison forum/Themes/default/Xml.template.php @ 76:e3e11437ecea website
Add forum code
author | Chris Cannam |
---|---|
date | Sun, 07 Jul 2013 11:25:48 +0200 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
75:72f59aa7e503 | 76:e3e11437ecea |
---|---|
1 <?php | |
2 /** | |
3 * Simple Machines Forum (SMF) | |
4 * | |
5 * @package SMF | |
6 * @author Simple Machines | |
7 * @copyright 2011 Simple Machines | |
8 * @license http://www.simplemachines.org/about/smf/license.php BSD | |
9 * | |
10 * @version 2.0 | |
11 */ | |
12 | |
13 function template_sendbody() | |
14 { | |
15 global $context, $settings, $options, $txt; | |
16 | |
17 echo '<', '?xml version="1.0" encoding="', $context['character_set'], '"?', '> | |
18 <smf> | |
19 <message view="', $context['view'], '">', cleanXml($context['message']), '</message> | |
20 </smf>'; | |
21 } | |
22 | |
23 function template_quotefast() | |
24 { | |
25 global $context, $settings, $options, $txt; | |
26 | |
27 echo '<', '?xml version="1.0" encoding="', $context['character_set'], '"?', '> | |
28 <smf> | |
29 <quote>', cleanXml($context['quote']['xml']), '</quote> | |
30 </smf>'; | |
31 } | |
32 | |
33 function template_modifyfast() | |
34 { | |
35 global $context, $settings, $options, $txt; | |
36 | |
37 echo '<', '?xml version="1.0" encoding="', $context['character_set'], '"?', '> | |
38 <smf> | |
39 <subject><![CDATA[', cleanXml($context['message']['subject']), ']]></subject> | |
40 <message id="msg_', $context['message']['id'], '"><![CDATA[', cleanXml($context['message']['body']), ']]></message> | |
41 </smf>'; | |
42 | |
43 } | |
44 | |
45 function template_modifydone() | |
46 { | |
47 global $context, $settings, $options, $txt; | |
48 | |
49 echo '<', '?xml version="1.0" encoding="', $context['character_set'], '"?', '> | |
50 <smf> | |
51 <message id="msg_', $context['message']['id'], '">'; | |
52 if (empty($context['message']['errors'])) | |
53 { | |
54 echo ' | |
55 <modified><![CDATA[', empty($context['message']['modified']['time']) ? '' : cleanXml('« <em>' . $txt['last_edit'] . ': ' . $context['message']['modified']['time'] . ' ' . $txt['by'] . ' ' . $context['message']['modified']['name'] . '</em> »'), ']]></modified> | |
56 <subject is_first="', $context['message']['first_in_topic'] ? '1' : '0', '"><![CDATA[', cleanXml($context['message']['subject']), ']]></subject> | |
57 <body><![CDATA[', $context['message']['body'], ']]></body>'; | |
58 } | |
59 else | |
60 echo ' | |
61 <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>'; | |
62 echo ' | |
63 </message> | |
64 </smf>'; | |
65 } | |
66 | |
67 function template_modifytopicdone() | |
68 { | |
69 global $context, $settings, $options, $txt; | |
70 | |
71 echo '<', '?xml version="1.0" encoding="', $context['character_set'], '"?', '> | |
72 <smf> | |
73 <message id="msg_', $context['message']['id'], '">'; | |
74 if (empty($context['message']['errors'])) | |
75 { | |
76 echo ' | |
77 <modified><![CDATA[', empty($context['message']['modified']['time']) ? '' : cleanXml('« <em>' . $txt['last_edit'] . ': ' . $context['message']['modified']['time'] . ' ' . $txt['by'] . ' ' . $context['message']['modified']['name'] . '</em> »'), ']]></modified>'; | |
78 if (!empty($context['message']['subject'])) | |
79 echo ' | |
80 <subject><![CDATA[', cleanXml($context['message']['subject']), ']]></subject>'; | |
81 } | |
82 else | |
83 echo ' | |
84 <error in_subject="', $context['message']['error_in_subject'] ? '1' : '0', '"><![CDATA[', cleanXml(implode('<br />', $context['message']['errors'])), ']]></error>'; | |
85 echo ' | |
86 </message> | |
87 </smf>'; | |
88 } | |
89 | |
90 function template_post() | |
91 { | |
92 global $context, $settings, $options, $txt; | |
93 | |
94 echo '<', '?xml version="1.0" encoding="', $context['character_set'], '"?', '> | |
95 <smf> | |
96 <preview> | |
97 <subject><![CDATA[', $context['preview_subject'], ']]></subject> | |
98 <body><![CDATA[', $context['preview_message'], ']]></body> | |
99 </preview> | |
100 <errors serious="', empty($context['error_type']) || $context['error_type'] != 'serious' ? '0' : '1', '" topic_locked="', $context['locked'] ? '1' : '0', '">'; | |
101 if (!empty($context['post_error']['messages'])) | |
102 foreach ($context['post_error']['messages'] as $message) | |
103 echo ' | |
104 <error><![CDATA[', cleanXml($message), ']]></error>'; | |
105 echo ' | |
106 <caption name="guestname" class="', isset($context['post_error']['long_name']) || isset($context['post_error']['no_name']) || isset($context['post_error']['bad_name']) ? 'error' : '', '" /> | |
107 <caption name="email" class="', isset($context['post_error']['no_email']) || isset($context['post_error']['bad_email']) ? 'error' : '', '" /> | |
108 <caption name="evtitle" class="', isset($context['post_error']['no_event']) ? 'error' : '', '" /> | |
109 <caption name="subject" class="', isset($context['post_error']['no_subject']) ? 'error' : '', '" /> | |
110 <caption name="question" class="', isset($context['post_error']['no_question']) ? 'error' : '', '" />', isset($context['post_error']['no_message']) || isset($context['post_error']['long_message']) ? ' | |
111 <post_error />' : '', ' | |
112 </errors> | |
113 <last_msg>', isset($context['topic_last_message']) ? $context['topic_last_message'] : '0', '</last_msg>'; | |
114 | |
115 if (!empty($context['previous_posts'])) | |
116 { | |
117 echo ' | |
118 <new_posts>'; | |
119 foreach ($context['previous_posts'] as $post) | |
120 echo ' | |
121 <post id="', $post['id'], '"> | |
122 <time><![CDATA[', $post['time'], ']]></time> | |
123 <poster><![CDATA[', cleanXml($post['poster']), ']]></poster> | |
124 <message><![CDATA[', cleanXml($post['message']), ']]></message> | |
125 <is_ignored>', $post['is_ignored'] ? '1' : '0', '</is_ignored> | |
126 </post>'; | |
127 echo ' | |
128 </new_posts>'; | |
129 } | |
130 | |
131 echo ' | |
132 </smf>'; | |
133 } | |
134 | |
135 function template_stats() | |
136 { | |
137 global $context, $settings, $options, $txt, $modSettings; | |
138 | |
139 echo '<', '?xml version="1.0" encoding="', $context['character_set'], '"?', '> | |
140 <smf>'; | |
141 foreach ($context['yearly'] as $year) | |
142 foreach ($year['months'] as $month); | |
143 { | |
144 echo ' | |
145 <month id="', $month['date']['year'], $month['date']['month'], '">'; | |
146 foreach ($month['days'] as $day) | |
147 echo ' | |
148 <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'] . '"', ' />'; | |
149 echo ' | |
150 </month>'; | |
151 } | |
152 echo ' | |
153 </smf>'; | |
154 } | |
155 | |
156 function template_split() | |
157 { | |
158 global $context, $settings, $options; | |
159 | |
160 echo '<', '?xml version="1.0" encoding="', $context['character_set'], '"?', '> | |
161 <smf> | |
162 <pageIndex section="not_selected" startFrom="', $context['not_selected']['start'], '"><![CDATA[', $context['not_selected']['page_index'], ']]></pageIndex> | |
163 <pageIndex section="selected" startFrom="', $context['selected']['start'], '"><![CDATA[', $context['selected']['page_index'], ']]></pageIndex>'; | |
164 foreach ($context['changes'] as $change) | |
165 { | |
166 if ($change['type'] == 'remove') | |
167 echo ' | |
168 <change id="', $change['id'], '" curAction="remove" section="', $change['section'], '" />'; | |
169 else | |
170 echo ' | |
171 <change id="', $change['id'], '" curAction="insert" section="', $change['section'], '"> | |
172 <subject><![CDATA[', cleanXml($change['insert_value']['subject']), ']]></subject> | |
173 <time><![CDATA[', cleanXml($change['insert_value']['time']), ']]></time> | |
174 <body><![CDATA[', cleanXml($change['insert_value']['body']), ']]></body> | |
175 <poster><![CDATA[', cleanXml($change['insert_value']['poster']), ']]></poster> | |
176 </change>'; | |
177 } | |
178 echo ' | |
179 </smf>'; | |
180 } | |
181 | |
182 // This is just to hold off some errors if people are stupid. | |
183 if (!function_exists('template_button_strip')) | |
184 { | |
185 function template_button_strip($button_strip, $direction = 'top', $strip_options = array()) | |
186 { | |
187 } | |
188 function template_menu() | |
189 { | |
190 } | |
191 function theme_linktree() | |
192 { | |
193 } | |
194 } | |
195 | |
196 function template_results() | |
197 { | |
198 global $context, $settings, $options, $txt; | |
199 echo '<', '?xml version="1.0" encoding="', $context['character_set'], '"?', '> | |
200 <smf>'; | |
201 | |
202 if (empty($context['topics'])) | |
203 echo ' | |
204 <noresults>', $txt['search_no_results'], '</noresults>'; | |
205 else | |
206 { | |
207 echo ' | |
208 <results>'; | |
209 | |
210 while ($topic = $context['get_topics']()) | |
211 { | |
212 echo ' | |
213 <result> | |
214 <id>', $topic['id'], '</id> | |
215 <relevance>', $topic['relevance'], '</relevance> | |
216 <board> | |
217 <id>', $topic['board']['id'], '</id> | |
218 <name>', cleanXml($topic['board']['name']), '</name> | |
219 <href>', $topic['board']['href'], '</href> | |
220 </board> | |
221 <category> | |
222 <id>', $topic['category']['id'], '</id> | |
223 <name>', cleanXml($topic['category']['name']), '</name> | |
224 <href>', $topic['category']['href'], '</href> | |
225 </category> | |
226 <messages>'; | |
227 foreach ($topic['matches'] as $message) | |
228 { | |
229 echo ' | |
230 <message> | |
231 <id>', $message['id'], '</id> | |
232 <subject><![CDATA[', cleanXml($message['subject_highlighted'] != '' ? $message['subject_highlighted'] : $message['subject']), ']]></subject> | |
233 <body><![CDATA[', cleanXml($message['body_highlighted'] != '' ? $message['body_highlighted'] : $message['body']), ']]></body> | |
234 <time>', $message['time'], '</time> | |
235 <timestamp>', $message['timestamp'], '</timestamp> | |
236 <start>', $message['start'], '</start> | |
237 | |
238 <author> | |
239 <id>', $message['member']['id'], '</id> | |
240 <name>', cleanXml($message['member']['name']), '</name> | |
241 <href>', $message['member']['href'], '</href> | |
242 </author> | |
243 </message>'; | |
244 } | |
245 echo ' | |
246 </messages> | |
247 </result>'; | |
248 } | |
249 | |
250 echo ' | |
251 </results>'; | |
252 } | |
253 | |
254 echo ' | |
255 </smf>'; | |
256 } | |
257 | |
258 function template_jump_to() | |
259 { | |
260 global $context, $settings, $options; | |
261 | |
262 echo '<', '?xml version="1.0" encoding="', $context['character_set'], '"?', '> | |
263 <smf>'; | |
264 foreach ($context['jump_to'] as $category) | |
265 { | |
266 echo ' | |
267 <item type="category" id="', $category['id'], '"><![CDATA[', cleanXml($category['name']), ']]></item>'; | |
268 foreach ($category['boards'] as $board) | |
269 echo ' | |
270 <item type="board" id="', $board['id'], '" childlevel="', $board['child_level'], '"><![CDATA[', cleanXml($board['name']), ']]></item>'; | |
271 } | |
272 echo ' | |
273 </smf>'; | |
274 } | |
275 | |
276 function template_message_icons() | |
277 { | |
278 global $context, $settings, $options; | |
279 | |
280 echo '<', '?xml version="1.0" encoding="', $context['character_set'], '"?', '> | |
281 <smf>'; | |
282 foreach ($context['icons'] as $icon) | |
283 echo ' | |
284 <icon value="', $icon['value'], '" url="', $icon['url'], '"><![CDATA[', cleanXml($icon['name']), ']]></icon>'; | |
285 echo ' | |
286 </smf>'; | |
287 } | |
288 | |
289 function template_check_username() | |
290 { | |
291 global $context, $settings, $options, $txt; | |
292 | |
293 echo '<', '?xml version="1.0" encoding="', $context['character_set'], '"?', '> | |
294 <smf> | |
295 <username valid="', $context['valid_username'] ? 1 : 0, '">', cleanXml($context['checked_username']), '</username> | |
296 </smf>'; | |
297 } | |
298 | |
299 // This prints XML in it's most generic form. | |
300 function template_generic_xml() | |
301 { | |
302 global $context, $settings, $options, $txt; | |
303 | |
304 echo '<', '?xml version="1.0" encoding="', $context['character_set'], '"?', '>'; | |
305 | |
306 // Show the data. | |
307 template_generic_xml_recursive($context['xml_data'], 'smf', '', -1); | |
308 } | |
309 | |
310 // Recursive function for displaying generic XML data. | |
311 function template_generic_xml_recursive($xml_data, $parent_ident, $child_ident, $level) | |
312 { | |
313 // This is simply for neat indentation. | |
314 $level++; | |
315 | |
316 echo "\n" . str_repeat("\t", $level), '<', $parent_ident, '>'; | |
317 | |
318 foreach ($xml_data as $key => $data) | |
319 { | |
320 // A group? | |
321 if (is_array($data) && isset($data['identifier'])) | |
322 template_generic_xml_recursive($data['children'], $key, $data['identifier'], $level); | |
323 // An item... | |
324 elseif (is_array($data) && isset($data['value'])) | |
325 { | |
326 echo "\n", str_repeat("\t", $level), '<', $child_ident; | |
327 | |
328 if (!empty($data['attributes'])) | |
329 foreach ($data['attributes'] as $k => $v) | |
330 echo ' ' . $k . '="' . $v . '"'; | |
331 echo '><![CDATA[', cleanXml($data['value']), ']]></', $child_ident, '>'; | |
332 } | |
333 | |
334 } | |
335 | |
336 echo "\n", str_repeat("\t", $level), '</', $parent_ident, '>'; | |
337 } | |
338 | |
339 function template_webslice_header_above() | |
340 { | |
341 global $settings; | |
342 | |
343 echo ' | |
344 <link rel="stylesheet" href="', $settings['default_theme_url'], '/css/wireless.css" type="text/css" />'; | |
345 } | |
346 | |
347 function template_webslice_header_below() | |
348 { | |
349 } | |
350 | |
351 // This shows a webslice of the recent posts. | |
352 function template_webslice_recent_posts() | |
353 { | |
354 global $context, $scripturl, $txt; | |
355 | |
356 echo ' | |
357 <div style="width: 100%; height: 100%; border: 1px solid black; padding: 0; margin: 0 0 0 0; font: 100.01%/100% Verdana, Helvetica, sans-serif;"> | |
358 <div style="background-color: #080436; color: #ffffff; padding: 4px;"> | |
359 ', cleanXml($txt['recent_posts']), ' | |
360 </div>'; | |
361 | |
362 $alternate = 0; | |
363 foreach ($context['recent_posts_data'] as $item) | |
364 { | |
365 echo ' | |
366 <div style="background-color: ', $alternate ? '#ECEDF3' : '#F6F6F6', '; font-size: 90%; padding: 2px;"> | |
367 <strong><a href="', $item['link'], '">', cleanXml($item['subject']), '</a></strong> ', cleanXml($txt['by']), ' ', cleanXml(!empty($item['poster']['link']) ? '<a href="' . $item['poster']['link'] . '">' . $item['poster']['name'] . '</a>' : $item['poster']['name']), ' | |
368 </div>'; | |
369 $alternate = !$alternate; | |
370 } | |
371 | |
372 echo ' | |
373 </div> | |
374 <div style="width: 100%; height: 100%; border: 0; padding: 0; margin: 0 0 0 0; font: 100.01%/100% Verdana, Helvetica, sans-serif;"> | |
375 <div style="font-size: xx-small;" class="righttext">'; | |
376 | |
377 if ($context['user']['is_guest']) | |
378 echo ' | |
379 <a href="', $scripturl, '?action=login">', $txt['login'], '</a>'; | |
380 else | |
381 echo ' | |
382 ', cleanXml($context['user']['name']), ', ', cleanXml($txt['msg_alert_you_have']), ' <a href="', $scripturl, '?action=pm">', cleanXml($context['user']['messages']), ' ', cleanXml($context['user']['messages'] != 1 ? $txt['msg_alert_messages'] : $txt['message_lowercase']), '</a>', cleanXml($txt['newmessages4'] . ' ' . $context['user']['unread_messages']), ' ', cleanXml($context['user']['unread_messages'] == 1 ? $txt['newmessages0'] : $txt['newmessages1']); | |
383 | |
384 echo ' | |
385 </div> | |
386 </div>'; | |
387 } | |
388 | |
389 ?> |