本文整理汇总了PHP中getLanguages函数的典型用法代码示例。如果您正苦于以下问题:PHP getLanguages函数的具体用法?PHP getLanguages怎么用?PHP getLanguages使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getLanguages函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: multi_configure
function multi_configure()
{
$lang_array = getLanguages();
foreach ($lang_array as $lang) {
$langOpt .= "<input type=\"checkbox\" name=\"langs[]\" value=\"{$lang}\"> {$lang} <br />";
}
echo <<<EOT
<form action="{$_SERVER['REQUEST_URI']}" method="post">
<p>
Select the languages you want to use
</p>
<div style="margin:25;">
<table border="0" cellspacing="0" cellpadding="0">
<tr>
{$langOpt}
</tr>
</table>
</div>
<span>
<input type="submit" name="submit" value="Submit" />
<input type="button" name="cancel" onClick="window.location='pluginmgr.php';" value="Cancel" />
</span>
</form>
EOT;
}
示例2: getHTML
public function getHTML()
{
$page = new Core_Template();
// Login first
$page->set('login', $this->getLogin());
$page->set('title', $this->getTitle());
$page->set('footer', $this->getFooter());
$page->set('content', $this->getContent());
$page->set('menu', $this->getMenu());
// Order baskes
$page->set('basket', $this->getBasket());
$text = Core_Text::__getInstance();
// Languages:
$langs = getLanguages();
foreach ($langs as $v) {
$page->addListValue('languages', array($text->get($v[0], 'languages', 'main', $v[0]), self::getUrl('page=home&language=' . $v[1])));
}
$langs = getLayouts();
foreach ($langs as $v) {
$page->addListValue('layouts', array($text->get($v[0], 'layouts', 'main', $v[0]), self::getUrl('page=home&layout=' . $v[1])));
}
$page->set('languages', $text->get('languages', 'main', 'main'));
$page->set('layouts', $text->get('layout', 'main', 'main'));
$page->set('footerSpoof', $text->get('footer', 'main', 'main'));
$page->set('printerFooter', $text->get('printerFooter', 'main', 'main'));
$page->sortList('languages');
$db = Core_Database::__getInstance();
$page->set('mysqlCount', $db->getCounter());
$page->set('order_url', array($text->get('shoplist', 'menu', 'main'), self::getUrl('page=order')));
return $page->parse('index.tpl');
}
示例3: gen_def_language
/**
* Creates a list of all current installed languages
*
* @param string $lang_selected Defines the selected language
*/
function gen_def_language($lang_selected)
{
$cfg = EasySCP_Registry::get('Config');
$tpl = EasySCP_TemplateEngine::getInstance();
$languages = getLanguages();
foreach ($languages as $lang => $language_name) {
$tpl->append(array('LANG_VALUE' => $lang, 'LANG_SELECTED' => $lang === $lang_selected ? $cfg->HTML_SELECTED : '', 'LANG_NAME' => tohtml($language_name)));
}
}
示例4: generateTitle
/**
* Generate an elang title
*
* @param object $elang E-Lang object
* @param array $options Array of options
*
* @return string String representation of the title
*
* @since 0.0.1
*/
function generateTitle($elang, $options)
{
// Get all the languages
$languages = getLanguages();
// Get the page title
if ($options['showlanguage']) {
return sprintf(get_string('formatname', 'elang'), $elang->name, $languages[$elang->language]);
} else {
return $elang->name;
}
}
示例5: list_getLanguages
/**
* Fetch the actual language information.
*
* What it does:
* - Callback for $listOptions['get_items']['function'] in action_edit.
* - Determines which languages are available by looking for the "index.{language}.php" file.
* - Also figures out how many users are using a particular language.
*
* @package Languages
*/
function list_getLanguages()
{
global $settings, $language, $txt;
$db = database();
$languages = array();
// Keep our old entries.
$old_txt = $txt;
$backup_actual_theme_dir = $settings['actual_theme_dir'];
$backup_base_theme_dir = !empty($settings['base_theme_dir']) ? $settings['base_theme_dir'] : '';
// Override these for now.
$settings['actual_theme_dir'] = $settings['base_theme_dir'] = $settings['default_theme_dir'];
$all_languages = getLanguages();
// Put them back.
$settings['actual_theme_dir'] = $backup_actual_theme_dir;
if (!empty($backup_base_theme_dir)) {
$settings['base_theme_dir'] = $backup_base_theme_dir;
} else {
unset($settings['base_theme_dir']);
}
// Get the language files and data...
foreach ($all_languages as $lang) {
// Load the file to get the character set.
require $lang['location'];
$languages[$lang['filename']] = array('id' => $lang['filename'], 'count' => 0, 'char_set' => 'UTF-8', 'default' => $language == $lang['filename'] || $language == '' && $lang['filename'] == 'english', 'locale' => $txt['lang_locale'], 'name' => Util::ucwords(strtr($lang['filename'], array('_' => ' ', '-utf8' => ''))));
}
// Work out how many people are using each language.
$request = $db->query('', '
SELECT lngfile, COUNT(*) AS num_users
FROM {db_prefix}members
GROUP BY lngfile', array());
while ($row = $db->fetch_assoc($request)) {
// Default?
if (empty($row['lngfile']) || !isset($languages[$row['lngfile']])) {
$row['lngfile'] = $language;
}
if (!isset($languages[$row['lngfile']]) && isset($languages['english'])) {
$languages['english']['count'] += $row['num_users'];
} elseif (isset($languages[$row['lngfile']])) {
$languages[$row['lngfile']]['count'] += $row['num_users'];
}
}
$db->free_result($request);
// Restore the current users language.
$txt = $old_txt;
// Return how many we have.
return $languages;
}
示例6: display_language_selectionform
function display_language_selectionform($formclass)
{
if ($formclass != "") {
?>
<form action='' method='POST' class="<?php
echo $formclass;
?>
">
<label for="language-selector"></label>
<?php
} else {
?>
<form action='' method='POST'>
<label for="language-selector"><?php
echo LANGUAGE_PROMPT;
?>
</label>
<?php
}
?>
<select name='language' id="language-selector">
<?php
/* I've just specified a random list of possible languages; "Nonsense" is minimal and just there so you can see the login page switch around */
$languages = getLanguages();
//$languages = array('en-GB' => 'English', 'nl-NL' => 'Nederlands', 'en-XX' => 'Nonsense', 'fr-FR' => 'French', 'es-ES' => 'Spanish', 'it-IT' => 'Italian', 'ca-ES' => "Catalan");
foreach ($languages as $key => $value) {
$selected = '';
if (isset($_SESSION['toolkits_language']) && $_SESSION['toolkits_language'] == $key) {
$selected = " selected=selected ";
}
echo "<option value='{$key}' {$selected}>{$value}</option>\n";
}
?>
</select>
<input type='submit' class="xerte_button" value='<?php
echo LANGUAGE_BUTTON_TEXT;
?>
' name='submit'/>
</form>
<?php
}
示例7: format_code
public function format_code($text, $post = null)
{
if (isset($post)) {
$code = $text;
if (preg_match("/\\[gist: ([0-9]+)\\]/i", $code, $matches)) {
return '<script src="http://gist.github.com/' . $matches[1] . '.js"></script>';
}
$post->code_unformatted = $post->code;
$languages = getLanguages();
$geshi = new GeSHi($code, $languages[$post->language]);
if ($geshi->error() !== false) {
return "<pre id='geshi_code'>" . $geshi->error() . "</pre>";
}
$geshi->set_overall_id('geshi_code');
$return = $geshi->parse_code();
return $return;
} else {
return "<pre id='geshi_code'>" . $text . "</pre>";
}
}
示例8: language_details
function language_details($changed)
{
global $xerte_toolkits_site;
echo "<p>" . MANAGEMENT_LIBRARY_LANGUAGES_EXPLAINED . "</p>";
echo "<p>" . MANAGEMENT_LIBRARY_ADD_LANGUAGE . "</p>";
echo "<p><br><form method=\"post\" enctype=\"multipart/form-data\" id=\"languagepopup\" name=\"languageform\" target=\"upload_iframe\" action=\"website_code/php/language/import_language.php\" onsubmit=\"javascript:iframe_upload_language_check_initialise();\"><input name=\"filenameuploaded\" type=\"file\" /><br /><br/><button type=\"submit\" class=\"xerte_button\" name=\"submitBtn\" onsubmit=\"javascript:iframe_language_check_initialise()\" >" . MANAGEMENT_LIBRARY_LANGUAGE_INSTALL . "</button></form></p>";
echo "<p>" . MANAGEMENT_LIBRARY_EXISTING_LANGUAGES . "</p>";
$langs = getLanguages();
$codes = array_keys($langs);
echo "<ul>";
foreach ($codes as $code) {
echo "<li>" . $langs[$code];
if ($code != "en-GB") {
echo " <button type=\"button\" class=\"xerte_button\" onclick=\"javascript:delete_language('" . $code . "')\">" . MANAGEMENT_LIBRARY_REMOVE . " </button></li>";
} else {
echo "</li>";
}
}
echo "</ul>";
if ($changed) {
echo "<p>" . MANAGEMENT_LIBRARY_LANGUAGES_UPDATED . "</p>";
}
}
示例9: checkFirstLanguagesMessageFilesContainAllExistingMessages
function checkFirstLanguagesMessageFilesContainAllExistingMessages($messagesDirectoryName, $moduleName, $basePath)
{
assert('is_string($messagesDirectoryName)');
assert('is_dir ($messagesDirectoryName)');
$problems = array();
$fileNamesToCategoriesToMessages = findFileNameToCategoryToMessage($messagesDirectoryName . '/..');
$categoriesToMessagesToFileNames = convertFileNameToCategoryToMessageToCategoryToMessageToFileName($fileNamesToCategoriesToMessages);
unset($categoriesToMessagesToFileNames['yii']);
$languages = getLanguages($messagesDirectoryName);
if (count($languages) > 0) {
$firstLanguage = $languages[0];
foreach ($categoriesToMessagesToFileNames as $category => $messagesToFileNames) {
$existingMessages = array_keys(MessageUtil::getMessages($firstLanguage, $moduleName, $category));
$duplicateCount = count($existingMessages) != count(array_unique($existingMessages));
if ($duplicateCount != 0) {
$problems[] = "{$moduleName} and its dependencies contain {$duplicateCount} duplicate entries.";
}
$yiiMessageFileName = "{$messagesDirectoryName}/{$firstLanguage}/{$category}.php";
$yiiMessages = (require "{$basePath}/../../yii/framework/messages/{$firstLanguage}/yii.php");
foreach ($messagesToFileNames as $message => $fileNames) {
$fileNames = join(', ', $fileNames);
if (!in_array($message, $existingMessages) && !in_array($message, $yiiMessages)) {
$problems[] = "'{$message}' in {$fileNames} not in {$firstLanguage}/{$category}.php in {$moduleName} or its dependencies.";
} elseif (in_array($message, $existingMessages) && in_array($message, $yiiMessages)) {
$problems[] = "'{$message}' in {$fileNames} in {$firstLanguage}/{$category}.php in {$moduleName} or its dependencies is a duplicate of definition already in Yii.";
}
}
}
} else {
$problems[] = 'No languages were found in the following directory:' . $messagesDirectoryName . "\n";
}
return $problems;
}
示例10: _t
<td width="120px"><?php
echo _t("Startpage");
?>
:</td>
<td><select name="startapp"><?php
echo makefileopts($apps, $wpref->startapp);
?>
</select></td>
</tr>
<tr>
<td width="120px"><?php
echo _t("Default language");
?>
:</td>
<td><select name="language"><?php
echo getLanguages($wpref->language);
?>
</select></td>
</tr>
<tr>
<td><?php
echo _t("No-Reply Email");
?>
:</td>
<td><input name="email" type="text" value="<?php
echo $wpref->noreply_email;
?>
" size="34" /></td>
</tr>
<tr>
<td><label for="clean_url"><?php
示例11: action_register2
//.........这里部分代码省略.........
foreach ($_POST as $key => $value) {
if (!is_array($_POST[$key])) {
$_POST[$key] = htmltrim__recursive(str_replace(array("\n", "\r"), '', $_POST[$key]));
}
}
// Collect all extra registration fields someone might have filled in.
$possible_strings = array('birthdate', 'time_format', 'buddy_list', 'pm_ignore_list', 'smiley_set', 'personal_text', 'avatar', 'lngfile', 'location', 'secret_question', 'secret_answer', 'website_url', 'website_title');
$possible_ints = array('pm_email_notify', 'notify_types', 'id_theme', 'gender');
$possible_floats = array('time_offset');
$possible_bools = array('notify_announcements', 'notify_regularity', 'notify_send_body', 'hide_email', 'show_online');
if (isset($_POST['secret_answer']) && $_POST['secret_answer'] != '') {
$_POST['secret_answer'] = md5($_POST['secret_answer']);
}
// Needed for isReservedName() and registerMember().
require_once SUBSDIR . '/Members.subs.php';
// Validation... even if we're not a mall.
if (isset($_POST['real_name']) && (!empty($modSettings['allow_editDisplayName']) || allowedTo('moderate_forum'))) {
$_POST['real_name'] = trim(preg_replace('~[\\t\\n\\r \\x0B\\0\\x{A0}\\x{AD}\\x{2000}-\\x{200F}\\x{201F}\\x{202F}\\x{3000}\\x{FEFF}]+~u', ' ', $_POST['real_name']));
if (trim($_POST['real_name']) != '' && !isReservedName($_POST['real_name']) && Util::strlen($_POST['real_name']) < 60) {
$possible_strings[] = 'real_name';
}
}
// Handle a string as a birthdate...
if (isset($_POST['birthdate']) && $_POST['birthdate'] != '') {
$_POST['birthdate'] = strftime('%Y-%m-%d', strtotime($_POST['birthdate']));
} elseif (!empty($_POST['bday1']) && !empty($_POST['bday2'])) {
$_POST['birthdate'] = sprintf('%04d-%02d-%02d', empty($_POST['bday3']) ? 0 : (int) $_POST['bday3'], (int) $_POST['bday1'], (int) $_POST['bday2']);
}
// By default assume email is hidden, only show it if we tell it to.
$_POST['hide_email'] = !empty($_POST['allow_email']) ? 0 : 1;
// Validate the passed language file.
if (isset($_POST['lngfile']) && !empty($modSettings['userLanguage'])) {
// Do we have any languages?
$context['languages'] = getLanguages();
// Did we find it?
if (isset($context['languages'][$_POST['lngfile']])) {
$_SESSION['language'] = $_POST['lngfile'];
} else {
unset($_POST['lngfile']);
}
} else {
unset($_POST['lngfile']);
}
// Some of these fields we may not want.
if (!empty($modSettings['registration_fields'])) {
// But we might want some of them if the admin asks for them.
$standard_fields = array('location', 'gender');
$reg_fields = explode(',', $modSettings['registration_fields']);
$exclude_fields = array_diff($standard_fields, $reg_fields);
// Website is a little different
if (!in_array('website', $reg_fields)) {
$exclude_fields = array_merge($exclude_fields, array('website_url', 'website_title'));
}
// We used to accept signature on registration but it's being abused by spammers these days, so no more.
$exclude_fields[] = 'signature';
} else {
$exclude_fields = array('signature', 'location', 'gender', 'website_url', 'website_title');
}
$possible_strings = array_diff($possible_strings, $exclude_fields);
$possible_ints = array_diff($possible_ints, $exclude_fields);
$possible_floats = array_diff($possible_floats, $exclude_fields);
$possible_bools = array_diff($possible_bools, $exclude_fields);
// Set the options needed for registration.
$regOptions = array('interface' => 'guest', 'username' => !empty($_POST['user']) ? $_POST['user'] : '', 'email' => !empty($_POST['email']) ? $_POST['email'] : '', 'password' => !empty($_POST['passwrd1']) ? $_POST['passwrd1'] : '', 'password_check' => !empty($_POST['passwrd2']) ? $_POST['passwrd2'] : '', 'openid' => !empty($_POST['openid_identifier']) ? $_POST['openid_identifier'] : '', 'auth_method' => !empty($_POST['authenticate']) ? $_POST['authenticate'] : '', 'check_reserved_name' => true, 'check_password_strength' => true, 'check_email_ban' => true, 'send_welcome_email' => !empty($modSettings['send_welcomeEmail']), 'require' => !empty($modSettings['coppaAge']) && !$verifiedOpenID && empty($_SESSION['skip_coppa']) ? 'coppa' : (empty($modSettings['registration_method']) ? 'nothing' : ($modSettings['registration_method'] == 1 ? 'activation' : 'approval')), 'extra_register_vars' => array(), 'theme_vars' => array());
// Include the additional options that might have been filled in.
foreach ($possible_strings as $var) {
示例12: loadUserSettings
//.........这里部分代码省略.........
$user_info['show_online'] = $user_settings['show_online'];
$user_info['time_offset'] = empty($user_settings['time_offset']) ? 0 : $user_settings['time_offset'];
} else {
// This is what a guest's variables should be.
$username = '';
$user_info = array('groups' => array(-1));
$user_settings = array();
if (isset($_COOKIE[$cookiename])) {
$_COOKIE[$cookiename] = '';
}
// Do we perhaps think this is a search robot? Check every five minutes just in case...
if ((!empty($modSettings['spider_mode']) || !empty($modSettings['spider_group'])) && (!isset($_SESSION['robot_check']) || $_SESSION['robot_check'] < time() - 300)) {
$user_info['possibly_robot'] = SpiderCheck();
} elseif (!empty($modSettings['spider_mode'])) {
$user_info['possibly_robot'] = isset($_SESSION['id_robot']) ? $_SESSION['id_robot'] : 0;
} else {
$ci_user_agent = strtolower($_SERVER['HTTP_USER_AGENT']);
$user_info['possibly_robot'] = strpos($_SERVER['HTTP_USER_AGENT'], 'Mozilla') === false && strpos($_SERVER['HTTP_USER_AGENT'], 'Opera') === false || strpos($ci_user_agent, 'googlebot') !== false || strpos($ci_user_agent, 'slurp') !== false || strpos($ci_user_agent, 'crawl') !== false;
}
$user_info['time_offset'] = isset($_SESSION['tzoffset']) ? $_SESSION['tzoffset'] : 0;
$user_info['guest_need_tzoffset'] = !isset($_SESSION['tzoffset']);
// don't have it yet, embed the js to determine tz offset for *guests only*
}
// Set up the $user_info array.
$user_info += array('id' => $id_member, 'username' => $username, 'name' => isset($user_settings['real_name']) ? $user_settings['real_name'] : '', 'email' => isset($user_settings['email_address']) ? $user_settings['email_address'] : '', 'passwd' => isset($user_settings['passwd']) ? $user_settings['passwd'] : '', 'language' => empty($user_settings['lngfile']) || empty($modSettings['userLanguage']) ? $language : $user_settings['lngfile'], 'is_guest' => $id_member == 0, 'is_admin' => in_array(1, $user_info['groups']), 'theme' => empty($user_settings['id_theme']) ? 0 : $user_settings['id_theme'], 'last_login' => empty($user_settings['last_login']) ? 0 : $user_settings['last_login'], 'ip' => $_SERVER['REMOTE_ADDR'], 'ip2' => $_SERVER['BAN_CHECK_IP'], 'posts' => empty($user_settings['posts']) ? 0 : $user_settings['posts'], 'time_format' => empty($user_settings['time_format']) ? $modSettings['time_format'] : $user_settings['time_format'], 'avatar' => array('url' => isset($user_settings['avatar']) ? $user_settings['avatar'] : '', 'filename' => empty($user_settings['filename']) ? '' : $user_settings['filename'], 'custom_dir' => !empty($user_settings['attachment_type']) && $user_settings['attachment_type'] == 1, 'id_attach' => isset($user_settings['id_attach']) ? $user_settings['id_attach'] : 0), 'smiley_set' => isset($user_settings['smiley_set']) ? $user_settings['smiley_set'] : '', 'messages' => empty($user_settings['instant_messages']) ? 0 : $user_settings['instant_messages'], 'unread_messages' => empty($user_settings['unread_messages']) ? 0 : $user_settings['unread_messages'], 'total_time_logged_in' => empty($user_settings['total_time_logged_in']) ? 0 : $user_settings['total_time_logged_in'], 'buddies' => !empty($modSettings['enable_buddylist']) && !empty($user_settings['buddy_list']) ? explode(',', $user_settings['buddy_list']) : array(), 'ignoreboards' => !empty($user_settings['ignore_boards']) && !empty($modSettings['allow_ignore_boards']) ? explode(',', $user_settings['ignore_boards']) : array(), 'ignoreusers' => !empty($user_settings['pm_ignore_list']) ? explode(',', $user_settings['pm_ignore_list']) : array(), 'warning' => isset($user_settings['warning']) ? $user_settings['warning'] : 0, 'likesgiven' => isset($user_settings['likes_given']) ? $user_settings['likes_given'] : 0, 'likesreceived' => isset($user_settings['likes_received']) ? $user_settings['likes_received'] : 0, 'permissions' => array(), 'act_optout' => isset($user_settings['act_optout']) ? $user_settings['act_optout'] : '', 'notify_optout' => isset($user_settings['notify_optout']) ? $user_settings['notify_optout'] : '', 'meta' => !empty($user_settings['meta']) ? @unserialize($user_settings['meta']) : array());
$user_info['smf_sidebar_disabled'] = 0;
$user_info['groups'] = array_unique($user_info['groups']);
// Make sure that the last item in the ignore boards array is valid. If the list was too long it could have an ending comma that could cause problems.
if (!empty($user_info['ignoreboards']) && empty($user_info['ignoreboards'][$tmp = count($user_info['ignoreboards']) - 1])) {
unset($user_info['ignoreboards'][$tmp]);
}
// Do we have any languages to validate this?
if (!empty($modSettings['userLanguage']) && (!empty($_GET['language']) || !empty($_SESSION['language']))) {
$languages = getLanguages();
}
// Allow the user to change their language if its valid.
if (!empty($modSettings['userLanguage']) && !empty($_GET['language']) && isset($languages[strtr($_GET['language'], './\\:', '____')])) {
$user_info['language'] = strtr($_GET['language'], './\\:', '____');
$_SESSION['language'] = $user_info['language'];
} elseif (!empty($modSettings['userLanguage']) && !empty($_SESSION['language']) && isset($languages[strtr($_SESSION['language'], './\\:', '____')])) {
$user_info['language'] = strtr($_SESSION['language'], './\\:', '____');
}
// map language to a numeric id
$n = 0;
if (isset($context['languages'])) {
foreach ($context['languages'] as $key => $lang) {
if ($key == $user_info['language']) {
break;
}
$n++;
}
}
$user_info['language_id'] = $n + 1;
// Just build this here, it makes it easier to change/use - administrators can see all boards.
if ($user_info['is_admin']) {
$user_info['query_see_board'] = '1=1';
} else {
$user_info['query_see_board'] = '(FIND_IN_SET(' . implode(', b.member_groups) != 0 OR FIND_IN_SET(', $user_info['groups']) . ', b.member_groups) != 0' . (isset($user_info['mod_cache']) ? ' OR ' . $user_info['mod_cache']['mq'] : '') . ')';
}
// Build the list of boards they WANT to see.
// This will take the place of query_see_boards in certain spots, so it better include the boards they can see also
// If they aren't ignoring any boards then they want to see all the boards they can see
if (empty($user_info['ignoreboards'])) {
$user_info['query_wanna_see_board'] = $user_info['query_see_board'];
} else {
$user_info['query_wanna_see_board'] = '(' . $user_info['query_see_board'] . ' AND b.id_board NOT IN (' . implode(',', $user_info['ignoreboards']) . '))';
示例13: checkAdmin
<?php
/**
* Site settings
**************************/
/* verify that user is admin */
checkAdmin();
/* fetch all settings */
$settings = getAllSettings();
/* get all languages */
$langs = getLanguages();
?>
<!-- title -->
<h4><?php
print _('phpIPAM Server settings');
?>
</h4>
<hr>
<form name="settings" id="settings">
<table id="settings" class="table table-hover table-condensed table-top">
<!-- site settings -->
<tr class="settings-title">
<th colspan="3"><h4><?php
print _('Site settings');
?>
</h4></th>
</tr>
示例14: ModifyLanguageSettings
function ModifyLanguageSettings($return_config = false)
{
global $scripturl, $context, $txt, $boarddir, $settings, $smcFunc;
// Warn the user if the backup of Settings.php failed.
$settings_not_writable = !is_writable($boarddir . '/Settings.php');
$settings_backup_fail = !@is_writable($boarddir . '/Settings_bak.php') || !@copy($boarddir . '/Settings.php', $boarddir . '/Settings_bak.php');
/* If you're writing a mod, it's a bad idea to add things here....
For each option:
variable name, description, type (constant), size/possible values, helptext.
OR an empty string for a horizontal rule.
OR a string for a titled section. */
$config_vars = array('language' => array('language', $txt['default_language'], 'file', 'select', array(), null, 'disabled' => $settings_not_writable), array('userLanguage', $txt['userLanguage'], 'db', 'check', null, 'userLanguage'));
if ($return_config) {
return $config_vars;
}
// Get our languages. No cache and use utf8.
getLanguages(false, false);
foreach ($context['languages'] as $lang) {
$config_vars['language'][4][$lang['filename']] = array($lang['filename'], strtr($lang['name'], array('-utf8' => ' (UTF-8)')));
}
// Saving settings?
if (isset($_REQUEST['save'])) {
checkSession();
saveSettings($config_vars);
redirectexit('action=admin;area=languages;sa=settings');
}
// Setup the template stuff.
$context['post_url'] = $scripturl . '?action=admin;area=languages;sa=settings;save';
$context['settings_title'] = $txt['language_settings'];
$context['save_disabled'] = $settings_not_writable;
if ($settings_not_writable) {
$context['settings_message'] = '<div class="centertext"><strong>' . $txt['settings_not_writable'] . '</strong></div><br />';
} elseif ($settings_backup_fail) {
$context['settings_message'] = '<div class="centertext"><strong>' . $txt['admin_backup_fail'] . '</strong></div><br />';
}
// Fill the config array.
prepareServerSettingsContext($config_vars);
}
示例15: settings
/**
* Admin panel interface to manage the anti spam question area
*
* @return mixed[]
*/
public function settings()
{
global $txt, $context, $language;
// Load any question and answers!
$filter = null;
if (isset($_GET['language'])) {
$filter = array('type' => 'language', 'value' => $_GET['language']);
}
$context['question_answers'] = $this->_loadAntispamQuestions($filter);
$languages = getLanguages();
// Languages dropdown only if we have more than a lang installed, otherwise is plain useless
if (count($languages) > 1) {
$context['languages'] = $languages;
foreach ($context['languages'] as &$lang) {
if ($lang['filename'] === $language) {
$lang['selected'] = true;
}
}
}
// Saving them?
if (isset($_GET['save'])) {
// Handle verification questions.
$questionInserts = array();
$count_questions = 0;
foreach ($_POST['question'] as $id => $question) {
$question = trim(Util::htmlspecialchars($question, ENT_COMPAT));
$answers = array();
$question_lang = isset($_POST['language'][$id]) && isset($languages[$_POST['language'][$id]]) ? $_POST['language'][$id] : $language;
if (!empty($_POST['answer'][$id])) {
foreach ($_POST['answer'][$id] as $answer) {
$answer = trim(Util::strtolower(Util::htmlspecialchars($answer, ENT_COMPAT)));
if ($answer != '') {
$answers[] = $answer;
}
}
}
// Already existed?
if (isset($context['question_answers'][$id])) {
$count_questions++;
// Changed?
if ($question == '' || empty($answers)) {
$this->_delete($id);
$count_questions--;
} else {
$this->_update($id, $question, $answers, $question_lang);
}
} elseif ($question != '' && !empty($answers)) {
$questionInserts[] = array('question' => $question, 'answer' => serialize($answers), 'language' => $question_lang);
$count_questions++;
}
}
// Any questions to insert?
if (!empty($questionInserts)) {
$this->_insert($questionInserts);
}
if (empty($count_questions) || $_POST['qa_verification_number'] > $count_questions) {
$_POST['qa_verification_number'] = $count_questions;
}
}
return array(array('title', 'setup_verification_questions'), array('desc', 'setup_verification_questions_desc'), array('int', 'qa_verification_number', 'postinput' => $txt['setting_qa_verification_number_desc']), array('callback', 'question_answer_list'));
}