SplitTopics.template.php 20 KB

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