本文整理汇总了PHP中Locale::list_all方法的典型用法代码示例。如果您正苦于以下问题:PHP Locale::list_all方法的具体用法?PHP Locale::list_all怎么用?PHP Locale::list_all使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Locale
的用法示例。
在下文中一共展示了Locale::list_all方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct()
{
parent::__construct();
// Let's register the options page form so we can use it with ajax
$self = $this;
FormUI::register('admin_options', function ($form, $name, $extra_data) use($self) {
$option_items = array();
$timezones = \DateTimeZone::listIdentifiers();
$timezones = array_merge(array('' => ''), array_combine(array_values($timezones), array_values($timezones)));
$option_items[_t('Name & Tagline')] = array('title' => array('label' => _t('Site Name'), 'type' => 'text', 'helptext' => ''), 'tagline' => array('label' => _t('Site Tagline'), 'type' => 'text', 'helptext' => ''), 'about' => array('label' => _t('About'), 'type' => 'textarea', 'helptext' => ''));
$option_items[_t('Publishing')] = array('pagination' => array('label' => _t('Items per Page'), 'type' => 'text', 'helptext' => ''), 'atom_entries' => array('label' => _t('Entries to show in Atom feed'), 'type' => 'text', 'helptext' => ''), 'comments_require_id' => array('label' => _t('Require Comment Author Email'), 'type' => 'checkbox', 'helptext' => ''), 'spam_percentage' => array('label' => _t('Comment SPAM Threshold'), 'type' => 'text', 'helptext' => _t('The likelihood a comment is considered SPAM, in percent.')));
$option_items[_t('Time & Date')] = array('timezone' => array('label' => _t('Time Zone'), 'type' => 'select', 'selectarray' => $timezones, 'helptext' => _t('Current Date Time: %s', array(DateTime::create()->format()))), 'dateformat' => array('label' => _t('Date Format'), 'type' => 'text', 'helptext' => _t('Current Date: %s', array(DateTime::create()->date))), 'timeformat' => array('label' => _t('Time Format'), 'type' => 'text', 'helptext' => _t('Current Time: %s', array(DateTime::create()->time))));
$option_items[_t('Language')] = array('locale' => array('label' => _t('Locale'), 'type' => 'select', 'selectarray' => array_merge(array('' => 'default'), array_combine(Locale::list_all(), Locale::list_all())), 'helptext' => Config::exists('locale') ? _t('International language code : This value is set in your config.php file, and cannot be changed here.') : _t('International language code'), 'disabled' => Config::exists('locale'), 'value' => Config::get('locale', Options::get('locale', 'en-us'))), 'system_locale' => array('label' => _t('System Locale'), 'type' => 'text', 'helptext' => _t('The appropriate locale code for your server')));
$option_items[_t('Troubleshooting')] = array('log_min_severity' => array('label' => _t('Minimum Severity'), 'type' => 'select', 'selectarray' => LogEntry::list_severities(), 'helptext' => _t('Only log entries with a this or higher severity.')), 'log_backtraces' => array('label' => _t('Log Backtraces'), 'type' => 'checkbox', 'helptext' => _t('Logs error backtraces to the log table\'s data column. Can drastically increase log size!')));
$option_items = Plugins::filter('admin_option_items', $option_items);
$tab_index = 3;
foreach ($option_items as $name => $option_fields) {
/** @var FormControlFieldset $fieldset */
$fieldset = $form->append(FormControlWrapper::create(Utils::slugify(_u($name)))->set_properties(array('class' => 'container main settings')));
$fieldset->append(FormControlStatic::create($name)->set_static('<h2 class="lead">' . htmlentities($name, ENT_COMPAT, 'UTF-8') . '</h2>'));
$fieldset->set_wrap_each('<div>%s</div>');
foreach ($option_fields as $option_name => $option) {
/** @var FormControlLabel $label */
$label = $fieldset->append(FormControlLabel::create('label_for_' . $option_name, null)->set_label($option['label']));
/** @var FormControl $field */
$field = $label->append($option['type'], $option_name, $option_name);
$label->set_for($field);
if (isset($option['value'])) {
$field->set_value($option['value']);
}
if (isset($option['disabled']) && $option['disabled'] == true) {
$field->set_properties(array('disabled' => 'disabled'));
}
if ($option['type'] == 'select' && isset($option['selectarray'])) {
$field->set_options($option['selectarray']);
}
$field->tabindex = $tab_index;
$tab_index++;
if (isset($option['helptext'])) {
$field->set_helptext($option['helptext']);
}
}
}
$buttons = $form->append(new FormControlWrapper('buttons', null, array('class' => 'container')));
$buttons->append(FormControlSubmit::create('apply', null, array('tabindex' => $tab_index))->set_caption(_t('Apply')));
$form->on_success(array($self, 'form_options_success'));
$form = Plugins::filter('admin_options_form', $form);
});
}
示例2: act_begin_install
/**
* Entry point for installation. The reason there is a begin_install
* method to handle is that conceivably, the user can stop installation
* mid-install and need an alternate entry point action at a later time.
*/
public function act_begin_install()
{
// Create a new theme to handle the display of the installer
$this->theme = Themes::create('installer', 'RawPHPEngine', HABARI_PATH . '/system/installer/');
/**
* Set user selected Locale or default
*/
$this->theme->locales = Locale::list_all();
if (isset($_POST['locale']) && $_POST['locale'] != null) {
Locale::set($_POST['locale']);
} else {
Locale::set(Config::get('locale', 'en-us'));
}
$this->theme->locale = Locale::get();
$this->handler_vars['locale'] = Locale::get();
/**
* Check .htaccess first because ajax doesn't work without it.
*/
if (!$this->check_htaccess()) {
$this->handler_vars['file_contents'] = htmlentities(implode("\n", $this->htaccess()));
$this->display('htaccess');
}
// Dispatch AJAX requests.
if (isset($_POST['ajax_action'])) {
switch ($_POST['ajax_action']) {
case 'check_mysql_credentials':
self::ajax_check_mysql_credentials();
exit;
break;
case 'check_pgsql_credentials':
self::ajax_check_pgsql_credentials();
exit;
break;
case 'check_sqlite_credentials':
self::ajax_check_sqlite_credentials();
exit;
break;
}
}
// set the default values now, which will be overriden as we go
$this->form_defaults();
if (!$this->meets_all_requirements()) {
$this->display('requirements');
}
/**
* Add the AJAX hooks
*/
Plugins::register(Method::create('\\Habari\\InstallHandler', 'ajax_check_mysql_credentials'), 'ajax_', 'check_mysql_credentials');
Plugins::register(Method::create('\\Habari\\InstallHandler', 'ajax_check_pgsql_credentials'), 'ajax_', 'check_pgsql_credentials');
/**
* Let's check the config.php file if no POST data was submitted
*/
if (!file_exists(Site::get_dir('config_file')) && !isset($_POST['admin_username'])) {
// no config file, and no HTTP POST
$this->display('db_setup');
}
// try to load any values that might be defined in config.php
if (file_exists(Site::get_dir('config_file'))) {
include Site::get_dir('config_file');
// check for old style config (global variable, pre-dates registry based config
if (!Config::exists('db_connection') && isset($db_connection)) {
// found old style config...
// set up registry:
Config::set('db_connection', $db_connection);
// assign handler vars (for config file write)
$this->set_handler_vars_from_db_connection();
// write new config file
if ($this->write_config_file(true)) {
// successful, so redirect:
Utils::redirect(Site::get_url('site'));
}
}
if (Config::exists('db_connection')) {
$this->set_handler_vars_from_db_connection();
}
// if a $blog_data array exists in config.php, use it
// to pre-load values for the installer
// ** this is completely optional **
if (Config::exists('blog_data')) {
$blog_data = Config::get('blog_data');
foreach ($blog_data as $blog_datum => $value) {
$this->handler_vars[$blog_datum] = $value;
}
}
}
// now merge in any HTTP POST values that might have been sent
// these will override the defaults and the config.php values
$this->handler_vars = $this->handler_vars->merge($_POST);
// we need details for the admin user to install
if ('' == $this->handler_vars['admin_username'] || '' == $this->handler_vars['admin_pass1'] || '' == $this->handler_vars['admin_pass2'] || '' == $this->handler_vars['admin_email']) {
// if none of the above are set, display the form
$this->display('db_setup');
}
$db_type = $this->handler_vars['db_type'];
if ((!Config::exists('db_connection') || Config::get('db_connection')->connection_string == '') && ($db_type == 'mysql' || $db_type == 'pgsql')) {
//.........这里部分代码省略.........
示例3: __construct
public function __construct()
{
$self = $this;
FormUI::register('add_user', function (FormUI $form, $name) use($self) {
$form->set_settings(array('use_session_errors' => true));
$form->append(FormControlText::create('username')->set_properties(array('class' => 'columns three', 'placeholder' => _t('Username')))->add_validator('validate_username')->add_validator('validate_required'));
$form->append(FormControlText::create('email')->set_properties(array('class' => 'columns four', 'placeholder' => _t('E-Mail')))->add_validator('validate_email')->add_validator('validate_required'));
$password = FormControlPassword::create('password')->set_properties(array('class' => 'columns three', 'placeholder' => _t('Password')))->add_validator('validate_required');
$form->append($password);
$form->append(FormControlPassword::create('password_again')->set_properties(array('class' => 'columns three', 'placeholder' => _t('Password Again')))->add_validator('validate_same', $password));
$form->append(FormControlSubmit::create('newuser')->set_caption('Add User'));
$form->add_validator(array($self, 'validate_add_user'));
$form->on_success(array($self, 'do_add_user'));
});
FormUI::register('delete_users', function (FormUI $form, $name) use($self) {
$form->set_settings(array('use_session_errors' => true));
$form->append(FormControlAggregate::create('deletion_queue')->set_selector('.select_user')->label('Select All'));
$author_list = Users::get_all();
$authors[0] = _t('nobody');
foreach ($author_list as $author) {
$authors[$author->id] = $author->displayname;
}
$form->append(FormControlSelect::create('reassign')->set_options($authors));
$form->append(FormControlSubmit::create('delete_selected')->set_caption(_t('Delete Selected')));
$form->add_validator(array($self, 'validate_delete_users'));
$form->on_success(array($self, 'do_delete_users'));
});
FormUI::register('edit_user', function (FormUI $form, $name, $form_type, $data) use($self) {
$form->set_settings(array('use_session_errors' => true));
$edit_user = $data['edit_user'];
$field_sections = array('user_info' => _t('User Information'), 'change_password' => _t('Change Password'), 'regional_settings' => _t('Regional Settings'), 'dashboard' => _t('Dashboard'));
// Create a tracker for who we are dealing with
$form->append(FormControlData::create('edit_user')->set_value($edit_user->id));
// Generate sections
foreach ($field_sections as $key => $name) {
$fieldset = $form->append('wrapper', $key, $name);
$fieldset->add_class('container main settings');
$fieldset->append(FormControlStatic::create($key)->set_static('<h2 class="lead">' . htmlentities($name, ENT_COMPAT, 'UTF-8') . '</h2>'));
}
// User Info
$displayname = FormControlText::create('displayname')->set_value($edit_user->displayname);
$form->user_info->append(FormControlLabel::wrap(_t('Display Name'), $displayname));
$username = FormControlText::create('username')->add_validator('validate_username', $edit_user->username)->set_value($edit_user->username);
$form->user_info->append(FormControlLabel::wrap(_t('User Name'), $username));
$email = FormControlText::create('email')->add_validator('validate_email')->set_value($edit_user->email);
$form->user_info->append(FormControlLabel::wrap(_t('Email'), $email));
$imageurl = FormControlText::create('imageurl')->set_value($edit_user->info->imageurl);
$form->user_info->append(FormControlLabel::wrap(_t('Portrait URL'), $imageurl));
// Change Password
$password1 = FormControlPassword::create('password1', null, array('autocomplete' => 'off'))->set_value('');
$form->change_password->append(FormControlLabel::wrap(_t('New Password'), $password1));
$password2 = FormControlPassword::create('password2', null, array('autocomplete' => 'off'))->set_value('');
$form->change_password->append(FormControlLabel::wrap(_t('New Password Again'), $password2));
$delete = $self->handler_vars->filter_keys('delete');
// don't validate password match if action is delete
if (!isset($delete['delete'])) {
$password2->add_validator('validate_same', $password1, _t('Passwords must match.'));
}
// Regional settings
$timezones = \DateTimeZone::listIdentifiers();
$timezones = array_merge(array_combine(array_values($timezones), array_values($timezones)));
$locale_tz = FormControlSelect::create('locale_tz', null, array('multiple' => false))->set_options($timezones)->set_value($edit_user->info->locale_tz);
$form->regional_settings->append(FormControlLabel::wrap(_t('Timezone'), $locale_tz));
$locale_date_format = FormControlText::create('locale_date_format')->set_value($edit_user->info->locale_date_format);
$form->regional_settings->append(FormControlLabel::wrap(_t('Date Format'), $locale_date_format));
$edit_user_info = $edit_user->info;
if (isset($edit_user_info->locale_date_format) && $edit_user_info->locale_date_format != '') {
$current = DateTime::create()->get($edit_user_info->locale_date_format);
} else {
$current = DateTime::create()->date;
}
$locale_date_format->set_helptext(_t('See <a href="%s">php.net/date</a> for details. Current format: %s', array('http://php.net/date', $current)));
$locale_time_format = FormControlText::create('locale_time_format')->set_value($edit_user_info->locale_time_format);
$form->regional_settings->append(FormControlLabel::wrap(_t('Time Format'), $locale_time_format));
if (isset($edit_user_info->locale_time_format) && $edit_user_info->locale_time_format != '') {
$current = DateTime::create()->get($edit_user_info->locale_time_format);
} else {
$current = DateTime::create()->time;
}
$locale_time_format->set_helptext(_t('See <a href="%s">php.net/date</a> for details. Current format: %s', array('http://php.net/date', $current)));
$locales = array_merge(array('' => _t('System default') . ' (' . Options::get('locale', 'en-us') . ')'), array_combine(Locale::list_all(), Locale::list_all()));
$locale_lang = FormcontrolSelect::create('locale_lang', null, array('multiple' => false))->set_options($locales)->set_value($edit_user_info->locale_lang);
$form->regional_settings->append(FormControlLabel::wrap(_t(' Language'), $locale_lang));
$spam_count = FormControlCheckbox::create('dashboard_hide_spam_count')->set_helptext(_t('Hide the number of SPAM comments on your dashboard.'))->set_value($edit_user_info->dashboard_hide_spam_count);
$form->dashboard->append(FormControlLabel::wrap(_t('Hide Spam Count'), $spam_count));
// Groups
if (User::identify()->can('manage_groups')) {
$fieldset = $form->append(FormControlWrapper::create('groups'));
$fieldset->add_class('container main settings');
$fieldset->append(FormControlStatic::create('groups_title')->set_static('<h2 class="lead">' . htmlentities(_t('Groups'), ENT_COMPAT, 'UTF-8') . '</h2>'));
$fieldset->append(FormControlCheckboxes::create('user_group_membership')->set_options(Utils::array_map_field(UserGroups::get_all(), 'name', 'id'))->set_value($edit_user->groups));
}
// Controls
$controls = $form->append(FormControlWrapper::create('page_controls')->add_class('container controls transparent'));
$apply = $controls->append(FormControlSubmit::create('apply')->set_caption(_t('Apply')));
// Get author list
$author_list = Users::get_all();
$authors[0] = _t('nobody');
foreach ($author_list as $author) {
$authors[$author->id] = $author->displayname;
//.........这里部分代码省略.........