ManageLanguages.template.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479
  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. /**
  13. * Download a new language file.
  14. */
  15. function template_download_language()
  16. {
  17. global $context, $settings, $txt, $scripturl, $modSettings;
  18. // Actually finished?
  19. if (!empty($context['install_complete']))
  20. {
  21. echo '
  22. <div id="admincenter">
  23. <div class="cat_bar">
  24. <h3 class="catbg">
  25. ', $txt['languages_download_complete'], '
  26. </h3>
  27. </div>
  28. <div class="windowbg">
  29. <div class="content">
  30. ', $context['install_complete'], '
  31. </div>
  32. </div>
  33. </div>';
  34. return;
  35. }
  36. // An error?
  37. if (!empty($context['error_message']))
  38. echo '
  39. <div class="errorbox">
  40. ', $context['error_message'], '
  41. </div>';
  42. // Provide something of an introduction...
  43. echo '
  44. <div id="admincenter">
  45. <form action="', $scripturl, '?action=admin;area=languages;sa=downloadlang;did=', $context['download_id'], ';', $context['session_var'], '=', $context['session_id'], '" method="post" accept-charset="', $context['character_set'], '">
  46. <div class="cat_bar">
  47. <h3 class="catbg">
  48. ', $txt['languages_download'], '
  49. </h3>
  50. </div>
  51. <div class="windowbg">
  52. <div class="content">
  53. <p>
  54. ', $txt['languages_download_note'], '
  55. </p>
  56. <div class="smalltext">
  57. ', $txt['languages_download_info'], '
  58. </div>
  59. </div>
  60. </div>';
  61. // Show the main files.
  62. template_show_list('lang_main_files_list');
  63. // Now, all the images and the likes, hidden via javascript 'cause there are so fecking many.
  64. echo '
  65. <br>
  66. <div class="title_bar">
  67. <h3 class="titlebg">
  68. ', $txt['languages_download_theme_files'], '
  69. </h3>
  70. </div>
  71. <table class="table_grid" cellspacing="0">
  72. <thead>
  73. <tr class="catbg">
  74. <th class="first_th" scope="col">
  75. ', $txt['languages_download_filename'], '
  76. </th>
  77. <th scope="col" width="100">
  78. ', $txt['languages_download_writable'], '
  79. </th>
  80. <th scope="col" width="100">
  81. ', $txt['languages_download_exists'], '
  82. </th>
  83. <th class="last_th centercol" scope="col" width="4%">
  84. ', $txt['languages_download_copy'], '
  85. </th>
  86. </tr>
  87. </thead>
  88. <tbody>';
  89. foreach ($context['files']['images'] as $theme => $group)
  90. {
  91. $count = 0;
  92. echo '
  93. <tr class="titlebg">
  94. <td colspan="4">
  95. <img class="sort" src="', $settings['images_url'], '/selected_open.png" id="toggle_image_', $theme, '" alt="*">&nbsp;', isset($context['theme_names'][$theme]) ? $context['theme_names'][$theme] : $theme, '
  96. </td>
  97. </tr>';
  98. $alternate = false;
  99. foreach ($group as $file)
  100. {
  101. echo '
  102. <tr class="windowbg', $alternate ? '2' : '', '" id="', $theme, '-', $count++, '">
  103. <td>
  104. <strong>', $file['name'], '</strong><br>
  105. <span class="smalltext">', $txt['languages_download_dest'], ': ', $file['destination'], '</span>
  106. </td>
  107. <td>
  108. <span style="color: ', ($file['writable'] ? 'green' : 'red'), ';">', ($file['writable'] ? $txt['yes'] : $txt['no']), '</span>
  109. </td>
  110. <td>
  111. ', $file['exists'] ? ($file['exists'] == 'same' ? $txt['languages_download_exists_same'] : $txt['languages_download_exists_different']) : $txt['no'], '
  112. </td>
  113. <td class="centercol">
  114. <input type="checkbox" name="copy_file[]" value="', $file['generaldest'], '"', ($file['default_copy'] ? ' checked' : ''), ' class="input_check">
  115. </td>
  116. </tr>';
  117. $alternate = !$alternate;
  118. }
  119. }
  120. echo '
  121. </tbody>
  122. </table>';
  123. // Do we want some FTP baby?
  124. // If the files are not writable, we might!
  125. if (!empty($context['still_not_writable']))
  126. {
  127. if (!empty($context['package_ftp']['error']))
  128. echo '
  129. <div class="errorbox">
  130. ', $context['package_ftp']['error'], '
  131. </div>';
  132. echo '
  133. <div class="cat_bar">
  134. <h3 class="catbg">
  135. ', $txt['package_ftp_necessary'], '
  136. </h3>
  137. </div>
  138. <div class="windowbg">
  139. <div class="content">
  140. <p>', $txt['package_ftp_why'],'</p>
  141. <dl class="settings">
  142. <dt
  143. <label for="ftp_server">', $txt['package_ftp_server'], ':</label>
  144. </dt>
  145. <dd>
  146. <div class="floatright" style="margin-right: 1px;"><label for="ftp_port" style="padding-top: 2px; padding-right: 2ex;">', $txt['package_ftp_port'], ':&nbsp;</label> <input type="text" size="3" name="ftp_port" id="ftp_port" value="', isset($context['package_ftp']['port']) ? $context['package_ftp']['port'] : (isset($modSettings['package_port']) ? $modSettings['package_port'] : '21'), '" class="input_text"></div>
  147. <input type="text" size="30" name="ftp_server" id="ftp_server" value="', isset($context['package_ftp']['server']) ? $context['package_ftp']['server'] : (isset($modSettings['package_server']) ? $modSettings['package_server'] : 'localhost'), '" style="width: 70%;" class="input_text">
  148. </dd>
  149. <dt>
  150. <label for="ftp_username">', $txt['package_ftp_username'], ':</label>
  151. </dt>
  152. <dd>
  153. <input type="text" size="50" name="ftp_username" id="ftp_username" value="', isset($context['package_ftp']['username']) ? $context['package_ftp']['username'] : (isset($modSettings['package_username']) ? $modSettings['package_username'] : ''), '" style="width: 99%;" class="input_text">
  154. </dd>
  155. <dt>
  156. <label for="ftp_password">', $txt['package_ftp_password'], ':</label>
  157. </dt>
  158. <dd>
  159. <input type="password" size="50" name="ftp_password" id="ftp_password" style="width: 99%;" class="input_text">
  160. </dd>
  161. <dt>
  162. <label for="ftp_path">', $txt['package_ftp_path'], ':</label>
  163. </dt>
  164. <dd>
  165. <input type="text" size="50" name="ftp_path" id="ftp_path" value="', $context['package_ftp']['path'], '" style="width: 99%;" class="input_text">
  166. </dd>
  167. </dl>
  168. </div>
  169. </div>';
  170. }
  171. // Install?
  172. echo '
  173. <div class="righttext padding">
  174. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
  175. <input type="hidden" name="', $context['admin-dlang_token_var'], '" value="', $context['admin-dlang_token'], '">
  176. <input type="submit" name="do_install" value="', $txt['add_language_smf_install'], '" class="button_submit">
  177. </div>
  178. </form>
  179. </div>';
  180. // The javascript for expand and collapse of sections.
  181. echo '
  182. <script><!-- // --><![CDATA[';
  183. // Each theme gets its own handler.
  184. foreach ($context['files']['images'] as $theme => $group)
  185. {
  186. $count = 0;
  187. echo '
  188. var oTogglePanel_', $theme, ' = new smc_Toggle({
  189. bToggleEnabled: true,
  190. bCurrentlyCollapsed: true,
  191. aSwappableContainers: [';
  192. foreach ($group as $file)
  193. echo '
  194. ', JavaScriptEscape($theme . '-' . $count++), ',';
  195. echo '
  196. null
  197. ],
  198. aSwapImages: [
  199. {
  200. sId: \'toggle_image_', $theme, '\',
  201. srcExpanded: smf_images_url + \'/selected_open.png\',
  202. altExpanded: \'*\',
  203. srcCollapsed: smf_images_url + \'/selected.png\',
  204. altCollapsed: \'*\'
  205. }
  206. ]
  207. });';
  208. }
  209. echo '
  210. // ]]></script>';
  211. }
  212. /**
  213. * Edit language entries.
  214. */
  215. function template_modify_language_entries()
  216. {
  217. global $context, $settings, $txt, $scripturl;
  218. echo '
  219. <div id="admincenter">
  220. <form action="', $scripturl, '?action=admin;area=languages;sa=editlang;lid=', $context['lang_id'], '" method="post" accept-charset="', $context['character_set'], '">
  221. <div class="cat_bar">
  222. <h3 class="catbg">
  223. ', $txt['edit_languages'], '
  224. </h3>
  225. </div>
  226. <div id="editlang_desc" class="information">
  227. ', $txt['edit_language_entries_primary'], '
  228. </div>';
  229. // Not writable?
  230. if (!empty($context['lang_file_not_writable_message']))
  231. {
  232. // Oops, show an error for ya.
  233. echo '
  234. <div class="errorbox">
  235. ', $context['lang_file_not_writable_message'], '
  236. </div>';
  237. }
  238. // Show the language entries
  239. echo '
  240. <div class="windowbg">
  241. <div class="content">
  242. <fieldset>
  243. <legend>', $context['primary_settings']['name'], '</legend>
  244. <dl class="settings">
  245. <dt>
  246. <label for="character_set">', $txt['languages_character_set'], ':</label>
  247. </dt>
  248. <dd>
  249. <input type="text" name="character_set" id="character_set" size="20" value="', $context['primary_settings']['character_set'], '"', (empty($context['file_entries']) ? '' : ' disabled'), ' class="input_text">
  250. </dd>
  251. <dt>
  252. <label for="locale>', $txt['languages_locale'], ':</label>
  253. </dt>
  254. <dd>
  255. <input type="text" name="locale" id="locale" size="20" value="', $context['primary_settings']['locale'], '"', (empty($context['file_entries']) ? '' : ' disabled'), ' class="input_text">
  256. </dd>
  257. <dt>
  258. <label for="dictionary">', $txt['languages_dictionary'], ':</label>
  259. </dt>
  260. <dd>
  261. <input type="text" name="dictionary" id="dictionary" size="20" value="', $context['primary_settings']['dictionary'], '"', (empty($context['file_entries']) ? '' : ' disabled'), ' class="input_text">
  262. </dd>
  263. <dt>
  264. <label for="spelling">', $txt['languages_spelling'], ':</label>
  265. </dt>
  266. <dd>
  267. <input type="text" name="spelling" id="spelling" size="20" value="', $context['primary_settings']['spelling'], '"', (empty($context['file_entries']) ? '' : ' disabled'), ' class="input_text">
  268. </dd>
  269. <dt>
  270. <label for="rtl">', $txt['languages_rtl'], ':</label>
  271. </dt>
  272. <dd>
  273. <input type="checkbox" name="rtl" id="rtl"', $context['primary_settings']['rtl'] ? ' checked' : '', ' class="input_check"', (empty($context['file_entries']) ? '' : ' disabled'), '>
  274. </dd>
  275. </dl>
  276. </fieldset>
  277. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
  278. <input type="hidden" name="', $context['admin-mlang_token_var'], '" value="', $context['admin-mlang_token'], '">
  279. <input type="submit" name="save_main" value="', $txt['save'], '"', $context['lang_file_not_writable_message'] || !empty($context['file_entries']) ? ' disabled' : '', ' class="button_submit">';
  280. // Allow deleting entries.
  281. if ($context['lang_id'] != 'english')
  282. {
  283. // English can't be deleted though.
  284. echo '
  285. <input type="submit" name="delete_main" value="', $txt['delete'], '"', $context['lang_file_not_writable_message'] || !empty($context['file_entries']) ? ' disabled' : '', ' onclick="confirm(\'', $txt['languages_delete_confirm'], '\');" class="button_submit">';
  286. }
  287. echo '
  288. </div>
  289. </div>
  290. </form>
  291. <form action="', $scripturl, '?action=admin;area=languages;sa=editlang;lid=', $context['lang_id'], ';entries" id="entry_form" method="post" accept-charset="', $context['character_set'], '">
  292. <div class="title_bar">
  293. <h3 class="titlebg">
  294. ', $txt['edit_language_entries'], '
  295. </h3>
  296. </div>
  297. <div id="taskpad" class="floatright">
  298. ', $txt['edit_language_entries_file'], ':
  299. <select name="tfid" onchange="if (this.value != -1) document.forms.entry_form.submit();">
  300. <option value="-1">&nbsp;</option>';
  301. foreach ($context['possible_files'] as $id_theme => $theme)
  302. {
  303. echo '
  304. <optgroup label="', $theme['name'], '">';
  305. foreach ($theme['files'] as $file)
  306. {
  307. echo '
  308. <option value="', $id_theme, '+', $file['id'], '"', $file['selected'] ? ' selected' : '', '> =&gt; ', $file['name'], '</option>';
  309. }
  310. echo '
  311. </optgroup>';
  312. }
  313. echo '
  314. </select>
  315. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '">
  316. <input type="hidden" name="', $context['admin-mlang_token_var'], '" value="', $context['admin-mlang_token'], '">
  317. <input type="submit" value="', $txt['go'], '" class="button_submit" style="float: none"/>
  318. </div>
  319. <br class="clear">';
  320. // Is it not writable?
  321. // Show an error.
  322. if (!empty($context['entries_not_writable_message']))
  323. echo '
  324. <div class="errorbox">
  325. ', $context['entries_not_writable_message'], '
  326. </div>';
  327. // Already have some file entries?
  328. if (!empty($context['file_entries']))
  329. {
  330. echo '
  331. <div class="windowbg2">
  332. <div class="content">
  333. <dl class="settings">';
  334. $cached = array();
  335. foreach ($context['file_entries'] as $entry)
  336. {
  337. // Do it in two's!
  338. if (empty($cached))
  339. {
  340. $cached = $entry;
  341. continue;
  342. }
  343. echo '
  344. <dt>
  345. <span class="smalltext">', $cached['key'], '</span>
  346. </dt>
  347. <dd>
  348. <span class="smalltext">', $entry['key'], '</span>
  349. </dd>
  350. <dt>
  351. <input type="hidden" name="comp[', $cached['key'], ']" value="', $cached['value'], '">
  352. <textarea name="entry[', $cached['key'], ']" cols="40" rows="', $cached['rows'] < 2 ? 2 : $cached['rows'], '" style="' . (isBrowser('is_ie8') ? 'width: 635px; max-width: 96%; min-width: 96%' : 'width: 96%') . ';">', $cached['value'], '</textarea>
  353. </dt>
  354. <dd>
  355. <input type="hidden" name="comp[', $entry['key'], ']" value="', $entry['value'], '">
  356. <textarea name="entry[', $entry['key'], ']" cols="40" rows="', $entry['rows'] < 2 ? 2 : $entry['rows'], '" style="' . (isBrowser('is_ie8') ? 'width: 635px; max-width: 96%; min-width: 96%' : 'width: 96%') . ';">', $entry['value'], '</textarea>
  357. </dd>';
  358. $cached = array();
  359. }
  360. // Odd number?
  361. if (!empty($cached))
  362. {
  363. // Alternative time
  364. echo '
  365. <dt>
  366. <span class="smalltext">', $cached['key'], '</span>
  367. </dt>
  368. <dd>
  369. </dd>
  370. <dt>
  371. <input type="hidden" name="comp[', $cached['key'], ']" value="', $cached['value'], '">
  372. <textarea name="entry[', $cached['key'], ']" cols="40" rows="2" style="' . (isBrowser('is_ie8') ? 'width: 635px; max-width: 96%; min-width: 96%' : 'width: 96%') . ';">', $cached['value'], '</textarea>
  373. </dt>
  374. <dd>
  375. </dd>';
  376. }
  377. echo '
  378. </dl>
  379. <input type="submit" name="save_entries" value="', $txt['save'], '"', !empty($context['entries_not_writable_message']) ? ' disabled' : '', ' class="button_submit">';
  380. echo '
  381. </div>
  382. </div>';
  383. }
  384. echo '
  385. </form>
  386. </div>';
  387. }
  388. /**
  389. * Add a new language
  390. *
  391. */
  392. function template_add_language()
  393. {
  394. global $context, $txt, $scripturl;
  395. echo '
  396. <div id="admincenter">
  397. <form id="admin_form_wrapper"action="', $scripturl, '?action=admin;area=languages;sa=add;', $context['session_var'], '=', $context['session_id'], '" method="post" accept-charset="', $context['character_set'], '">
  398. <div class="cat_bar">
  399. <h3 class="catbg">
  400. ', $txt['add_language'], '
  401. </h3>
  402. </div>
  403. <div class="windowbg">
  404. <div class="content">
  405. <fieldset>
  406. <legend>', $txt['add_language_smf'], '</legend>
  407. <label class="smalltext">', $txt['add_language_smf_browse'], '</label>
  408. <input type="text" name="smf_add" size="40" value="', !empty($context['smf_search_term']) ? $context['smf_search_term'] : '', '" class="input_text">';
  409. // Do we have some errors? Too bad.
  410. if (!empty($context['smf_error']))
  411. {
  412. // Display a little error box.
  413. echo '
  414. <div><br><p class="errorbox">', $txt['add_language_error_' . $context['smf_error']], '</p></div>';
  415. }
  416. echo '
  417. </fieldset>', isBrowser('is_ie') ? '<input type="text" name="ie_fix" style="display: none;" class="input_text"> ' : '', '
  418. <input type="submit" name="smf_add_sub" value="', $txt['search'], '" class="button_submit">
  419. <br>
  420. </div>
  421. </div>
  422. ';
  423. // Had some results?
  424. if (!empty($context['smf_languages']['rows']))
  425. {
  426. echo '
  427. <div class="cat_bar"><h3 class="catbg">', $txt['add_language_found_title'], '</div><div class="information">', $txt['add_language_smf_found'], '</div>';
  428. template_show_list('smf_languages');
  429. }
  430. echo '
  431. </form>
  432. </div>';
  433. }
  434. ?>