SplitTopics.template.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458
  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.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. <input type="submit" value="', $txt['split'], '" class="button_submit" />
  41. <br class="clear_right" />
  42. </div>
  43. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  44. </div>
  45. </form>
  46. </div>';
  47. }
  48. function template_main()
  49. {
  50. global $context, $settings, $options, $txt, $scripturl;
  51. echo '
  52. <div id="split_topics">
  53. <div class="cat_bar">
  54. <h3 class="catbg">', $txt['split'], '</h3>
  55. </div>
  56. <div class="windowbg">
  57. <div class="content">
  58. <p>', $txt['split_successful'], '</p>
  59. <ul class="reset">
  60. <li>
  61. <a href="', $scripturl, '?board=', $context['current_board'], '.0">', $txt['message_index'], '</a>
  62. </li>
  63. <li>
  64. <a href="', $scripturl, '?topic=', $context['old_topic'], '.0">', $txt['origin_topic'], '</a>
  65. </li>
  66. <li>
  67. <a href="', $scripturl, '?topic=', $context['new_topic'], '.0">', $txt['new_topic'], '</a>
  68. </li>
  69. </ul>
  70. </div>
  71. </div>
  72. </div>';
  73. }
  74. function template_select()
  75. {
  76. global $context, $settings, $options, $txt, $scripturl;
  77. echo '
  78. <div id="split_topics">
  79. <form action="', $scripturl, '?action=splittopics;sa=splitSelection;board=', $context['current_board'], '.0" method="post" accept-charset="', $context['character_set'], '">
  80. <div id="not_selected" class="floatleft">
  81. <div class="cat_bar">
  82. <h3 class="catbg">', $txt['split'], ' - ', $txt['select_split_posts'], '</h3>
  83. </div>
  84. <div class="information">
  85. ', $txt['please_select_split'], '
  86. </div>
  87. <div class="pagesection">
  88. <strong>', $txt['pages'], ':</strong> <span id="pageindex_not_selected">', $context['not_selected']['page_index'], '</span>
  89. </div>
  90. <ul id="messages_not_selected" class="split_messages smalltext reset">';
  91. foreach ($context['not_selected']['messages'] as $message)
  92. echo '
  93. <li class="windowbg', $message['alternate'] ? '2' : '', '" id="not_selected_', $message['id'], '">
  94. <div class="content">
  95. <div class="message_header">
  96. <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>
  97. <strong>', $message['subject'], '</strong> ', $txt['by'], ' <strong>', $message['poster'], '</strong><br />
  98. <em>', $message['time'], '</em>
  99. </div>
  100. <div class="post">', $message['body'], '</div>
  101. </div>
  102. </li>';
  103. echo '
  104. <li class="dummy" />
  105. </ul>
  106. </div>
  107. <div id="selected" class="floatright">
  108. <div class="cat_bar">
  109. <h3 class="catbg">
  110. ', $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>)
  111. </h3>
  112. </div>
  113. <div class="information">
  114. ', $txt['split_selected_posts_desc'], '
  115. </div>
  116. <div class="pagesection">
  117. <strong>', $txt['pages'], ':</strong> <span id="pageindex_selected">', $context['selected']['page_index'], '</span>
  118. </div>
  119. <ul id="messages_selected" class="split_messages smalltext reset">';
  120. if (!empty($context['selected']['messages']))
  121. foreach ($context['selected']['messages'] as $message)
  122. echo '
  123. <li class="windowbg', $message['alternate'] ? '2' : '', '" id="selected_', $message['id'], '">
  124. <div class="content">
  125. <div class="message_header">
  126. <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>
  127. <strong>', $message['subject'], '</strong> ', $txt['by'], ' <strong>', $message['poster'], '</strong><br />
  128. <em>', $message['time'], '</em>
  129. </div>
  130. <div class="post">', $message['body'], '</div>
  131. </div>
  132. </li>';
  133. echo '
  134. <li class="dummy" />
  135. </ul>
  136. </div>
  137. <br class="clear" />
  138. <p>
  139. <input type="hidden" name="topic" value="', $context['current_topic'], '" />
  140. <input type="hidden" name="subname" value="', $context['new_subject'], '" />
  141. <input type="submit" value="', $txt['split'], '" class="button_submit" />
  142. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  143. </p>
  144. </form>
  145. </div>
  146. <br class="clear" />
  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. <strong>', $txt['pages'], ':</strong> ', $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. <strong>', $txt['pages'], ':</strong> ', $context['page_index'], '
  321. </div>
  322. </div>
  323. <br class="clear" />';
  324. }
  325. function template_merge_extra_options()
  326. {
  327. global $context, $settings, $options, $txt, $scripturl;
  328. echo '
  329. <div id="merge_topics">
  330. <form action="', $scripturl, '?action=mergetopics;sa=execute;" method="post" accept-charset="', $context['character_set'], '">
  331. <div class="title_bar">
  332. <h3 class="titlebg">', $txt['merge_topic_list'], '</h3>
  333. </div>
  334. <table width="100%" class="bordercolor table_grid">
  335. <thead>
  336. <tr class="catbg">
  337. <th scope="col" class="first_th" align="center" width="10px">', $txt['merge_check'], '</th>
  338. <th scope="col" class="lefttext">', $txt['subject'], '</th>
  339. <th scope="col" class="lefttext">', $txt['started_by'], '</th>
  340. <th scope="col" class="lefttext">', $txt['last_post'], '</th>
  341. <th scope="col" class="last_th" width="20px">' . $txt['merge_include_notifications'] . '</th>
  342. </tr>
  343. </thead>
  344. <tbody>';
  345. foreach ($context['topics'] as $topic)
  346. echo '
  347. <tr class="windowbg2">
  348. <td align="center">
  349. <input type="checkbox" class="input_check" name="topics[]" value="' . $topic['id'] . '" checked="checked" />
  350. </td>
  351. <td>
  352. <a href="' . $scripturl . '?topic=' . $topic['id'] . '.0" target="_blank" class="new_win">' . $topic['subject'] . '</a>
  353. </td>
  354. <td>
  355. ', $topic['started']['link'], '<br />
  356. <span class="smalltext">', $topic['started']['time'], '</span>
  357. </td>
  358. <td>
  359. ' . $topic['updated']['link'] . '<br />
  360. <span class="smalltext">', $topic['updated']['time'], '</span>
  361. </td>
  362. <td align="center">
  363. <input type="checkbox" class="input_check" name="notifications[]" value="' . $topic['id'] . '" checked="checked" />
  364. </td>
  365. </tr>';
  366. echo '
  367. </tbody>
  368. </table>
  369. <br />
  370. <div class="windowbg">
  371. <div class="content">';
  372. echo '
  373. <fieldset id="merge_subject" class="merge_options">
  374. <legend>', $txt['merge_select_subject'], '</legend>
  375. <select name="subject" onchange="this.form.custom_subject.style.display = (this.options[this.selectedIndex].value != 0) ? \'none\': \'\' ;">';
  376. foreach ($context['topics'] as $topic)
  377. echo '
  378. <option value="', $topic['id'], '"' . ($topic['selected'] ? ' selected="selected"' : '') . '>', $topic['subject'], '</option>';
  379. echo '
  380. <option value="0">', $txt['merge_custom_subject'], ':</option>
  381. </select>
  382. <br /><input type="text" name="custom_subject" size="60" id="custom_subject" class="input_text custom_subject" style="display: none;" />
  383. <br />
  384. <label for="enforce_subject"><input type="checkbox" class="input_check" name="enforce_subject" id="enforce_subject" value="1" /> ', $txt['merge_enforce_subject'], '</label>
  385. </fieldset>';
  386. if (!empty($context['boards']) && count($context['boards']) > 1)
  387. {
  388. echo '
  389. <fieldset id="merge_board" class="merge_options">
  390. <legend>', $txt['merge_select_target_board'], '</legend>
  391. <ul class="reset">';
  392. foreach ($context['boards'] as $board)
  393. echo '
  394. <li>
  395. <input type="radio" name="board" value="' . $board['id'] . '"' . ($board['selected'] ? ' checked="checked"' : '') . ' class="input_radio" /> ' . $board['name'] . '
  396. </li>';
  397. echo '
  398. </ul>
  399. </fieldset>';
  400. }
  401. if (!empty($context['polls']))
  402. {
  403. echo '
  404. <fieldset id="merge_poll" class="merge_options">
  405. <legend>' . $txt['merge_select_poll'] . '</legend>
  406. <ul class="reset">';
  407. foreach ($context['polls'] as $poll)
  408. echo '
  409. <li>
  410. <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>)
  411. </li>';
  412. echo '
  413. <li>
  414. <input type="radio" name="poll" value="-1" class="input_radio" /> (' . $txt['merge_no_poll'] . ')
  415. </li>
  416. </ul>
  417. </fieldset>';
  418. }
  419. echo '
  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. <br class="clear_right" />
  424. </div>
  425. </div>
  426. </form>
  427. </div>
  428. <br class="clear" />';
  429. }
  430. ?>