Post.template.php 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077
  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. // The main template for the post page.
  13. function template_main()
  14. {
  15. global $context, $settings, $options, $txt, $scripturl, $modSettings, $counter;
  16. // Start the javascript... and boy is there a lot.
  17. echo '
  18. <script type="text/javascript"><!-- // --><![CDATA[';
  19. // When using Go Back due to fatal_error, allow the form to be re-submitted with changes.
  20. if (isBrowser('is_firefox'))
  21. echo '
  22. window.addEventListener("pageshow", reActivate, false);';
  23. // Start with message icons - and any missing from this theme.
  24. echo '
  25. var icon_urls = {';
  26. foreach ($context['icons'] as $icon)
  27. echo '
  28. \'', $icon['value'], '\': \'', $icon['url'], '\'', $icon['is_last'] ? '' : ',';
  29. echo '
  30. };';
  31. // If this is a poll - use some javascript to ensure the user doesn't create a poll with illegal option combinations.
  32. if ($context['make_poll'])
  33. echo '
  34. var pollOptionNum = 0, pollTabIndex;
  35. var pollOptionId = ', $context['last_choice_id'], ';
  36. function addPollOption()
  37. {
  38. if (pollOptionNum == 0)
  39. {
  40. for (var i = 0, n = document.forms.postmodify.elements.length; i < n; i++)
  41. if (document.forms.postmodify.elements[i].id.substr(0, 8) == \'options-\')
  42. {
  43. pollOptionNum++;
  44. pollTabIndex = document.forms.postmodify.elements[i].tabIndex;
  45. }
  46. }
  47. pollOptionNum++
  48. pollOptionId++
  49. setOuterHTML(document.getElementById(\'pollMoreOptions\'), ', JavaScriptEscape('<li><label for="options-'), ' + pollOptionId + ', JavaScriptEscape('">' . $txt['option'] . ' '), ' + pollOptionNum + ', JavaScriptEscape('</label>: <input type="text" name="options['), ' + pollOptionId + ', JavaScriptEscape(']" id="options-'), ' + pollOptionId + ', JavaScriptEscape('" value="" size="80" maxlength="255" tabindex="'), ' + pollTabIndex + ', JavaScriptEscape('" class="input_text" /></li><li id="pollMoreOptions"></li>'), ');
  50. }';
  51. // If we are making a calendar event we want to ensure we show the current days in a month etc... this is done here.
  52. if ($context['make_event'])
  53. echo '
  54. var monthLength = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];';
  55. // End of the javascript, start the form and display the link tree.
  56. echo '
  57. // ]]></script>
  58. <form action="', $scripturl, '?action=', $context['destination'], ';', empty($context['current_board']) ? '' : 'board=' . $context['current_board'], '" method="post" accept-charset="', $context['character_set'], '" name="postmodify" id="postmodify" class="flow_hidden" onsubmit="', ($context['becomes_approved'] ? '' : 'alert(\'' . $txt['js_post_will_require_approval'] . '\');'), 'submitonce(this);smc_saveEntities(\'postmodify\', [\'subject\', \'', $context['post_box_name'], '\', \'guestname\', \'evtitle\', \'question\'], \'options\');" enctype="multipart/form-data">';
  59. // If the user wants to see how their message looks - the preview section is where it's at!
  60. echo '
  61. <div id="preview_section"', isset($context['preview_message']) ? '' : ' style="display: none;"', '>
  62. <div class="cat_bar">
  63. <h3 class="catbg">
  64. <span id="preview_subject">', empty($context['preview_subject']) ? '' : $context['preview_subject'], '</span>
  65. </h3>
  66. </div>
  67. <div class="windowbg">
  68. <div class="content">
  69. <div class="post" id="preview_body">
  70. ', empty($context['preview_message']) ? '<br />' : $context['preview_message'], '
  71. </div>
  72. </div>
  73. </div>
  74. </div><br />';
  75. if ($context['make_event'] && (!$context['event']['new'] || !empty($context['current_board'])))
  76. echo '
  77. <input type="hidden" name="eventid" value="', $context['event']['id'], '" />';
  78. // Start the main table.
  79. echo '
  80. <div class="cat_bar">
  81. <h3 class="catbg">', $context['page_title'], '</h3>
  82. </div>
  83. <div>
  84. <div class="roundframe">', isset($context['current_topic']) ? '
  85. <input type="hidden" name="topic" value="' . $context['current_topic'] . '" />' : '';
  86. // If an error occurred, explain what happened.
  87. echo '
  88. <div class="', empty($context['error_type']) || $context['error_type'] != 'serious' ? 'noticebox' : 'errorbox', '"', empty($context['post_error']) ? ' style="display: none"' : '', ' id="errors">
  89. <dl>
  90. <dt>
  91. <strong id="error_serious">', $txt['error_while_submitting'], '</strong>
  92. </dt>
  93. <dd class="error" id="error_list">
  94. ', empty($context['post_error']) ? '' : implode('<br />', $context['post_error']), '
  95. </dd>
  96. </dl>
  97. </div>';
  98. // If this won't be approved let them know!
  99. if (!$context['becomes_approved'])
  100. {
  101. echo '
  102. <p class="information">
  103. <em>', $txt['wait_for_approval'], '</em>
  104. <input type="hidden" name="not_approved" value="1" />
  105. </p>';
  106. }
  107. // If it's locked, show a message to warn the replyer.
  108. echo '
  109. <p class="information"', $context['locked'] ? '' : ' style="display: none"', ' id="lock_warning">
  110. ', $txt['topic_locked_no_reply'], '
  111. </p>';
  112. // The post header... important stuff
  113. echo '
  114. <dl id="post_header">';
  115. // Guests have to put in their name and email...
  116. if (isset($context['name']) && isset($context['email']))
  117. {
  118. echo '
  119. <dt>
  120. <span', isset($context['post_error']['long_name']) || isset($context['post_error']['no_name']) || isset($context['post_error']['bad_name']) ? ' class="error"' : '', ' id="caption_guestname">', $txt['name'], ':</span>
  121. </dt>
  122. <dd>
  123. <input type="text" name="guestname" size="25" value="', $context['name'], '" tabindex="', $context['tabindex']++, '" class="input_text" />
  124. </dd>';
  125. if (empty($modSettings['guest_post_no_email']))
  126. echo '
  127. <dt>
  128. <span', isset($context['post_error']['no_email']) || isset($context['post_error']['bad_email']) ? ' class="error"' : '', ' id="caption_email">', $txt['email'], ':</span>
  129. </dt>
  130. <dd>
  131. <input type="text" name="email" size="25" value="', $context['email'], '" tabindex="', $context['tabindex']++, '" class="input_text" />
  132. </dd>';
  133. }
  134. // Now show the subject box for this post.
  135. echo '
  136. <dt class="clear">
  137. <span', isset($context['post_error']['no_subject']) ? ' class="error"' : '', ' id="caption_subject">', $txt['subject'], ':</span>
  138. </dt>
  139. <dd>
  140. <input type="text" name="subject"', $context['subject'] == '' ? '' : ' value="' . $context['subject'] . '"', ' tabindex="', $context['tabindex']++, '" size="80" maxlength="80"', isset($context['post_error']['no_subject']) ? ' class="error"' : ' class="input_text"', '/>
  141. </dd>
  142. <dt class="clear_left">
  143. ', $txt['message_icon'], ':
  144. </dt>
  145. <dd>
  146. <select name="icon" id="icon" onchange="showimage()">';
  147. // Loop through each message icon allowed, adding it to the drop down list.
  148. foreach ($context['icons'] as $icon)
  149. echo '
  150. <option value="', $icon['value'], '"', $icon['value'] == $context['icon'] ? ' selected="selected"' : '', '>', $icon['name'], '</option>';
  151. echo '
  152. </select>
  153. <img src="', $context['icon_url'], '" name="icons" hspace="15" alt="" />
  154. </dd>
  155. </dl><hr class="clear" />';
  156. // Are you posting a calendar event?
  157. if ($context['make_event'])
  158. {
  159. echo '
  160. <div id="post_event">
  161. <fieldset id="event_main">
  162. <legend><span', isset($context['post_error']['no_event']) ? ' class="error"' : '', ' id="caption_evtitle">', $txt['calendar_event_title'], '</span></legend>
  163. <input type="text" name="evtitle" maxlength="255" size="55" value="', $context['event']['title'], '" tabindex="', $context['tabindex']++, '" class="input_text" />
  164. <div class="smalltext" style="white-space: nowrap;">
  165. <input type="hidden" name="calendar" value="1" />', $txt['calendar_year'], '
  166. <select name="year" id="year" tabindex="', $context['tabindex']++, '" onchange="generateDays();">';
  167. // Show a list of all the years we allow...
  168. for ($year = $modSettings['cal_minyear']; $year <= $modSettings['cal_maxyear']; $year++)
  169. echo '
  170. <option value="', $year, '"', $year == $context['event']['year'] ? ' selected="selected"' : '', '>', $year, '&nbsp;</option>';
  171. echo '
  172. </select>
  173. ', $txt['calendar_month'], '
  174. <select name="month" id="month" onchange="generateDays();">';
  175. // There are 12 months per year - ensure that they all get listed.
  176. for ($month = 1; $month <= 12; $month++)
  177. echo '
  178. <option value="', $month, '"', $month == $context['event']['month'] ? ' selected="selected"' : '', '>', $txt['months'][$month], '&nbsp;</option>';
  179. echo '
  180. </select>
  181. ', $txt['calendar_day'], '
  182. <select name="day" id="day">';
  183. // This prints out all the days in the current month - this changes dynamically as we switch months.
  184. for ($day = 1; $day <= $context['event']['last_day']; $day++)
  185. echo '
  186. <option value="', $day, '"', $day == $context['event']['day'] ? ' selected="selected"' : '', '>', $day, '&nbsp;</option>';
  187. echo '
  188. </select>
  189. </div>
  190. </fieldset>';
  191. if (!empty($modSettings['cal_allowspan']) || ($context['event']['new'] && $context['is_new_post']))
  192. {
  193. echo '
  194. <fieldset id="event_options">
  195. <legend>', $txt['calendar_event_options'], '</legend>
  196. <div class="event_options smalltext">
  197. <ul class="event_options">';
  198. // If events can span more than one day then allow the user to select how long it should last.
  199. if (!empty($modSettings['cal_allowspan']))
  200. {
  201. echo '
  202. <li>
  203. ', $txt['calendar_numb_days'], '
  204. <select name="span">';
  205. for ($days = 1; $days <= $modSettings['cal_maxspan']; $days++)
  206. echo '
  207. <option value="', $days, '"', $days == $context['event']['span'] ? ' selected="selected"' : '', '>', $days, '&nbsp;</option>';
  208. echo '
  209. </select>
  210. </li>';
  211. }
  212. // If this is a new event let the user specify which board they want the linked post to be put into.
  213. if ($context['event']['new'] && $context['is_new_post'])
  214. {
  215. echo '
  216. <li>
  217. ', $txt['calendar_post_in'], '
  218. <select name="board">';
  219. foreach ($context['event']['categories'] as $category)
  220. {
  221. echo '
  222. <optgroup label="', $category['name'], '">';
  223. foreach ($category['boards'] as $board)
  224. echo '
  225. <option value="', $board['id'], '"', $board['selected'] ? ' selected="selected"' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=&gt;' : '', ' ', $board['name'], '&nbsp;</option>';
  226. echo '
  227. </optgroup>';
  228. }
  229. echo '
  230. </select>
  231. </li>';
  232. }
  233. echo '
  234. </ul>
  235. </div>
  236. </fieldset>';
  237. }
  238. echo '
  239. </div>';
  240. }
  241. // If this is a poll then display all the poll options!
  242. if ($context['make_poll'])
  243. {
  244. echo '
  245. <div id="edit_poll">
  246. <fieldset id="poll_main">
  247. <legend><span ', (isset($context['poll_error']['no_question']) ? ' class="error"' : ''), '>', $txt['poll_question'], '</span></legend>
  248. <input type="text" name="question" value="', isset($context['question']) ? $context['question'] : '', '" tabindex="', $context['tabindex']++, '" size="80" class="input_text" />
  249. <ul class="poll_main">';
  250. // Loop through all the choices and print them out.
  251. foreach ($context['choices'] as $choice)
  252. {
  253. echo '
  254. <li>
  255. <label for="options-', $choice['id'], '">', $txt['option'], ' ', $choice['number'], '</label>:
  256. <input type="text" name="options[', $choice['id'], ']" id="options-', $choice['id'], '" value="', $choice['label'], '" tabindex="', $context['tabindex']++, '" size="80" maxlength="255" class="input_text" />
  257. </li>';
  258. }
  259. echo '
  260. <li id="pollMoreOptions"></li>
  261. </ul>
  262. <strong><a href="javascript:addPollOption(); void(0);">(', $txt['poll_add_option'], ')</a></strong>
  263. </fieldset>
  264. <fieldset id="poll_options">
  265. <legend>', $txt['poll_options'], '</legend>
  266. <dl class="settings poll_options">
  267. <dt>
  268. <label for="poll_max_votes">', $txt['poll_max_votes'], ':</label>
  269. </dt>
  270. <dd>
  271. <input type="text" name="poll_max_votes" id="poll_max_votes" size="2" value="', $context['poll_options']['max_votes'], '" class="input_text" />
  272. </dd>
  273. <dt>
  274. <label for="poll_expire">', $txt['poll_run'], ':</label><br />
  275. <em class="smalltext">', $txt['poll_run_limit'], '</em>
  276. </dt>
  277. <dd>
  278. <input type="text" name="poll_expire" id="poll_expire" size="2" value="', $context['poll_options']['expire'], '" onchange="pollOptions();" maxlength="4" class="input_text" /> ', $txt['days_word'], '
  279. </dd>
  280. <dt>
  281. <label for="poll_change_vote">', $txt['poll_do_change_vote'], ':</label>
  282. </dt>
  283. <dd>
  284. <input type="checkbox" id="poll_change_vote" name="poll_change_vote"', !empty($context['poll']['change_vote']) ? ' checked="checked"' : '', ' class="input_check" />
  285. </dd>';
  286. if ($context['poll_options']['guest_vote_enabled'])
  287. echo '
  288. <dt>
  289. <label for="poll_guest_vote">', $txt['poll_guest_vote'], ':</label>
  290. </dt>
  291. <dd>
  292. <input type="checkbox" id="poll_guest_vote" name="poll_guest_vote"', !empty($context['poll_options']['guest_vote']) ? ' checked="checked"' : '', ' class="input_check" />
  293. </dd>';
  294. echo '
  295. <dt>
  296. ', $txt['poll_results_visibility'], ':
  297. </dt>
  298. <dd>
  299. <input type="radio" name="poll_hide" id="poll_results_anyone" value="0"', $context['poll_options']['hide'] == 0 ? ' checked="checked"' : '', ' class="input_radio" /> <label for="poll_results_anyone">', $txt['poll_results_anyone'], '</label><br />
  300. <input type="radio" name="poll_hide" id="poll_results_voted" value="1"', $context['poll_options']['hide'] == 1 ? ' checked="checked"' : '', ' class="input_radio" /> <label for="poll_results_voted">', $txt['poll_results_voted'], '</label><br />
  301. <input type="radio" name="poll_hide" id="poll_results_expire" value="2"', $context['poll_options']['hide'] == 2 ? ' checked="checked"' : '', empty($context['poll_options']['expire']) ? 'disabled="disabled"' : '', ' class="input_radio" /> <label for="poll_results_expire">', $txt['poll_results_after'], '</label>
  302. </dd>
  303. </dl>
  304. </fieldset>
  305. </div>';
  306. }
  307. // Show the actual posting area...
  308. echo '
  309. ', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message');
  310. // If this message has been edited in the past - display when it was.
  311. if (isset($context['last_modified']))
  312. echo '
  313. <div class="padding smalltext">
  314. <strong>', $txt['last_edit'], ':</strong>
  315. ', $context['last_modified'], '
  316. </div>';
  317. // If the admin has enabled the hiding of the additional options - show a link and image for it.
  318. if (!empty($settings['additional_options_collapsable']))
  319. echo '
  320. <div id="postAdditionalOptionsHeader" class="title_bar">
  321. <h4 class="titlebg">
  322. <img id="postMoreExpand" class="panel_toggle" style="display: none;" src="', $settings['images_url'], '/collapse.png" alt="-" /> <strong><a href="#" id="postMoreExpandLink">', $context['can_post_attachment'] ? $txt['post_additionalopt_attach'] : $txt['post_additionalopt'], '</a></strong>
  323. </h4>
  324. </div>';
  325. // Display the check boxes for all the standard options - if they are available to the user!
  326. echo '
  327. <div id="postMoreOptions" class="smalltext">
  328. <ul class="post_options">
  329. ', $context['can_notify'] ? '<li><input type="hidden" name="notify" value="0" /><label for="check_notify"><input type="checkbox" name="notify" id="check_notify"' . ($context['notify'] || !empty($options['auto_notify']) ? ' checked="checked"' : '') . ' value="1" class="input_check" /> ' . $txt['notify_replies'] . '</label></li>' : '', '
  330. ', $context['can_lock'] ? '<li><input type="hidden" name="lock" value="0" /><label for="check_lock"><input type="checkbox" name="lock" id="check_lock"' . ($context['locked'] ? ' checked="checked"' : '') . ' value="1" class="input_check" /> ' . $txt['lock_topic'] . '</label></li>' : '', '
  331. <li><label for="check_back"><input type="checkbox" name="goback" id="check_back"' . ($context['back_to_topic'] || !empty($options['return_to_post']) ? ' checked="checked"' : '') . ' value="1" class="input_check" /> ' . $txt['back_to_topic'] . '</label></li>
  332. ', $context['can_sticky'] ? '<li><input type="hidden" name="sticky" value="0" /><label for="check_sticky"><input type="checkbox" name="sticky" id="check_sticky"' . ($context['sticky'] ? ' checked="checked"' : '') . ' value="1" class="input_check" /> ' . $txt['sticky_after'] . '</label></li>' : '', '
  333. <li><label for="check_smileys"><input type="checkbox" name="ns" id="check_smileys"', $context['use_smileys'] ? '' : ' checked="checked"', ' value="NS" class="input_check" /> ', $txt['dont_use_smileys'], '</label></li>', '
  334. ', $context['can_move'] ? '<li><input type="hidden" name="move" value="0" /><label for="check_move"><input type="checkbox" name="move" id="check_move" value="1" class="input_check" ' . (!empty($context['move']) ? 'checked="checked" ' : '') . '/> ' . $txt['move_after2'] . '</label></li>' : '', '
  335. ', $context['can_announce'] && $context['is_first_post'] ? '<li><label for="check_announce"><input type="checkbox" name="announce_topic" id="check_announce" value="1" class="input_check" ' . (!empty($context['announce']) ? 'checked="checked" ' : '') . '/> ' . $txt['announce_topic'] . '</label></li>' : '', '
  336. ', $context['show_approval'] ? '<li><label for="approve"><input type="checkbox" name="approve" id="approve" value="2" class="input_check" ' . ($context['show_approval'] === 2 ? 'checked="checked"' : '') . ' /> ' . $txt['approve_this_post'] . '</label></li>' : '', '
  337. </ul>
  338. </div>';
  339. // If this post already has attachments on it - give information about them.
  340. if (!empty($context['current_attachments']))
  341. {
  342. echo '
  343. <dl id="postAttachment">
  344. <dt>
  345. ', $txt['attached'], ':
  346. </dt>
  347. <dd class="smalltext">
  348. <input type="hidden" name="attach_del[]" value="0" />
  349. ', $txt['uncheck_unwatchd_attach'], ':
  350. </dd>';
  351. foreach ($context['current_attachments'] as $attachment)
  352. echo '
  353. <dd class="smalltext">
  354. <label for="attachment_', $attachment['id'], '"><input type="checkbox" id="attachment_', $attachment['id'], '" name="attach_del[]" value="', $attachment['id'], '"', empty($attachment['unchecked']) ? ' checked="checked"' : '', ' class="input_check" /> ', $attachment['name'], (empty($attachment['approved']) ? ' (' . $txt['awaiting_approval'] . ')' : ''),
  355. !empty($modSettings['attachmentPostLimit']) || !empty($modSettings['attachmentSizeLimit']) ? sprintf($txt['attach_kb'], comma_format(round(max($attachment['size'], 1028) / 1028), 0)) : '', '</label>
  356. </dd>';
  357. if (!empty($context['files_in_session_warning']))
  358. echo '
  359. <dd class="smalltext">', $context['files_in_session_warning'], '</dd>';
  360. echo '
  361. </dl>';
  362. }
  363. // Is the user allowed to post any additional ones? If so give them the boxes to do it!
  364. if ($context['can_post_attachment'])
  365. {
  366. echo '
  367. <dl id="postAttachment2">';
  368. // But, only show them if they haven't reached a limit. Or a mod author hasn't hidden them.
  369. if ($context['num_allowed_attachments'] > 0 || !empty($context['dont_show_them']))
  370. {
  371. echo '
  372. <dt>
  373. ', $txt['attach'], ':
  374. </dt>
  375. <dd class="smalltext">
  376. ', empty($modSettings['attachmentSizeLimit']) ? '' : ('<input type="hidden" name="MAX_FILE_SIZE" value="' . $modSettings['attachmentSizeLimit'] * 1028 . '" />'), '
  377. <input type="file" size="60" name="attachment[]" id="attachment1" class="input_file" /> (<a href="javascript:void(0);" onclick="cleanFileInput(\'attachment1\');">', $txt['clean_attach'], '</a>)';
  378. // Show more boxes if they aren't approaching that limit.
  379. if ($context['num_allowed_attachments'] > 1)
  380. echo '
  381. <script type="text/javascript"><!-- // --><![CDATA[
  382. var allowed_attachments = ', $context['num_allowed_attachments'], ';
  383. var current_attachment = 1;
  384. function addAttachment()
  385. {
  386. allowed_attachments = allowed_attachments - 1;
  387. current_attachment = current_attachment + 1;
  388. if (allowed_attachments <= 0)
  389. return alert("', $txt['more_attachments_error'], '");
  390. setOuterHTML(document.getElementById("moreAttachments"), \'<dd class="smalltext"><input type="file" size="60" name="attachment[]" id="attachment\' + current_attachment + \'" class="input_file" /> (<a href="javascript:void(0);" onclick="cleanFileInput(\\\'attachment\' + current_attachment + \'\\\');">', $txt['clean_attach'], '<\/a>)\' + \'<\/dd><dd class="smalltext" id="moreAttachments"><a href="#" onclick="addAttachment(); return false;">(', $txt['more_attachments'], ')<\' + \'/a><\' + \'/dd>\');
  391. return true;
  392. }
  393. // ]]></script>
  394. </dd>
  395. <dd class="smalltext" id="moreAttachments"><a href="#" onclick="addAttachment(); return false;">(', $txt['more_attachments'], ')</a></dd>';
  396. else
  397. echo '
  398. </dd>';
  399. }
  400. // Add any template changes for an alternative upload system here.
  401. call_integration_hook('integrate_upload_template');
  402. echo '
  403. <dd class="smalltext">';
  404. // Show some useful information such as allowed extensions, maximum size and amount of attachments allowed.
  405. if (!empty($modSettings['attachmentCheckExtensions']))
  406. echo '
  407. ', $txt['allowed_types'], ': ', $context['allowed_extensions'], '<br />';
  408. if (!empty($context['attachment_restrictions']))
  409. echo '
  410. ', $txt['attach_restrictions'], ' ', implode(', ', $context['attachment_restrictions']), '<br />';
  411. if ($context['num_allowed_attachments'] == 0)
  412. echo '
  413. ', $txt['attach_limit_nag'], '<br />';
  414. if (!$context['can_post_attachment_unapproved'])
  415. echo '
  416. <span class="alert">', $txt['attachment_requires_approval'], '</span>', '<br />';
  417. echo '
  418. </dd>
  419. </dl>';
  420. }
  421. // Is visual verification enabled?
  422. if ($context['require_verification'])
  423. {
  424. echo '
  425. <div class="post_verification">
  426. <span', !empty($context['post_error']['need_qr_verification']) ? ' class="error"' : '', '>
  427. <strong>', $txt['verification'], ':</strong>
  428. </span>
  429. ', template_control_verification($context['visual_verification_id'], 'all'), '
  430. </div>';
  431. }
  432. // Finally, the submit buttons.
  433. echo '
  434. <hr class="hrcolor" />
  435. <span class="smalltext" >
  436. ', isBrowser('is_firefox') ? $txt['shortcuts_firefox'] : $txt['shortcuts'], '
  437. </span>
  438. <span id="post_confirm_buttons">
  439. ', template_control_richedit_buttons($context['post_box_name']);
  440. // Option to delete an event if user is editing one.
  441. if ($context['make_event'] && !$context['event']['new'])
  442. echo '
  443. <input type="submit" name="deleteevent" value="', $txt['event_delete'], '" onclick="return confirm(\'', $txt['event_delete_confirm'], '\');" class="button_submit" />';
  444. echo '
  445. </span>
  446. <br class="clear_right" />
  447. </div>
  448. </div>
  449. <br class="clear" />';
  450. // Assuming this isn't a new topic pass across the last message id.
  451. if (isset($context['topic_last_message']))
  452. echo '
  453. <input type="hidden" name="last_msg" value="', $context['topic_last_message'], '" />';
  454. echo '
  455. <input type="hidden" name="additional_options" id="additional_options" value="', $context['show_additional_options'] ? '1' : '0', '" />
  456. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  457. <input type="hidden" name="seqnum" value="', $context['form_sequence_number'], '" />
  458. </form>';
  459. echo '
  460. <script type="text/javascript"><!-- // --><![CDATA[';
  461. // The functions used to preview a posts without loading a new page.
  462. echo '
  463. var current_board = ', empty($context['current_board']) ? 'null' : $context['current_board'], ';
  464. var make_poll = ', $context['make_poll'] ? 'true' : 'false', ';
  465. var txt_preview_title = "', $txt['preview_title'], '";
  466. var txt_preview_fetch = "', $txt['preview_fetch'], '";
  467. var new_replies = new Array();
  468. var reply_counter = ', empty($counter) ? 0 : $counter, ';
  469. function previewPost()
  470. {';
  471. if (isBrowser('is_firefox'))
  472. echo '
  473. // Firefox doesn\'t render <marquee> that have been put it using javascript
  474. if (document.forms.postmodify.elements[', JavaScriptEscape($context['post_box_name']), '].value.indexOf(\'[move]\') != -1)
  475. {
  476. return submitThisOnce(document.forms.postmodify);
  477. }';
  478. echo '
  479. if (window.XMLHttpRequest)
  480. {
  481. // Opera didn\'t support setRequestHeader() before 8.01.
  482. if (\'opera\' in window)
  483. {
  484. var test = new XMLHttpRequest();
  485. if (!(\'setRequestHeader\' in test))
  486. return submitThisOnce(document.forms.postmodify);
  487. }
  488. // @todo Currently not sending poll options and option checkboxes.
  489. var x = new Array();
  490. var textFields = [\'subject\', ', JavaScriptEscape($context['post_box_name']), ', ', JavaScriptEscape($context['session_var']), ', \'icon\', \'guestname\', \'email\', \'evtitle\', \'question\', \'topic\'];
  491. var numericFields = [
  492. \'board\', \'topic\', \'last_msg\',
  493. \'eventid\', \'calendar\', \'year\', \'month\', \'day\',
  494. \'poll_max_votes\', \'poll_expire\', \'poll_change_vote\', \'poll_hide\'
  495. ];
  496. var checkboxFields = [
  497. \'ns\'
  498. ];
  499. for (var i = 0, n = textFields.length; i < n; i++)
  500. if (textFields[i] in document.forms.postmodify)
  501. {
  502. // Handle the WYSIWYG editor.
  503. if (textFields[i] == ', JavaScriptEscape($context['post_box_name']), ' && $("#', $context['post_box_name'], '").data("sceditor") != undefined)
  504. x[x.length] = textFields[i] + \'=\' + $("#', $context['post_box_name'], '").data("sceditor").getText().replace(/&#/g, \'&#38;#\').php_to8bit().php_urlencode();
  505. else
  506. x[x.length] = textFields[i] + \'=\' + document.forms.postmodify[textFields[i]].value.replace(/&#/g, \'&#38;#\').php_to8bit().php_urlencode();
  507. }
  508. for (var i = 0, n = numericFields.length; i < n; i++)
  509. if (numericFields[i] in document.forms.postmodify && \'value\' in document.forms.postmodify[numericFields[i]])
  510. x[x.length] = numericFields[i] + \'=\' + parseInt(document.forms.postmodify.elements[numericFields[i]].value);
  511. for (var i = 0, n = checkboxFields.length; i < n; i++)
  512. if (checkboxFields[i] in document.forms.postmodify && document.forms.postmodify.elements[checkboxFields[i]].checked)
  513. x[x.length] = checkboxFields[i] + \'=\' + document.forms.postmodify.elements[checkboxFields[i]].value;
  514. sendXMLDocument(smf_prepareScriptUrl(smf_scripturl) + \'action=post2\' + (current_board ? \';board=\' + current_board : \'\') + (make_poll ? \';poll\' : \'\') + \';preview;xml\', x.join(\'&\'), onDocSent);
  515. document.getElementById(\'preview_section\').style.display = \'\';
  516. setInnerHTML(document.getElementById(\'preview_subject\'), txt_preview_title);
  517. setInnerHTML(document.getElementById(\'preview_body\'), txt_preview_fetch);
  518. return false;
  519. }
  520. else
  521. return submitThisOnce(document.forms.postmodify);
  522. }
  523. function onDocSent(XMLDoc)
  524. {
  525. if (!XMLDoc)
  526. {
  527. document.forms.postmodify.preview.onclick = new function ()
  528. {
  529. return true;
  530. }
  531. document.forms.postmodify.preview.click();
  532. }
  533. // Show the preview section.
  534. var preview = XMLDoc.getElementsByTagName(\'smf\')[0].getElementsByTagName(\'preview\')[0];
  535. setInnerHTML(document.getElementById(\'preview_subject\'), preview.getElementsByTagName(\'subject\')[0].firstChild.nodeValue);
  536. var bodyText = \'\';
  537. for (var i = 0, n = preview.getElementsByTagName(\'body\')[0].childNodes.length; i < n; i++)
  538. bodyText += preview.getElementsByTagName(\'body\')[0].childNodes[i].nodeValue;
  539. setInnerHTML(document.getElementById(\'preview_body\'), bodyText);
  540. document.getElementById(\'preview_body\').className = \'post\';
  541. // Show a list of errors (if any).
  542. var errors = XMLDoc.getElementsByTagName(\'smf\')[0].getElementsByTagName(\'errors\')[0];
  543. var errorList = new Array();
  544. for (var i = 0, numErrors = errors.getElementsByTagName(\'error\').length; i < numErrors; i++)
  545. errorList[errorList.length] = errors.getElementsByTagName(\'error\')[i].firstChild.nodeValue;
  546. document.getElementById(\'errors\').style.display = numErrors == 0 ? \'none\' : \'\';
  547. document.getElementById(\'errors\').className = errors.getAttribute(\'serious\') == 1 ? \'errorbox\' : \'noticebox\';
  548. document.getElementById(\'error_serious\').style.display = numErrors == 0 ? \'none\' : \'\';
  549. setInnerHTML(document.getElementById(\'error_list\'), numErrors == 0 ? \'\' : errorList.join(\'<br />\'));
  550. // Show a warning if the topic has been locked.
  551. document.getElementById(\'lock_warning\').style.display = errors.getAttribute(\'topic_locked\') == 1 ? \'\' : \'none\';
  552. // Adjust the color of captions if the given data is erroneous.
  553. var captions = errors.getElementsByTagName(\'caption\');
  554. for (var i = 0, numCaptions = errors.getElementsByTagName(\'caption\').length; i < numCaptions; i++)
  555. if (document.getElementById(\'caption_\' + captions[i].getAttribute(\'name\')))
  556. document.getElementById(\'caption_\' + captions[i].getAttribute(\'name\')).className = captions[i].getAttribute(\'class\');
  557. if (errors.getElementsByTagName(\'post_error\').length == 1)
  558. document.forms.postmodify.', $context['post_box_name'], '.style.border = \'1px solid red\';
  559. else if (document.forms.postmodify.', $context['post_box_name'], '.style.borderColor == \'red\' || document.forms.postmodify.', $context['post_box_name'], '.style.borderColor == \'red red red red\')
  560. {
  561. if (\'runtimeStyle\' in document.forms.postmodify.', $context['post_box_name'], ')
  562. document.forms.postmodify.', $context['post_box_name'], '.style.borderColor = \'\';
  563. else
  564. document.forms.postmodify.', $context['post_box_name'], '.style.border = null;
  565. }
  566. // Set the new last message id.
  567. if (\'last_msg\' in document.forms.postmodify)
  568. document.forms.postmodify.last_msg.value = XMLDoc.getElementsByTagName(\'smf\')[0].getElementsByTagName(\'last_msg\')[0].firstChild.nodeValue;
  569. // Remove the new image from old-new replies!
  570. for (i = 0; i < new_replies.length; i++)
  571. document.getElementById(\'image_new_\' + new_replies[i]).style.display = \'none\';
  572. new_replies = new Array();
  573. var ignored_replies = new Array(), ignoring;
  574. var newPosts = XMLDoc.getElementsByTagName(\'smf\')[0].getElementsByTagName(\'new_posts\')[0] ? XMLDoc.getElementsByTagName(\'smf\')[0].getElementsByTagName(\'new_posts\')[0].getElementsByTagName(\'post\') : {length: 0};
  575. var numNewPosts = newPosts.length;
  576. if (numNewPosts != 0)
  577. {
  578. var newPostsHTML = \'<span id="new_replies"><\' + \'/span>\';
  579. for (var i = 0; i < numNewPosts; i++)
  580. {
  581. new_replies[new_replies.length] = newPosts[i].getAttribute("id");
  582. ignoring = false;
  583. if (newPosts[i].getElementsByTagName("is_ignored")[0].firstChild.nodeValue != 0)
  584. ignored_replies[ignored_replies.length] = ignoring = newPosts[i].getAttribute("id");
  585. newPostsHTML += \'<div class="windowbg\' + (++reply_counter % 2 == 0 ? \'2\' : \'\') + \' core_posts"><div class="content" id="msg\' + newPosts[i].getAttribute("id") + \'"><div class="floatleft"><h5>', $txt['posted_by'], ': \' + newPosts[i].getElementsByTagName("poster")[0].firstChild.nodeValue + \'</h5><span class="smalltext">&#171;&nbsp;<strong>', $txt['on'], ':</strong> \' + newPosts[i].getElementsByTagName("time")[0].firstChild.nodeValue + \'&nbsp;&#187;</span> <span class="new_posts" id="image_new_\' + newPosts[i].getAttribute("id") + \'">', $txt['new'], '</span></div>\';';
  586. if ($context['can_quote'])
  587. echo '
  588. newPostsHTML += \'<ul class="reset smalltext quickbuttons" id="msg_\' + newPosts[i].getAttribute("id") + \'_quote"><li><a href="#postmodify" onclick="return insertQuoteFast(\\\'\' + newPosts[i].getAttribute("id") + \'\\\');" class="quote_button"><span>',$txt['bbc_quote'],'</span><\' + \'/a></li></ul>\';';
  589. echo '
  590. newPostsHTML += \'<br class="clear" />\';
  591. if (ignoring)
  592. newPostsHTML += \'<div id="msg_\' + newPosts[i].getAttribute("id") + \'_ignored_prompt" class="smalltext">', $txt['ignoring_user'], '<a href="#" id="msg_\' + newPosts[i].getAttribute("id") + \'_ignored_link" style="display: none;">', $txt['show_ignore_user_post'], '</a></div>\';
  593. newPostsHTML += \'<div class="list_posts smalltext" id="msg_\' + newPosts[i].getAttribute("id") + \'_body">\' + newPosts[i].getElementsByTagName("message")[0].firstChild.nodeValue + \'<\' + \'/div></div></div>\';
  594. }
  595. setOuterHTML(document.getElementById(\'new_replies\'), newPostsHTML);
  596. }
  597. var numIgnoredReplies = ignored_replies.length;
  598. if (numIgnoredReplies != 0)
  599. {
  600. for (var i = 0; i < numIgnoredReplies; i++)
  601. {
  602. aIgnoreToggles[ignored_replies[i]] = new smc_Toggle({
  603. bToggleEnabled: true,
  604. bCurrentlyCollapsed: true,
  605. aSwappableContainers: [
  606. \'msg_\' + ignored_replies[i] + \'_body\',
  607. \'msg_\' + ignored_replies[i] + \'_quote\',
  608. ],
  609. aSwapLinks: [
  610. {
  611. sId: \'msg_\' + ignored_replies[i] + \'_ignored_link\',
  612. msgExpanded: \'\',
  613. msgCollapsed: ', JavaScriptEscape($txt['show_ignore_user_post']), '
  614. }
  615. ]
  616. });
  617. }
  618. }
  619. location.hash = \'#\' + \'preview_section\';
  620. if (typeof(smf_codeFix) != \'undefined\')
  621. smf_codeFix();
  622. }';
  623. // Code for showing and hiding additional options.
  624. if (!empty($settings['additional_options_collapsable']))
  625. echo '
  626. var oSwapAdditionalOptions = new smc_Toggle({
  627. bToggleEnabled: true,
  628. bCurrentlyCollapsed: ', $context['show_additional_options'] ? 'false' : 'true', ',
  629. funcOnBeforeCollapse: function () {
  630. document.getElementById(\'additional_options\').value = \'0\';
  631. },
  632. funcOnBeforeExpand: function () {
  633. document.getElementById(\'additional_options\').value = \'1\';
  634. },
  635. aSwappableContainers: [
  636. \'postMoreOptions\',
  637. \'postAttachment\',
  638. \'postAttachment2\',
  639. \'postAttachment3\'
  640. ],
  641. aSwapImages: [
  642. {
  643. sId: \'postMoreExpand\',
  644. srcExpanded: smf_images_url + \'/collapse.png\',
  645. altExpanded: \'-\',
  646. srcCollapsed: smf_images_url + \'/expand.png\',
  647. altCollapsed: \'+\'
  648. }
  649. ],
  650. aSwapLinks: [
  651. {
  652. sId: \'postMoreExpandLink\',
  653. msgExpanded: ', JavaScriptEscape($context['can_post_attachment'] ? $txt['post_additionalopt_attach'] : $txt['post_additionalopt']), ',
  654. msgCollapsed: ', JavaScriptEscape($context['can_post_attachment'] ? $txt['post_additionalopt_attach'] : $txt['post_additionalopt']), '
  655. }
  656. ]
  657. });';
  658. echo '
  659. // ]]></script>';
  660. // If the user is replying to a topic show the previous posts.
  661. if (isset($context['previous_posts']) && count($context['previous_posts']) > 0)
  662. {
  663. echo '
  664. <div id="recent" class="flow_hidden main_section">
  665. <div class="cat_bar">
  666. <h3 class="catbg">', $txt['topic_summary'], '</h3>
  667. </div>
  668. <span id="new_replies"></span>';
  669. $ignored_posts = array();
  670. foreach ($context['previous_posts'] as $post)
  671. {
  672. $ignoring = false;
  673. if (!empty($post['is_ignored']))
  674. $ignored_posts[] = $ignoring = $post['id'];
  675. echo '
  676. <div class="', $post['alternate'] == 0 ? 'windowbg' : 'windowbg2', ' core_posts">
  677. <div class="content" id="msg', $post['id'], '">
  678. <div class="floatleft">
  679. <h5>', $txt['posted_by'], ': ', $post['poster'], '</h5>
  680. <span class="smalltext">&#171;&nbsp;<strong>', $txt['on'], ':</strong> ', $post['time'], '&nbsp;&#187;</span>
  681. </div>';
  682. if ($context['can_quote'])
  683. {
  684. echo '
  685. <ul class="reset smalltext quickbuttons" id="msg_', $post['id'], '_quote">
  686. <li><a href="#postmodify" onclick="return insertQuoteFast(', $post['id'], ');" class="quote_button"><span>',$txt['bbc_quote'],'</span></a></li>
  687. </ul>';
  688. }
  689. echo '
  690. <br class="clear" />';
  691. if ($ignoring)
  692. {
  693. echo '
  694. <div id="msg_', $post['id'], '_ignored_prompt" class="smalltext">
  695. ', $txt['ignoring_user'], '
  696. <a href="#" id="msg_', $post['id'], '_ignored_link" style="display: none;">', $txt['show_ignore_user_post'], '</a>
  697. </div>';
  698. }
  699. echo '
  700. <div class="list_posts smalltext" id="msg_', $post['id'], '_body">', $post['message'], '</div>
  701. </div>
  702. </div>';
  703. }
  704. echo '
  705. </div>
  706. <script type="text/javascript"><!-- // --><![CDATA[
  707. var aIgnoreToggles = new Array();';
  708. foreach ($ignored_posts as $post_id)
  709. {
  710. echo '
  711. aIgnoreToggles[', $post_id, '] = new smc_Toggle({
  712. bToggleEnabled: true,
  713. bCurrentlyCollapsed: true,
  714. aSwappableContainers: [
  715. \'msg_', $post_id, '_body\',
  716. \'msg_', $post_id, '_quote\',
  717. ],
  718. aSwapLinks: [
  719. {
  720. sId: \'msg_', $post_id, '_ignored_link\',
  721. msgExpanded: \'\',
  722. msgCollapsed: ', JavaScriptEscape($txt['show_ignore_user_post']), '
  723. }
  724. ]
  725. });';
  726. }
  727. echo '
  728. function insertQuoteFast(messageid)
  729. {
  730. if (window.XMLHttpRequest)
  731. getXMLDocument(smf_prepareScriptUrl(smf_scripturl) + \'action=quotefast;quote=\' + messageid + \';xml;pb=', $context['post_box_name'], ';mode=0\', onDocReceived);
  732. else
  733. reqWin(smf_prepareScriptUrl(smf_scripturl) + \'action=quotefast;quote=\' + messageid + \';pb=', $context['post_box_name'], ';mode=0\', 240, 90);
  734. return true;
  735. }
  736. function onDocReceived(XMLDoc)
  737. {
  738. var text = \'\';
  739. for (var i = 0, n = XMLDoc.getElementsByTagName(\'quote\')[0].childNodes.length; i < n; i++)
  740. text += XMLDoc.getElementsByTagName(\'quote\')[0].childNodes[i].nodeValue;
  741. $("#', $context['post_box_name'], '").data("sceditor").InsertText(text);
  742. }
  743. function onReceiveOpener(text)
  744. {
  745. $("#', $context['post_box_name'], '").data("sceditor").InsertText(text);
  746. }
  747. // ]]></script>';
  748. }
  749. }
  750. // The template for the spellchecker.
  751. function template_spellcheck()
  752. {
  753. global $context, $settings, $options, $txt;
  754. // The style information that makes the spellchecker look... like the forum hopefully!
  755. echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  756. <html xmlns="http://www.w3.org/1999/xhtml"', $context['right_to_left'] ? ' dir="rtl"' : '', '>
  757. <head>
  758. <title>', $txt['spell_check'], '</title>
  759. <meta http-equiv="Content-Type" content="text/html; charset=', $context['character_set'], '" />
  760. <link rel="stylesheet" type="text/css" href="', $settings['theme_url'], '/css/index', $context['theme_variant'], '.css?alp21" />
  761. <style type="text/css">
  762. body, td
  763. {
  764. font-size: small;
  765. margin: 0;
  766. background: #f0f0f0;
  767. color: #000;
  768. padding: 10px;
  769. }
  770. .highlight
  771. {
  772. color: red;
  773. font-weight: bold;
  774. }
  775. #spellview
  776. {
  777. border-style: outset;
  778. border: 1px solid black;
  779. padding: 5px;
  780. width: 95%;
  781. height: 314px;
  782. overflow: auto;
  783. background: #ffffff;
  784. }';
  785. // As you may expect - we need a lot of javascript for this... load it form the separate files.
  786. echo '
  787. </style>
  788. <script type="text/javascript"><!-- // --><![CDATA[
  789. var spell_formname = window.opener.spell_formname;
  790. var spell_fieldname = window.opener.spell_fieldname;
  791. // ]]></script>
  792. <script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/spellcheck.js"></script>
  793. <script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/script.js"></script>
  794. <script type="text/javascript"><!-- // --><![CDATA[
  795. ', $context['spell_js'], '
  796. // ]]></script>
  797. </head>
  798. <body onload="nextWord(false);">
  799. <form action="#" method="post" accept-charset="', $context['character_set'], '" name="spellingForm" id="spellingForm" onsubmit="return false;" style="margin: 0;">
  800. <div id="spellview">&nbsp;</div>
  801. <table border="0" cellpadding="4" cellspacing="0" width="100%"><tr class="windowbg">
  802. <td width="50%" valign="top">
  803. ', $txt['spellcheck_change_to'], '<br />
  804. <input type="text" name="changeto" style="width: 98%;" class="input_text" />
  805. </td>
  806. <td width="50%">
  807. ', $txt['spellcheck_suggest'], '<br />
  808. <select name="suggestions" style="width: 98%;" size="5" onclick="if (this.selectedIndex != -1) this.form.changeto.value = this.options[this.selectedIndex].text;" ondblclick="replaceWord();">
  809. </select>
  810. </td>
  811. </tr></table>
  812. <div class="righttext" style="padding: 4px;">
  813. <input type="button" name="change" value="', $txt['spellcheck_change'], '" onclick="replaceWord();" class="button_submit" />
  814. <input type="button" name="changeall" value="', $txt['spellcheck_change_all'], '" onclick="replaceAll();" class="button_submit" />
  815. <input type="button" name="ignore" value="', $txt['spellcheck_ignore'], '" onclick="nextWord(false);" class="button_submit" />
  816. <input type="button" name="ignoreall" value="', $txt['spellcheck_ignore_all'], '" onclick="nextWord(true);" class="button_submit" />
  817. </div>
  818. </form>
  819. </body>
  820. </html>';
  821. }
  822. function template_quotefast()
  823. {
  824. global $context, $settings, $options, $txt;
  825. echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  826. <html xmlns="http://www.w3.org/1999/xhtml"', $context['right_to_left'] ? ' dir="rtl"' : '', '>
  827. <head>
  828. <meta http-equiv="Content-Type" content="text/html; charset=', $context['character_set'], '" />
  829. <title>', $txt['retrieving_quote'], '</title>
  830. <script type="text/javascript" src="', $settings['default_theme_url'], '/scripts/script.js"></script>
  831. </head>
  832. <body>
  833. ', $txt['retrieving_quote'], '
  834. <div id="temporary_posting_area" style="display: none;"></div>
  835. <script type="text/javascript"><!-- // --><![CDATA[';
  836. if ($context['close_window'])
  837. echo '
  838. window.close();';
  839. else
  840. {
  841. // Lucky for us, Internet Explorer has an "innerText" feature which basically converts entities <--> text. Use it if possible ;).
  842. echo '
  843. var quote = \'', $context['quote']['text'], '\';
  844. var stage = \'createElement\' in document ? document.createElement("DIV") : document.getElementById("temporary_posting_area");
  845. if (\'DOMParser\' in window && !(\'opera\' in window))
  846. {
  847. var xmldoc = new DOMParser().parseFromString("<temp>" + \'', $context['quote']['mozilla'], '\'.replace(/\n/g, "_SMF-BREAK_").replace(/\t/g, "_SMF-TAB_") + "</temp>", "text/xml");
  848. quote = xmldoc.childNodes[0].textContent.replace(/_SMF-BREAK_/g, "\n").replace(/_SMF-TAB_/g, "\t");
  849. }
  850. else if (\'innerText\' in stage)
  851. {
  852. setInnerHTML(stage, quote.replace(/\n/g, "_SMF-BREAK_").replace(/\t/g, "_SMF-TAB_").replace(/</g, "&lt;").replace(/>/g, "&gt;"));
  853. quote = stage.innerText.replace(/_SMF-BREAK_/g, "\n").replace(/_SMF-TAB_/g, "\t");
  854. }
  855. if (\'opera\' in window)
  856. quote = quote.replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, \'"\').replace(/&amp;/g, "&");
  857. window.opener.onReceiveOpener(quote);
  858. window.focus();
  859. setTimeout("window.close();", 400);';
  860. }
  861. echo '
  862. // ]]></script>
  863. </body>
  864. </html>';
  865. }
  866. function template_announce()
  867. {
  868. global $context, $settings, $options, $txt, $scripturl;
  869. echo '
  870. <div id="announcement">
  871. <form action="', $scripturl, '?action=announce;sa=send" method="post" accept-charset="', $context['character_set'], '">
  872. <div class="cat_bar">
  873. <h3 class="catbg">', $txt['announce_title'], '</h3>
  874. </div>
  875. <div class="information">
  876. ', $txt['announce_desc'], '
  877. </div>
  878. <div class="windowbg2">
  879. <div class="content">
  880. <p>
  881. ', $txt['announce_this_topic'], ' <a href="', $scripturl, '?topic=', $context['current_topic'], '.0">', $context['topic_subject'], '</a>
  882. </p>
  883. <ul class="reset">';
  884. foreach ($context['groups'] as $group)
  885. echo '
  886. <li>
  887. <label for="who_', $group['id'], '"><input type="checkbox" name="who[', $group['id'], ']" id="who_', $group['id'], '" value="', $group['id'], '" checked="checked" class="input_check" /> ', $group['name'], '</label> <em>(', $group['member_count'], ')</em>
  888. </li>';
  889. echo '
  890. <li>
  891. <label for="checkall"><input type="checkbox" id="checkall" class="input_check" onclick="invertAll(this, this.form);" checked="checked" /> <em>', $txt['check_all'], '</em></label>
  892. </li>
  893. </ul>
  894. <hr class="hrcolor" />
  895. <div id="confirm_buttons">
  896. <input type="submit" value="', $txt['post'], '" class="button_submit" />
  897. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  898. <input type="hidden" name="topic" value="', $context['current_topic'], '" />
  899. <input type="hidden" name="move" value="', $context['move'], '" />
  900. <input type="hidden" name="goback" value="', $context['go_back'], '" />
  901. </div>
  902. </div>
  903. <br class="clear_right" />
  904. </div>
  905. </form>
  906. </div>
  907. <br />';
  908. }
  909. function template_announcement_send()
  910. {
  911. global $context, $settings, $options, $txt, $scripturl;
  912. echo '
  913. <div id="announcement">
  914. <form action="' . $scripturl . '?action=announce;sa=send" method="post" accept-charset="', $context['character_set'], '" name="autoSubmit" id="autoSubmit">
  915. <div class="windowbg2">
  916. <div class="content">
  917. <p>', $txt['announce_sending'], ' <a href="', $scripturl, '?topic=', $context['current_topic'], '.0" target="_blank" class="new_win">', $context['topic_subject'], '</a></p>
  918. <div class="progress_bar">
  919. <div class="full_bar">', $context['percentage_done'], '% ', $txt['announce_done'], '</div>
  920. <div class="green_percent" style="width: ', $context['percentage_done'], '%;">&nbsp;</div>
  921. </div>
  922. <hr class="hrcolor" />
  923. <div id="confirm_buttons">
  924. <input type="submit" name="b" value="', $txt['announce_continue'], '" class="button_submit" />
  925. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  926. <input type="hidden" name="topic" value="', $context['current_topic'], '" />
  927. <input type="hidden" name="move" value="', $context['move'], '" />
  928. <input type="hidden" name="goback" value="', $context['go_back'], '" />
  929. <input type="hidden" name="start" value="', $context['start'], '" />
  930. <input type="hidden" name="membergroups" value="', $context['membergroups'], '" />
  931. </div>
  932. </div>
  933. <br class="clear_right" />
  934. </div>
  935. </form>
  936. </div>
  937. <br />
  938. <script type="text/javascript"><!-- // --><![CDATA[
  939. var countdown = 2;
  940. doAutoSubmit();
  941. function doAutoSubmit()
  942. {
  943. if (countdown == 0)
  944. document.forms.autoSubmit.submit();
  945. else if (countdown == -1)
  946. return;
  947. document.forms.autoSubmit.b.value = "', $txt['announce_continue'], ' (" + countdown + ")";
  948. countdown--;
  949. setTimeout("doAutoSubmit();", 1000);
  950. }
  951. // ]]></script>';
  952. }
  953. ?>