ManageNews.template.php 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464
  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_email_members()
  13. {
  14. global $context, $settings, $txt, $scripturl;
  15. // Are we done sending the newsletter?
  16. if (!empty($context['newsletter_sent']))
  17. echo '
  18. <div class="infobox">', $txt['admin_news_newsletter_'. $context['newsletter_sent']] ,'</div>';
  19. echo '
  20. <div id="admincenter">
  21. <form action="', $scripturl, '?action=admin;area=news;sa=mailingcompose" method="post" id="admin_newsletters" class="flow_hidden" accept-charset="', $context['character_set'], '">
  22. <div class="cat_bar">
  23. <h3 class="catbg">', $txt['admin_newsletters'], '</h3>
  24. </div>
  25. <div class="information">
  26. ', $txt['admin_news_select_recipients'], '
  27. </div>
  28. <div class="windowbg">
  29. <div class="content">
  30. <dl class="settings">
  31. <dt>
  32. <strong>', $txt['admin_news_select_group'], ':</strong><br>
  33. <span class="smalltext">', $txt['admin_news_select_group_desc'], '</span>
  34. </dt>
  35. <dd>';
  36. foreach ($context['groups'] as $group)
  37. echo '
  38. <label for="groups_', $group['id'], '"><input type="checkbox" name="groups[', $group['id'], ']" id="groups_', $group['id'], '" value="', $group['id'], '" checked class="input_check"> ', $group['name'], '</label> <em>(', $group['member_count'], ')</em><br>';
  39. echo '
  40. <br>
  41. <label for="checkAllGroups"><input type="checkbox" id="checkAllGroups" checked onclick="invertAll(this, this.form, \'groups\');" class="input_check"> <em>', $txt['check_all'], '</em></label>';
  42. echo '
  43. </dd>
  44. </dl>
  45. <br class="clear">
  46. </div>
  47. </div>
  48. <br>
  49. <div id="advanced_panel_header" class="title_bar">
  50. <h3 class="titlebg">
  51. <span id="advanced_panel_toggle" class="toggle_down floatright" style="display: none;"></span>
  52. <a href="#" id="advanced_panel_link">', $txt['advanced'], '</a>
  53. </h3>
  54. </div>
  55. <div id="advanced_panel_div" class="windowbg2">
  56. <div class="content">
  57. <dl class="settings">
  58. <dt>
  59. <strong>', $txt['admin_news_select_email'], ':</strong><br>
  60. <span class="smalltext">', $txt['admin_news_select_email_desc'], '</span>
  61. </dt>
  62. <dd>
  63. <textarea name="emails" rows="5" cols="30" style="' . (isBrowser('is_ie8') ? 'width: 635px; max-width: 98%; min-width: 98%' : 'width: 98%') . ';"></textarea>
  64. </dd>
  65. <dt>
  66. <strong>', $txt['admin_news_select_members'], ':</strong><br>
  67. <span class="smalltext">', $txt['admin_news_select_members_desc'], '</span>
  68. </dt>
  69. <dd>
  70. <input type="text" name="members" id="members" value="" size="30" class="input_text">
  71. <span id="members_container"></span>
  72. </dd>
  73. </dl>
  74. <hr class="bordercolor">
  75. <dl class="settings">
  76. <dt>
  77. <strong>', $txt['admin_news_select_excluded_groups'], ':</strong><br>
  78. <span class="smalltext">', $txt['admin_news_select_excluded_groups_desc'], '</span>
  79. </dt>
  80. <dd>';
  81. foreach ($context['groups'] as $group)
  82. echo '
  83. <label for="exclude_groups_', $group['id'], '"><input type="checkbox" name="exclude_groups[', $group['id'], ']" id="exclude_groups_', $group['id'], '" value="', $group['id'], '" class="input_check"> ', $group['name'], '</label> <em>(', $group['member_count'], ')</em><br>';
  84. echo '
  85. <br>
  86. <label for="checkAllGroupsExclude"><input type="checkbox" id="checkAllGroupsExclude" onclick="invertAll(this, this.form, \'exclude_groups\');" class="input_check"> <em>', $txt['check_all'], '</em></label><br>
  87. </dd>
  88. <dt>
  89. <strong>', $txt['admin_news_select_excluded_members'], ':</strong><br>
  90. <span class="smalltext">', $txt['admin_news_select_excluded_members_desc'], '</span>
  91. </dt>
  92. <dd>
  93. <input type="text" name="exclude_members" id="exclude_members" value="" size="30" class="input_text">
  94. <span id="exclude_members_container"></span>
  95. </dd>
  96. </dl>
  97. <hr class="bordercolor">
  98. <dl class="settings">
  99. <dt>
  100. <label for="email_force"><strong>', $txt['admin_news_select_override_notify'], ':</strong></label><br>
  101. <span class="smalltext">', $txt['email_force'], '</span>
  102. </dt>
  103. <dd>
  104. <input type="checkbox" name="email_force" id="email_force" value="1" class="input_check">
  105. </dd>
  106. </dl>
  107. </div>
  108. </div>
  109. <div class="righttext">
  110. <input type="submit" value="', $txt['admin_next'], '" class="button_submit">
  111. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
  112. </div>
  113. </form>
  114. </div>';
  115. // This is some javascript for the simple/advanced toggling and member suggest
  116. echo '
  117. <script><!-- // --><![CDATA[
  118. var oAdvancedPanelToggle = new smc_Toggle({
  119. bToggleEnabled: true,
  120. bCurrentlyCollapsed: true,
  121. aSwappableContainers: [
  122. \'advanced_panel_div\'
  123. ],
  124. aSwapImages: [
  125. {
  126. sId: \'advanced_panel_toggle\',
  127. altExpanded: ', JavaScriptEscape($txt['hide']), ',
  128. altCollapsed: ', JavaScriptEscape($txt['show']), '
  129. }
  130. ],
  131. aSwapLinks: [
  132. {
  133. sId: \'advanced_panel_link\',
  134. msgExpanded: ', JavaScriptEscape($txt['advanced']), ',
  135. msgCollapsed: ', JavaScriptEscape($txt['advanced']), '
  136. }
  137. ]
  138. });
  139. // ]]></script>
  140. <script src="', $settings['default_theme_url'], '/scripts/suggest.js?alp21"></script>
  141. <script><!-- // --><![CDATA[
  142. var oMemberSuggest = new smc_AutoSuggest({
  143. sSelf: \'oMemberSuggest\',
  144. sSessionId: smf_session_id,
  145. sSessionVar: smf_session_var,
  146. sSuggestId: \'members\',
  147. sControlId: \'members\',
  148. sSearchType: \'member\',
  149. bItemList: true,
  150. sPostName: \'member_list\',
  151. sURLMask: \'action=profile;u=%item_id%\',
  152. sTextDeleteItem: \'', $txt['autosuggest_delete_item'], '\',
  153. sItemListContainerId: \'members_container\',
  154. aListItems: []
  155. });
  156. var oExcludeMemberSuggest = new smc_AutoSuggest({
  157. sSelf: \'oExcludeMemberSuggest\',
  158. sSessionId: \'', $context['session_id'], '\',
  159. sSessionVar: \'', $context['session_var'], '\',
  160. sSuggestId: \'exclude_members\',
  161. sControlId: \'exclude_members\',
  162. sSearchType: \'member\',
  163. bItemList: true,
  164. sPostName: \'exclude_member_list\',
  165. sURLMask: \'action=profile;u=%item_id%\',
  166. sTextDeleteItem: \'', $txt['autosuggest_delete_item'], '\',
  167. sItemListContainerId: \'exclude_members_container\',
  168. aListItems: []
  169. });
  170. // ]]></script>';
  171. }
  172. function template_email_members_compose()
  173. {
  174. global $context, $settings, $txt, $scripturl;
  175. echo '
  176. <div id="preview_section"', isset($context['preview_message']) ? '' : ' style="display: none;"', '>
  177. <div class="cat_bar">
  178. <h3 class="catbg">
  179. <span id="preview_subject">', empty($context['preview_subject']) ? '' : $context['preview_subject'], '</span>
  180. </h3>
  181. </div>
  182. <div class="windowbg">
  183. <div class="content">
  184. <div class="post" id="preview_body">
  185. ', empty($context['preview_message']) ? '<br>' : $context['preview_message'], '
  186. </div>
  187. </div>
  188. </div>
  189. </div><br>';
  190. echo '
  191. <div id="admincenter">
  192. <form name="newsmodify" action="', $scripturl, '?action=admin;area=news;sa=mailingsend" method="post" accept-charset="', $context['character_set'], '">
  193. <div class="cat_bar">
  194. <h3 class="catbg">
  195. <a href="', $scripturl, '?action=helpadmin;help=email_members" onclick="return reqOverlayDiv(this.href);" class="help"><img src="', $settings['images_url'], '/helptopics_hd.png" alt="', $txt['help'], '" class="icon"></a> ', $txt['admin_newsletters'], '
  196. </h3>
  197. </div>
  198. <div class="information">
  199. ', $txt['email_variables'], '
  200. </div>
  201. <div class="windowbg">
  202. <div class="content">
  203. <div class="', empty($context['error_type']) || $context['error_type'] != 'serious' ? 'noticebox' : 'errorbox', '"', empty($context['post_error']['messages']) ? ' style="display: none"' : '', ' id="errors">
  204. <dl>
  205. <dt>
  206. <strong id="error_serious">', $txt['error_while_submitting'] , '</strong>
  207. </dt>
  208. <dd class="error" id="error_list">
  209. ', empty($context['post_error']['messages']) ? '' : implode('<br>', $context['post_error']['messages']), '
  210. </dd>
  211. </dl>
  212. </div>
  213. <dl id="post_header">
  214. <dt class="clear_left">
  215. <span', (isset($context['post_error']['no_subject']) ? ' class="error"' : ''), ' id="caption_subject">', $txt['subject'], ':</span>
  216. </dt>
  217. <dd id="pm_subject">
  218. <input type="text" name="subject" value="', $context['subject'], '" tabindex="', $context['tabindex']++, '" size="60" maxlength="60"',isset($context['post_error']['no_subject']) ? ' class="error"' : ' class="input_text"', '/>
  219. </dd>
  220. </dl><hr class="clear">
  221. <div id="bbcBox_message"></div>';
  222. // What about smileys?
  223. if (!empty($context['smileys']['postform']) || !empty($context['smileys']['popup']))
  224. echo '
  225. <div id="smileyBox_message"></div>';
  226. // Show BBC buttons, smileys and textbox.
  227. echo '
  228. ', template_control_richedit($context['post_box_name'], 'smileyBox_message', 'bbcBox_message');
  229. echo '
  230. <ul class="reset">
  231. <li><label for="send_pm"><input type="checkbox" name="send_pm" id="send_pm"', !empty($context['send_pm']) ? ' checked' : '', ' class="input_check" onclick="checkboxes_status(this);"> ', $txt['email_as_pms'], '</label></li>
  232. <li><label for="send_html"><input type="checkbox" name="send_html" id="send_html"', !empty($context['send_html']) ? ' checked' : '', ' class="input_check" onclick="checkboxes_status(this);"> ', $txt['email_as_html'], '</label></li>
  233. <li><label for="parse_html"><input type="checkbox" name="parse_html" id="parse_html" checked disabled class="input_check"> ', $txt['email_parsed_html'], '</label></li>
  234. </ul>
  235. <br class="clear_right">
  236. <span id="post_confirm_buttons">
  237. ', template_control_richedit_buttons($context['post_box_name']), '
  238. </span>
  239. </div>
  240. </div>
  241. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
  242. <input type="hidden" name="email_force" value="', $context['email_force'], '">
  243. <input type="hidden" name="total_emails" value="', $context['total_emails'], '">';
  244. foreach ($context['recipients'] as $key => $values)
  245. echo '
  246. <input type="hidden" name="', $key, '" value="', implode(($key == 'emails' ? ';' : ','), $values), '">';
  247. echo '
  248. <script><!-- // --><![CDATA[';
  249. // The functions used to preview a posts without loading a new page.
  250. echo '
  251. var txt_preview_title = "', $txt['preview_title'], '";
  252. var txt_preview_fetch = "', $txt['preview_fetch'], '";
  253. function previewPost()
  254. {';
  255. if (isBrowser('is_firefox'))
  256. echo '
  257. // Firefox doesn\'t render <marquee> that have been put it using javascript
  258. if (document.forms.newsmodify.elements[', JavaScriptEscape($context['post_box_name']), '].value.indexOf(\'[move]\') != -1)
  259. {
  260. return submitThisOnce(document.forms.newsmodify);
  261. }';
  262. echo '
  263. if (window.XMLHttpRequest)
  264. {
  265. // Opera didn\'t support setRequestHeader() before 8.01.
  266. // @todo Remove support for old browsers
  267. if (\'opera\' in window)
  268. {
  269. var test = new XMLHttpRequest();
  270. if (!(\'setRequestHeader\' in test))
  271. return submitThisOnce(document.forms.newsmodify);
  272. }
  273. // @todo Currently not sending poll options and option checkboxes.
  274. var x = new Array();
  275. var textFields = [\'subject\', ', JavaScriptEscape($context['post_box_name']), '];
  276. var checkboxFields = [\'send_html\', \'send_pm\'];
  277. for (var i = 0, n = textFields.length; i < n; i++)
  278. if (textFields[i] in document.forms.newsmodify)
  279. {
  280. // Handle the WYSIWYG editor.
  281. if (textFields[i] == ', JavaScriptEscape($context['post_box_name']), ' && ', JavaScriptEscape('oEditorHandle_' . $context['post_box_name']), ' in window && oEditorHandle_', $context['post_box_name'], '.bRichTextEnabled)
  282. x[x.length] = \'message_mode=1&\' + textFields[i] + \'=\' + oEditorHandle_', $context['post_box_name'], '.getText(false).replace(/&#/g, \'&#38;#\').php_to8bit().php_urlencode();
  283. else
  284. x[x.length] = textFields[i] + \'=\' + document.forms.newsmodify[textFields[i]].value.replace(/&#/g, \'&#38;#\').php_to8bit().php_urlencode();
  285. }
  286. for (var i = 0, n = checkboxFields.length; i < n; i++)
  287. if (checkboxFields[i] in document.forms.newsmodify && document.forms.newsmodify.elements[checkboxFields[i]].checked)
  288. x[x.length] = checkboxFields[i] + \'=\' + document.forms.newsmodify.elements[checkboxFields[i]].value;
  289. x[x.length] = \'item=newsletterpreview\';
  290. sendXMLDocument(smf_prepareScriptUrl(smf_scripturl) + \'action=xmlhttp;sa=previews;xml\', x.join(\'&\'), onDocSent);
  291. document.getElementById(\'preview_section\').style.display = \'\';
  292. setInnerHTML(document.getElementById(\'preview_subject\'), txt_preview_title);
  293. setInnerHTML(document.getElementById(\'preview_body\'), txt_preview_fetch);
  294. return false;
  295. }
  296. else
  297. return submitThisOnce(document.forms.newsmodify);
  298. }
  299. function onDocSent(XMLDoc)
  300. {
  301. if (!XMLDoc)
  302. {
  303. document.forms.newsmodify.preview.onclick = new function ()
  304. {
  305. return true;
  306. }
  307. document.forms.newsmodify.preview.click();
  308. }
  309. // Show the preview section.
  310. var preview = XMLDoc.getElementsByTagName(\'smf\')[0].getElementsByTagName(\'preview\')[0];
  311. setInnerHTML(document.getElementById(\'preview_subject\'), preview.getElementsByTagName(\'subject\')[0].firstChild.nodeValue);
  312. var bodyText = \'\';
  313. for (var i = 0, n = preview.getElementsByTagName(\'body\')[0].childNodes.length; i < n; i++)
  314. bodyText += preview.getElementsByTagName(\'body\')[0].childNodes[i].nodeValue;
  315. setInnerHTML(document.getElementById(\'preview_body\'), bodyText);
  316. document.getElementById(\'preview_body\').className = \'post\';
  317. // Show a list of errors (if any).
  318. var errors = XMLDoc.getElementsByTagName(\'smf\')[0].getElementsByTagName(\'errors\')[0];
  319. var errorList = new Array();
  320. for (var i = 0, numErrors = errors.getElementsByTagName(\'error\').length; i < numErrors; i++)
  321. errorList[errorList.length] = errors.getElementsByTagName(\'error\')[i].firstChild.nodeValue;
  322. document.getElementById(\'errors\').style.display = numErrors == 0 ? \'none\' : \'\';
  323. setInnerHTML(document.getElementById(\'error_list\'), numErrors == 0 ? \'\' : errorList.join(\'<br>\'));
  324. // Adjust the color of captions if the given data is erroneous.
  325. var captions = errors.getElementsByTagName(\'caption\');
  326. for (var i = 0, numCaptions = errors.getElementsByTagName(\'caption\').length; i < numCaptions; i++)
  327. if (document.getElementById(\'caption_\' + captions[i].getAttribute(\'name\')))
  328. document.getElementById(\'caption_\' + captions[i].getAttribute(\'name\')).className = captions[i].getAttribute(\'class\');
  329. if (errors.getElementsByTagName(\'post_error\').length == 1)
  330. document.forms.newsmodify.', $context['post_box_name'], '.style.border = \'1px solid red\';
  331. else if (document.forms.newsmodify.', $context['post_box_name'], '.style.borderColor == \'red\' || document.forms.newsmodify.', $context['post_box_name'], '.style.borderColor == \'red red red red\')
  332. {
  333. if (\'runtimeStyle\' in document.forms.newsmodify.', $context['post_box_name'], ')
  334. document.forms.newsmodify.', $context['post_box_name'], '.style.borderColor = \'\';
  335. else
  336. document.forms.newsmodify.', $context['post_box_name'], '.style.border = null;
  337. }
  338. location.hash = \'#\' + \'preview_section\';
  339. }';
  340. echo '
  341. // ]]></script>';
  342. echo '
  343. <script><!-- // --><![CDATA[
  344. function checkboxes_status (item)
  345. {
  346. if (item.id == \'send_html\')
  347. document.getElementById(\'parse_html\').disabled = !document.getElementById(\'parse_html\').disabled;
  348. if (item.id == \'send_pm\')
  349. {
  350. if (!document.getElementById(\'send_html\').checked)
  351. document.getElementById(\'parse_html\').disabled = true;
  352. else
  353. document.getElementById(\'parse_html\').disabled = false;
  354. document.getElementById(\'send_html\').disabled = !document.getElementById(\'send_html\').disabled;
  355. }
  356. }
  357. // ]]></script>
  358. </form>
  359. </div>';
  360. }
  361. function template_email_members_send()
  362. {
  363. global $context, $settings, $txt, $scripturl;
  364. echo '
  365. <div id="admincenter">
  366. <form action="', $scripturl, '?action=admin;area=news;sa=mailingsend" method="post" accept-charset="', $context['character_set'], '" name="autoSubmit" id="autoSubmit">
  367. <div class="cat_bar">
  368. <h3 class="catbg">
  369. <a href="', $scripturl, '?action=helpadmin;help=email_members" onclick="return reqOverlayDiv(this.href);" class="help"><img src="', $settings['images_url'], '/helptopics_hd.png" alt="', $txt['help'], '"></a> ', $txt['admin_newsletters'], '
  370. </h3>
  371. </div>
  372. <div class="windowbg">
  373. <div class="content">
  374. <div class="progress_bar">
  375. <div class="full_bar">', $context['percentage_done'], '% ', $txt['email_done'], '</div>
  376. <div class="green_percent" style="width: ', $context['percentage_done'], '%;">&nbsp;</div>
  377. </div>
  378. <hr class="hrcolor">
  379. <input type="submit" name="b" value="', $txt['email_continue'], '" class="button_submit">
  380. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
  381. <input type="hidden" name="subject" value="', $context['subject'], '">
  382. <input type="hidden" name="message" value="', $context['message'], '">
  383. <input type="hidden" name="start" value="', $context['start'], '">
  384. <input type="hidden" name="total_members" value="', $context['total_members'], '">
  385. <input type="hidden" name="total_emails" value="', $context['total_emails'], '">
  386. <input type="hidden" name="send_pm" value="', $context['send_pm'], '">
  387. <input type="hidden" name="send_html" value="', $context['send_html'], '">
  388. <input type="hidden" name="parse_html" value="', $context['parse_html'], '">';
  389. // All the things we must remember!
  390. foreach ($context['recipients'] as $key => $values)
  391. echo '
  392. <input type="hidden" name="', $key, '" value="', implode(($key == 'emails' ? ';' : ','), $values), '">';
  393. echo '
  394. </div>
  395. </div>
  396. </form>
  397. </div>
  398. <script><!-- // --><![CDATA[
  399. var countdown = 2;
  400. doAutoSubmit();
  401. function doAutoSubmit()
  402. {
  403. if (countdown == 0)
  404. document.forms.autoSubmit.submit();
  405. else if (countdown == -1)
  406. return;
  407. document.forms.autoSubmit.b.value = "', $txt['email_continue'], ' (" + countdown + ")";
  408. countdown--;
  409. setTimeout("doAutoSubmit();", 1000);
  410. }
  411. // ]]></script>';
  412. }
  413. function template_news_lists()
  414. {
  415. global $context, $txt;
  416. if (!empty($context['saved_successful']))
  417. echo '
  418. <div class="infobox">', $txt['settings_saved'], '</div>';
  419. template_show_list('news_lists');
  420. }
  421. ?>