コード例 #1
0
ファイル: admintagshandler.php プロジェクト: habari/system
 public function __construct()
 {
     self::$facets = array(_t('More than .. posts') => 'morethan', _t('Less than .. posts') => 'lessthan', _t('Order by') => 'orderby');
     self::$facet_values = array('orderby' => array(_t('Publication date (descending)') => 'pubdate_desc', _t('Publication date (ascending)') => 'pubdate_asc', _t('Post count (descending)') => 'count_desc', _t('Post count (ascending)') => 'count_asc', _t('Alphabetical (descending)') => 'alphabetical_desc', _t('Alphabetical (ascending)') => 'alphabetical_asc'));
     // We could avoid "translating" for sure, but it adds an additional layer of security, so we keep it
     self::$orderby_translate = array('pubdate' => 'pubdate', 'count' => 'count', 'alphabetical' => 'term_display');
     return parent::__construct();
 }
コード例 #2
0
ファイル: admingroupshandler.php プロジェクト: habari/system
 public function __construct()
 {
     $self = $this;
     FormUI::register('add_group', function (FormUI $form, $name) use($self) {
         $form->set_settings(array('use_session_errors' => true));
         $form->append(FormControlText::create('groupname')->add_validator('validate_required', _t('The group must have a name'))->add_validator('validate_groupname')->label(_t('Group Name'))->add_class('incontent')->set_template('control.label.outsideleft'));
         $form->append(FormControlSubmit::create('newgroup')->set_caption('Add Group'));
         $form->add_validator(array($self, 'validate_add_group'));
         $form->on_success(array($self, 'do_add_group'));
     });
     parent::__construct();
 }
コード例 #3
0
ファイル: adminoptionshandler.php プロジェクト: habari/system
 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);
     });
 }
コード例 #4
0
 /**
  * Constructor
  */
 function __construct()
 {
     parent::__construct();
     $this->addRoleAssignment(array(ROLE_ID_SITE_ADMIN), array('systemInfo', 'editSystemConfig', 'saveSystemConfig', 'phpinfo', 'expireSessions', 'clearTemplateCache', 'clearDataCache', 'downloadScheduledTaskLogFile', 'clearScheduledTaskLogFiles'));
 }
コード例 #5
0
 /**
  * Constructor
  */
 function __construct()
 {
     parent::__construct();
     $this->addRoleAssignment(array(ROLE_ID_SITE_ADMIN), array('contexts'));
 }
コード例 #6
0
ファイル: adminusershandler.php プロジェクト: habari/system
 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;
         }
         unset($authors[$edit_user->id]);
         // We can't reassign this user's posts to themselves if we're deleting them
         $reassign = FormControlSelect::create('reassign')->set_options($authors);
         $reassign_label = FormControlLabel::wrap(_t('Reassign posts to:'), $reassign)->set_settings(array('wrap' => '<span class="reassigntext">%s</span>'));
         $controls->append($reassign_label);
         $controls->append(FormControlStatic::create('conjunction')->set_static(_t('and'))->set_settings(array('wrap' => '<span class="conjunction">%s</span>')));
         $delete = $controls->append(FormControlSubmit::create('delete')->set_caption(_t('Delete'))->set_settings(array('wrap' => '<span>%s</span>'))->add_class('button'));
         $delete->on_success(array($self, 'edit_user_delete'));
         $delete->add_validator(array($self, 'validate_delete_user'));
         $apply->on_success(array($self, 'edit_user_apply'));
         $apply->add_validator(array($self, 'validate_edit_user'));
     });
     parent::__construct();
 }