本文整理汇总了PHP中list_languages函数的典型用法代码示例。如果您正苦于以下问题:PHP list_languages函数的具体用法?PHP list_languages怎么用?PHP list_languages使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了list_languages函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: index
/**
* Display a form with various site settings including site name and
* registration settings
*
* @return void
*/
public function index()
{
$this->load->config('extended_settings');
$extended_settings = config_item('extended_settings_fields');
if (isset($_POST['save'])) {
if ($this->saveSettings($extended_settings)) {
Template::set_message(lang('settings_saved_success'), 'success');
} else {
Template::set_message(lang('settings_error_success'), 'error');
$settingsError = $this->settings_lib->getError();
if ($settingsError) {
Template::set_message($settingsError, 'error');
}
}
redirect(SITE_AREA . '/settings/settings');
}
// Read the current settings
$settings = $this->settings_lib->find_all();
// Get the available languages
$this->load->helper('translate/languages');
Template::set_view('settings/settings/index');
Template::set('extended_settings', $extended_settings);
Template::set('languages', list_languages());
Template::set('selected_languages', unserialize($settings['site.languages']));
Template::set('settings', $settings);
Template::set('showDeveloperTab', $this->auth->has_permission($this->permissionDevView));
Template::render();
}
示例2: language
function language($params)
{
$languages = list_languages();
if (isset($languages[$params[0]])) {
$_SESSION['lang'] = $params[0];
}
header('location:' . $_SERVER['HTTP_REFERER']);
}
示例3: __construct
/**
* Loads required classes
*
* @todo Add permission restrictions
*
* @return void
*/
public function __construct()
{
parent::__construct();
// restrict access - View and Manage
$this->auth->restrict('Bonfire.Translate.View');
$this->auth->restrict('Bonfire.Translate.Manage');
$this->lang->load('translate');
$this->load->helper('languages');
$this->langs = list_languages();
Template::set_block('sub_nav', 'developer/_sub_nav');
}
示例4: edit
function edit($params)
{
global $content_schema, $method;
$method = 'index';
$content_schema['lang']['enum'] = list_languages();
$data = array('schema' => $content_schema);
$db = connect_database();
//
$data['article'] = row_assoc($db->query('SELECT id, slug, lang, published, title, content FROM content WHERE id = ' . $params[0]));
//
$data['html_head'] = array('title' => 'Edit Content');
return $data;
}
示例5: index
/**
* Displays a form with various site setings including site name and
* registration settings
*
* @access public
*
* @return void
*/
public function index()
{
if ($this->input->post('submit')) {
if ($this->save_settings()) {
Template::set_message(lang('settings_saved_success'), 'success');
redirect(SITE_AREA . '/settings');
} else {
Template::set_message(lang('settings_error_success'), 'error');
}
}
// Read our current settings
$settings = $this->settings_lib->find_all();
Template::set('settings', $settings);
// Get the possible languages
$this->load->helper('translate/languages');
Template::set('languages', list_languages());
Template::set('selected_languages', unserialize($settings['site.languages']));
Assets::add_module_js('settings', 'js/settings.js');
Template::set_view('settings/settings/index');
Template::render();
}
示例6: index
/**
* Display a form with various site settings including site name and
* registration settings
*
* @return void
*/
public function index()
{
$this->load->config('extended_settings');
$extended_settings = config_item('extended_settings_fields');
if (isset($_POST['save'])) {
if ($this->save_settings($extended_settings)) {
Template::set_message(lang('settings_saved_success'), 'success');
redirect(SITE_AREA . '/settings/settings');
}
Template::set_message(lang('settings_error_success'), 'error');
}
// Read the current settings
$settings = $this->settings_lib->find_all();
// Get the available languages
$this->load->helper('translate/languages');
Assets::add_module_js('settings', 'js/settings.js');
Template::set_view('settings/settings/index');
Template::set('extended_settings', $extended_settings);
Template::set('languages', list_languages());
Template::set('selected_languages', unserialize($settings['site.languages']));
Template::set('settings', $settings);
Template::render();
}
示例7: index
function index($params)
{
global $method, $user;
if ($user['id'] == -1 && $method != 'log_in') {
redirect('user', 'log_in');
}
//
global $users_schema, $logins_schema;
$users_schema['timezone']['enum'] = json_decode(file_get_contents('data/timezones.json'));
$db = connect_database();
//
if (isset($params['email'])) {
if ($params['password'] == '[encrypted]') {
unset($params['password']);
} else {
if ($params['password'] != $params['password_conf']) {
flash_message('Password confirmation does not match.', 'error');
} else {
$params['password'] = md5($params['password'] . ':' . COMMON_SALT);
}
}
$params['id'] = $user['id'];
$params['reset_code'] = '';
$db->update('user', $params);
flash_message('Settings are updated.', 'success');
redirect('user');
}
//
$users_schema['lang']['enum'] = list_languages();
$user['password'] = '[encrypted]';
$user['password_conf'] = '';
$data = array('schema' => $users_schema, 'logins_schema' => $logins_schema, 'user' => $user);
$data['logins'] = $db->query('SELECT id, cookie, remember, ip, last_login, useragent FROM login WHERE user_id = ' . $user['id'] . ' ORDER BY last_login DESC');
//
$data['html_head'] = array('title' => 'My Account');
return $data;
}
示例8: remove_language
/**
* Remove all language strings for the given lang code.
*
* Removed language code is specified with 'lang_code' HTTP POST
* parameter.
*/
function remove_language()
{
$lang_code = ps('lang_code');
$ret = safe_delete('txp_lang', "lang = '" . doSlash($lang_code) . "'");
if ($ret) {
callback_event('lang_deleted', '', 0, $lang_code);
$msg = gTxt($lang_code) . sp . gTxt('deleted');
} else {
$msg = gTxt('cannot_delete', array('{thing}' => $lang_code));
}
list_languages($msg);
}
示例9: get_language
function get_language()
{
global $prefs, $txpcfg, $textarray;
require_once txpath . '/lib/IXRClass.php';
$lang_code = gps('lang_code');
$client = new IXR_Client(RPC_SERVER);
// $client->debug = true;
@set_time_limit(90);
if (gps('force') == 'file' || !$client->query('tups.getLanguage', $prefs['blog_uid'], $lang_code)) {
if ((gps('force') == 'file' || gps('updating') !== '1') && install_language_from_file($lang_code)) {
if (defined('LANG')) {
$textarray = load_lang(LANG);
}
return list_languages(gTxt($lang_code) . sp . gTxt('updated'));
} else {
$install_langfile = gTxt('install_langfile', array('{url}' => strong('<a href="' . RPC_SERVER . '/lang/">' . RPC_SERVER . '/lang/</a>')));
if ($install_langfile == 'install_langfile') {
$install_langfile = 'To install new languages from file you can download them from <b><a href="' . RPC_SERVER . '/lang/">' . RPC_SERVER . '/lang/</a></b> and place them inside your ./textpattern/lang/ directory.';
}
pagetop(gTxt('installing_language'));
echo tag(gTxt('rpc_connect_error') . "<!--" . $client->getErrorCode() . ' ' . $client->getErrorMessage() . "-->", 'p', ' style="text-align:center;color:red;width:50%;margin: 2em auto"');
echo tag($install_langfile, 'p', ' style="text-align:center;width:50%;margin: 2em auto"');
}
} else {
$response = $client->getResponse();
$lang_struct = unserialize($response);
function install_lang_key(&$value, $key)
{
extract(gpsa(array('lang_code', 'updating')));
$exists = safe_field('name', 'txp_lang', "name='" . doSlash($value['name']) . "' AND lang='" . doSlash($lang_code) . "'");
$q = "name='" . doSlash($value['name']) . "', event='" . doSlash($value['event']) . "', data='" . doSlash($value['data']) . "', lastmod='" . doSlash(strftime('%Y%m%d%H%M%S', $value['uLastmod'])) . "'";
if ($exists) {
$value['ok'] = safe_update('txp_lang', $q, "lang='" . doSlash($lang_code) . "' AND name='" . doSlash($value['name']) . "'");
} else {
$value['ok'] = safe_insert('txp_lang', $q . ", lang='" . doSlash($lang_code) . "'");
}
}
array_walk($lang_struct, 'install_lang_key');
$size = count($lang_struct);
$errors = 0;
for ($i = 0; $i < $size; $i++) {
$errors += !$lang_struct[$i]['ok'];
}
if (defined('LANG')) {
$textarray = load_lang(LANG);
}
$msg = gTxt($lang_code) . sp . gTxt('updated');
if ($errors > 0) {
$msg .= sprintf(" (%s errors, %s ok)", $errors, $size - $errors);
}
return list_languages($msg);
}
}
示例10: get_textpack
function get_textpack()
{
$textpack = ps('textpack');
$n = install_textpack($textpack, true);
return list_languages(gTxt('textpack_strings_installed', array('{count}' => $n)));
}
示例11: get_language
function get_language()
{
global $prefs;
require_once txpath . '/lib/IXRClass.php';
$lang_code = gps('lang_code');
$client = new IXR_Client('http://rpc.textpattern.com');
// $client->debug = true;
if (!$client->query('tups.getLanguage', $prefs['blog_uid'], $lang_code)) {
# try to install the current file on the languages table
$lang_file = txpath . '/lang/' . LANG . '.txt';
# first attempt with local file
if (is_file($lang_file) && is_readable($lang_file)) {
$lang_file = txpath . '/lang/' . LANG . '.txt';
if (!is_file($lang_file) || !is_readable($lang_file)) {
return;
}
$file = @fopen($lang_file, "r");
if ($file) {
$lastmod = @filemtime($lang_file);
$lastmod = date('YmdHis', $lastmod);
$data = array();
$event = '';
while (!feof($file)) {
$line = fgets($file, 4096);
# any line starting with #, not followed by @ is a simple comment
if ($line[0] == '#' && $line[1] != '@' && $line[1] != '#') {
continue;
}
# each language section should be prefixed by #@
if ($line[0] == '#' && $line[1] == '@') {
if (!empty($data)) {
foreach ($data as $name => $value) {
safe_insert('txp_lang', "lang='" . LANG . "', name='{$name}', lastmod='{$lastmod}', event='{$event}', data='{$value}'");
}
}
# reset
$data = array();
$event = substr($line, 2, strlen($line) - 2);
$event = rtrim($event);
continue;
}
@(list($name, $val) = explode(' => ', trim($line)));
$data[$name] = $val;
}
# remember to add the last one
if (!empty($data)) {
foreach ($data as $name => $value) {
safe_insert('txp_lang', "lang='" . LANG . "', name='{$name}', lastmod='0000-00-00 00:00:00', event='{$event}', data='{$value}'");
}
}
@fclose($filename);
# clean empty values from table
safe_delete('txp_lang', "data=''");
$msg = 'Language installed from file';
}
} else {
$msg = 'Error trying to install language. Please try again later.<br />
If connections to the RPC server continue to fail, please visit <a href="http://rpc.textpattern.com/lang/">http://rpc.textpattern.com/lang/</a>, download the
desired language file and place it in the /lang/ directory of your textpattern install. Textpattern will attempt to install using that file.';
}
pagetop(gTxt('installing_language'));
echo startTable('list'), tr(tda($msg), ' style="color:red;"'), endTable();
} else {
$response = $client->getResponse();
$lang_struct = unserialize($response);
function install_lang_key($value, $key)
{
extract(gpsa(array('lang_code', 'updating')));
$exists = safe_field('name', 'txp_lang', "name='{$value['name']}' AND lang='{$lang_code}'");
$q = "name='" . doSlash($value['name']) . "', event='" . doSlash($value['event']) . "', data='" . doSlash($value['data']) . "', lastmod='" . strftime('%Y%m%d%H%M%S', $value['uLastmod']) . "'";
if ($exists) {
safe_update('txp_lang', $q, "lang='{$lang_code}' AND name='{$value['name']}'");
} else {
safe_insert('txp_lang', $q . ", lang='{$lang_code}'");
}
}
array_walk($lang_struct, 'install_lang_key');
return list_languages(gTxt($lang_code) . sp . gTxt('updated'));
}
}
示例12: list_languages
?>
</a>
<a href="<?php
echo BASE_URL;
?>
user/sign-out"><?php
echo $lex['log-out'];
?>
</a>
<?php
}
?>
</div>
<ul class="languages">
<?php
$languages = list_languages();
foreach ($languages as $code => $details) {
?>
<li><a href="<?php
echo BASE_URL;
?>
language/<?php
echo $code;
?>
" title="<?php
echo $details['title'];
?>
"><img src="<?php
echo BASE_URL_STATIC;
echo $details['flag'];
?>
示例13: css
padding: 0;
width: 0;
height: 0;
overflow: hidden;
}
/* Global imageset items */
' . css($images_global, './images/') . '
/* English images for fallback */
' . css($images_en, './en/');
if (strlen($bidi_code)) {
$code .= "\n/* RTL imageset entries */\n" . $bidi_code;
}
echo 'Code to add to CSS file:', dump_code($code, 'imageset.css');
$list = list_languages($imageset_path);
for ($i = 0; $i < count($list); $i++) {
$lang = $list[$i];
$images = get_imageset($imageset_path . '/' . $lang);
if (!count($images)) {
continue;
}
$code = '/* ' . strtoupper($lang) . ' Language Pack */
' . css($images, './');
echo 'New CSS file: ', $theme_path, '/', $lang, '/stylesheet.css', dump_code($code, 'stylesheet_' . $lang . '.css');
}
echo ob_get_clean();
return;
/*
Functions
*/
示例14: get_language
function get_language()
{
global $prefs;
require_once txpath . '/lib/IXRClass.php';
$lang_code = gps('lang_code');
$client = new IXR_Client(RPC_SERVER);
// $client->debug = true;
if (gps('force') == 'file' || !$client->query('tups.getLanguage', $prefs['blog_uid'], $lang_code)) {
include_once txpath . '/lib/txplib_update.php';
if ((gps('force') == 'file' || gps('updating') !== '1') && install_language_from_file($lang_code)) {
return list_languages(gTxt($lang_code) . sp . gTxt('updated'));
} else {
$install_langfile = str_replace('{url}', strong('<a href="' . RPC_SERVER . '/lang/">' . RPC_SERVER . '/lang/</a>'), gTxt('install_langfile'));
if ($install_langfile == 'install_langfile') {
$install_langfile = 'To install new languages from file you can download them from <b><a href="' . RPC_SERVER . '/lang/">' . RPC_SERVER . '/lang/</a></b> and place them inside your ./textpattern/lang/ directory.';
}
pagetop(gTxt('installing_language'));
echo tag(gTxt('rpc_connect_error'), 'p', ' style="text-align:center;color:red;width:50%;margin: 2em auto"');
echo tag($install_langfile, 'p', ' style="text-align:center;width:50%;margin: 2em auto"');
}
} else {
$response = $client->getResponse();
$lang_struct = unserialize($response);
function install_lang_key($value, $key)
{
extract(gpsa(array('lang_code', 'updating')));
$exists = safe_field('name', 'txp_lang', "name='{$value['name']}' AND lang='{$lang_code}'");
$q = "name='" . doSlash($value['name']) . "', event='" . doSlash($value['event']) . "', data='" . doSlash($value['data']) . "', lastmod='" . strftime('%Y%m%d%H%M%S', $value['uLastmod']) . "'";
if ($exists) {
safe_update('txp_lang', $q, "lang='{$lang_code}' AND name='{$value['name']}'");
} else {
safe_insert('txp_lang', $q . ", lang='{$lang_code}'");
}
}
array_walk($lang_struct, 'install_lang_key');
return list_languages(gTxt($lang_code) . sp . gTxt('updated'));
}
}
示例15: _add_edit_user
function _add_edit_user($params)
{
global $user, $method;
$users_schema = load_schema('user');
$method = '_add_edit_user';
$users_schema['timezone']['enum'] = json_decode(file_get_contents('data/timezones.json'));
$users_schema['lang']['enum'] = list_languages();
//
$db = connect_database();
$users_schema['groups']['enum'] = array();
$groups = $db->query('SELECT id, username FROM `user` WHERE organization = ' . $user['organization'] . ' AND password = \'[GROUP]\'');
while ($group = row_assoc($groups)) {
$users_schema['groups']['enum'][$group['id']] = $group['username'];
}
//
$data = array('schema' => $users_schema);
//
$data['schema']['auth']['enum'] = _subfolders('./modules/');
return $data;
}