SplitTopics.template.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  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. <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. <hr class="hrcolor" />
  41. <input type="submit" value="', $txt['split'], '" class="button_submit" />
  42. <br class="clear_right" />
  43. </div>
  44. <span class="botslice"><span></span></span>
  45. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  46. </div>
  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.png" 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.png" 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 onDocReceived(XMLDoc)
  170. {
  171. var i, j, pageIndex;
  172. for (i = 0; i < 2; i++)
  173. {
  174. pageIndex = XMLDoc.getElementsByTagName("pageIndex")[i];
  175. setInnerHTML(document.getElementById("pageindex_" + pageIndex.getAttribute("section")), pageIndex.firstChild.nodeValue);
  176. start[i] = pageIndex.getAttribute("startFrom");
  177. }
  178. var numChanges = XMLDoc.getElementsByTagName("change").length;
  179. var curChange, curSection, curAction, curId, curList, curData, newItem, sInsertBeforeId;
  180. for (i = 0; i < numChanges; i++)
  181. {
  182. curChange = XMLDoc.getElementsByTagName("change")[i];
  183. curSection = curChange.getAttribute("section");
  184. curAction = curChange.getAttribute("curAction");
  185. curId = curChange.getAttribute("id");
  186. curList = document.getElementById("messages_" + curSection);
  187. if (curAction == "remove")
  188. curList.removeChild(document.getElementById(curSection + "_" + curId));
  189. // Insert a message.
  190. else
  191. {
  192. // By default, insert the element at the end of the list.
  193. sInsertBeforeId = null;
  194. // Loop through the list to try and find an item to insert after.
  195. oListItems = curList.getElementsByTagName("LI");
  196. for (j = 0; j < oListItems.length; j++)
  197. {
  198. if (parseInt(oListItems[j].id.substr(curSection.length + 1)) < curId)
  199. {
  200. // This would be a nice place to insert the row.
  201. sInsertBeforeId = oListItems[j].id;
  202. // We\'re done for now. Escape the loop.
  203. j = oListItems.length + 1;
  204. }
  205. }
  206. // Let\'s create a nice container for the message.
  207. newItem = document.createElement("LI");
  208. newItem.className = "windowbg2";
  209. newItem.id = curSection + "_" + curId;
  210. 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.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><span class=\\"botslice\\"><span></span></span>";
  211. // So, where do we insert it?
  212. if (typeof sInsertBeforeId == "string")
  213. curList.insertBefore(newItem, document.getElementById(sInsertBeforeId));
  214. else
  215. curList.appendChild(newItem);
  216. }
  217. }
  218. // After all changes, make sure the window backgrounds are still correct for both lists.
  219. applyWindowClasses(document.getElementById("messages_selected"));
  220. applyWindowClasses(document.getElementById("messages_not_selected"));
  221. }
  222. // ]]></script>';
  223. }
  224. function template_merge_done()
  225. {
  226. global $context, $settings, $options, $txt, $scripturl;
  227. echo '
  228. <div id="merge_topics">
  229. <div class="cat_bar">
  230. <h3 class="catbg">', $txt['merge'], '</h3>
  231. </div>
  232. <div class="windowbg">
  233. <span class="topslice"><span></span></span>
  234. <div class="content">
  235. <p>', $txt['merge_successful'], '</p>
  236. <br />
  237. <ul class="reset">
  238. <li>
  239. <a href="', $scripturl, '?board=', $context['target_board'], '.0">', $txt['message_index'], '</a>
  240. </li>
  241. <li>
  242. <a href="', $scripturl, '?topic=', $context['target_topic'], '.0">', $txt['new_merged_topic'], '</a>
  243. </li>
  244. </ul>
  245. </div>
  246. <span class="botslice"><span></span></span>
  247. </div>
  248. </div>
  249. <br class="clear" />';
  250. }
  251. function template_merge()
  252. {
  253. global $context, $settings, $options, $txt, $scripturl;
  254. echo '
  255. <div id="merge_topics">
  256. <div class="cat_bar">
  257. <h3 class="catbg">', $txt['merge'], '</h3>
  258. </div>
  259. <div class="information">
  260. ', $txt['merge_desc'], '
  261. </div>
  262. <div class="windowbg">
  263. <span class="topslice"><span></span></span>
  264. <div class="content">
  265. <dl class="settings merge_topic">
  266. <dt>
  267. <strong>', $txt['topic_to_merge'], ':</strong>
  268. </dt>
  269. <dd>
  270. ', $context['origin_subject'], '
  271. </dd>';
  272. if (!empty($context['boards']) && count($context['boards']) > 1)
  273. {
  274. echo '
  275. <dt>
  276. <strong>', $txt['target_board'], ':</strong>
  277. </dt>
  278. <dd>
  279. <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'], '">
  280. <input type="hidden" name="from" value="' . $context['origin_topic'] . '" />
  281. <select name="targetboard" onchange="this.form.submit();">';
  282. foreach ($context['boards'] as $board)
  283. echo '
  284. <option value="', $board['id'], '"', $board['id'] == $context['target_board'] ? ' selected="selected"' : '', '>', $board['category'], ' - ', $board['name'], '</option>';
  285. echo '
  286. </select>
  287. <input type="submit" value="', $txt['go'], '" class="button_submit" />
  288. </form>
  289. </dd>';
  290. }
  291. echo '
  292. </dl>
  293. <hr class="hrcolor" />
  294. <dl class="settings merge_topic">
  295. <dt>
  296. <strong>', $txt['merge_to_topic_id'], ': </strong>
  297. </dt>
  298. <dd>
  299. <form action="', $scripturl , '?action=mergetopics;sa=options" method="post" accept-charset="', $context['character_set'], '">
  300. <input type="hidden" name="topics[]" value="', $context['origin_topic'], '" />
  301. <input type="text" name="topics[]" class="input_text" />
  302. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  303. <input type="submit" value="', $txt['merge'], '" class="button_submit" />
  304. </form>
  305. </dd>';
  306. echo '
  307. </dl>
  308. </div>
  309. <span class="botslice"><span></span></span>
  310. </div><br />
  311. <div class="cat_bar">
  312. <h3 class="catbg">', $txt['target_topic'], '</h3>
  313. </div>
  314. <div class="pagesection">
  315. <strong>', $txt['pages'], ':</strong> ', $context['page_index'], '
  316. </div>
  317. <div class="windowbg2">
  318. <span class="topslice"><span></span></span>
  319. <div class="content">
  320. <ul class="reset merge_topics">';
  321. $merge_button = create_button('merge.png', 'merge', '');
  322. foreach ($context['topics'] as $topic)
  323. echo '
  324. <li>
  325. <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;
  326. <a href="', $scripturl, '?topic=', $topic['id'], '.0" target="_blank" class="new_win">', $topic['subject'], '</a> ', $txt['started_by'], ' ', $topic['poster']['link'], '
  327. </li>';
  328. echo '
  329. </ul>
  330. </div>
  331. <span class="botslice"><span></span></span>
  332. </div>
  333. <div class="pagesection">
  334. <strong>', $txt['pages'], ':</strong> ', $context['page_index'], '
  335. </div>
  336. </div>
  337. <br class="clear" />';
  338. }
  339. function template_merge_extra_options()
  340. {
  341. global $context, $settings, $options, $txt, $scripturl;
  342. echo '
  343. <div id="merge_topics">
  344. <form action="', $scripturl, '?action=mergetopics;sa=execute;" method="post" accept-charset="', $context['character_set'], '">
  345. <div class="title_bar">
  346. <h3 class="titlebg">', $txt['merge_topic_list'], '</h3>
  347. </div>
  348. <table width="100%" class="bordercolor table_grid">
  349. <thead>
  350. <tr class="catbg">
  351. <th scope="col" class="first_th" align="center" width="10px">', $txt['merge_check'], '</th>
  352. <th scope="col" class="lefttext">', $txt['subject'], '</th>
  353. <th scope="col" class="lefttext">', $txt['started_by'], '</th>
  354. <th scope="col" class="lefttext">', $txt['last_post'], '</th>
  355. <th scope="col" class="last_th" width="20px">' . $txt['merge_include_notifications'] . '</th>
  356. </tr>
  357. </thead>
  358. <tbody>';
  359. foreach ($context['topics'] as $topic)
  360. echo '
  361. <tr class="windowbg2">
  362. <td align="center">
  363. <input type="checkbox" class="input_check" name="topics[]" value="' . $topic['id'] . '" checked="checked" />
  364. </td>
  365. <td>
  366. <a href="' . $scripturl . '?topic=' . $topic['id'] . '.0" target="_blank" class="new_win">' . $topic['subject'] . '</a>
  367. </td>
  368. <td>
  369. ', $topic['started']['link'], '<br />
  370. <span class="smalltext">', $topic['started']['time'], '</span>
  371. </td>
  372. <td>
  373. ' . $topic['updated']['link'] . '<br />
  374. <span class="smalltext">', $topic['updated']['time'], '</span>
  375. </td>
  376. <td align="center">
  377. <input type="checkbox" class="input_check" name="notifications[]" value="' . $topic['id'] . '" checked="checked" />
  378. </td>
  379. </tr>';
  380. echo '
  381. </tbody>
  382. </table>
  383. <br />
  384. <div class="windowbg">
  385. <span class="topslice"><span></span></span>
  386. <div class="content">';
  387. echo '
  388. <fieldset id="merge_subject" class="merge_options">
  389. <legend>', $txt['merge_select_subject'], '</legend>
  390. <select name="subject" onchange="this.form.custom_subject.style.display = (this.options[this.selectedIndex].value != 0) ? \'none\': \'\' ;">';
  391. foreach ($context['topics'] as $topic)
  392. echo '
  393. <option value="', $topic['id'], '"' . ($topic['selected'] ? ' selected="selected"' : '') . '>', $topic['subject'], '</option>';
  394. echo '
  395. <option value="0">', $txt['merge_custom_subject'], ':</option>
  396. </select>
  397. <br /><input type="text" name="custom_subject" size="60" id="custom_subject" class="input_text custom_subject" style="display: none;" />
  398. <br />
  399. <label for="enforce_subject"><input type="checkbox" class="input_check" name="enforce_subject" id="enforce_subject" value="1" /> ', $txt['merge_enforce_subject'], '</label>
  400. </fieldset>';
  401. if (!empty($context['boards']) && count($context['boards']) > 1)
  402. {
  403. echo '
  404. <fieldset id="merge_board" class="merge_options">
  405. <legend>', $txt['merge_select_target_board'], '</legend>
  406. <ul class="reset">';
  407. foreach ($context['boards'] as $board)
  408. echo '
  409. <li>
  410. <input type="radio" name="board" value="' . $board['id'] . '"' . ($board['selected'] ? ' checked="checked"' : '') . ' class="input_radio" /> ' . $board['name'] . '
  411. </li>';
  412. echo '
  413. </ul>
  414. </fieldset>';
  415. }
  416. if (!empty($context['polls']))
  417. {
  418. echo '
  419. <fieldset id="merge_poll" class="merge_options">
  420. <legend>' . $txt['merge_select_poll'] . '</legend>
  421. <ul class="reset">';
  422. foreach ($context['polls'] as $poll)
  423. echo '
  424. <li>
  425. <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>)
  426. </li>';
  427. echo '
  428. <li>
  429. <input type="radio" name="poll" value="-1" class="input_radio" /> (' . $txt['merge_no_poll'] . ')
  430. </li>
  431. </ul>
  432. </fieldset>';
  433. }
  434. echo '
  435. <input type="submit" value="' . $txt['merge'] . '" class="button_submit" />
  436. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  437. <input type="hidden" name="sa" value="execute" />
  438. <br class="clear_right" />
  439. </div>
  440. <span class="botslice"><span></span></span>
  441. </div>
  442. </form>
  443. </div>
  444. <br class="clear" />';
  445. }
  446. ?>