123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479 |
- <?php
- /**
- * Simple Machines Forum (SMF)
- *
- * @package SMF
- * @author Simple Machines
- * @copyright 2014 Simple Machines and individual contributors
- * @license http://www.simplemachines.org/about/smf/license.php BSD
- *
- * @version 2.1 Alpha 1
- */
- /**
- * Download a new language file.
- */
- function template_download_language()
- {
- global $context, $settings, $txt, $scripturl, $modSettings;
- // Actually finished?
- if (!empty($context['install_complete']))
- {
- echo '
- <div id="admincenter">
- <div class="cat_bar">
- <h3 class="catbg">
- ', $txt['languages_download_complete'], '
- </h3>
- </div>
- <div class="windowbg">
- <div class="content">
- ', $context['install_complete'], '
- </div>
- </div>
- </div>';
- return;
- }
- // An error?
- if (!empty($context['error_message']))
- echo '
- <div class="errorbox">
- ', $context['error_message'], '
- </div>';
- // Provide something of an introduction...
- echo '
- <div id="admincenter">
- <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'], '">
- <div class="cat_bar">
- <h3 class="catbg">
- ', $txt['languages_download'], '
- </h3>
- </div>
- <div class="windowbg">
- <div class="content">
- <p>
- ', $txt['languages_download_note'], '
- </p>
- <div class="smalltext">
- ', $txt['languages_download_info'], '
- </div>
- </div>
- </div>';
- // Show the main files.
- template_show_list('lang_main_files_list');
- // Now, all the images and the likes, hidden via javascript 'cause there are so fecking many.
- echo '
- <br />
- <div class="title_bar">
- <h3 class="titlebg">
- ', $txt['languages_download_theme_files'], '
- </h3>
- </div>
- <table class="table_grid" cellspacing="0">
- <thead>
- <tr class="catbg">
- <th class="first_th" scope="col">
- ', $txt['languages_download_filename'], '
- </th>
- <th scope="col" width="100">
- ', $txt['languages_download_writable'], '
- </th>
- <th scope="col" width="100">
- ', $txt['languages_download_exists'], '
- </th>
- <th class="last_th centercol" scope="col" width="4%">
- ', $txt['languages_download_copy'], '
- </th>
- </tr>
- </thead>
- <tbody>';
- foreach ($context['files']['images'] as $theme => $group)
- {
- $count = 0;
- echo '
- <tr class="titlebg">
- <td colspan="4">
- <img class="sort" src="', $settings['images_url'], '/selected_open.png" id="toggle_image_', $theme, '" alt="*" /> ', isset($context['theme_names'][$theme]) ? $context['theme_names'][$theme] : $theme, '
- </td>
- </tr>';
- $alternate = false;
- foreach ($group as $file)
- {
- echo '
- <tr class="windowbg', $alternate ? '2' : '', '" id="', $theme, '-', $count++, '">
- <td>
- <strong>', $file['name'], '</strong><br />
- <span class="smalltext">', $txt['languages_download_dest'], ': ', $file['destination'], '</span>
- </td>
- <td>
- <span style="color: ', ($file['writable'] ? 'green' : 'red'), ';">', ($file['writable'] ? $txt['yes'] : $txt['no']), '</span>
- </td>
- <td>
- ', $file['exists'] ? ($file['exists'] == 'same' ? $txt['languages_download_exists_same'] : $txt['languages_download_exists_different']) : $txt['no'], '
- </td>
- <td class="centercol">
- <input type="checkbox" name="copy_file[]" value="', $file['generaldest'], '"', ($file['default_copy'] ? ' checked' : ''), ' class="input_check" />
- </td>
- </tr>';
- $alternate = !$alternate;
- }
- }
- echo '
- </tbody>
- </table>';
- // Do we want some FTP baby?
- // If the files are not writable, we might!
- if (!empty($context['still_not_writable']))
- {
- if (!empty($context['package_ftp']['error']))
- echo '
- <div class="errorbox">
- ', $context['package_ftp']['error'], '
- </div>';
- echo '
- <div class="cat_bar">
- <h3 class="catbg">
- ', $txt['package_ftp_necessary'], '
- </h3>
- </div>
- <div class="windowbg">
- <div class="content">
- <p>', $txt['package_ftp_why'],'</p>
- <dl class="settings">
- <dt
- <label for="ftp_server">', $txt['package_ftp_server'], ':</label>
- </dt>
- <dd>
- <div class="floatright" style="margin-right: 1px;"><label for="ftp_port" style="padding-top: 2px; padding-right: 2ex;">', $txt['package_ftp_port'], ': </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>
- <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" />
- </dd>
- <dt>
- <label for="ftp_username">', $txt['package_ftp_username'], ':</label>
- </dt>
- <dd>
- <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" />
- </dd>
- <dt>
- <label for="ftp_password">', $txt['package_ftp_password'], ':</label>
- </dt>
- <dd>
- <input type="password" size="50" name="ftp_password" id="ftp_password" style="width: 99%;" class="input_text" />
- </dd>
- <dt>
- <label for="ftp_path">', $txt['package_ftp_path'], ':</label>
- </dt>
- <dd>
- <input type="text" size="50" name="ftp_path" id="ftp_path" value="', $context['package_ftp']['path'], '" style="width: 99%;" class="input_text" />
- </dd>
- </dl>
- </div>
- </div>';
- }
- // Install?
- echo '
- <div class="righttext padding">
- <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
- <input type="hidden" name="', $context['admin-dlang_token_var'], '" value="', $context['admin-dlang_token'], '" />
- <input type="submit" name="do_install" value="', $txt['add_language_smf_install'], '" class="button_submit" />
- </div>
- </form>
- </div>';
- // The javascript for expand and collapse of sections.
- echo '
- <script><!-- // --><![CDATA[';
- // Each theme gets its own handler.
- foreach ($context['files']['images'] as $theme => $group)
- {
- $count = 0;
- echo '
- var oTogglePanel_', $theme, ' = new smc_Toggle({
- bToggleEnabled: true,
- bCurrentlyCollapsed: true,
- aSwappableContainers: [';
- foreach ($group as $file)
- echo '
- ', JavaScriptEscape($theme . '-' . $count++), ',';
- echo '
- null
- ],
- aSwapImages: [
- {
- sId: \'toggle_image_', $theme, '\',
- srcExpanded: smf_images_url + \'/selected_open.png\',
- altExpanded: \'*\',
- srcCollapsed: smf_images_url + \'/selected.png\',
- altCollapsed: \'*\'
- }
- ]
- });';
- }
- echo '
- // ]]></script>';
- }
- /**
- * Edit language entries.
- */
- function template_modify_language_entries()
- {
- global $context, $settings, $txt, $scripturl;
- echo '
- <div id="admincenter">
- <form action="', $scripturl, '?action=admin;area=languages;sa=editlang;lid=', $context['lang_id'], '" method="post" accept-charset="', $context['character_set'], '">
- <div class="cat_bar">
- <h3 class="catbg">
- ', $txt['edit_languages'], '
- </h3>
- </div>
- <div id="editlang_desc" class="information">
- ', $txt['edit_language_entries_primary'], '
- </div>';
- // Not writable?
- if (!empty($context['lang_file_not_writable_message']))
- {
- // Oops, show an error for ya.
- echo '
- <div class="errorbox">
- ', $context['lang_file_not_writable_message'], '
- </div>';
- }
- // Show the language entries
- echo '
- <div class="windowbg">
- <div class="content">
- <fieldset>
- <legend>', $context['primary_settings']['name'], '</legend>
- <dl class="settings">
- <dt>
- <label for="character_set">', $txt['languages_character_set'], ':</label>
- </dt>
- <dd>
- <input type="text" name="character_set" id="character_set" size="20" value="', $context['primary_settings']['character_set'], '"', (empty($context['file_entries']) ? '' : ' disabled'), ' class="input_text" />
- </dd>
- <dt>
- <label for="locale>', $txt['languages_locale'], ':</label>
- </dt>
- <dd>
- <input type="text" name="locale" id="locale" size="20" value="', $context['primary_settings']['locale'], '"', (empty($context['file_entries']) ? '' : ' disabled'), ' class="input_text" />
- </dd>
- <dt>
- <label for="dictionary">', $txt['languages_dictionary'], ':</label>
- </dt>
- <dd>
- <input type="text" name="dictionary" id="dictionary" size="20" value="', $context['primary_settings']['dictionary'], '"', (empty($context['file_entries']) ? '' : ' disabled'), ' class="input_text" />
- </dd>
- <dt>
- <label for="spelling">', $txt['languages_spelling'], ':</label>
- </dt>
- <dd>
- <input type="text" name="spelling" id="spelling" size="20" value="', $context['primary_settings']['spelling'], '"', (empty($context['file_entries']) ? '' : ' disabled'), ' class="input_text" />
- </dd>
- <dt>
- <label for="rtl">', $txt['languages_rtl'], ':</label>
- </dt>
- <dd>
- <input type="checkbox" name="rtl" id="rtl"', $context['primary_settings']['rtl'] ? ' checked' : '', ' class="input_check"', (empty($context['file_entries']) ? '' : ' disabled'), ' />
- </dd>
- </dl>
- </fieldset>
- <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
- <input type="hidden" name="', $context['admin-mlang_token_var'], '" value="', $context['admin-mlang_token'], '" />
- <input type="submit" name="save_main" value="', $txt['save'], '"', $context['lang_file_not_writable_message'] || !empty($context['file_entries']) ? ' disabled' : '', ' class="button_submit" />';
- // Allow deleting entries.
- if ($context['lang_id'] != 'english')
- {
- // English can't be deleted though.
- echo '
- <input type="submit" name="delete_main" value="', $txt['delete'], '"', $context['lang_file_not_writable_message'] || !empty($context['file_entries']) ? ' disabled' : '', ' onclick="confirm(\'', $txt['languages_delete_confirm'], '\');" class="button_submit" />';
- }
- echo '
- </div>
- </div>
- </form>
- <form action="', $scripturl, '?action=admin;area=languages;sa=editlang;lid=', $context['lang_id'], ';entries" id="entry_form" method="post" accept-charset="', $context['character_set'], '">
- <div class="title_bar">
- <h3 class="titlebg">
- ', $txt['edit_language_entries'], '
- </h3>
- </div>
- <div id="taskpad" class="floatright">
- ', $txt['edit_language_entries_file'], ':
- <select name="tfid" onchange="if (this.value != -1) document.forms.entry_form.submit();">
- <option value="-1"> </option>';
- foreach ($context['possible_files'] as $id_theme => $theme)
- {
- echo '
- <optgroup label="', $theme['name'], '">';
- foreach ($theme['files'] as $file)
- {
- echo '
- <option value="', $id_theme, '+', $file['id'], '"', $file['selected'] ? ' selected' : '', '> => ', $file['name'], '</option>';
- }
- echo '
- </optgroup>';
- }
- echo '
- </select>
- <input type="hidden" name="', $context['session_var'], '" value="', $context['session_id'], '" />
- <input type="hidden" name="', $context['admin-mlang_token_var'], '" value="', $context['admin-mlang_token'], '" />
- <input type="submit" value="', $txt['go'], '" class="button_submit" style="float: none"/>
- </div>
- <br class="clear" />';
- // Is it not writable?
- // Show an error.
- if (!empty($context['entries_not_writable_message']))
- echo '
- <div class="errorbox">
- ', $context['entries_not_writable_message'], '
- </div>';
- // Already have some file entries?
- if (!empty($context['file_entries']))
- {
- echo '
- <div class="windowbg2">
- <div class="content">
- <dl class="settings">';
- $cached = array();
- foreach ($context['file_entries'] as $entry)
- {
- // Do it in two's!
- if (empty($cached))
- {
- $cached = $entry;
- continue;
- }
- echo '
- <dt>
- <span class="smalltext">', $cached['key'], '</span>
- </dt>
- <dd>
- <span class="smalltext">', $entry['key'], '</span>
- </dd>
- <dt>
- <input type="hidden" name="comp[', $cached['key'], ']" value="', $cached['value'], '" />
- <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>
- </dt>
- <dd>
- <input type="hidden" name="comp[', $entry['key'], ']" value="', $entry['value'], '" />
- <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>
- </dd>';
- $cached = array();
- }
- // Odd number?
- if (!empty($cached))
- {
- // Alternative time
- echo '
- <dt>
- <span class="smalltext">', $cached['key'], '</span>
- </dt>
- <dd>
- </dd>
- <dt>
- <input type="hidden" name="comp[', $cached['key'], ']" value="', $cached['value'], '" />
- <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>
- </dt>
- <dd>
- </dd>';
- }
- echo '
- </dl>
- <input type="submit" name="save_entries" value="', $txt['save'], '"', !empty($context['entries_not_writable_message']) ? ' disabled' : '', ' class="button_submit" />';
- echo '
- </div>
- </div>';
- }
- echo '
- </form>
- </div>';
- }
- /**
- * Add a new language
- *
- */
- function template_add_language()
- {
- global $context, $txt, $scripturl;
- echo '
- <div id="admincenter">
- <form id="admin_form_wrapper"action="', $scripturl, '?action=admin;area=languages;sa=add;', $context['session_var'], '=', $context['session_id'], '" method="post" accept-charset="', $context['character_set'], '">
- <div class="cat_bar">
- <h3 class="catbg">
- ', $txt['add_language'], '
- </h3>
- </div>
- <div class="windowbg">
- <div class="content">
- <fieldset>
- <legend>', $txt['add_language_smf'], '</legend>
- <label class="smalltext">', $txt['add_language_smf_browse'], '</label>
- <input type="text" name="smf_add" size="40" value="', !empty($context['smf_search_term']) ? $context['smf_search_term'] : '', '" class="input_text" />';
- // Do we have some errors? Too bad.
- if (!empty($context['smf_error']))
- {
- // Display a little error box.
- echo '
- <div><br /><p class="errorbox">', $txt['add_language_error_' . $context['smf_error']], '</p></div>';
- }
- echo '
- </fieldset>', isBrowser('is_ie') ? '<input type="text" name="ie_fix" style="display: none;" class="input_text" /> ' : '', '
- <input type="submit" name="smf_add_sub" value="', $txt['search'], '" class="button_submit" />
- <br />
- </div>
- </div>
- ';
- // Had some results?
- if (!empty($context['smf_languages']['rows']))
- {
- echo '
- <div class="cat_bar"><h3 class="catbg">', $txt['add_language_found_title'], '</div><div class="information">', $txt['add_language_smf_found'], '</div>';
- template_show_list('smf_languages');
- }
- echo '
- </form>
- </div>';
- }
- ?>
|