本文整理汇总了PHP中Utils::array_map_field方法的典型用法代码示例。如果您正苦于以下问题:PHP Utils::array_map_field方法的具体用法?PHP Utils::array_map_field怎么用?PHP Utils::array_map_field使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Utils
的用法示例。
在下文中一共展示了Utils::array_map_field方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: check
/**
* Perform a check of all beaconids.
* Notifies update_check plugin hooks when checking so that they can add their beaconids to the list.
* @return array An array of update beacon information for components that have updates
* @throws \Exception
*/
public static function check()
{
try {
// get a local version of the instance to save typing
$instance = self::instance();
// load beacons
self::register_beacons();
// setup the remote request
$request = new RemoteRequest(self::UPDATE_URL, 'POST');
// add all the beacon versions as parameters
$request->set_params(Utils::array_map_field($instance->beacons, 'version'));
// we're not desperate enough to wait too long
$request->set_timeout(5);
// execute the request
$result = $request->execute();
// grab the body of the response, which has our xml in it
$update_data = $request->get_response_body();
// i don't know why we hold the XML in a class variable, but we'll keep doing that in this rewrite
$instance->update = new \SimpleXMLElement($update_data);
foreach ($instance->update as $beacon) {
$beacon_id = (string) $beacon['id'];
$beacon_url = (string) $beacon['url'];
$beacon_type = isset($beacon['type']) ? (string) $beacon['type'] : 'addon';
// do we have this beacon? if not, don't process it
// even though we POST all our beacons to the update script right now, it still hands back the whole list
if (empty($instance->beacons[$beacon_id])) {
continue;
}
// add the beacon's basic info
$instance->beacons[$beacon_id]['id'] = $beacon_id;
$instance->beacons[$beacon_id]['url'] = $beacon_url;
$instance->beacons[$beacon_id]['type'] = $beacon_type;
foreach ($beacon->update as $update) {
// pick out and cast all the values from the XML
$u = array('severity' => (string) $update['severity'], 'version' => (string) $update['version'], 'date' => isset($update['date']) ? (string) $update['date'] : '', 'url' => isset($update['url']) ? (string) $update['url'] : '', 'text' => (string) $update);
// if the remote update info version is newer... we want all newer versions
if (version_compare($u['version'], $instance->beacons[$beacon_id]['version']) > 0) {
// if this version is more recent than all the other versions
if (!isset($instance->beacons[$beacon_id]['latest_version']) || version_compare($u['version'], $instance->beacons[$beacon_id]['latest_version']) > 0) {
// set this as the latest version
$instance->beacons[$beacon_id]['latest_version'] = $u['version'];
}
// add the version to the list
$instance->beacons[$beacon_id]['updates'][$u['version']] = $u;
}
}
}
// return an array of beacons that have updates
return array_filter($instance->beacons, Method::create('\\Habari\\Update', 'filter_unchanged'));
} catch (\Exception $e) {
// catches any RemoteRequest errors or XML parsing problems, etc.
// bubble up
throw $e;
}
}
示例2: get_form
public function get_form()
{
$users = Users::get_all();
$users = Utils::array_map_field($users, 'username', 'id');
$form = new FormUI('sudo');
$form->append(new FormControlSelect('userlist', 'null:null', 'Become User:', $users));
$form->userlist->value = User::identify()->id;
$form->append(new FormControlSubmit('submit', 'Submit'));
$form->set_option('form_action', URL::get('sudo'));
$form->onsubmit = 'return dosudo.setuser();';
return $form;
}
示例3: get_themes
/**
* Handles GET requests for the theme listing
*/
public function get_themes()
{
$all_themes = Themes::get_all_data();
$theme_names = Utils::array_map_field($all_themes, 'name');
$available_updates = Options::get('updates_available', array());
foreach ($all_themes as $name => $theme) {
// only themes with a guid can be checked for updates
if (isset($theme['info']->guid)) {
if (isset($available_updates[(string) $theme['info']->guid])) {
// @todo this doesn't use the URL and is therefore worthless
$all_themes[$name]['info']->update = $available_updates[(string) $theme['info']->guid]['latest_version'];
}
}
// If this theme requires a parent to be present and it's not, send an error
if (isset($theme['info']->parent) && !in_array((string) $theme['info']->parent, $theme_names)) {
$all_themes[$name]['req_parent'] = $theme['info']->parent;
}
}
$this->theme->all_themes = $all_themes;
$this->theme->active_theme = Themes::get_active_data(true);
$this->theme->active_theme_dir = $this->theme->active_theme['path'];
// If the active theme is configurable, allow it to configure
$this->theme->active_theme_name = $this->theme->active_theme['info']->name;
$this->theme->configurable = Plugins::filter('theme_config', false, $this->active_theme);
$this->theme->assign('configure', Controller::get_var('configure'));
$this->theme->areas = $this->get_areas(0);
$this->theme->previewed = Themes::get_theme_dir(false);
$this->theme->help = isset($this->theme->active_theme['info']->help) ? $this->theme->active_theme['info']->help : false;
$this->theme->help_active = Controller::get_var('help') == $this->theme->active_theme['dir'];
$this->prepare_block_list();
$blocks_areas_t = DB::get_results('SELECT b.*, ba.scope_id, ba.area, ba.display_order FROM {blocks} b INNER JOIN {blocks_areas} ba ON ba.block_id = b.id ORDER BY ba.scope_id ASC, ba.area ASC, ba.display_order ASC', array());
$blocks_areas = array();
foreach ($blocks_areas_t as $block) {
if (!isset($blocks_areas[$block->scope_id])) {
$blocks_areas[$block->scope_id] = array();
}
$blocks_areas[$block->scope_id][$block->area][$block->display_order] = $block;
}
$this->theme->blocks_areas = $blocks_areas;
$scopes = DB::get_results('SELECT * FROM {scopes} ORDER BY name ASC;');
$scopes = Plugins::filter('get_scopes', $scopes);
$this->theme->scopes = $scopes;
$this->theme->scopeid = 0;
$this->theme->theme_loader = Plugins::filter('theme_loader', '', $this->theme);
$this->theme->display('themes');
}
示例4: array_map_field
/**
* Given an array of arrays, return an array that contains the value of a particular common field
* Example:
* $a = array(
* array('foo'=>1, 'bar'=>2),
* array('foo'=>3, 'bar'=>4),
* );
* $b = Utils::array_map_field($a, 'foo'); // $b = array(1, 3);
*
* @param \Countable $array An array of arrays or objects with similar keys or properties
* @param string $field The name of a common field within each array/object
* @param string $key Optional field to use as the key in the result array
* @return array An array of the values of the specified field within each array/object
*/
public static function array_map_field($array, $field, $key = null)
{
if (count($array) == 0) {
return $array;
}
if (is_null($key)) {
if ($array instanceof \ArrayObject) {
$array = $array->getArrayCopy();
}
return array_map(function ($element) use($field) {
return is_array($element) ? $element[$field] : (is_object($element) ? $element->{$field} : null);
}, $array);
} else {
return array_combine(Utils::array_map_field($array, $key), Utils::array_map_field($array, $field));
}
}
示例5: theme_query_time
/**
* Returns total query execution time in seconds
*
* @return float Query execution time in seconds, with fractions.
*/
public function theme_query_time()
{
return array_sum(Utils::array_map_field(DB::get_profiles(), 'total_time'));
}
示例6: get_user
//.........这里部分代码省略.........
// Redirect to the users management page if we're trying to edit a non-existent user
if (!$edit_user) {
Session::error(_t('No such user!'));
Utils::redirect(URL::get('admin', 'page=users'));
}
$this->theme->edit_user = $edit_user;
$field_sections = array('user_info' => $possessive, 'change_password' => _t('Change Password'), 'regional_settings' => _t('Regional Settings'), 'dashboard' => _t('Dashboard'));
$form = new FormUI('User Options');
// Create a tracker for who we are dealing with
$form->append('hidden', 'edit_user', 'edit_user');
$form->edit_user->value = $edit_user->id;
// Generate sections
foreach ($field_sections as $key => $name) {
$fieldset = $form->append('wrapper', $key, $name);
$fieldset->class = 'container settings';
$fieldset->append('static', $key, '<h2>' . htmlentities($name, ENT_COMPAT, 'UTF-8') . '</h2>');
}
// User Info
$displayname = $form->user_info->append('text', 'displayname', 'null:null', _t('Display Name'), 'optionscontrol_text');
$displayname->class[] = 'important item clear';
$displayname->value = $edit_user->displayname;
$username = $form->user_info->append('text', 'username', 'null:null', _t('User Name'), 'optionscontrol_text');
$username->class[] = 'item clear';
$username->value = $edit_user->username;
$username->add_validator('validate_username', $edit_user->username);
$email = $form->user_info->append('text', 'email', 'null:null', _t('Email'), 'optionscontrol_text');
$email->class[] = 'item clear';
$email->value = $edit_user->email;
$email->add_validator('validate_email');
$imageurl = $form->user_info->append('text', 'imageurl', 'null:null', _t('Portrait URL'), 'optionscontrol_text');
$imageurl->class[] = 'item clear';
$imageurl->value = $edit_user->info->imageurl;
// Change Password
$password1 = $form->change_password->append('text', 'password1', 'null:null', _t('New Password'), 'optionscontrol_text');
$password1->class[] = 'item clear';
$password1->type = 'password';
$password1->value = '';
$password1->autocomplete = 'off';
$password2 = $form->change_password->append('text', 'password2', 'null:null', _t('New Password Again'), 'optionscontrol_text');
$password2->class[] = 'item clear';
$password2->type = 'password';
$password2->value = '';
$password2->autocomplete = 'off';
$delete = $this->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 = $form->regional_settings->append('select', 'locale_tz', 'null:null', _t('Timezone'));
$locale_tz->class[] = 'item clear';
$locale_tz->value = $edit_user->info->locale_tz;
$locale_tz->options = $timezones;
$locale_tz->multiple = false;
$locale_tz->template = 'optionscontrol_select';
$locale_date_format = $form->regional_settings->append('text', 'locale_date_format', 'null:null', _t('Date Format'), 'optionscontrol_text');
$locale_date_format->class[] = 'item clear';
$locale_date_format->value = $edit_user->info->locale_date_format;
if (isset($edit_user->info->locale_date_format) && $edit_user->info->locale_date_format != '') {
$current = HabariDateTime::date_create()->get($edit_user->info->locale_date_format);
} else {
$current = HabariDateTime::date_create()->date;
}
$locale_date_format->helptext = _t('See <a href="%s">php.net/date</a> for details. Current format: %s', array('http://php.net/date', $current));
$locale_time_format = $form->regional_settings->append('text', 'locale_time_format', 'null:null', _t('Time Format'), 'optionscontrol_text');
$locale_time_format->class[] = 'item clear';
$locale_time_format->value = $edit_user->info->locale_time_format;
if (isset($edit_user->info->locale_time_format) && $edit_user->info->locale_time_format != '') {
$current = HabariDateTime::date_create()->get($edit_user->info->locale_time_format);
} else {
$current = HabariDateTime::date_create()->time;
}
$locale_time_format->helptext = _t('See <a href="%s">php.net/date</a> for details. Current format: %s', array('http://php.net/date', $current));
$spam_count = $form->dashboard->append('checkbox', 'dashboard_hide_spam_count', 'null:null', _t('Hide Spam Count'), 'optionscontrol_checkbox');
$spam_count->class[] = 'item clear';
$spam_count->helptext = _t('Hide the number of SPAM comments on your dashboard.');
$spam_count->value = $edit_user->info->dashboard_hide_spam_count;
// Groups
if (User::identify()->can('manage_groups')) {
$fieldset = $form->append('wrapper', 'groups', _t('Groups'));
$fieldset->class = 'container settings';
$fieldset->append('static', 'groups', '<h2>' . htmlentities(_t('Groups'), ENT_COMPAT, 'UTF-8') . '</h2>');
$form->groups->append('checkboxes', 'user_group_membership', 'null:null', _t('Groups'), Utils::array_map_field(UserGroups::get_all(), 'name', 'id'));
$form->user_group_membership->value = $edit_user->groups;
}
// Controls
$controls = $form->append('wrapper', 'page_controls');
$controls->class = 'container controls transparent';
$submit = $controls->append('submit', 'apply', _t('Apply'), 'optionscontrol_submit');
$submit->class[] = 'pct30';
$controls->append('static', 'reassign', '<span class="pct35 reassigntext">' . _t('Reassign posts to: %s', array(Utils::html_select('reassign', $authors))) . '</span><span class="minor pct5 conjunction">' . _t('and') . '</span><span class="pct30"><input type="submit" name="delete" value="' . _t('Delete') . '" class="delete button"></span>');
$form->on_success(array($this, 'form_user_success'));
// Let plugins alter this form
Plugins::act('form_user', $form, $edit_user);
$this->theme->form = $form->get();
$this->theme->admin_page = $self ? _t('My Profile') : _t('User');
$this->theme->display('user');
}
示例7: get_menu_type_ids
/**
* @return array The data array
*/
public function get_menu_type_ids()
{
static $menu_item_ids = null;
if (empty($menu_item_ids)) {
$menu_item_types = $this->get_menu_type_data();
$menu_item_types = Utils::array_map_field($menu_item_types, 'type_id');
$menu_item_types = array_flip($menu_item_ids);
}
return $menu_item_ids;
}
示例8: validate_theme
/**
* Ensure that a theme meets requirements for activation/preview
* @static
* @param string $theme_dir the directory of the theme
* @return bool True if the theme meets all requirements
*/
public static function validate_theme($theme_dir)
{
$all_themes = Themes::get_all_data();
// @todo Make this a closure in php 5.3
$theme_names = Utils::array_map_field($all_themes, 'name');
$theme_data = $all_themes[$theme_dir];
$ok = true;
if (isset($theme_data['info']->parent) && !in_array((string) $theme_data['info']->parent, $theme_names)) {
Session::error(_t('This theme requires the parent theme named "%s" to be present prior to activation.', array($theme_data['info']->parent)));
$ok = false;
}
if (isset($theme_data['info']->requires)) {
$provided = Plugins::provided();
foreach ($theme_data['info']->requires->feature as $requirement) {
if (!isset($provided[(string) $requirement])) {
Session::error(_t('This theme requires the feature "<a href="%2$s">%1$s</a>" to be present prior to activation.', array((string) $requirement, $requirement['url'])));
$ok = false;
}
}
}
return $ok;
}
示例9: changed_since_last_activation
/**
* Detects whether the plugins that exist have changed since they were last
* activated.
* @return boolean true if the plugins have changed, false if not.
*/
public static function changed_since_last_activation()
{
$old_plugins = Options::get('plugins_present');
// If the plugin list was never stored, then they've changed.
if (!is_array($old_plugins)) {
return true;
}
// add base path onto stored path
foreach ($old_plugins as $old_plugin) {
$old_plugin = HABARI_PATH . $old_plugin;
}
// If the file list is not identical, then they've changed.
$new_plugin_files = Plugins::list_all();
$old_plugin_files = Utils::array_map_field($old_plugins, 'file');
if (count(array_intersect($new_plugin_files, $old_plugin_files)) != count($new_plugin_files)) {
return true;
}
// If the files are not identical, then they've changed.
$old_plugin_checksums = Utils::array_map_field($old_plugins, 'checksum');
$new_plugin_checksums = array_map('md5_file', $new_plugin_files);
if (count(array_intersect($old_plugin_checksums, $new_plugin_checksums)) != count($new_plugin_checksums)) {
return true;
}
return false;
}
示例10: summarize
/**
* Returns a shortened version of whatever is passed in.
* @param string $value A string to shorten
* @param integer $count Maximum words to display [100]
* @param integer $max_paragraphs Maximum paragraphs to display [1]
* @return string The string, shortened
*/
public static function summarize($text, $count = 100, $max_paragraphs = 1)
{
$ellipsis = '…';
$showmore = false;
$ht = new HtmlTokenizer($text, false);
$set = $ht->parse();
$stack = array();
$para = 0;
$token = $set->current();
$summary = new HTMLTokenSet();
$set->rewind();
$remaining_words = $count;
// $bail lets the loop end naturally and close all open elements without adding new ones.
$bail = false;
for ($token = $set->current(); $set->valid(); $token = $set->next()) {
if (!$bail && $token['type'] == HTMLTokenizer::NODE_TYPE_ELEMENT_OPEN) {
$stack[] = $token;
}
if (!$bail) {
switch ($token['type']) {
case HTMLTokenizer::NODE_TYPE_TEXT:
$words = preg_split('/(\\s+)/u', $token['value'], -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
// word count is doubled because spaces between words are captured as their own array elements via PREG_SPLIT_DELIM_CAPTURE
$words = array_slice($words, 0, $remaining_words * 2);
$remaining_words -= count($words) / 2;
$token['value'] = implode('', $words);
if ($remaining_words <= 0) {
$token['value'] .= $ellipsis;
$summary[] = $token;
$bail = true;
} else {
$summary[] = $token;
}
break;
case HTMLTokenizer::NODE_TYPE_ELEMENT_CLOSE:
// don't handle this case here
break;
default:
$summary[] = $token;
break;
}
}
if ($token['type'] == HTMLTokenizer::NODE_TYPE_ELEMENT_CLOSE) {
if (count($stack) > 0 && in_array($token['name'], Utils::array_map_field($stack, 'name'))) {
do {
$end = array_pop($stack);
$end['type'] = HTMLTokenizer::NODE_TYPE_ELEMENT_CLOSE;
$end['attrs'] = null;
$end['value'] = null;
$summary[] = $end;
} while (($bail || $end['name'] != $token['name']) && count($stack) > 0);
} else {
$end['name'] = $token['name'];
$end['type'] = HTMLTokenizer::NODE_TYPE_ELEMENT_CLOSE;
$end['attrs'] = null;
$end['value'] = null;
}
if (count($stack) == 0) {
$para++;
}
if ($bail || $para >= $max_paragraphs) {
break;
}
}
}
return (string) $summary;
}
示例11: __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;
//.........这里部分代码省略.........