ManageLanguages.template.php 16 KB

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