Improve performance on preferences sections list (by skipping building the form)
Support dont_override feature for all calendar configuration options
This commit is contained in:
parent
70a71cdfa7
commit
d06d00172f
1 changed files with 93 additions and 20 deletions
|
@ -308,10 +308,19 @@ class calendar extends rcube_plugin
|
|||
*/
|
||||
function preferences_list($p)
|
||||
{
|
||||
if ($p['section'] == 'calendar') {
|
||||
$this->load_driver();
|
||||
if ($p['section'] != 'calendar') {
|
||||
return $p;
|
||||
}
|
||||
|
||||
$p['blocks']['view']['name'] = $this->gettext('mainoptions');
|
||||
$no_override = array_flip((array)$this->rc->config->get('dont_override'));
|
||||
|
||||
$p['blocks']['view']['name'] = $this->gettext('mainoptions');
|
||||
|
||||
if (!isset($no_override['calendar_default_view'])) {
|
||||
if (!$p['current']) {
|
||||
$p['blocks']['view']['content'] = true;
|
||||
return $p;
|
||||
}
|
||||
|
||||
$field_id = 'rcmfd_default_view';
|
||||
$select = new html_select(array('name' => '_default_view', 'id' => $field_id));
|
||||
|
@ -323,6 +332,13 @@ class calendar extends rcube_plugin
|
|||
'title' => html::label($field_id, Q($this->gettext('default_view'))),
|
||||
'content' => $select->show($this->rc->config->get('calendar_default_view', $this->defaults['calendar_default_view'])),
|
||||
);
|
||||
}
|
||||
|
||||
if (!isset($no_override['calendar_timeslots'])) {
|
||||
if (!$p['current']) {
|
||||
$p['blocks']['view']['content'] = true;
|
||||
return $p;
|
||||
}
|
||||
|
||||
$field_id = 'rcmfd_timeslot';
|
||||
$choices = array('1', '2', '3', '4', '6');
|
||||
|
@ -332,6 +348,13 @@ class calendar extends rcube_plugin
|
|||
'title' => html::label($field_id, Q($this->gettext('timeslots'))),
|
||||
'content' => $select->show($this->rc->config->get('calendar_timeslots', $this->defaults['calendar_timeslots'])),
|
||||
);
|
||||
}
|
||||
|
||||
if (!isset($no_override['calendar_first_day'])) {
|
||||
if (!$p['current']) {
|
||||
$p['blocks']['view']['content'] = true;
|
||||
return $p;
|
||||
}
|
||||
|
||||
$field_id = 'rcmfd_firstday';
|
||||
$select = new html_select(array('name' => '_first_day', 'id' => $field_id));
|
||||
|
@ -346,6 +369,13 @@ class calendar extends rcube_plugin
|
|||
'title' => html::label($field_id, Q($this->gettext('first_day'))),
|
||||
'content' => $select->show(strval($this->rc->config->get('calendar_first_day', $this->defaults['calendar_first_day']))),
|
||||
);
|
||||
}
|
||||
|
||||
if (!isset($no_override['calendar_first_hour'])) {
|
||||
if (!$p['current']) {
|
||||
$p['blocks']['view']['content'] = true;
|
||||
return $p;
|
||||
}
|
||||
|
||||
$time_format = $this->rc->config->get('time_format', libcalendaring::to_php_date_format($this->rc->config->get('calendar_time_format', $this->defaults['calendar_time_format'])));
|
||||
$select_hours = new html_select();
|
||||
|
@ -357,6 +387,13 @@ class calendar extends rcube_plugin
|
|||
'title' => html::label($field_id, Q($this->gettext('first_hour'))),
|
||||
'content' => $select_hours->show($this->rc->config->get('calendar_first_hour', $this->defaults['calendar_first_hour']), array('name' => '_first_hour', 'id' => $field_id)),
|
||||
);
|
||||
}
|
||||
|
||||
if (!isset($no_override['calendar_work_start'])) {
|
||||
if (!$p['current']) {
|
||||
$p['blocks']['view']['content'] = true;
|
||||
return $p;
|
||||
}
|
||||
|
||||
$field_id = 'rcmfd_workstart';
|
||||
$p['blocks']['view']['options']['workinghours'] = array(
|
||||
|
@ -364,6 +401,13 @@ class calendar extends rcube_plugin
|
|||
'content' => $select_hours->show($this->rc->config->get('calendar_work_start', $this->defaults['calendar_work_start']), array('name' => '_work_start', 'id' => $field_id)) .
|
||||
' — ' . $select_hours->show($this->rc->config->get('calendar_work_end', $this->defaults['calendar_work_end']), array('name' => '_work_end', 'id' => $field_id)),
|
||||
);
|
||||
}
|
||||
|
||||
if (!isset($no_override['calendar_event_coloring'])) {
|
||||
if (!$p['current']) {
|
||||
$p['blocks']['view']['content'] = true;
|
||||
return $p;
|
||||
}
|
||||
|
||||
$field_id = 'rcmfd_coloring';
|
||||
$select_colors = new html_select(array('name' => '_event_coloring', 'id' => $field_id));
|
||||
|
@ -376,6 +420,16 @@ class calendar extends rcube_plugin
|
|||
'title' => html::label($field_id . 'value', Q($this->gettext('eventcoloring'))),
|
||||
'content' => $select_colors->show($this->rc->config->get('calendar_event_coloring', $this->defaults['calendar_event_coloring'])),
|
||||
);
|
||||
}
|
||||
|
||||
// loading driver is expensive, don't do it if not needed
|
||||
$this->load_driver();
|
||||
|
||||
if (!isset($no_override['calendar_default_alarm_type'])) {
|
||||
if (!$p['current']) {
|
||||
$p['blocks']['view']['content'] = true;
|
||||
return $p;
|
||||
}
|
||||
|
||||
$field_id = 'rcmfd_alarm';
|
||||
$select_type = new html_select(array('name' => '_alarm_type', 'id' => $field_id));
|
||||
|
@ -383,21 +437,36 @@ class calendar extends rcube_plugin
|
|||
foreach ($this->driver->alarm_types as $type)
|
||||
$select_type->add(rcube_label(strtolower("alarm{$type}option"), 'libcalendaring'), $type);
|
||||
|
||||
$p['blocks']['view']['options']['alarmtype'] = array(
|
||||
'title' => html::label($field_id, Q($this->gettext('defaultalarmtype'))),
|
||||
'content' => $select_type->show($this->rc->config->get('calendar_default_alarm_type', '')),
|
||||
);
|
||||
}
|
||||
|
||||
if (!isset($no_override['calendar_default_alarm_offset'])) {
|
||||
if (!$p['current']) {
|
||||
$p['blocks']['view']['content'] = true;
|
||||
return $p;
|
||||
}
|
||||
|
||||
$field_id = 'rcmfd_alarm';
|
||||
$input_value = new html_inputfield(array('name' => '_alarm_value', 'id' => $field_id . 'value', 'size' => 3));
|
||||
$select_offset = new html_select(array('name' => '_alarm_offset', 'id' => $field_id . 'offset'));
|
||||
foreach (array('-M','-H','-D','+M','+H','+D') as $trigger)
|
||||
$select_offset->add(rcube_label('trigger' . $trigger, 'libcalendaring'), $trigger);
|
||||
|
||||
$p['blocks']['view']['options']['alarmtype'] = array(
|
||||
'title' => html::label($field_id, Q($this->gettext('defaultalarmtype'))),
|
||||
'content' => $select_type->show($this->rc->config->get('calendar_default_alarm_type', '')),
|
||||
);
|
||||
$preset = libcalendaring::parse_alaram_value($this->rc->config->get('calendar_default_alarm_offset', '-15M'));
|
||||
$p['blocks']['view']['options']['alarmoffset'] = array(
|
||||
'title' => html::label($field_id . 'value', Q($this->gettext('defaultalarmoffset'))),
|
||||
'content' => $input_value->show($preset[0]) . ' ' . $select_offset->show($preset[1]),
|
||||
);
|
||||
}
|
||||
|
||||
if (!isset($no_override['calendar_default_calendar'])) {
|
||||
if (!$p['current']) {
|
||||
$p['blocks']['view']['content'] = true;
|
||||
return $p;
|
||||
}
|
||||
// default calendar selection
|
||||
$field_id = 'rcmfd_default_calendar';
|
||||
$select_cal = new html_select(array('name' => '_default_calendar', 'id' => $field_id, 'is_escaped' => true));
|
||||
|
@ -410,12 +479,17 @@ class calendar extends rcube_plugin
|
|||
'title' => html::label($field_id . 'value', Q($this->gettext('defaultcalendar'))),
|
||||
'content' => $select_cal->show($this->rc->config->get('calendar_default_calendar', $default_calendar)),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// category definitions
|
||||
if (!$this->driver->nocategories) {
|
||||
// category definitions
|
||||
if (!$this->driver->nocategories && !isset($no_override['calendar_categories'])) {
|
||||
$p['blocks']['categories']['name'] = $this->gettext('categories');
|
||||
|
||||
if (!$p['current']) {
|
||||
$p['blocks']['categories']['content'] = true;
|
||||
return $p;
|
||||
}
|
||||
|
||||
$categories = (array) $this->driver->list_categories();
|
||||
$categories_list = '';
|
||||
foreach ($categories as $name => $color) {
|
||||
|
@ -464,7 +538,6 @@ class calendar extends rcube_plugin
|
|||
$this->include_stylesheet($this->local_skin_path() . '/jquery.miniColors.css');
|
||||
$this->rc->output->set_env('mscolors', $this->driver->get_color_values());
|
||||
$this->rc->output->add_script('$("input.colors").miniColors({ colorValues:rcmail.env.mscolors })', 'docready');
|
||||
}
|
||||
}
|
||||
|
||||
return $p;
|
||||
|
|
Loading…
Add table
Reference in a new issue