ManageSmileys.template.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531
  1. <?php
  2. /**
  3. * Simple Machines Forum (SMF)
  4. *
  5. * @package SMF
  6. * @author Simple Machines
  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. // Editing the smiley sets.
  13. function template_editsets()
  14. {
  15. global $context, $scripturl, $txt, $modSettings;
  16. echo '
  17. <div id="admincenter">';
  18. template_show_list('smiley_set_list');
  19. echo '
  20. <br>
  21. <div class="cat_bar">
  22. <h3 class="catbg">', $txt['smiley_sets_latest'], '</h3>
  23. </div>
  24. <div class="windowbg">
  25. <div class="content">
  26. <div id="smileysLatest">', $txt['smiley_sets_latest_fetch'], '</div>
  27. </div>
  28. </div>
  29. </div>
  30. <script><!-- // --><![CDATA[
  31. window.smfForum_scripturl = smf_scripturl;
  32. window.smfForum_sessionid = smf_session_id;
  33. window.smfForum_sessionvar = smf_session_var;
  34. // ]]></script>';
  35. if (empty($modSettings['disable_smf_js']))
  36. echo '
  37. <script src="', $scripturl, '?action=viewsmfile;filename=latest-smileys.js"></script>';
  38. echo '
  39. <script><!-- // --><![CDATA[
  40. function smfSetLatestSmileys()
  41. {
  42. if (typeof(window.smfLatestSmileys) != "undefined")
  43. setInnerHTML(document.getElementById("smileysLatest"), window.smfLatestSmileys);';
  44. if (!empty($context['selected_set']))
  45. echo '
  46. changeSet("', $context['selected_set'], '");';
  47. if (!empty($context['selected_smiley']))
  48. echo '
  49. loadSmiley(', $context['selected_smiley'], ');';
  50. echo '
  51. }';
  52. echo '
  53. smfSetLatestSmileys();';
  54. echo '
  55. // ]]></script>';
  56. }
  57. // Modifying a smiley set.
  58. function template_modifyset()
  59. {
  60. global $context, $scripturl, $txt, $modSettings;
  61. echo '
  62. <div id="admincenter">
  63. <form action="', $scripturl, '?action=admin;area=smileys;sa=editsets" method="post" accept-charset="', $context['character_set'], '">
  64. <div class="cat_bar">
  65. <h3 class="catbg">
  66. ', $context['current_set']['is_new'] ? $txt['smiley_set_new'] : $txt['smiley_set_modify_existing'], '
  67. </h3>
  68. </div>';
  69. // If this is an existing set, and there are still un-added smileys - offer an import opportunity.
  70. if (!empty($context['current_set']['can_import']))
  71. {
  72. echo '
  73. <div class="information">
  74. ', $context['current_set']['can_import'] == 1 ? sprintf($txt['smiley_set_import_single'], $context['current_set']['import_url']) : sprintf($txt['smiley_set_import_multiple'], $context['current_set']['can_import'], $context['current_set']['import_url']), '
  75. </div>';
  76. }
  77. echo '
  78. <div class="windowbg">
  79. <div class="content">
  80. <dl class="settings">
  81. <dt>
  82. <strong><label for="smiley_sets_name">', $txt['smiley_sets_name'], '</label>: </strong>
  83. </dt>
  84. <dd>
  85. <input type="text" name="smiley_sets_name" id="smiley_sets_name" value="', $context['current_set']['name'], '" class="input_text">
  86. </dd>
  87. <dt>
  88. <strong><label for="smiley_sets_path">', $txt['smiley_sets_url'], '</label>: </strong>
  89. </dt>
  90. <dd>
  91. ', $modSettings['smileys_url'], '/';
  92. if ($context['current_set']['id'] == 'default')
  93. echo '<strong>default</strong><input type="hidden" name="smiley_sets_path" id="smiley_sets_path" value="default">';
  94. elseif (empty($context['smiley_set_dirs']))
  95. echo '
  96. <input type="text" name="smiley_sets_path" id="smiley_sets_path" value="', $context['current_set']['path'], '" class="input_text"> ';
  97. else
  98. {
  99. echo '
  100. <select name="smiley_sets_path" id="smiley_sets_path">';
  101. foreach ($context['smiley_set_dirs'] as $smiley_set_dir)
  102. echo '
  103. <option value="', $smiley_set_dir['id'], '"', $smiley_set_dir['current'] ? ' selected' : '', $smiley_set_dir['selectable'] ? '' : ' disabled', '>', $smiley_set_dir['id'], '</option>';
  104. echo '
  105. </select> ';
  106. }
  107. echo '
  108. /..
  109. </dd>
  110. <dt>
  111. <strong><label for="smiley_sets_default">', $txt['smiley_set_select_default'], '</label>: </strong>
  112. </dt>
  113. <dd>
  114. <input type="checkbox" name="smiley_sets_default" id="smiley_sets_default" value="1"', $context['current_set']['selected'] ? ' checked' : '', ' class="input_check">
  115. </dd>';
  116. // If this is a new smiley set they have the option to import smileys already in the directory.
  117. if ($context['current_set']['is_new'] && !empty($modSettings['smiley_enable']))
  118. echo '
  119. <dt>
  120. <strong><label for="smiley_sets_import">', $txt['smiley_set_import_directory'], '</label>: </strong>
  121. </dt>
  122. <dd>
  123. <input type="checkbox" name="smiley_sets_import" id="smiley_sets_import" value="1" class="input_check">
  124. </dd>';
  125. echo '
  126. </dl>
  127. <hr class="hrcolor">
  128. <input type="submit" name="smiley_save" value="', $txt['smiley_sets_save'], '" class="button_submit">
  129. </div>
  130. </div>
  131. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
  132. <input type="hidden" name="', $context['admin-mss_token_var'], '" value="', $context['admin-mss_token'], '">
  133. <input type="hidden" name="set" value="', $context['current_set']['id'], '">
  134. </form>
  135. </div>';
  136. }
  137. // Editing an individual smiley
  138. function template_modifysmiley()
  139. {
  140. global $context, $scripturl, $txt, $modSettings;
  141. echo '
  142. <div id="admincenter">
  143. <form action="', $scripturl, '?action=admin;area=smileys;sa=editsmileys" method="post" accept-charset="', $context['character_set'], '" name="smileyForm" id="smileyForm">
  144. <div class="cat_bar">
  145. <h3 class="catbg">', $txt['smiley_modify_existing'], '</h3>
  146. </div>
  147. <div class="windowbg">
  148. <div class="content">
  149. <dl class="settings">
  150. <dt>
  151. <strong>', $txt['smiley_preview'], ': </strong>
  152. </dt>
  153. <dd>
  154. <img src="', $modSettings['smileys_url'], '/', $modSettings['smiley_sets_default'], '/', $context['current_smiley']['filename'], '" id="preview" alt=""> (', $txt['smiley_preview_using'], ': <select name="set" onchange="updatePreview();">';
  155. foreach ($context['smiley_sets'] as $smiley_set)
  156. echo '
  157. <option value="', $smiley_set['path'], '"', $context['selected_set'] == $smiley_set['path'] ? ' selected' : '', '>', $smiley_set['name'], '</option>';
  158. echo '
  159. </select>)
  160. </dd>
  161. <dt>
  162. <strong><label for="smiley_code">', $txt['smileys_code'], '</label>: </strong>
  163. </dt>
  164. <dd>
  165. <input type="text" name="smiley_code" id="smiley_code" value="', $context['current_smiley']['code'], '" class="input_text">
  166. </dd>
  167. <dt>
  168. <strong><label for="smiley_filename">', $txt['smileys_filename'], '</label>: </strong>
  169. </dt>
  170. <dd>';
  171. if (empty($context['filenames']))
  172. echo '
  173. <input type="text" name="smiley_filename" id="smiley_filename" value="', $context['current_smiley']['filename'], '" class="input_text">';
  174. else
  175. {
  176. echo '
  177. <select name="smiley_filename" id="smiley_filename" onchange="updatePreview();">';
  178. foreach ($context['filenames'] as $filename)
  179. echo '
  180. <option value="', $filename['id'], '"', $filename['selected'] ? ' selected' : '', '>', $filename['id'], '</option>';
  181. echo '
  182. </select>';
  183. }
  184. echo '
  185. </dd>
  186. <dt>
  187. <strong><label for="smiley_description">', $txt['smileys_description'], '</label>: </strong>
  188. </dt>
  189. <dd>
  190. <input type="text" name="smiley_description" id="smiley_description" value="', $context['current_smiley']['description'], '" class="input_text">
  191. </dd>
  192. <dt>
  193. <strong><label for="smiley_location">', $txt['smileys_location'], '</label>: </strong>
  194. </dt>
  195. <dd>
  196. <select name="smiley_location" id="smiley_location">
  197. <option value="0"', $context['current_smiley']['location'] == 0 ? ' selected' : '', '>
  198. ', $txt['smileys_location_form'], '
  199. </option>
  200. <option value="1"', $context['current_smiley']['location'] == 1 ? ' selected' : '', '>
  201. ', $txt['smileys_location_hidden'], '
  202. </option>
  203. <option value="2"', $context['current_smiley']['location'] == 2 ? ' selected' : '', '>
  204. ', $txt['smileys_location_popup'], '
  205. </option>
  206. </select>
  207. </dd>
  208. </dl>
  209. <hr class="hrcolor">
  210. <input type="submit" name="smiley_save" value="', $txt['smileys_save'], '" class="button_submit">
  211. <input type="submit" name="deletesmiley" value="', $txt['smileys_delete'], '" onclick="return confirm(\'', $txt['smileys_delete_confirm'], '\');" class="button_submit">
  212. </div>
  213. </div>
  214. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
  215. <input type="hidden" name="smiley" value="', $context['current_smiley']['id'], '">
  216. </form>
  217. </div>
  218. <script><!-- // --><![CDATA[
  219. function updatePreview()
  220. {
  221. var currentImage = document.getElementById("preview");
  222. currentImage.src = "', $modSettings['smileys_url'], '/" + document.forms.smileyForm.set.value + "/" + document.forms.smileyForm.smiley_filename.value;
  223. }
  224. // ]]></script>';
  225. }
  226. // Adding a new smiley.
  227. function template_addsmiley()
  228. {
  229. global $context, $scripturl, $txt, $modSettings;
  230. echo '
  231. <div id="admincenter">
  232. <form action="', $scripturl, '?action=admin;area=smileys;sa=addsmiley" method="post" accept-charset="', $context['character_set'], '" name="smileyForm" id="smileyForm" enctype="multipart/form-data">
  233. <div class="cat_bar">
  234. <h3 class="catbg">', $txt['smileys_add_method'], '</h3>
  235. </div>
  236. <div class="windowbg">
  237. <div class="content">
  238. <ul class="reset">
  239. <li>
  240. <label for="method-existing"><input type="radio" onclick="switchType();" name="method" id="method-existing" value="existing" checked class="input_radio"> ', $txt['smileys_add_existing'], '</label>
  241. </li>
  242. <li>
  243. <label for="method-upload"><input type="radio" onclick="switchType();" name="method" id="method-upload" value="upload" class="input_radio"> ', $txt['smileys_add_upload'], '</label>
  244. </li>
  245. </ul>
  246. <br>
  247. <fieldset id="ex_settings">
  248. <dl class="settings">
  249. <dt>
  250. <img src="', $modSettings['smileys_url'], '/', $modSettings['smiley_sets_default'], '/', $context['filenames'][0]['id'], '" id="preview" alt="">
  251. </dt>
  252. <dd>
  253. ', $txt['smiley_preview_using'], ': <select name="set" onchange="updatePreview();selectMethod(\'existing\');">
  254. ';
  255. foreach ($context['smiley_sets'] as $smiley_set)
  256. echo '
  257. <option value="', $smiley_set['path'], '"', $context['selected_set'] == $smiley_set['path'] ? ' selected' : '', '>', $smiley_set['name'], '</option>';
  258. echo '
  259. </select>
  260. </dd>
  261. <dt>
  262. <strong><label for="smiley_filename">', $txt['smileys_filename'], '</label>: </strong>
  263. </dt>
  264. <dd>';
  265. if (empty($context['filenames']))
  266. echo '
  267. <input type="text" name="smiley_filename" id="smiley_filename" value="', $context['current_smiley']['filename'], '" onchange="selectMethod(\'existing\');" class="input_text">';
  268. else
  269. {
  270. echo '
  271. <select name="smiley_filename" id="smiley_filename" onchange="updatePreview();selectMethod(\'existing\');">';
  272. foreach ($context['filenames'] as $filename)
  273. echo '
  274. <option value="', $filename['id'], '"', $filename['selected'] ? ' selected' : '', '>', $filename['id'], '</option>';
  275. echo '
  276. </select>';
  277. }
  278. echo '
  279. </dd>
  280. </dl>
  281. </fieldset>
  282. <fieldset id="ul_settings" style="display: none;">
  283. <dl class="settings">
  284. <dt>
  285. <strong>', $txt['smileys_add_upload_choose'], ':</strong><br>
  286. <span class="smalltext">', $txt['smileys_add_upload_choose_desc'], '</span>
  287. </dt>
  288. <dd>
  289. <input type="file" name="uploadSmiley" id="uploadSmiley" onchange="selectMethod(\'upload\');" class="input_file">
  290. </dd>
  291. <dt>
  292. <strong><label for="sameall">', $txt['smileys_add_upload_all'], ':</label></strong>
  293. </dt>
  294. <dd>
  295. <input type="checkbox" name="sameall" id="sameall" checked class="input_check" onclick="swapUploads(); selectMethod(\'upload\');">
  296. </dd>
  297. </dl>
  298. </fieldset>
  299. <dl id="uploadMore" style="display: none;" class="settings">';
  300. foreach ($context['smiley_sets'] as $smiley_set)
  301. echo '
  302. <dt>
  303. ', $txt['smileys_add_upload_for1'], ' <strong>', $smiley_set['name'], '</strong> ', $txt['smileys_add_upload_for2'], ':
  304. </dt>
  305. <dd>
  306. <input type="file" name="individual_', $smiley_set['name'], '" onchange="selectMethod(\'upload\');" class="input_file">
  307. </dd>';
  308. echo '
  309. </dl>
  310. </div>
  311. </div>
  312. <div class="cat_bar">
  313. <h3 class="catbg">', $txt['smiley_new'], '</h3>
  314. </div>
  315. <div class="windowbg">
  316. <div class="content">
  317. <dl class="settings">
  318. <dt>
  319. <strong><label for="smiley_code">', $txt['smileys_code'], '</label>: </strong>
  320. </dt>
  321. <dd>
  322. <input type="text" name="smiley_code" id="smiley_code" value="" class="input_text">
  323. </dd>
  324. <dt>
  325. <strong><label for="smiley_description">', $txt['smileys_description'], '</label>: </strong>
  326. </dt>
  327. <dd>
  328. <input type="text" name="smiley_description" id="smiley_description" value="" class="input_text">
  329. </dd>
  330. <dt>
  331. <strong><label for="smiley_location">', $txt['smileys_location'], '</label>: </strong>
  332. </dt>
  333. <dd>
  334. <select name="smiley_location" id="smiley_location">
  335. <option value="0" selected>
  336. ', $txt['smileys_location_form'], '
  337. </option>
  338. <option value="1">
  339. ', $txt['smileys_location_hidden'], '
  340. </option>
  341. <option value="2">
  342. ', $txt['smileys_location_popup'], '
  343. </option>
  344. </select>
  345. </dd>
  346. </dl>
  347. <hr class="hrcolor">
  348. <input type="submit" name="smiley_save" value="', $txt['smileys_save'], '" class="button_submit">
  349. </div>
  350. </div>
  351. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
  352. </form>
  353. </div>';
  354. }
  355. // Ordering smileys.
  356. function template_setorder()
  357. {
  358. global $context, $scripturl, $txt, $modSettings;
  359. echo '
  360. <div id="admincenter">';
  361. foreach ($context['smileys'] as $location)
  362. {
  363. echo '
  364. <form action="', $scripturl, '?action=admin;area=smileys;sa=editsmileys" method="post" accept-charset="', $context['character_set'], '">
  365. <div class="cat_bar">
  366. <h3 class="catbg">', $location['title'], '</h3>
  367. </div>
  368. <div class="information">
  369. ', $location['description'], '
  370. </div>
  371. <div class="windowbg">
  372. <div class="content">
  373. <strong>', empty($context['move_smiley']) ? $txt['smileys_move_select_smiley'] : $txt['smileys_move_select_destination'], '...</strong><br>';
  374. foreach ($location['rows'] as $row)
  375. {
  376. if (!empty($context['move_smiley']))
  377. echo '
  378. <a href="', $scripturl, '?action=admin;area=smileys;sa=setorder;location=', $location['id'], ';source=', $context['move_smiley'], ';row=', $row[0]['row'], ';reorder=1;', $context['session_var'], '=', $context['session_id'], '"><span class="select_spot below" title="', $txt['smileys_move_here'], '"></span></a>';
  379. foreach ($row as $smiley)
  380. {
  381. if (empty($context['move_smiley']))
  382. echo '<a href="', $scripturl, '?action=admin;area=smileys;sa=setorder;move=', $smiley['id'], '"><img src="', $modSettings['smileys_url'], '/', $modSettings['smiley_sets_default'], '/', $smiley['filename'], '" style="padding: 2px; border: 0px solid black;" alt="', $smiley['description'], '"></a>';
  383. else
  384. echo '<img src="', $modSettings['smileys_url'], '/', $modSettings['smiley_sets_default'], '/', $smiley['filename'], '" style="padding: 2px; border: ', $smiley['selected'] ? '2px solid red' : '0px solid black', ';" alt="', $smiley['description'], '"><a href="', $scripturl, '?action=admin;area=smileys;sa=setorder;location=', $location['id'], ';source=', $context['move_smiley'], ';after=', $smiley['id'], ';reorder=1;', $context['session_var'], '=', $context['session_id'], '" title="', $txt['smileys_move_here'], '"><span class="select_spot below" title="', $txt['smileys_move_here'], '"></span></a>';
  385. }
  386. echo '
  387. <br>';
  388. }
  389. if (!empty($context['move_smiley']))
  390. echo '
  391. <a href="', $scripturl, '?action=admin;area=smileys;sa=setorder;location=', $location['id'], ';source=', $context['move_smiley'], ';row=', $location['last_row'], ';reorder=1;', $context['session_var'], '=', $context['session_id'], '"><span class="select_spot below" title="', $txt['smileys_move_here'], '"></span></a>';
  392. echo '
  393. </div>
  394. </div>
  395. <input type="hidden" name="reorder" value="1">
  396. </form>';
  397. }
  398. echo '
  399. </div>';
  400. }
  401. // Editing Message Icons
  402. function template_editicons()
  403. {
  404. template_show_list('message_icon_list');
  405. }
  406. // Editing an individual message icon
  407. function template_editicon()
  408. {
  409. global $context, $scripturl, $txt, $modSettings;
  410. echo '
  411. <div id="admincenter">
  412. <form action="', $scripturl, '?action=admin;area=smileys;sa=editicon;icon=', $context['new_icon'] ? '0' : $context['icon']['id'], '" method="post" accept-charset="', $context['character_set'], '">
  413. <div class="cat_bar">
  414. <h3 class="catbg">
  415. ', $context['new_icon'] ? $txt['icons_new_icon'] : $txt['icons_edit_icon'], '
  416. </h3>
  417. </div>
  418. <div class="windowbg">
  419. <div class="content">
  420. <dl class="settings">';
  421. if (!$context['new_icon'])
  422. echo '
  423. <dt>
  424. <strong>', $txt['smiley_preview'], ': </strong>
  425. </dt>
  426. <dd>
  427. <img src="', $context['icon']['image_url'], '" alt="', $context['icon']['title'], '">
  428. </dd>';
  429. echo '
  430. <dt>
  431. <strong><label for="icon_filename">', $txt['smileys_filename'], '</label>: </strong><br><span class="smalltext">', $txt['icons_filename_all_png'], '</span>
  432. </dt>
  433. <dd>
  434. <input type="text" name="icon_filename" id="icon_filename" value="', !empty($context['icon']['filename']) ? $context['icon']['filename'] . '.png' : '', '" class="input_text">
  435. </dd>
  436. <dt>
  437. <strong><label for="icon_description">', $txt['smileys_description'], '</label>: </strong>
  438. </dt>
  439. <dd>
  440. <input type="text" name="icon_description" id="icon_description" value="', !empty($context['icon']['title']) ? $context['icon']['title'] : '', '" class="input_text">
  441. </dd>
  442. <dt>
  443. <strong><label for="icon_board_select">', $txt['icons_board'], '</label>: </strong>
  444. </dt>
  445. <dd>
  446. <select name="icon_board" id="icon_board_select">
  447. <option value="0"', empty($context['icon']['board_id']) ? ' selected' : '', '>', $txt['icons_edit_icons_all_boards'], '</option>';
  448. foreach ($context['categories'] as $category)
  449. {
  450. echo '
  451. <optgroup label="', $category['name'], '">';
  452. foreach ($category['boards'] as $board)
  453. echo '
  454. <option value="', $board['id'], '"', $board['selected'] ? ' selected' : '', '>', $board['child_level'] > 0 ? str_repeat('==', $board['child_level'] - 1) . '=&gt;' : '', ' ', $board['name'], '</option>';
  455. echo '
  456. </optgroup>';
  457. }
  458. echo '
  459. </select>
  460. </dd>
  461. <dt>
  462. <strong><label for="icon_location">', $txt['smileys_location'], '</label>: </strong>
  463. </dt>
  464. <dd>
  465. <select name="icon_location" id="icon_location">
  466. <option value="0"', empty($context['icon']['after']) ? ' selected' : '', '>', $txt['icons_location_first_icon'], '</option>';
  467. // Print the list of all the icons it can be put after...
  468. foreach ($context['icons'] as $id => $data)
  469. if (empty($context['icon']['id']) || $id != $context['icon']['id'])
  470. echo '
  471. <option value="', $id, '"', !empty($context['icon']['after']) && $id == $context['icon']['after'] ? ' selected' : '', '>', $txt['icons_location_after'], ': ', $data['title'], '</option>';
  472. echo '
  473. </select>
  474. </dd>
  475. </dl>';
  476. if (!$context['new_icon'])
  477. echo '
  478. <input type="hidden" name="icon" value="', $context['icon']['id'], '">';
  479. echo '
  480. <hr class="hrcolor">
  481. <input type="submit" name="icons_save" value="', $txt['smileys_save'], '" class="button_submit">
  482. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
  483. </div>
  484. </div>
  485. </form>
  486. </div>';
  487. }
  488. ?>