ManageLanguages.template.php 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475
  1. <?php
  2. /**
  3. * Simple Machines Forum (SMF)
  4. *
  5. * @package SMF
  6. * @author Simple Machines
  7. * @copyright 2012 Simple Machines
  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, $options, $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" width="100%">
  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'], '/sort_down.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="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 type="text/javascript"><!-- // --><![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 + \'/sort_down.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, $options, $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="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="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="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="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="checked"' : '', ' class="input_check"', (empty($context['file_entries']) ? '' : ' disabled="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="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="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. foreach ($context['possible_files'] as $id_theme => $theme)
  301. {
  302. echo '
  303. <option value="-1">', $theme['name'], '</option>';
  304. foreach ($theme['files'] as $file)
  305. {
  306. echo '
  307. <option value="', $id_theme, '+', $file['id'], '"', $file['selected'] ? ' selected="selected"' : '', '> =&gt; ', $file['name'], '</option>';
  308. }
  309. }
  310. echo '
  311. </select>
  312. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  313. <input type="hidden" name="', $context['admin-mlang_token_var'], '" value="', $context['admin-mlang_token'], '" />
  314. <input type="submit" value="', $txt['go'], '" class="button_submit" style="float: none"/>
  315. </div>
  316. <br class="clear" />';
  317. // Is it not writable?
  318. // Show an error.
  319. if (!empty($context['entries_not_writable_message']))
  320. echo '
  321. <div class="errorbox">
  322. ', $context['entries_not_writable_message'], '
  323. </div>';
  324. // Already have some file entries?
  325. if (!empty($context['file_entries']))
  326. {
  327. echo '
  328. <div class="windowbg2">
  329. <div class="content">
  330. <dl class="settings">';
  331. $cached = array();
  332. foreach ($context['file_entries'] as $entry)
  333. {
  334. // Do it in two's!
  335. if (empty($cached))
  336. {
  337. $cached = $entry;
  338. continue;
  339. }
  340. echo '
  341. <dt>
  342. <span class="smalltext">', $cached['key'], '</span>
  343. </dt>
  344. <dd>
  345. <span class="smalltext">', $entry['key'], '</span>
  346. </dd>
  347. <dt>
  348. <input type="hidden" name="comp[', $cached['key'], ']" value="', $cached['value'], '" />
  349. <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>
  350. </dt>
  351. <dd>
  352. <input type="hidden" name="comp[', $entry['key'], ']" value="', $entry['value'], '" />
  353. <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>
  354. </dd>';
  355. $cached = array();
  356. }
  357. // Odd number?
  358. if (!empty($cached))
  359. {
  360. // Alternative time
  361. echo '
  362. <dt>
  363. <span class="smalltext">', $cached['key'], '</span>
  364. </dt>
  365. <dd>
  366. </dd>
  367. <dt>
  368. <input type="hidden" name="comp[', $cached['key'], ']" value="', $cached['value'], '" />
  369. <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>
  370. </dt>
  371. <dd>
  372. </dd>';
  373. }
  374. echo '
  375. </dl>
  376. <input type="submit" name="save_entries" value="', $txt['save'], '"', !empty($context['entries_not_writable_message']) ? ' disabled="disabled"' : '', ' class="button_submit" />';
  377. echo '
  378. </div>
  379. </div>';
  380. }
  381. echo '
  382. </form>
  383. </div>';
  384. }
  385. /**
  386. * Add a new language
  387. *
  388. */
  389. function template_add_language()
  390. {
  391. global $context, $settings, $options, $txt, $scripturl;
  392. echo '
  393. <div id="admincenter">
  394. <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'], '">
  395. <div class="cat_bar">
  396. <h3 class="catbg">
  397. ', $txt['add_language'], '
  398. </h3>
  399. </div>
  400. <div class="windowbg">
  401. <div class="content">
  402. <fieldset>
  403. <legend>', $txt['add_language_smf'], '</legend>
  404. <label class="smalltext">', $txt['add_language_smf_browse'], '</label>
  405. <input type="text" name="smf_add" size="40" value="', !empty($context['smf_search_term']) ? $context['smf_search_term'] : '', '" class="input_text" />';
  406. // Do we have some errors? Too bad.
  407. if (!empty($context['smf_error']))
  408. {
  409. // Display a little error box.
  410. echo '
  411. <div><br /><p class="errorbox">', $txt['add_language_error_' . $context['smf_error']], '</p></div>';
  412. }
  413. echo '
  414. </fieldset>', isBrowser('is_ie') ? '<input type="text" name="ie_fix" style="display: none;" class="input_text" /> ' : '', '
  415. <input type="submit" name="smf_add_sub" value="', $txt['search'], '" class="button_submit" />
  416. <br />
  417. </div>
  418. </div>
  419. ';
  420. // Had some results?
  421. if (!empty($context['smf_languages']))
  422. {
  423. echo '
  424. <div class="information">', $txt['add_language_smf_found'], '</div>';
  425. template_show_list('smf_languages');
  426. }
  427. echo '
  428. </form>
  429. </div>';
  430. }
  431. ?>