Display.template.php 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947
  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. function template_main()
  13. {
  14. global $context, $settings, $options, $txt, $scripturl, $modSettings;
  15. // Let them know, if their report was a success!
  16. if ($context['report_sent'])
  17. {
  18. echo '
  19. <div class="infobox">
  20. ', $txt['report_sent'], '
  21. </div>';
  22. }
  23. // Show the anchor for the top and for the first message. If the first message is new, say so.
  24. echo '
  25. <a id="msg', $context['first_message'], '"></a>', $context['first_new_message'] ? '<a id="new"></a>' : '';
  26. // Is this topic also a poll?
  27. if ($context['is_poll'])
  28. {
  29. echo '
  30. <div id="poll">
  31. <div class="cat_bar">
  32. <h3 class="catbg">
  33. <img src="', $settings['images_url'], '/topic/', $context['poll']['is_locked'] ? 'normal_poll_locked' : 'normal_poll', '.png" alt="" class="icon"> ', $txt['poll'], '
  34. </h3>
  35. </div>
  36. <div class="windowbg">
  37. <div class="content" id="poll_options">
  38. <h4 id="pollquestion">
  39. ', $context['poll']['question'], '
  40. </h4>';
  41. // Are they not allowed to vote but allowed to view the options?
  42. if ($context['poll']['show_results'] || !$context['allow_vote'])
  43. {
  44. echo '
  45. <dl class="options">';
  46. // Show each option with its corresponding percentage bar.
  47. foreach ($context['poll']['options'] as $option)
  48. {
  49. echo '
  50. <dt class="', $option['voted_this'] ? ' voted' : '', '">', $option['option'], '</dt>
  51. <dd class="statsbar', $option['voted_this'] ? ' voted' : '', '">';
  52. if ($context['allow_poll_view'])
  53. echo '
  54. ', $option['bar_ndt'], '
  55. <span class="percentage">', $option['votes'], ' (', $option['percent'], '%)</span>';
  56. echo '
  57. </dd>';
  58. }
  59. echo '
  60. </dl>';
  61. if ($context['allow_poll_view'])
  62. echo '
  63. <p><strong>', $txt['poll_total_voters'], ':</strong> ', $context['poll']['total_votes'], '</p>';
  64. }
  65. // They are allowed to vote! Go to it!
  66. else
  67. {
  68. echo '
  69. <form action="', $scripturl, '?action=vote;topic=', $context['current_topic'], '.', $context['start'], ';poll=', $context['poll']['id'], '" method="post" accept-charset="', $context['character_set'], '">';
  70. // Show a warning if they are allowed more than one option.
  71. if ($context['poll']['allowed_warning'])
  72. echo '
  73. <p class="smallpadding">', $context['poll']['allowed_warning'], '</p>';
  74. echo '
  75. <ul class="reset options">';
  76. // Show each option with its button - a radio likely.
  77. foreach ($context['poll']['options'] as $option)
  78. echo '
  79. <li>', $option['vote_button'], ' <label for="', $option['id'], '">', $option['option'], '</label></li>';
  80. echo '
  81. </ul>
  82. <div class="submitbutton">
  83. <input type="submit" value="', $txt['poll_vote'], '" class="button_submit">
  84. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
  85. </div>
  86. </form>';
  87. }
  88. // Is the clock ticking?
  89. if (!empty($context['poll']['expire_time']))
  90. echo '
  91. <p><strong>', ($context['poll']['is_expired'] ? $txt['poll_expired_on'] : $txt['poll_expires_on']), ':</strong> ', $context['poll']['expire_time'], '</p>';
  92. echo '
  93. </div>
  94. </div>
  95. </div>
  96. <div id="pollmoderation">';
  97. template_button_strip($context['poll_buttons']);
  98. echo '
  99. </div>';
  100. }
  101. // Does this topic have some events linked to it?
  102. if (!empty($context['linked_calendar_events']))
  103. {
  104. echo '
  105. <div class="linked_events">
  106. <div class="title_bar">
  107. <h3 class="titlebg headerpadding">', $txt['calendar_linked_events'], '</h3>
  108. </div>
  109. <div class="description">
  110. <div class="content">
  111. <ul class="reset">';
  112. foreach ($context['linked_calendar_events'] as $event)
  113. echo '
  114. <li>
  115. ', ($event['can_edit'] ? '<a href="' . $event['modify_href'] . '"> <img src="' . $settings['images_url'] . '/icons/calendar_modify.png" alt="" title="' . $txt['modify'] . '" class="edit_event"></a> ' : ''), '<strong>', $event['title'], '</strong>: ', $event['start_date'], ($event['start_date'] != $event['end_date'] ? ' - ' . $event['end_date'] : ''), '
  116. </li>';
  117. echo '
  118. </ul>
  119. </div>
  120. </div>
  121. </div>';
  122. }
  123. // Show the page index... "Pages: [1]".
  124. echo '
  125. <div class="pagesection">
  126. ', template_button_strip($context['normal_buttons'], 'right'), '
  127. ', $context['menu_separator'], '<a href="#bot" class="topbottom floatleft">', $txt['go_down'], '</a>
  128. <div class="pagelinks floatleft">
  129. ', $context['page_index'], '
  130. </div>
  131. </div>';
  132. // Show the topic information - icon, subject, etc.
  133. echo '
  134. <div id="forumposts">
  135. <div class="cat_bar">
  136. <h3 class="catbg">
  137. <img src="', $settings['images_url'], '/topic/', $context['class'], '.png" alt="">
  138. <span id="top_subject">', $txt['topic'], ': ', $context['subject'], '&nbsp;<span>(', $context['num_views_text'], ')</span></span>
  139. <span class="nextlinks floatright">', $context['previous_next'], '</span>
  140. </h3>
  141. </div>';
  142. if (!empty($settings['display_who_viewing']))
  143. {
  144. echo '
  145. <p id="whoisviewing">';
  146. // Show just numbers...?
  147. if ($settings['display_who_viewing'] == 1)
  148. echo count($context['view_members']), ' ', count($context['view_members']) == 1 ? $txt['who_member'] : $txt['members'];
  149. // Or show the actual people viewing the topic?
  150. else
  151. echo empty($context['view_members_list']) ? '0 ' . $txt['members'] : implode(', ', $context['view_members_list']) . ((empty($context['view_num_hidden']) || $context['can_moderate_forum']) ? '' : ' (+ ' . $context['view_num_hidden'] . ' ' . $txt['hidden'] . ')');
  152. // Now show how many guests are here too.
  153. echo $txt['who_and'], $context['view_num_guests'], ' ', $context['view_num_guests'] == 1 ? $txt['guest'] : $txt['guests'], $txt['who_viewing_topic'], '
  154. </p>';
  155. }
  156. echo '
  157. <form action="', $scripturl, '?action=quickmod2;topic=', $context['current_topic'], '.', $context['start'], '" method="post" accept-charset="', $context['character_set'], '" name="quickModForm" id="quickModForm" style="margin: 0;" onsubmit="return oQuickModify.bInEditMode ? oQuickModify.modifySave(\'' . $context['session_id'] . '\', \'' . $context['session_var'] . '\') : false">';
  158. $context['ignoredMsgs'] = array();
  159. $context['removableMessageIDs'] = array();
  160. // Get all the messages...
  161. while ($message = $context['get_message']())
  162. template_single_post($message);
  163. echo '
  164. </form>
  165. </div>';
  166. // Show the page index... "Pages: [1]".
  167. echo '
  168. <div class="pagesection">
  169. ', template_button_strip($context['normal_buttons'], 'right'), '
  170. ', $context['menu_separator'], '<a href="#main_content_section" class="topbottom floatleft">', $txt['go_up'], '</a>
  171. <div class="pagelinks floatleft">
  172. ', $context['page_index'], '
  173. </div>
  174. </div>';
  175. // Show the lower breadcrumbs.
  176. theme_linktree();
  177. echo '
  178. <div id="moderationbuttons">', template_button_strip($context['mod_buttons'], 'bottom', array('id' => 'moderationbuttons_strip')), '</div>';
  179. // Show the jumpto box, or actually...let Javascript do it.
  180. echo '
  181. <div class="plainbox" id="display_jump_to">&nbsp;</div>';
  182. if ($context['can_reply'])
  183. {
  184. echo '
  185. <a id="quickreply"></a>
  186. <div class="tborder" id="quickreplybox">
  187. <div class="cat_bar">
  188. <h3 class="catbg">
  189. ', $txt['quick_reply'], '
  190. </h3>
  191. </div>
  192. <div id="quickReplyOptions">
  193. <div class="roundframe">
  194. <p class="smalltext lefttext">', $txt['quick_reply_desc'], '</p>
  195. ', $context['is_locked'] ? '<p class="alert smalltext">' . $txt['quick_reply_warning'] . '</p>' : '',
  196. $context['oldTopicError'] ? '<p class="alert smalltext">' . sprintf($txt['error_old_topic'], $modSettings['oldTopicDays']) . '</p>' : '', '
  197. ', $context['can_reply_approved'] ? '' : '<em>' . $txt['wait_for_approval'] . '</em>', '
  198. ', !$context['can_reply_approved'] && $context['require_verification'] ? '<br>' : '', '
  199. <form action="', $scripturl, '?board=', $context['current_board'], ';action=post2" method="post" accept-charset="', $context['character_set'], '" name="postmodify" id="postmodify" onsubmit="submitonce(this);">
  200. <input type="hidden" name="topic" value="', $context['current_topic'], '">
  201. <input type="hidden" name="subject" value="', $context['response_prefix'], $context['subject'], '">
  202. <input type="hidden" name="icon" value="xx">
  203. <input type="hidden" name="from_qr" value="1">
  204. <input type="hidden" name="notify" value="', $context['is_marked_notify'] || !empty($options['auto_notify']) ? '1' : '0', '">
  205. <input type="hidden" name="not_approved" value="', !$context['can_reply_approved'], '">
  206. <input type="hidden" name="goback" value="', empty($options['return_to_post']) ? '0' : '1', '">
  207. <input type="hidden" name="last_msg" value="', $context['topic_last_message'], '">
  208. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
  209. <input type="hidden" name="seqnum" value="', $context['form_sequence_number'], '">';
  210. // Guests just need more.
  211. if ($context['user']['is_guest'])
  212. echo '
  213. <strong>', $txt['name'], ':</strong> <input type="text" name="guestname" value="', $context['name'], '" size="25" class="input_text" tabindex="', $context['tabindex']++, '">
  214. <strong>', $txt['email'], ':</strong> <input type="text" name="email" value="', $context['email'], '" size="25" class="input_text" tabindex="', $context['tabindex']++, '"><br>';
  215. // Is visual verification enabled?
  216. if ($context['require_verification'])
  217. echo '
  218. <strong>', $txt['verification'], ':</strong>', template_control_verification($context['visual_verification_id'], 'quick_reply'), '<br>';
  219. // Using the full editor
  220. if (empty($options['use_editor_quick_reply']))
  221. {
  222. echo '
  223. <div class="quickReplyContent">
  224. <textarea cols="600" rows="7" name="message" tabindex="', $context['tabindex']++, '"></textarea>
  225. </div>';
  226. }
  227. else
  228. {
  229. // Show the actual posting area...
  230. if ($context['show_bbc'])
  231. {
  232. echo '
  233. <div id="bbcBox_message"></div>';
  234. }
  235. // What about smileys?
  236. if (!empty($context['smileys']['postform']) || !empty($context['smileys']['popup']))
  237. echo '
  238. <div id="smileyBox_message"></div>';
  239. echo '
  240. ', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message'), '
  241. <script><!-- // --><![CDATA[
  242. function insertQuoteFast(messageid)
  243. {
  244. if (window.XMLHttpRequest)
  245. getXMLDocument(smf_prepareScriptUrl(smf_scripturl) + \'action=quotefast;quote=\' + messageid + \';xml;pb=', $context['post_box_name'], ';mode=\' + (oEditorHandle_', $context['post_box_name'], '.bRichTextEnabled ? 1 : 0), onDocReceived);
  246. else
  247. reqWin(smf_prepareScriptUrl(smf_scripturl) + \'action=quotefast;quote=\' + messageid + \';pb=', $context['post_box_name'], ';mode=\' + (oEditorHandle_', $context['post_box_name'], '.bRichTextEnabled ? 1 : 0), 240, 90);
  248. return false;
  249. }
  250. function onDocReceived(XMLDoc)
  251. {
  252. var text = \'\';
  253. for (var i = 0, n = XMLDoc.getElementsByTagName(\'quote\')[0].childNodes.length; i < n; i++)
  254. text += XMLDoc.getElementsByTagName(\'quote\')[0].childNodes[i].nodeValue;
  255. oEditorHandle_', $context['post_box_name'], '.insertText(text, false, true);
  256. ajax_indicator(false);
  257. }
  258. // ]]></script>';
  259. }
  260. echo '
  261. <div class="padding">
  262. <input type="submit" name="post" value="', $txt['post'], '" onclick="return submitThisOnce(this);" accesskey="s" tabindex="', $context['tabindex']++, '" class="button_submit">
  263. <input type="submit" name="preview" value="', $txt['preview'], '" onclick="return submitThisOnce(this);" accesskey="p" tabindex="', $context['tabindex']++, '" class="button_submit">';
  264. if ($context['show_spellchecking'])
  265. echo '
  266. <input type="button" value="', $txt['spell_check'], '" onclick="spellCheck(\'postmodify\', \'message\');" tabindex="', $context['tabindex']++, '" class="button_submit">';
  267. if ($context['drafts_save'])
  268. echo '
  269. <input type="submit" name="save_draft" value="', $txt['draft_save'], '" onclick="return confirm(' . JavaScriptEscape($txt['draft_save_note']) . ') && submitThisOnce(this);" accesskey="d" tabindex="', $context['tabindex']++, '" class="button_submit">
  270. <input type="hidden" id="id_draft" name="id_draft" value="', empty($context['id_draft']) ? 0 : $context['id_draft'], '">';
  271. if (!empty($context['drafts_autosave']) && !empty($options['drafts_autosave_enabled']))
  272. echo '
  273. <div class="clear righttext padding"><span id="throbber" style="display:none"><img src="' . $settings['images_url'] . '/loading_sm.gif" alt="" class="centericon">&nbsp;</span><span id="draft_lastautosave" ></span></div>';
  274. echo '
  275. </div>
  276. </form>
  277. </div>
  278. </div>
  279. </div>';
  280. }
  281. else
  282. echo '
  283. <br class="clear">';
  284. // draft autosave available and the user has it enabled?
  285. if (!empty($context['drafts_autosave']) && !empty($options['drafts_autosave_enabled']))
  286. echo '
  287. <script><!-- // --><![CDATA[
  288. var oDraftAutoSave = new smf_DraftAutoSave({
  289. sSelf: \'oDraftAutoSave\',
  290. sLastNote: \'draft_lastautosave\',
  291. sLastID: \'id_draft\',', !empty($context['post_box_name']) ? '
  292. sSceditorID: \'' . $context['post_box_name'] . '\',' : '', '
  293. sType: \'', 'quick', '\',
  294. iBoard: ', (empty($context['current_board']) ? 0 : $context['current_board']), ',
  295. iFreq: ', (empty($modSettings['masterAutoSaveDraftsDelay']) ? 60000 : $modSettings['masterAutoSaveDraftsDelay'] * 1000), '
  296. });
  297. // ]]></script>';
  298. if ($context['show_spellchecking'])
  299. echo '
  300. <form action="', $scripturl, '?action=spellcheck" method="post" accept-charset="', $context['character_set'], '" name="spell_form" id="spell_form" target="spellWindow"><input type="hidden" name="spellstring" value=""></form>';
  301. echo '
  302. <script><!-- // --><![CDATA[';
  303. if (!empty($context['some_likes']))
  304. echo '
  305. add_like_popup();';
  306. echo '
  307. var oQuickReply = new QuickReply({
  308. bDefaultCollapsed: false,
  309. iTopicId: ', $context['current_topic'], ',
  310. iStart: ', $context['start'], ',
  311. sScriptUrl: smf_scripturl,
  312. sImagesUrl: smf_images_url,
  313. sContainerId: "quickReplyOptions",
  314. sImageId: "quickReplyExpand",
  315. sClassCollapsed: "toggle_up",
  316. sClassExpanded: "toggle_down",
  317. sJumpAnchor: "quickreply",
  318. bIsFull: ', !empty($options['use_editor_quick_reply']) ? 'true' : 'false', '
  319. });';
  320. if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && $context['can_remove_post'])
  321. echo '
  322. var oInTopicModeration = new InTopicModeration({
  323. sSelf: \'oInTopicModeration\',
  324. sCheckboxContainerMask: \'in_topic_mod_check_\',
  325. aMessageIds: [\'', implode('\', \'', $context['removableMessageIDs']), '\'],
  326. sSessionId: smf_session_id,
  327. sSessionVar: smf_session_var,
  328. sButtonStrip: \'moderationbuttons\',
  329. sButtonStripDisplay: \'moderationbuttons_strip\',
  330. bUseImageButton: false,
  331. bCanRemove: ', $context['can_remove_post'] ? 'true' : 'false', ',
  332. sRemoveButtonLabel: \'', $txt['quickmod_delete_selected'], '\',
  333. sRemoveButtonImage: \'delete_selected.png\',
  334. sRemoveButtonConfirm: \'', $txt['quickmod_confirm'], '\',
  335. bCanRestore: ', $context['can_restore_msg'] ? 'true' : 'false', ',
  336. sRestoreButtonLabel: \'', $txt['quick_mod_restore'], '\',
  337. sRestoreButtonImage: \'restore_selected.png\',
  338. sRestoreButtonConfirm: \'', $txt['quickmod_confirm'], '\',
  339. bCanSplit: ', $context['can_split'] ? 'true' : 'false', ',
  340. sSplitButtonLabel: \'', $txt['quickmod_split_selected'], '\',
  341. sSplitButtonImage: \'split_selected.png\',
  342. sSplitButtonConfirm: \'', $txt['quickmod_confirm'], '\',
  343. sFormId: \'quickModForm\'
  344. });';
  345. echo '
  346. if (\'XMLHttpRequest\' in window)
  347. {
  348. var oQuickModify = new QuickModify({
  349. sScriptUrl: smf_scripturl,
  350. sClassName: \'quick_edit\',
  351. bShowModify: ', $settings['show_modify'] ? 'true' : 'false', ',
  352. iTopicId: ', $context['current_topic'], ',
  353. sTemplateBodyEdit: ', JavaScriptEscape('
  354. <div id="quick_edit_body_container" style="width: 90%">
  355. <div id="error_box" style="padding: 4px;" class="error"></div>
  356. <textarea class="editor" name="message" rows="12" style="' . (isBrowser('is_ie8') ? 'width: 635px; max-width: 100%; min-width: 100%' : 'width: 100%') . '; margin-bottom: 10px;" tabindex="' . $context['tabindex']++ . '">%body%</textarea><br>
  357. <input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '">
  358. <input type="hidden" name="topic" value="' . $context['current_topic'] . '">
  359. <input type="hidden" name="msg" value="%msg_id%">
  360. <div class="righttext">
  361. <input type="submit" name="post" value="' . $txt['save'] . '" tabindex="' . $context['tabindex']++ . '" onclick="return oQuickModify.modifySave(\'' . $context['session_id'] . '\', \'' . $context['session_var'] . '\');" accesskey="s" class="button_submit">&nbsp;&nbsp;' . ($context['show_spellchecking'] ? '<input type="button" value="' . $txt['spell_check'] . '" tabindex="' . $context['tabindex']++ . '" onclick="spellCheck(\'quickModForm\', \'message\');" class="button_submit">&nbsp;&nbsp;' : '') . '<input type="submit" name="cancel" value="' . $txt['modify_cancel'] . '" tabindex="' . $context['tabindex']++ . '" onclick="return oQuickModify.modifyCancel();" class="button_submit">
  362. </div>
  363. </div>'), ',
  364. sTemplateSubjectEdit: ', JavaScriptEscape('<input type="text" style="width: 90%;" name="subject" value="%subject%" size="80" maxlength="80" tabindex="' . $context['tabindex']++ . '" class="input_text">'), ',
  365. sTemplateBodyNormal: ', JavaScriptEscape('%body%'), ',
  366. sTemplateSubjectNormal: ', JavaScriptEscape('<a href="' . $scripturl . '?topic=' . $context['current_topic'] . '.msg%msg_id%#msg%msg_id%" rel="nofollow">%subject%</a>'), ',
  367. sTemplateTopSubject: ', JavaScriptEscape($txt['topic'] . ': %subject% &nbsp;(' . $context['num_views_text'] . ')'), ',
  368. sTemplateReasonEdit: ', JavaScriptEscape('<input type="text" style="width: 90%;" name="modify_reason" value="%modify_reason%" size="80" maxlength="80" tabindex="' . $context['tabindex']++ . '" class="input_text">)'), ',
  369. sTemplateReasonNormal: ', JavaScriptEscape('%modify_text'), ',
  370. sErrorBorderStyle: ', JavaScriptEscape('1px solid red'), ($context['can_reply']) ? ',
  371. sFormRemoveAccessKeys: \'postmodify\'' : '', '
  372. });
  373. aJumpTo[aJumpTo.length] = new JumpTo({
  374. sContainerId: "display_jump_to",
  375. sJumpToTemplate: "<label class=\"smalltext\" for=\"%select_id%\">', $context['jump_to']['label'], ':<" + "/label> %dropdown_list%",
  376. iCurBoardId: ', $context['current_board'], ',
  377. iCurBoardChildLevel: ', $context['jump_to']['child_level'], ',
  378. sCurBoardName: "', $context['jump_to']['board_name'], '",
  379. sBoardChildLevelIndicator: "==",
  380. sBoardPrefix: "=> ",
  381. sCatSeparator: "-----------------------------",
  382. sCatPrefix: "",
  383. sGoButtonLabel: "', $txt['go'], '"
  384. });
  385. aIconLists[aIconLists.length] = new IconList({
  386. sBackReference: "aIconLists[" + aIconLists.length + "]",
  387. sIconIdPrefix: "msg_icon_",
  388. sScriptUrl: smf_scripturl,
  389. bShowModify: ', $settings['show_modify'] ? 'true' : 'false', ',
  390. iBoardId: ', $context['current_board'], ',
  391. iTopicId: ', $context['current_topic'], ',
  392. sSessionId: smf_session_id,
  393. sSessionVar: smf_session_var,
  394. sLabelIconList: "', $txt['message_icon'], '",
  395. sBoxBackground: "transparent",
  396. sBoxBackgroundHover: "#ffffff",
  397. iBoxBorderWidthHover: 1,
  398. sBoxBorderColorHover: "#adadad" ,
  399. sContainerBackground: "#ffffff",
  400. sContainerBorder: "1px solid #adadad",
  401. sItemBorder: "1px solid #ffffff",
  402. sItemBorderHover: "1px dotted gray",
  403. sItemBackground: "transparent",
  404. sItemBackgroundHover: "#e0e0f0"
  405. });
  406. }';
  407. if (!empty($context['ignoredMsgs']))
  408. echo '
  409. ignore_toggles([', implode(', ', $context['ignoredMsgs']), '], ', JavaScriptEscape($txt['show_ignore_user_post']), ');';
  410. echo '
  411. // ]]></script>';
  412. }
  413. function template_single_post($message, $force_alternate = null)
  414. {
  415. global $context, $settings, $options, $txt, $scripturl, $modSettings;
  416. static $alternate = false;
  417. if ($force_alternate !== null)
  418. $alternate = $force_alternate;
  419. $ignoring = false;
  420. if ($message['can_remove'])
  421. $context['removableMessageIDs'][] = $message['id'];
  422. // Are we ignoring this message?
  423. if (!empty($message['is_ignored']))
  424. {
  425. $ignoring = true;
  426. $context['ignoredMsgs'][] = $message['id'];
  427. }
  428. // Show the message anchor and a "new" anchor if this message is new.
  429. echo '
  430. <div class="', $message['approved'] ? ($message['alternate'] == 0 ? 'windowbg' : 'windowbg2') : 'approvebg', '">', $message['id'] != $context['first_message'] ? '
  431. <a id="msg' . $message['id'] . '"></a>' . ($message['first_new'] ? '<a id="new"></a>' : '') : '', '
  432. <div class="post_wrapper">';
  433. // Show information about the poster of this message.
  434. echo '
  435. <div class="poster">
  436. <h4>';
  437. // Show online and offline buttons?
  438. if (!empty($modSettings['onlineEnable']) && !$message['member']['is_guest'])
  439. echo '
  440. ', $context['can_send_pm'] ? '<a href="' . $message['member']['online']['href'] . '" title="' . $message['member']['online']['label'] . '">' : '', '<img src="', $message['member']['online']['image_href'], '" alt="', $message['member']['online']['text'], '">', $context['can_send_pm'] ? '</a>' : '';
  441. // Show a link to the member's profile.
  442. echo '
  443. ', $message['member']['link'], '
  444. </h4>';
  445. echo '
  446. <ul>';
  447. // Show the user's avatar.
  448. if (!empty($settings['show_user_images']) && empty($options['show_no_avatars']) && !empty($message['member']['avatar']['image']))
  449. echo '
  450. <li class="avatar">
  451. <a href="', $scripturl, '?action=profile;u=', $message['member']['id'], '">', $message['member']['avatar']['image'], '</a>
  452. </li>';
  453. // Show the post group icons, but not for guests.
  454. if (!$message['member']['is_guest'])
  455. echo '
  456. <li class="icons">', $message['member']['group_icons'], '</li>';
  457. // Show the member's primary group (like 'Administrator') if they have one.
  458. if (!empty($message['member']['group']))
  459. echo '
  460. <li class="membergroup">', $message['member']['group'], '</li>';
  461. // Show the member's custom title, if they have one.
  462. if (!empty($message['member']['title']))
  463. echo '
  464. <li class="title">', $message['member']['title'], '</li>';
  465. // Don't show these things for guests.
  466. if (!$message['member']['is_guest'])
  467. {
  468. // Show the post group if and only if they have no other group or the option is on, and they are in a post group.
  469. if ((empty($settings['hide_post_group']) || $message['member']['group'] == '') && $message['member']['post_group'] != '')
  470. echo '
  471. <li class="postgroup">', $message['member']['post_group'], '</li>';
  472. // Show how many posts they have made.
  473. if (!isset($context['disabled_fields']['posts']))
  474. echo '
  475. <li class="postcount">', $txt['member_postcount'], ': ', $message['member']['posts'], '</li>';
  476. // Is karma display enabled? Total or +/-?
  477. if ($modSettings['karmaMode'] == '1')
  478. echo '
  479. <li class="karma">', $modSettings['karmaLabel'], ' ', $message['member']['karma']['good'] - $message['member']['karma']['bad'], '</li>';
  480. elseif ($modSettings['karmaMode'] == '2')
  481. echo '
  482. <li class="karma">', $modSettings['karmaLabel'], ' +', $message['member']['karma']['good'], '/-', $message['member']['karma']['bad'], '</li>';
  483. // Is this user allowed to modify this member's karma?
  484. if ($message['member']['karma']['allow'])
  485. echo '
  486. <li class="karma_allow">
  487. <a href="', $scripturl, '?action=modifykarma;sa=applaud;uid=', $message['member']['id'], ';topic=', $context['current_topic'], '.' . $context['start'], ';m=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $modSettings['karmaApplaudLabel'], '</a>
  488. <a href="', $scripturl, '?action=modifykarma;sa=smite;uid=', $message['member']['id'], ';topic=', $context['current_topic'], '.', $context['start'], ';m=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $modSettings['karmaSmiteLabel'], '</a>
  489. </li>';
  490. // Show their personal text?
  491. if (!empty($settings['show_blurb']) && $message['member']['blurb'] != '')
  492. echo '
  493. <li class="blurb">', $message['member']['blurb'], '</li>';
  494. // Any custom fields to show as icons?
  495. if (!empty($message['member']['custom_fields']))
  496. {
  497. $shown = false;
  498. foreach ($message['member']['custom_fields'] as $custom)
  499. {
  500. if ($custom['placement'] != 1 || empty($custom['value']))
  501. continue;
  502. if (empty($shown))
  503. {
  504. $shown = true;
  505. echo '
  506. <li class="im_icons">
  507. <ol>';
  508. }
  509. echo '
  510. <li>', $custom['value'], '</li>';
  511. }
  512. if ($shown)
  513. echo '
  514. </ol>
  515. </li>';
  516. }
  517. // Show the website and email address buttons.
  518. if ($message['member']['show_profile_buttons'])
  519. {
  520. echo '
  521. <li class="profile">
  522. <ol class="profile_icons">';
  523. // Don't show an icon if they haven't specified a website.
  524. if ($message['member']['website']['url'] != '' && !isset($context['disabled_fields']['website']))
  525. echo '
  526. <li><a href="', $message['member']['website']['url'], '" title="' . $message['member']['website']['title'] . '" target="_blank" class="new_win">', ($settings['use_image_buttons'] ? '<span class="generic_icons www centericon" title="' . $message['member']['website']['title'] . '"></span>' : $txt['www']), '</a></li>';
  527. // Since we know this person isn't a guest, you *can* message them.
  528. if ($context['can_send_pm'])
  529. echo '
  530. <li><a href="', $scripturl, '?action=pm;sa=send;u=', $message['member']['id'], '" title="', $message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline'], '">', $settings['use_image_buttons'] ? '<span class="pm_icons im_' . ($message['member']['online']['is_online'] ? 'on' : 'off') . ' centericon" title="' . ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']) . '"></span>' : ($message['member']['online']['is_online'] ? $txt['pm_online'] : $txt['pm_offline']), '</a></li>';
  531. echo '
  532. </ol>
  533. </li>';
  534. }
  535. // Any custom fields for standard placement?
  536. if (!empty($message['member']['custom_fields']))
  537. {
  538. foreach ($message['member']['custom_fields'] as $custom)
  539. if (empty($custom['placement']) || empty($custom['value']))
  540. echo '
  541. <li class="custom">', $custom['title'], ': ', $custom['value'], '</li>';
  542. }
  543. }
  544. // Otherwise, show the guest's email.
  545. elseif (!empty($message['member']['email']) && $message['member']['show_email'])
  546. echo '
  547. <li class="email"><a href="mailto:' . $message['member']['email'] . '" rel="nofollow">', ($settings['use_image_buttons'] ? '<span class="generic_icons mail centericon" title="' . $txt['email'] . '"></span>' : $txt['email']), '</a></li>';
  548. // Show the IP to this user for this post - because you can moderate?
  549. if (!empty($context['can_moderate_forum']) && !empty($message['member']['ip']))
  550. echo '
  551. <li class="poster_ip"><a href="', $scripturl, '?action=', !empty($message['member']['is_guest']) ? 'trackip' : 'profile;area=tracking;sa=ip;u=' . $message['member']['id'], ';searchip=', $message['member']['ip'], '">', $message['member']['ip'], '</a> <a href="', $scripturl, '?action=helpadmin;help=see_admin_ip" onclick="return reqOverlayDiv(this.href);" class="help">(?)</a></li>';
  552. // Or, should we show it because this is you?
  553. elseif ($message['can_see_ip'])
  554. echo '
  555. <li class="poster_ip"><a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $message['member']['ip'], '</a></li>';
  556. // Okay, are you at least logged in? Then we can show something about why IPs are logged...
  557. elseif (!$context['user']['is_guest'])
  558. echo '
  559. <li class="poster_ip"><a href="', $scripturl, '?action=helpadmin;help=see_member_ip" onclick="return reqOverlayDiv(this.href);" class="help">', $txt['logged'], '</a></li>';
  560. // Otherwise, you see NOTHING!
  561. else
  562. echo '
  563. <li class="poster_ip">', $txt['logged'], '</li>';
  564. // Are we showing the warning status?
  565. // Don't show these things for guests.
  566. if (!$message['member']['is_guest'] && $message['member']['can_see_warning'])
  567. echo '
  568. <li class="warning">', $context['can_issue_warning'] ? '<a href="' . $scripturl . '?action=profile;area=issuewarning;u=' . $message['member']['id'] . '">' : '', '<img src="', $settings['images_url'], '/warning_', $message['member']['warning_status'], '.png" alt="', $txt['user_warn_' . $message['member']['warning_status']], '">', $context['can_issue_warning'] ? '</a>' : '', '<span class="warn_', $message['member']['warning_status'], '">', $txt['warn_' . $message['member']['warning_status']], '</span></li>';
  569. echo '
  570. </ul>';
  571. echo '
  572. </div>
  573. <div class="postarea">
  574. <div class="keyinfo">
  575. <div class="messageicon" ', ($message['icon_url'] !== $settings['images_url'] . '/post/xx.png') ? '' : 'style="position: absolute; z-index: -1;"', '>
  576. <img src="', $message['icon_url'] . '" alt=""', $message['can_modify'] ? ' id="msg_icon_' . $message['id'] . '"' : '', '>
  577. </div>';
  578. //Some people dont want subject ... The div is still required or quick edit breaks...
  579. echo '
  580. <div id="subject_', $message['id'], '" class="subject_title">', (empty($settings['subject_toggle']) ? '' : '<a href="' . $message['href'] . '" rel="nofollow">' . $message['subject'] . '</a>'), '</div>';
  581. echo '
  582. <div class="page_number floatright">
  583. ', !empty($message['counter']) ? ' #' . $message['counter'] : '', ' ', '
  584. </div>
  585. <h5>
  586. <a href="', $message['href'], '" rel="nofollow" title="', !empty($message['counter']) ? sprintf($txt['reply_number'], $message['counter']) : '', ' - ', $message['subject'], '" class="smalltext">', $message['time'], '</a>';
  587. // Show "<< Last Edit: Time by Person >>" if this post was edited. But we need the div even if it wasn't modified!
  588. // Because we insert into it through AJAX and we don't want to stop themers moving it around if they so wish so they can put it where they want it.
  589. echo '
  590. <span class="smalltext modified" id="modified_', $message['id'], '">';
  591. if ($settings['show_modify'] && !empty($message['modified']['name']))
  592. echo $message['modified']['last_edit_text'];
  593. echo '</span>';
  594. echo '
  595. </h5>
  596. <div id="msg_', $message['id'], '_quick_mod"', $ignoring ? ' style="display:none;"' : '', '></div>
  597. </div>';
  598. // Ignoring this user? Hide the post.
  599. if ($ignoring)
  600. echo '
  601. <div id="msg_', $message['id'], '_ignored_prompt">
  602. ', $txt['ignoring_user'], '
  603. <a href="#" id="msg_', $message['id'], '_ignored_link" style="display: none;">', $txt['show_ignore_user_post'], '</a>
  604. </div>';
  605. // Show the post itself, finally!
  606. echo '
  607. <div class="post">';
  608. if (!$message['approved'] && $message['member']['id'] != 0 && $message['member']['id'] == $context['user']['id'])
  609. echo '
  610. <div class="approve_post">
  611. ', $txt['post_awaiting_approval'], '
  612. </div>';
  613. echo '
  614. <div class="inner" id="msg_', $message['id'], '"', $ignoring ? ' style="display:none;"' : '', '>', $message['body'], '</div>
  615. </div>';
  616. // Assuming there are attachments...
  617. if (!empty($message['attachment']))
  618. {
  619. echo '
  620. <div id="msg_', $message['id'], '_footer" class="attachments"', $ignoring ? ' style="display:none;"' : '', '>';
  621. $last_approved_state = 1;
  622. $attachments_per_line = 4;
  623. $i = 0;
  624. foreach ($message['attachment'] as $attachment)
  625. {
  626. // Show a special box for unapproved attachments...
  627. if ($attachment['is_approved'] != $last_approved_state)
  628. {
  629. $last_approved_state = 0;
  630. echo '
  631. <fieldset>
  632. <legend>', $txt['attach_awaiting_approve'];
  633. if ($context['can_approve'])
  634. echo '
  635. &nbsp;[<a href="', $scripturl, '?action=attachapprove;sa=all;mid=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve_all'], '</a>]';
  636. echo '
  637. </legend>';
  638. }
  639. echo '
  640. <div class="floatleft">';
  641. if ($attachment['is_image'])
  642. {
  643. echo '
  644. <div class="attachments_top">';
  645. if ($attachment['thumbnail']['has_thumb'])
  646. echo '
  647. <a href="', $attachment['href'], ';image" id="link_', $attachment['id'], '" onclick="', $attachment['thumbnail']['javascript'], '"><img src="', $attachment['thumbnail']['href'], '" alt="" id="thumb_', $attachment['id'], '"></a>';
  648. else
  649. echo '
  650. <img src="' . $attachment['href'] . ';image" alt="" width="' . $attachment['width'] . '" height="' . $attachment['height'] . '"/>';
  651. echo '
  652. </div>';
  653. }
  654. echo '
  655. <div class="attachments_bot">
  656. <a href="' . $attachment['href'] . '"><img src="' . $settings['images_url'] . '/icons/clip.png" class="centericon" alt="*">&nbsp;' . $attachment['name'] . '</a> ';
  657. if (!$attachment['is_approved'] && $context['can_approve'])
  658. echo '
  659. [<a href="', $scripturl, '?action=attachapprove;sa=approve;aid=', $attachment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['approve'], '</a>]&nbsp;|&nbsp;[<a href="', $scripturl, '?action=attachapprove;sa=reject;aid=', $attachment['id'], ';', $context['session_var'], '=', $context['session_id'], '">', $txt['delete'], '</a>] ';
  660. echo '
  661. <br>', $attachment['size'], ($attachment['is_image'] ? ', ' . $attachment['real_width'] . 'x' . $attachment['real_height'] . '<br>' . sprintf($txt['attach_viewed'], $attachment['downloads']) : '<br>' . sprintf($txt['attach_downloaded'], $attachment['downloads'])), '
  662. </div>';
  663. echo '
  664. </div>';
  665. // Next attachment line ?
  666. if (++$i % $attachments_per_line === 0)
  667. echo '
  668. <hr>';
  669. }
  670. // If we had unapproved attachments clean up.
  671. if ($last_approved_state == 0)
  672. echo '
  673. </fieldset>';
  674. echo '
  675. </div>';
  676. }
  677. // And stuff below the attachments
  678. echo '
  679. <div class="under_message">';
  680. // Maybe they want to report this post to the moderator(s)?
  681. if ($context['can_report_moderator'])
  682. echo '
  683. <ul class="floatright smalltext">
  684. <li class="report_link"><a href="', $scripturl, '?action=reporttm;topic=', $context['current_topic'], '.', $message['counter'], ';msg=', $message['id'], '">', $txt['report_to_mod'], '</a></li>
  685. </ul>';
  686. // What about likes?
  687. echo '
  688. <ul class="floatleft">';
  689. if (!empty($message['likes']['can_like']))
  690. {
  691. echo '
  692. <li class="like_button"><a href="', $scripturl, '?action=likes;ltype=msg;like=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '"><span class="', $message['likes']['you'] ? 'unlike' : 'like', '"></span>', $message['likes']['you'] ? $txt['unlike'] : $txt['like'], '</a></li>';
  693. }
  694. if (!empty($message['likes']['count']))
  695. {
  696. $context['some_likes'] = true;
  697. $count = $message['likes']['count'];
  698. $base = 'likes_';
  699. if ($message['likes']['you'])
  700. {
  701. $base = 'you_' . $base;
  702. $count--;
  703. }
  704. $base .= (isset($txt[$base . $count])) ? $count : 'n';
  705. echo '
  706. <li class="like_count smalltext">', sprintf($txt[$base], $scripturl . '?action=likes;view;ltype=msg;like=' . $message['id'], comma_format($count)), '</li>';
  707. }
  708. echo '
  709. </ul>';
  710. // Show the quickbuttons, for various operations on posts.
  711. if ($message['can_approve'] || $message['can_unapprove'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'] || $context['can_quote'])
  712. {
  713. echo '
  714. <ul class="quickbuttons">';
  715. // Can they reply?
  716. if ($context['can_quote'])
  717. echo '
  718. <li><a href="', $scripturl, '?action=post;quote=', $message['id'], ';topic=', $context['current_topic'], '.', $context['start'], ';last_msg=', $context['topic_last_message'], '" onclick="return oQuickReply.quote(', $message['id'], ');" class="quote_button">', $txt['quote_action'], '</a></li>';
  719. // Can the user modify the contents of this post? Show the modify inline image.
  720. if ($message['can_modify'])
  721. echo '
  722. <li class="quick_edit"><img src="', $settings['images_url'], '/icons/modify_inline.png" alt="', $txt['modify_msg'], '" title="', $txt['modify_msg'], '" class="modifybutton" id="modify_button_', $message['id'], '" style="cursor: pointer" onclick="oQuickModify.modifyMsg(\'', $message['id'], '\')">', $txt['quick_edit'], '</li>';
  723. if ($message['can_approve'] || $message['can_unapprove'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'])
  724. echo '
  725. <li class="post_options">', $txt['post_options'];
  726. echo '
  727. <ul>';
  728. // Can the user modify the contents of this post?
  729. if ($message['can_modify'])
  730. echo '
  731. <li><a href="', $scripturl, '?action=post;msg=', $message['id'], ';topic=', $context['current_topic'], '.', $context['start'], '" class="modify_button">', $txt['modify'], '</a></li>';
  732. // How about... even... remove it entirely?!
  733. if ($message['can_remove'])
  734. echo '
  735. <li><a href="', $scripturl, '?action=deletemsg;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '" onclick="return confirm(\'', $txt['remove_message'], '?\');" class="remove_button">', $txt['remove'], '</a></li>';
  736. // What about splitting it off the rest of the topic?
  737. if ($context['can_split'] && !empty($context['real_num_replies']))
  738. echo '
  739. <li><a href="', $scripturl, '?action=splittopics;topic=', $context['current_topic'], '.0;at=', $message['id'], '" class="split_button">', $txt['split'], '</a></li>';
  740. // Can we issue a warning because of this post? Remember, we can't give guests warnings.
  741. if ($context['can_issue_warning'] && !$message['is_message_author'] && !$message['member']['is_guest'])
  742. echo '
  743. <li><a href="', $scripturl, '?action=profile;area=issuewarning;u=', $message['member']['id'], ';msg=', $message['id'], '" class="warn_button">', $txt['issue_warning'], '</a></li>';
  744. // Can we restore topics?
  745. if ($context['can_restore_msg'])
  746. echo '
  747. <li><a href="', $scripturl, '?action=restoretopic;msgs=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '" class="restore_button">', $txt['restore_message'], '</a></li>';
  748. // Maybe we can approve it, maybe we should?
  749. if ($message['can_approve'])
  750. echo '
  751. <li><a href="', $scripturl, '?action=moderate;area=postmod;sa=approve;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '" class="approve_button">', $txt['approve'], '</a></li>';
  752. // Maybe we can unapprove it?
  753. if ($message['can_unapprove'])
  754. echo '
  755. <li><a href="', $scripturl, '?action=moderate;area=postmod;sa=approve;topic=', $context['current_topic'], '.', $context['start'], ';msg=', $message['id'], ';', $context['session_var'], '=', $context['session_id'], '" class="unapprove_button">', $txt['unapprove'], '</a></li>';
  756. echo '
  757. </ul>
  758. </li>';
  759. // Show a checkbox for quick moderation?
  760. if (!empty($options['display_quick_mod']) && $options['display_quick_mod'] == 1 && $message['can_remove'])
  761. echo '
  762. <li class="inline_mod_check" style="display: none;" id="in_topic_mod_check_', $message['id'], '"></li>';
  763. if ($message['can_approve'] || $context['can_reply'] || $message['can_modify'] || $message['can_remove'] || $context['can_split'] || $context['can_restore_msg'])
  764. echo '
  765. </ul>';
  766. }
  767. echo '
  768. </div>
  769. </div>';
  770. echo '
  771. <div class="moderatorbar">';
  772. // Are there any custom profile fields for above the signature?
  773. if (!empty($message['member']['custom_fields']))
  774. {
  775. $shown = false;
  776. foreach ($message['member']['custom_fields'] as $custom)
  777. {
  778. if ($custom['placement'] != 2 || empty($custom['value']))
  779. continue;
  780. if (empty($shown))
  781. {
  782. $shown = true;
  783. echo '
  784. <div class="custom_fields_above_signature">
  785. <ul class="reset nolist">';
  786. }
  787. echo '
  788. <li>', $custom['value'], '</li>';
  789. }
  790. if ($shown)
  791. echo '
  792. </ul>
  793. </div>';
  794. }
  795. // Show the member's signature?
  796. if (!empty($message['member']['signature']) && empty($options['show_no_signatures']) && $context['signature_enabled'])
  797. echo '
  798. <div class="signature" id="msg_', $message['id'], '_signature"', $ignoring ? ' style="display:none;"' : '', '>', $message['member']['signature'], '</div>';
  799. echo '
  800. </div>
  801. </div>
  802. </div>
  803. <hr class="post_separator">';
  804. }
  805. ?>