comparison forum/Themes/default/SplitTopics.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_ask()
14 {
15 global $context, $settings, $options, $txt, $scripturl;
16
17 echo '
18 <div id="split_topics">
19 <form action="', $scripturl, '?action=splittopics;sa=execute;topic=', $context['current_topic'], '.0" method="post" accept-charset="', $context['character_set'], '">
20 <input type="hidden" name="at" value="', $context['message']['id'], '" />
21 <div class="cat_bar">
22 <h3 class="catbg">', $txt['split'], '</h3>
23 </div>
24 <div class="windowbg">
25 <span class="topslice"><span></span></span>
26 <div class="content">
27 <p class="split_topics">
28 <strong><label for="subname">', $txt['subject_new_topic'], '</label>:</strong>
29 <input type="text" name="subname" id="subname" value="', $context['message']['subject'], '" size="25" class="input_text" />
30 </p>
31 <ul class="reset split_topics">
32 <li>
33 <input type="radio" id="onlythis" name="step2" value="onlythis" checked="checked" class="input_radio" /> <label for="onlythis">', $txt['split_this_post'], '</label>
34 </li>
35 <li>
36 <input type="radio" id="afterthis" name="step2" value="afterthis" class="input_radio" /> <label for="afterthis">', $txt['split_after_and_this_post'], '</label>
37 </li>
38 <li>
39 <input type="radio" id="selective" name="step2" value="selective" class="input_radio" /> <label for="selective">', $txt['select_split_posts'], '</label>
40 </li>
41 </ul>
42 <div class="righttext">
43 <input type="submit" value="', $txt['split'], '" class="button_submit" />
44 </div>
45 </div>
46 <span class="botslice"><span></span></span>
47 </div>
48 <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
49 </form>
50 </div>';
51 }
52
53 function template_main()
54 {
55 global $context, $settings, $options, $txt, $scripturl;
56
57 echo '
58 <div id="split_topics">
59 <div class="cat_bar">
60 <h3 class="catbg">', $txt['split'], '</h3>
61 </div>
62 <div class="windowbg">
63 <span class="topslice"><span></span></span>
64 <div class="content">
65 <p>', $txt['split_successful'], '</p>
66 <ul class="reset">
67 <li>
68 <a href="', $scripturl, '?board=', $context['current_board'], '.0">', $txt['message_index'], '</a>
69 </li>
70 <li>
71 <a href="', $scripturl, '?topic=', $context['old_topic'], '.0">', $txt['origin_topic'], '</a>
72 </li>
73 <li>
74 <a href="', $scripturl, '?topic=', $context['new_topic'], '.0">', $txt['new_topic'], '</a>
75 </li>
76 </ul>
77 </div>
78 <span class="botslice"><span></span></span>
79 </div>
80 </div>';
81 }
82
83 function template_select()
84 {
85 global $context, $settings, $options, $txt, $scripturl;
86
87 echo '
88 <div id="split_topics">
89 <form action="', $scripturl, '?action=splittopics;sa=splitSelection;board=', $context['current_board'], '.0" method="post" accept-charset="', $context['character_set'], '">
90 <div id="not_selected" class="floatleft">
91 <div class="cat_bar">
92 <h3 class="catbg">', $txt['split'], ' - ', $txt['select_split_posts'], '</h3>
93 </div>
94 <div class="information">
95 ', $txt['please_select_split'], '
96 </div>
97 <div class="pagesection">
98 <strong>', $txt['pages'], ':</strong> <span id="pageindex_not_selected">', $context['not_selected']['page_index'], '</span>
99 </div>
100 <ul id="messages_not_selected" class="split_messages smalltext reset">';
101
102 foreach ($context['not_selected']['messages'] as $message)
103 echo '
104 <li class="windowbg', $message['alternate'] ? '2' : '', '" id="not_selected_', $message['id'], '">
105 <span class="topslice"><span></span></span>
106 <div class="content">
107 <div class="message_header">
108 <a class="split_icon floatright" href="', $scripturl, '?action=splittopics;sa=selectTopics;subname=', $context['topic']['subject'], ';topic=', $context['topic']['id'], '.', $context['not_selected']['start'], ';start2=', $context['selected']['start'], ';move=down;msg=', $message['id'], '" onclick="return select(\'down\', ', $message['id'], ');"><img src="', $settings['images_url'], '/split_select.gif" alt="-&gt;" /></a>
109 <strong>', $message['subject'], '</strong> ', $txt['by'], ' <strong>', $message['poster'], '</strong><br />
110 <em>', $message['time'], '</em>
111 </div>
112 <div class="post">', $message['body'], '</div>
113 </div>
114 <span class="botslice"><span></span></span>
115 </li>';
116
117 echo '
118 <li class="dummy" />
119 </ul>
120 </div>
121 <div id="selected" class="floatright">
122 <div class="cat_bar">
123 <h3 class="catbg">
124 ', $txt['split_selected_posts'], ' (<a href="', $scripturl, '?action=splittopics;sa=selectTopics;subname=', $context['topic']['subject'], ';topic=', $context['topic']['id'], '.', $context['not_selected']['start'], ';start2=', $context['selected']['start'], ';move=reset;msg=0" onclick="return select(\'reset\', 0);">', $txt['split_reset_selection'], '</a>)
125 </h3>
126 </div>
127 <div class="information">
128 ', $txt['split_selected_posts_desc'], '
129 </div>
130 <div class="pagesection">
131 <strong>', $txt['pages'], ':</strong> <span id="pageindex_selected">', $context['selected']['page_index'], '</span>
132 </div>
133 <ul id="messages_selected" class="split_messages smalltext reset">';
134
135 if (!empty($context['selected']['messages']))
136 foreach ($context['selected']['messages'] as $message)
137 echo '
138 <li class="windowbg', $message['alternate'] ? '2' : '', '" id="selected_', $message['id'], '">
139 <span class="topslice"><span></span></span>
140 <div class="content">
141 <div class="message_header">
142 <a class="split_icon floatleft" href="', $scripturl, '?action=splittopics;sa=selectTopics;subname=', $context['topic']['subject'], ';topic=', $context['topic']['id'], '.', $context['not_selected']['start'], ';start2=', $context['selected']['start'], ';move=up;msg=', $message['id'], '" onclick="return select(\'up\', ', $message['id'], ');"><img src="', $settings['images_url'], '/split_deselect.gif" alt="&lt;-" /></a>
143 <strong>', $message['subject'], '</strong> ', $txt['by'], ' <strong>', $message['poster'], '</strong><br />
144 <em>', $message['time'], '</em>
145 </div>
146 <div class="post">', $message['body'], '</div>
147 </div>
148 <span class="botslice"><span></span></span>
149 </li>';
150
151 echo '
152 <li class="dummy" />
153 </ul>
154 </div>
155 <br class="clear" />
156 <p>
157 <input type="hidden" name="topic" value="', $context['current_topic'], '" />
158 <input type="hidden" name="subname" value="', $context['new_subject'], '" />
159 <input type="submit" value="', $txt['split'], '" class="button_submit" />
160 <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
161 </p>
162 </form>
163 </div>
164 <br class="clear" />
165 <script type="text/javascript"><!-- // --><![CDATA[
166 var start = new Array();
167 start[0] = ', $context['not_selected']['start'], ';
168 start[1] = ', $context['selected']['start'], ';
169
170 function select(direction, msg_id)
171 {
172 if (window.XMLHttpRequest)
173 {
174 getXMLDocument(smf_prepareScriptUrl(smf_scripturl) + "action=splittopics;sa=selectTopics;subname=', $context['topic']['subject'], ';topic=', $context['topic']['id'], '." + start[0] + ";start2=" + start[1] + ";move=" + direction + ";msg=" + msg_id + ";xml", onDocReceived);
175 return false;
176 }
177 else
178 return true;
179 }
180 function applyWindowClasses(oList)
181 {
182 var bAlternate = false;
183 oListItems = oList.getElementsByTagName("LI");
184 for (i = 0; i < oListItems.length; i++)
185 {
186 // Skip dummies.
187 if (oListItems[i].id == "")
188 continue;
189 oListItems[i].className = "windowbg" + (bAlternate ? "2" : "");
190 bAlternate = !bAlternate;
191 }
192 }
193 function onDocReceived(XMLDoc)
194 {
195 var i, j, pageIndex;
196 for (i = 0; i < 2; i++)
197 {
198 pageIndex = XMLDoc.getElementsByTagName("pageIndex")[i];
199 setInnerHTML(document.getElementById("pageindex_" + pageIndex.getAttribute("section")), pageIndex.firstChild.nodeValue);
200 start[i] = pageIndex.getAttribute("startFrom");
201 }
202 var numChanges = XMLDoc.getElementsByTagName("change").length;
203 var curChange, curSection, curAction, curId, curList, curData, newItem, sInsertBeforeId;
204 for (i = 0; i < numChanges; i++)
205 {
206 curChange = XMLDoc.getElementsByTagName("change")[i];
207 curSection = curChange.getAttribute("section");
208 curAction = curChange.getAttribute("curAction");
209 curId = curChange.getAttribute("id");
210 curList = document.getElementById("messages_" + curSection);
211 if (curAction == "remove")
212 curList.removeChild(document.getElementById(curSection + "_" + curId));
213 // Insert a message.
214 else
215 {
216 // By default, insert the element at the end of the list.
217 sInsertBeforeId = null;
218 // Loop through the list to try and find an item to insert after.
219 oListItems = curList.getElementsByTagName("LI");
220 for (j = 0; j < oListItems.length; j++)
221 {
222 if (parseInt(oListItems[j].id.substr(curSection.length + 1)) < curId)
223 {
224 // This would be a nice place to insert the row.
225 sInsertBeforeId = oListItems[j].id;
226 // We\'re done for now. Escape the loop.
227 j = oListItems.length + 1;
228 }
229 }
230
231 // Let\'s create a nice container for the message.
232 newItem = document.createElement("LI");
233 newItem.className = "windowbg2";
234 newItem.id = curSection + "_" + curId;
235 newItem.innerHTML = "<span class=\\"topslice\\"><span></span></span><div class=\\"content\\"><div class=\\"message_header\\"><a class=\\"split_icon float" + (curSection == "selected" ? "left" : "right") + "\\" href=\\"" + smf_prepareScriptUrl(smf_scripturl) + "action=splittopics;sa=selectTopics;subname=', $context['topic']['subject'], ';topic=', $context['topic']['id'], '.', $context['not_selected']['start'], ';start2=', $context['selected']['start'], ';move=" + (curSection == "selected" ? "up" : "down") + ";msg=" + curId + "\\" onclick=\\"return select(\'" + (curSection == "selected" ? "up" : "down") + "\', " + curId + ");\\"><img src=\\"', $settings['images_url'], '/split_" + (curSection == "selected" ? "de" : "") + "select.gif\\" alt=\\"" + (curSection == "selected" ? "&lt;-" : "-&gt;") + "\\" /></a><strong>" + curChange.getElementsByTagName("subject")[0].firstChild.nodeValue + "</strong> ', $txt['by'], ' <strong>" + curChange.getElementsByTagName("poster")[0].firstChild.nodeValue + "</strong><br /><em>" + curChange.getElementsByTagName("time")[0].firstChild.nodeValue + "</em></div><div class=\\"post\\">" + curChange.getElementsByTagName("body")[0].firstChild.nodeValue + "</div></div><span class=\\"botslice\\"><span></span></span>";
236
237 // So, where do we insert it?
238 if (typeof sInsertBeforeId == "string")
239 curList.insertBefore(newItem, document.getElementById(sInsertBeforeId));
240 else
241 curList.appendChild(newItem);
242 }
243 }
244 // After all changes, make sure the window backgrounds are still correct for both lists.
245 applyWindowClasses(document.getElementById("messages_selected"));
246 applyWindowClasses(document.getElementById("messages_not_selected"));
247 }
248 // ]]></script>';
249 }
250
251 function template_merge_done()
252 {
253 global $context, $settings, $options, $txt, $scripturl;
254
255 echo '
256 <div id="merge_topics">
257 <div class="cat_bar">
258 <h3 class="catbg">', $txt['merge'], '</h3>
259 </div>
260 <div class="windowbg">
261 <span class="topslice"><span></span></span>
262 <div class="content">
263 <p>', $txt['merge_successful'], '</p>
264 <br />
265 <ul class="reset">
266 <li>
267 <a href="', $scripturl, '?board=', $context['target_board'], '.0">', $txt['message_index'], '</a>
268 </li>
269 <li>
270 <a href="', $scripturl, '?topic=', $context['target_topic'], '.0">', $txt['new_merged_topic'], '</a>
271 </li>
272 </ul>
273 </div>
274 <span class="botslice"><span></span></span>
275 </div>
276 </div>
277 <br class="clear" />';
278 }
279
280 function template_merge()
281 {
282 global $context, $settings, $options, $txt, $scripturl;
283
284 echo '
285 <div id="merge_topics">
286 <div class="cat_bar">
287 <h3 class="catbg">', $txt['merge'], '</h3>
288 </div>
289 <div class="information">
290 ', $txt['merge_desc'], '
291 </div>
292 <div class="windowbg">
293 <span class="topslice"><span></span></span>
294 <div class="content">
295 <dl class="settings merge_topic">
296 <dt>
297 <strong>', $txt['topic_to_merge'], ':</strong>
298 </dt>
299 <dd>
300 ', $context['origin_subject'], '
301 </dd>';
302
303 if (!empty($context['boards']) && count($context['boards']) > 1)
304 {
305 echo '
306 <dt>
307 <strong>', $txt['target_board'], ':</strong>
308 </dt>
309 <dd>
310 <form action="' . $scripturl . '?action=mergetopics;from=' . $context['origin_topic'] . ';targetboard=' . $context['target_board'] . ';board=' . $context['current_board'] . '.0" method="post" accept-charset="', $context['character_set'], '">
311 <input type="hidden" name="from" value="' . $context['origin_topic'] . '" />
312 <select name="targetboard" onchange="this.form.submit();">';
313 foreach ($context['boards'] as $board)
314 echo '
315 <option value="', $board['id'], '"', $board['id'] == $context['target_board'] ? ' selected="selected"' : '', '>', $board['category'], ' - ', $board['name'], '</option>';
316 echo '
317 </select>
318 <input type="submit" value="', $txt['go'], '" class="button_submit" />
319 </form>
320 </dd>';
321 }
322
323 echo '
324 </dl>
325 <hr class="hrcolor" />
326 <dl class="settings merge_topic">
327 <dt>
328 <strong>', $txt['merge_to_topic_id'], ': </strong>
329 </dt>
330 <dd>
331 <form action="', $scripturl , '?action=mergetopics;sa=options" method="post" accept-charset="', $context['character_set'], '">
332 <input type="hidden" name="topics[]" value="', $context['origin_topic'], '" />
333 <input type="text" name="topics[]" class="input_text" />
334 <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
335 <input type="submit" value="', $txt['merge'], '" class="button_submit" />
336 </form>
337 </dd>';
338
339 echo '
340 </dl>
341 </div>
342 <span class="botslice"><span></span></span>
343 </div><br />
344 <div class="cat_bar">
345 <h3 class="catbg">', $txt['target_topic'], '</h3>
346 </div>
347 <div class="pagesection">
348 <strong>', $txt['pages'], ':</strong> ', $context['page_index'], '
349 </div>
350 <div class="windowbg2">
351 <span class="topslice"><span></span></span>
352 <div class="content">
353 <ul class="reset merge_topics">';
354
355 $merge_button = create_button('merge.gif', 'merge', '');
356
357 foreach ($context['topics'] as $topic)
358 echo '
359 <li>
360 <a href="', $scripturl, '?action=mergetopics;sa=options;board=', $context['current_board'], '.0;from=', $context['origin_topic'], ';to=', $topic['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $merge_button, '</a>&nbsp;
361 <a href="', $scripturl, '?topic=', $topic['id'], '.0" target="_blank" class="new_win">', $topic['subject'], '</a> ', $txt['started_by'], ' ', $topic['poster']['link'], '
362 </li>';
363
364 echo '
365 </ul>
366 </div>
367 <span class="botslice"><span></span></span>
368 </div>
369 <div class="pagesection">
370 <strong>', $txt['pages'], ':</strong> ', $context['page_index'], '
371 </div>
372 </div>
373 <br class="clear" />';
374 }
375
376 function template_merge_extra_options()
377 {
378 global $context, $settings, $options, $txt, $scripturl;
379
380 echo '
381 <div id="merge_topics">
382 <form action="', $scripturl, '?action=mergetopics;sa=execute;" method="post" accept-charset="', $context['character_set'], '">
383 <div class="title_bar">
384 <h3 class="titlebg">', $txt['merge_topic_list'], '</h3>
385 </div>
386 <table width="100%" class="bordercolor table_grid">
387 <thead>
388 <tr class="catbg">
389 <th scope="col" class="first_th" align="center" width="10px">', $txt['merge_check'], '</th>
390 <th scope="col" class="lefttext">', $txt['subject'], '</th>
391 <th scope="col" class="lefttext">', $txt['started_by'], '</th>
392 <th scope="col" class="lefttext">', $txt['last_post'], '</th>
393 <th scope="col" class="last_th" width="20px">' . $txt['merge_include_notifications'] . '</th>
394 </tr>
395 </thead>
396 <tbody>';
397 foreach ($context['topics'] as $topic)
398 echo '
399 <tr class="windowbg2">
400 <td align="center">
401 <input type="checkbox" class="input_check" name="topics[]" value="' . $topic['id'] . '" checked="checked" />
402 </td>
403 <td>
404 <a href="' . $scripturl . '?topic=' . $topic['id'] . '.0" target="_blank" class="new_win">' . $topic['subject'] . '</a>
405 </td>
406 <td>
407 ', $topic['started']['link'], '<br />
408 <span class="smalltext">', $topic['started']['time'], '</span>
409 </td>
410 <td>
411 ' . $topic['updated']['link'] . '<br />
412 <span class="smalltext">', $topic['updated']['time'], '</span>
413 </td>
414 <td align="center">
415 <input type="checkbox" class="input_check" name="notifications[]" value="' . $topic['id'] . '" checked="checked" />
416 </td>
417 </tr>';
418 echo '
419 </tbody>
420 </table>
421 <br />
422 <div class="windowbg">
423 <span class="topslice"><span></span></span>
424 <div class="content">';
425
426 echo '
427 <fieldset id="merge_subject" class="merge_options">
428 <legend>', $txt['merge_select_subject'], '</legend>
429 <select name="subject" onchange="this.form.custom_subject.style.display = (this.options[this.selectedIndex].value != 0) ? \'none\': \'\' ;">';
430 foreach ($context['topics'] as $topic)
431 echo '
432 <option value="', $topic['id'], '"' . ($topic['selected'] ? ' selected="selected"' : '') . '>', $topic['subject'], '</option>';
433 echo '
434 <option value="0">', $txt['merge_custom_subject'], ':</option>
435 </select>
436 <br /><input type="text" name="custom_subject" size="60" id="custom_subject" class="input_text custom_subject" style="display: none;" />
437 <br />
438 <label for="enforce_subject"><input type="checkbox" class="input_check" name="enforce_subject" id="enforce_subject" value="1" /> ', $txt['merge_enforce_subject'], '</label>
439 </fieldset>';
440
441 if (!empty($context['boards']) && count($context['boards']) > 1)
442 {
443 echo '
444 <fieldset id="merge_board" class="merge_options">
445 <legend>', $txt['merge_select_target_board'], '</legend>
446 <ul class="reset">';
447 foreach ($context['boards'] as $board)
448 echo '
449 <li>
450 <input type="radio" name="board" value="' . $board['id'] . '"' . ($board['selected'] ? ' checked="checked"' : '') . ' class="input_radio" /> ' . $board['name'] . '
451 </li>';
452 echo '
453 </ul>
454 </fieldset>';
455 }
456 if (!empty($context['polls']))
457 {
458 echo '
459 <fieldset id="merge_poll" class="merge_options">
460 <legend>' . $txt['merge_select_poll'] . '</legend>
461 <ul class="reset">';
462 foreach ($context['polls'] as $poll)
463 echo '
464 <li>
465 <input type="radio" name="poll" value="' . $poll['id'] . '"' . ($poll['selected'] ? ' checked="checked"' : '') . ' class="input_radio" /> ' . $poll['question'] . ' (' . $txt['topic'] . ': <a href="' . $scripturl . '?topic=' . $poll['topic']['id'] . '.0" target="_blank" class="new_win">' . $poll['topic']['subject'] . '</a>)
466 </li>';
467 echo '
468 <li>
469 <input type="radio" name="poll" value="-1" class="input_radio" /> (' . $txt['merge_no_poll'] . ')
470 </li>
471 </ul>
472 </fieldset>';
473 }
474 echo '
475 <input type="submit" value="' . $txt['merge'] . '" class="button_submit floatright" />
476 <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
477 <input type="hidden" name="sa" value="execute" /><br class="clear" />
478 </div>
479 <span class="botslice"><span></span></span>
480 </div>
481 </form>
482 </div>
483 <br class="clear" />';
484 }
485
486 ?>