ManageLanguages.template.php 15 KB

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