ManageLanguages.template.php 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521
  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 id="errorbox">
  43. <p>', $context['error_message'], '</p>
  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 src="', $settings['images_url'], '/sort_down.gif" 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 id="errorbox">
  135. <tt>', $context['package_ftp']['error'], '</tt>
  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="submit" name="do_install" value="', $txt['add_language_smf_install'], '" class="button_submit" />
  183. </div>
  184. </form>
  185. </div>
  186. <br class="clear" />';
  187. // The javascript for expand and collapse of sections.
  188. echo '
  189. <script type="text/javascript"><!-- // --><![CDATA[';
  190. // Each theme gets its own handler.
  191. foreach ($context['files']['images'] as $theme => $group)
  192. {
  193. $count = 0;
  194. echo '
  195. var oTogglePanel_', $theme, ' = new smc_Toggle({
  196. bToggleEnabled: true,
  197. bCurrentlyCollapsed: true,
  198. aSwappableContainers: [';
  199. foreach ($group as $file)
  200. echo '
  201. ', JavaScriptEscape($theme . '-' . $count++), ',';
  202. echo '
  203. null
  204. ],
  205. aSwapImages: [
  206. {
  207. sId: \'toggle_image_', $theme, '\',
  208. srcExpanded: smf_images_url + \'/sort_down.gif\',
  209. altExpanded: \'*\',
  210. srcCollapsed: smf_images_url + \'/selected.gif\',
  211. altCollapsed: \'*\'
  212. }
  213. ]
  214. });';
  215. }
  216. echo '
  217. // ]]></script>';
  218. }
  219. /**
  220. * Edit language entries.
  221. */
  222. function template_modify_language_entries()
  223. {
  224. global $context, $settings, $options, $txt, $scripturl;
  225. echo '
  226. <div id="admincenter">
  227. <form action="', $scripturl, '?action=admin;area=languages;sa=editlang;lid=', $context['lang_id'], '" method="post" accept-charset="', $context['character_set'], '">
  228. <div class="cat_bar">
  229. <h3 class="catbg">
  230. ', $txt['edit_languages'], '
  231. </h3>
  232. </div>';
  233. // Not writable?
  234. if ($context['lang_file_not_writable_message'])
  235. {
  236. // Oops, show an error for ya.
  237. echo '
  238. <div id="errorbox">
  239. <p class="alert">', $context['lang_file_not_writable_message'], '</p>
  240. </div>';
  241. }
  242. // Show the language entries
  243. echo '
  244. <div class="information">
  245. ', $txt['edit_language_entries_primary'], '
  246. </div>
  247. <div class="windowbg">
  248. <span class="topslice"><span></span></span>
  249. <div class="content">
  250. <fieldset>
  251. <legend>', $context['primary_settings']['name'], '</legend>
  252. <dl class="settings">
  253. <dt>
  254. ', $txt['languages_character_set'], ':
  255. </dt>
  256. <dd>
  257. <input type="text" name="character_set" size="20" value="', $context['primary_settings']['character_set'], '"', (empty($context['file_entries']) ? '' : ' disabled="disabled"'), ' class="input_text" />
  258. </dd>
  259. <dt>
  260. ', $txt['languages_locale'], ':
  261. </dt>
  262. <dd>
  263. <input type="text" name="locale" size="20" value="', $context['primary_settings']['locale'], '"', (empty($context['file_entries']) ? '' : ' disabled="disabled"'), ' class="input_text" />
  264. </dd>
  265. <dt>
  266. ', $txt['languages_dictionary'], ':
  267. </dt>
  268. <dd>
  269. <input type="text" name="dictionary" size="20" value="', $context['primary_settings']['dictionary'], '"', (empty($context['file_entries']) ? '' : ' disabled="disabled"'), ' class="input_text" />
  270. </dd>
  271. <dt>
  272. ', $txt['languages_spelling'], ':
  273. </dt>
  274. <dd>
  275. <input type="text" name="spelling" size="20" value="', $context['primary_settings']['spelling'], '"', (empty($context['file_entries']) ? '' : ' disabled="disabled"'), ' class="input_text" />
  276. </dd>
  277. <dt>
  278. ', $txt['languages_rtl'], ':
  279. </dt>
  280. <dd>
  281. <input type="checkbox" name="rtl"', $context['primary_settings']['rtl'] ? ' checked="checked"' : '', ' class="input_check"', (empty($context['file_entries']) ? '' : ' disabled="disabled"'), ' />
  282. </dd>
  283. </dl>
  284. </fieldset>
  285. <div class="righttext">
  286. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  287. <input type="submit" name="save_main" value="', $txt['save'], '"', $context['lang_file_not_writable_message'] || !empty($context['file_entries']) ? ' disabled="disabled"' : '', ' class="button_submit" />';
  288. // Allow deleting entries.
  289. if ($context['lang_id'] != 'english')
  290. {
  291. // English can't be deleted though.
  292. echo '
  293. <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" />';
  294. }
  295. echo '
  296. </div>
  297. </div>
  298. <span class="botslice"><span></span></span>
  299. </div>
  300. </form>
  301. <form action="', $scripturl, '?action=admin;area=languages;sa=editlang;lid=', $context['lang_id'], ';entries" id="entry_form" method="post" accept-charset="', $context['character_set'], '">
  302. <div class="title_bar">
  303. <h3 class="titlebg">
  304. ', $txt['edit_language_entries'], '
  305. </h3>
  306. </div>
  307. <div id="taskpad" class="floatright">
  308. ', $txt['edit_language_entries_file'], ':
  309. <select name="tfid" onchange="if (this.value != -1) document.forms.entry_form.submit();">';
  310. foreach ($context['possible_files'] as $id_theme => $theme)
  311. {
  312. echo '
  313. <option value="-1">', $theme['name'], '</option>';
  314. foreach ($theme['files'] as $file)
  315. {
  316. echo '
  317. <option value="', $id_theme, '+', $file['id'], '"', $file['selected'] ? ' selected="selected"' : '', '> =&gt; ', $file['name'], '</option>';
  318. }
  319. }
  320. echo '
  321. </select>
  322. <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
  323. <input type="hidden" name="', $context['admin-mlang_token_var'], '" value="', $context['admin-mlang_token'], '" />
  324. <input type="submit" value="', $txt['go'], '" class="button_submit" />
  325. </div>';
  326. // Is it not writable?
  327. // Show an error.
  328. if (!empty($context['entries_not_writable_message']))
  329. echo '
  330. <div id="errorbox">
  331. <span class="alert">', $context['entries_not_writable_message'], '</span>
  332. </div>';
  333. // Already have some file entries?
  334. if (!empty($context['file_entries']))
  335. {
  336. echo '
  337. <div class="windowbg2">
  338. <span class="topslice"><span></span></span>
  339. <div class="content">
  340. <dl class="settings">';
  341. $cached = array();
  342. foreach ($context['file_entries'] as $entry)
  343. {
  344. // Do it in two's!
  345. if (empty($cached))
  346. {
  347. $cached = $entry;
  348. continue;
  349. }
  350. echo '
  351. <dt>
  352. <span class="smalltext">', $cached['key'], '</span>
  353. </dt>
  354. <dd>
  355. <span class="smalltext">', $entry['key'], '</span>
  356. </dd>
  357. <dt>
  358. <input type="hidden" name="comp[', $cached['key'], ']" value="', $cached['value'], '" />
  359. <textarea name="entry[', $cached['key'], ']" cols="40" rows="', $cached['rows'] < 2 ? 2 : $cached['rows'], '" style="' . ($context['browser']['is_ie8'] ? 'width: 635px; max-width: 96%; min-width: 96%' : 'width: 96%') . ';">', $cached['value'], '</textarea>
  360. </dt>
  361. <dd>
  362. <input type="hidden" name="comp[', $entry['key'], ']" value="', $entry['value'], '" />
  363. <textarea name="entry[', $entry['key'], ']" cols="40" rows="', $entry['rows'] < 2 ? 2 : $entry['rows'], '" style="' . ($context['browser']['is_ie8'] ? 'width: 635px; max-width: 96%; min-width: 96%' : 'width: 96%') . ';">', $entry['value'], '</textarea>
  364. </dd>';
  365. $cached = array();
  366. }
  367. // Odd number?
  368. if (!empty($cached))
  369. {
  370. // Alternative time
  371. echo '
  372. <dt>
  373. <span class="smalltext">', $cached['key'], '</span>
  374. </dt>
  375. <dd>
  376. </dd>
  377. <dt>
  378. <input type="hidden" name="comp[', $cached['key'], ']" value="', $cached['value'], '" />
  379. <textarea name="entry[', $cached['key'], ']" cols="40" rows="2" style="' . ($context['browser']['is_ie8'] ? 'width: 635px; max-width: 96%; min-width: 96%' : 'width: 96%') . ';">', $cached['value'], '</textarea>
  380. </dt>
  381. <dd>
  382. </dd>';
  383. }
  384. echo '
  385. </dl>
  386. <input type="submit" name="save_entries" value="', $txt['save'], '"', !empty($context['entries_not_writable_message']) ? ' disabled="disabled"' : '', ' class="button_submit" />';
  387. echo '
  388. </div>
  389. <span class="botslice"><span></span></span>
  390. </div>';
  391. }
  392. echo '
  393. </form>
  394. </div>
  395. <br class="clear" />';
  396. }
  397. /**
  398. * Add a new language
  399. *
  400. */
  401. function template_add_language()
  402. {
  403. global $context, $settings, $options, $txt, $scripturl;
  404. echo '
  405. <div id="admincenter">
  406. <form action="', $scripturl, '?action=admin;area=languages;sa=add;', $context['session_var'], '=', $context['session_id'], '" method="post" accept-charset="', $context['character_set'], '">
  407. <div class="cat_bar">
  408. <h3 class="catbg">
  409. ', $txt['add_language'], '
  410. </h3>
  411. </div>
  412. <div class="windowbg">
  413. <span class="topslice"><span></span></span>
  414. <div class="content">
  415. <fieldset>
  416. <legend>', $txt['add_language_smf'], '</legend>
  417. <label class="smalltext">', $txt['add_language_smf_browse'], '</label>
  418. <input type="text" name="smf_add" size="40" value="', !empty($context['smf_search_term']) ? $context['smf_search_term'] : '', '" class="input_text" />';
  419. // Do we have some errors? Too bad.
  420. if (!empty($context['smf_error']))
  421. {
  422. // Display a little error box.
  423. echo '
  424. <div class="smalltext error">', $txt['add_language_error_' . $context['smf_error']], '</div>';
  425. }
  426. echo '
  427. </fieldset>
  428. <div class="righttext">
  429. ', $context['browser']['is_ie'] ? '<input type="text" name="ie_fix" style="display: none;" class="input_text" /> ' : '', '
  430. <input type="submit" name="smf_add_sub" value="', $txt['search'], '" class="button_submit" />
  431. </div>
  432. </div>
  433. <span class="botslice"><span></span></span>
  434. </div>
  435. ';
  436. // Had some results?
  437. if (!empty($context['smf_languages']))
  438. {
  439. echo '
  440. <div class="information">', $txt['add_language_smf_found'], '</div>
  441. <table class="table_grid" cellspacing="0" width="100%">
  442. <thead>
  443. <tr class="catbg">
  444. <th class="first_th" scope="col">', $txt['name'], '</th>
  445. <th scope="col">', $txt['add_language_smf_desc'], '</th>
  446. <th scope="col">', $txt['add_language_smf_version'], '</th>
  447. <th scope="col">', $txt['add_language_smf_utf8'], '</th>
  448. <th class="last_th" scope="col">', $txt['add_language_smf_install'], '</th>
  449. </tr>
  450. </thead>
  451. <tbody>';
  452. foreach ($context['smf_languages'] as $language)
  453. {
  454. // Write each language information out.
  455. echo '
  456. <tr class="windowbg2">
  457. <td align="left">', $language['name'], '</td>
  458. <td align="left">', $language['description'], '</td>
  459. <td align="left">', $language['version'], '</td>
  460. <td align="center">', $language['utf8'] ? $txt['yes'] : $txt['no'], '</td>
  461. <td align="left"><a href="', $language['link'], '">', $txt['add_language_smf_install'], '</a></td>
  462. </tr>';
  463. }
  464. echo '
  465. </tbody>
  466. </table>';
  467. }
  468. echo '
  469. </form>
  470. </div>
  471. <br class="clear" />';
  472. }
  473. ?>