ManageLanguages.template.php 17 KB

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