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="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. </div>
  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 id="errorbox">
  332. <span class="alert">', $context['entries_not_writable_message'], '</span>
  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. <span class="botslice"><span></span></span>
  391. </div>';
  392. }
  393. echo '
  394. </form>
  395. </div>
  396. <br class="clear" />';
  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 class="smalltext error">', $txt['add_language_error_' . $context['smf_error']], '</div>';
  426. }
  427. echo '
  428. </fieldset>
  429. <div class="righttext">
  430. ', isBrowser('is_ie') ? '<input type="text" name="ie_fix" style="display: none;" class="input_text" /> ' : '', '
  431. <input type="submit" name="smf_add_sub" value="', $txt['search'], '" class="button_submit" />
  432. </div>
  433. </div>
  434. <span class="botslice"><span></span></span>
  435. </div>
  436. ';
  437. // Had some results?
  438. if (!empty($context['smf_languages']))
  439. {
  440. echo '
  441. <div class="information">', $txt['add_language_smf_found'], '</div>
  442. <table class="table_grid" cellspacing="0" width="100%">
  443. <thead>
  444. <tr class="catbg">
  445. <th class="first_th" scope="col">', $txt['name'], '</th>
  446. <th scope="col">', $txt['add_language_smf_desc'], '</th>
  447. <th scope="col">', $txt['add_language_smf_version'], '</th>
  448. <th scope="col">', $txt['add_language_smf_utf8'], '</th>
  449. <th class="last_th" scope="col">', $txt['add_language_smf_install'], '</th>
  450. </tr>
  451. </thead>
  452. <tbody>';
  453. foreach ($context['smf_languages'] as $language)
  454. {
  455. // Write each language information out.
  456. echo '
  457. <tr class="windowbg2">
  458. <td align="left">', $language['name'], '</td>
  459. <td align="left">', $language['description'], '</td>
  460. <td align="left">', $language['version'], '</td>
  461. <td align="center">', $language['utf8'] ? $txt['yes'] : $txt['no'], '</td>
  462. <td align="left"><a href="', $language['link'], '">', $txt['add_language_smf_install'], '</a></td>
  463. </tr>';
  464. }
  465. echo '
  466. </tbody>
  467. </table>';
  468. }
  469. echo '
  470. </form>
  471. </div>
  472. <br class="clear" />';
  473. }
  474. ?>