SplitTopics.template.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457
  1. <?php
  2. /**
  3. * Simple Machines Forum (SMF)
  4. *
  5. * @package SMF
  6. * @author Simple Machines
  7. * @copyright 2013 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, $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. <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, $settings, $options, $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, $options, $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 type="text/javascript"><!-- // --><![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, $settings, $options, $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, $settings, $options, $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 (!empty($context['boards']) && count($context['boards']) > 1)
  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['boards'] as $board)
  272. echo '
  273. <option value="', $board['id'], '"', $board['id'] == $context['target_board'] ? ' selected="selected"' : '', '>', $board['category'], ' - ', $board['name'], '</option>';
  274. echo '
  275. </select>
  276. <input type="submit" value="', $txt['go'], '" class="button_submit" />
  277. </form>
  278. </dd>';
  279. }
  280. echo '
  281. </dl>
  282. <hr class="hrcolor" />
  283. <dl class="settings merge_topic">
  284. <dt>
  285. <strong>', $txt['merge_to_topic_id'], ': </strong>
  286. </dt>
  287. <dd>
  288. <form action="', $scripturl , '?action=mergetopics;sa=options" method="post" accept-charset="', $context['character_set'], '">
  289. <input type="hidden" name="topics[]" value="', $context['origin_topic'], '" />
  290. <input type="text" name="topics[]" class="input_text" />
  291. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  292. <input type="submit" value="', $txt['merge'], '" class="button_submit" />
  293. </form>
  294. </dd>';
  295. echo '
  296. </dl>
  297. </div>
  298. </div><br />
  299. <div class="cat_bar">
  300. <h3 class="catbg">', $txt['target_topic'], '</h3>
  301. </div>
  302. <div class="pagesection">
  303. ', $context['page_index'], '
  304. </div>
  305. <div class="windowbg2">
  306. <div class="content">
  307. <ul class="reset merge_topics">';
  308. $merge_button = create_button('merge.png', 'merge', '');
  309. foreach ($context['topics'] as $topic)
  310. echo '
  311. <li>
  312. <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;
  313. <a href="', $scripturl, '?topic=', $topic['id'], '.0" target="_blank" class="new_win">', $topic['subject'], '</a> ', $txt['started_by'], ' ', $topic['poster']['link'], '
  314. </li>';
  315. echo '
  316. </ul>
  317. </div>
  318. </div>
  319. <div class="pagesection">
  320. ', $context['page_index'], '
  321. </div>
  322. </div>';
  323. }
  324. function template_merge_extra_options()
  325. {
  326. global $context, $settings, $options, $txt, $scripturl;
  327. echo '
  328. <div id="merge_topics">
  329. <form action="', $scripturl, '?action=mergetopics;sa=execute;" method="post" accept-charset="', $context['character_set'], '">
  330. <div class="title_bar">
  331. <h3 class="titlebg">', $txt['merge_topic_list'], '</h3>
  332. </div>
  333. <table width="100%" class="bordercolor table_grid">
  334. <thead>
  335. <tr class="catbg">
  336. <th scope="col" class="first_th" align="center" width="10px">', $txt['merge_check'], '</th>
  337. <th scope="col" class="lefttext">', $txt['subject'], '</th>
  338. <th scope="col" class="lefttext">', $txt['started_by'], '</th>
  339. <th scope="col" class="lefttext">', $txt['last_post'], '</th>
  340. <th scope="col" class="last_th" width="20px">' . $txt['merge_include_notifications'] . '</th>
  341. </tr>
  342. </thead>
  343. <tbody>';
  344. foreach ($context['topics'] as $topic)
  345. echo '
  346. <tr class="windowbg2">
  347. <td align="center">
  348. <input type="checkbox" class="input_check" name="topics[]" value="' . $topic['id'] . '" checked="checked" />
  349. </td>
  350. <td>
  351. <a href="' . $scripturl . '?topic=' . $topic['id'] . '.0" target="_blank" class="new_win">' . $topic['subject'] . '</a>
  352. </td>
  353. <td>
  354. ', $topic['started']['link'], '<br />
  355. <span class="smalltext">', $topic['started']['time'], '</span>
  356. </td>
  357. <td>
  358. ' . $topic['updated']['link'] . '<br />
  359. <span class="smalltext">', $topic['updated']['time'], '</span>
  360. </td>
  361. <td align="center">
  362. <input type="checkbox" class="input_check" name="notifications[]" value="' . $topic['id'] . '" checked="checked" />
  363. </td>
  364. </tr>';
  365. echo '
  366. </tbody>
  367. </table>
  368. <br />
  369. <div class="windowbg">
  370. <div class="content">';
  371. echo '
  372. <fieldset id="merge_subject" class="merge_options">
  373. <legend>', $txt['merge_select_subject'], '</legend>
  374. <select name="subject" onchange="this.form.custom_subject.style.display = (this.options[this.selectedIndex].value != 0) ? \'none\': \'\' ;">';
  375. foreach ($context['topics'] as $topic)
  376. echo '
  377. <option value="', $topic['id'], '"' . ($topic['selected'] ? ' selected="selected"' : '') . '>', $topic['subject'], '</option>';
  378. echo '
  379. <option value="0">', $txt['merge_custom_subject'], ':</option>
  380. </select>
  381. <br /><input type="text" name="custom_subject" size="60" id="custom_subject" class="input_text custom_subject" style="display: none;" />
  382. <br />
  383. <label for="enforce_subject"><input type="checkbox" class="input_check" name="enforce_subject" id="enforce_subject" value="1" /> ', $txt['merge_enforce_subject'], '</label>
  384. </fieldset>';
  385. if (!empty($context['boards']) && count($context['boards']) > 1)
  386. {
  387. echo '
  388. <fieldset id="merge_board" class="merge_options">
  389. <legend>', $txt['merge_select_target_board'], '</legend>
  390. <ul class="reset">';
  391. foreach ($context['boards'] as $board)
  392. echo '
  393. <li>
  394. <input type="radio" name="board" value="' . $board['id'] . '"' . ($board['selected'] ? ' checked="checked"' : '') . ' class="input_radio" /> ' . $board['name'] . '
  395. </li>';
  396. echo '
  397. </ul>
  398. </fieldset>';
  399. }
  400. if (!empty($context['polls']))
  401. {
  402. echo '
  403. <fieldset id="merge_poll" class="merge_options">
  404. <legend>' . $txt['merge_select_poll'] . '</legend>
  405. <ul class="reset">';
  406. foreach ($context['polls'] as $poll)
  407. echo '
  408. <li>
  409. <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>)
  410. </li>';
  411. echo '
  412. <li>
  413. <input type="radio" name="poll" value="-1" class="input_radio" /> (' . $txt['merge_no_poll'] . ')
  414. </li>
  415. </ul>
  416. </fieldset>';
  417. }
  418. echo '
  419. <div class="auto_flow">
  420. <input type="submit" value="' . $txt['merge'] . '" class="button_submit" />
  421. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  422. <input type="hidden" name="sa" value="execute" />
  423. </div>
  424. </div>
  425. </div>
  426. </form>
  427. </div>';
  428. }
  429. ?>