Post.template.php 47 KB

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