2
0

SplitTopics.template.php 18 KB

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