From: Chuck Hagenbuch Date: Sat, 21 Nov 2009 19:19:26 +0000 (-0500) Subject: Move file for new Ui package and PHP 5 updates X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=b82f98693c45a6a2f10d3fb61712eaadfdbd4c9a;p=horde.git Move file for new Ui package and PHP 5 updates --- diff --git a/nag/lib/UI/VarRenderer/nag.php b/nag/lib/UI/VarRenderer/nag.php deleted file mode 100644 index 71a94ab1a..000000000 --- a/nag/lib/UI/VarRenderer/nag.php +++ /dev/null @@ -1,406 +0,0 @@ - - * @package Nag - */ -class Horde_Ui_VarRenderer_nag extends Horde_Ui_VarRenderer_html { - - protected function _renderVarInput_nag_method($form, &$var, &$vars) - { - $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset); - $varvalue = $var->getValue($vars); - if (isset($varvalue['on'])) { - // Submitted form. - $methods = array(); - $types = $vars->get('task_alarms'); - if (!empty($varvalue['on']) && !empty($types)) { - foreach ($types as $type) { - $methods[$type] = array(); - switch ($type){ - case 'notify': - $methods[$type]['sound'] = $vars->get('task_alarms_sound'); - break; - case 'mail': - $methods[$type]['email'] = $vars->get('task_alarms_email'); - break; - case 'popup': - break; - } - } - } - } else { - // Prefilled form. - $methods = $varvalue; - } - - printf('
', - $varname, - $varname, - !empty($methods) ? '' : ' checked="checked"', - $this->_getActionScripts($form, $var), - $varname, - _("Use default notification method")); - printf('', - $varname, - !empty($methods) ? ' checked="checked"' : '', - $this->_getActionScripts($form, $var), - $varname, - _("Use custom notification method")); - - if (!empty($methods)) { - echo '
'; - - global $registry, $prefs; - $pref = 'task_alarms'; - $_prefs = array($pref => array('desc' => '')); - $helplink = ''; - $original_value = $prefs->getValue($pref); - if (!empty($methods)) { - $prefs->setValue($pref, serialize($methods)); - } - include $GLOBALS['registry']->get('templates', 'horde') . '/prefs/alarm.inc'; - if (!empty($methods)) { - $prefs->setValue($pref, $original_value); - } - } - } - - protected function _renderVarInput_nag_start($form, &$var, &$vars) - { - $var->type->getInfo($vars, $var, $task_start); - if ($task_start == 0) { - $start_date = getdate(time() + 604800); // About a week from now - } else { - $start_date = getdate($task_start); - } - - $javascript_start = 'onchange="document.' . $form->getName() . '.start_date[1].checked = true;"'; - - /* Set up the radio buttons. */ - $no_start_checked = ($task_start == 0) ? 'checked="checked" ' : ''; - $specified_start_checked = ($task_start > 0) ? 'checked="checked" ' : ''; -?> - /> - -
- - /> - - - - -buildDayWidget('start[day]', $start_date['mday'], $javascript_start) . ' ' . $this->buildMonthWidget('start[month]', $start_date['mon'], $javascript_start) . ' ' . $this->buildYearWidget('start[year]', 3, $start_date['year'], $javascript_start) ?> -hasFeature('javascript')) { -Horde::addScriptFile('open_calendar.js', 'horde', array('direct' => false)); -echo ''; -echo Horde::link('#', _("Select a date"), '', '', 'openCalendar(\'startimg\', \'start\', \'document.' . $form->getName() . '.start_date[1].checked = true;\'); return false;') . Horde::img('calendar.png', _("Calendar"), 'align="top" id="startimg"', $GLOBALS['registry']->getImageDir('horde')) . ''; -} ?> -type->getInfo($vars, $var, $task_due); - if ($task_due == 0) { - $date = '+' . (int)$GLOBALS['prefs']->getValue('default_due_days') . ' days'; - $time = $GLOBALS['prefs']->getValue('default_due_time'); - if ($time == 'now') { - $time = ''; - } else { - $time = ' ' . $time; - } - $due_date = getdate(strtotime($date . $time)); - - // Default to having a due date for new tasks if the - // default_due preference is set. - if (!$vars->exists('task_id') && $GLOBALS['prefs']->getValue('default_due')) { - $task_due = strtotime($date . $time); - } - } else { - $due_date = getdate($task_due); - } - - $javascript_due = 'onchange="document.' . $form->getName() . '.due_type[1].checked = true;"'; - $hour_widget = $this->buildHourWidget('due_hour', $due_date['hours'], $javascript_due); - $minute_widget = $this->buildMinuteWidget('due_minute', 15, $due_date['minutes'], $javascript_due); - $am_pm_widget = $this->buildAmPmWidget('due_am_pm', $due_date['hours'], $javascript_due, $javascript_due); - - /* Set up the radio buttons. */ - $none_checked = ($task_due == 0) ? 'checked="checked" ' : ''; - $specified_checked = ($task_due > 0) ? 'checked="checked" ' : ''; -?> - /> - -
- - /> - - - - -buildDayWidget('due[day]', $due_date['mday'], $javascript_due) . ' ' . $this->buildMonthWidget('due[month]', $due_date['mon'], $javascript_due) . ' ' . $this->buildYearWidget('due[year]', 3, $due_date['year'], $javascript_due) ?> -hasFeature('javascript')) { -echo ''; -echo Horde::link('#', _("Select a date"), '', '', 'openCalendar(\'dueimg\', \'due\', \'document.' . $form->getName() . '.due_type[1].checked = true;\'); return false;') . Horde::img('calendar.png', _("Calendar"), 'align="top" id="dueimg"', $GLOBALS['registry']->getImageDir('horde')) . ''; -} ?> -
- - - - - -getVarName(), ENT_QUOTES, $this->_charset); - $value = $var->getValue($vars); - if (!is_array($value)) { - if ($value) { - if ($value % 10080 == 0) { - $value = array('value' => $value / 10080, 'unit' => 10080); - } elseif ($value % 1440 == 0) { - $value = array('value' => $value / 1440, 'unit' => 1440); - } elseif ($value % 60 == 0) { - $value = array('value' => $value / 60, 'unit' => 60); - } else { - $value = array('value' => $value, 'unit' => 1); - } - $value['on'] = true; - } - } - $units = array(1 => _("Minute(s)"), 60 => _("Hour(s)"), - 1440 => _("Day(s)"), 10080 => _("Week(s)")); - $options = ''; - foreach ($units as $unit => $label) { - $options .= ''; - } - - return sprintf('
', - $varname, - $varname, - $value['on'] ? '' : ' checked="checked"', - $varname, - _("None")) - . sprintf('', - $varname, - $value['on'] ? ' checked="checked"' : '') - . sprintf('', - $varname, - $varname, - $value['on'] ? htmlspecialchars($value['value']) : 15) - . sprintf(' ', - $varname, - $varname, - $options); - } - - /** - * Generates the HTML for a day selection widget. - * - * @param string $name The name of the widget. - * @param integer $default The value to select by default. Range: 1-31 - * @param string $params Any additional parameters to include in the - * widget. - */ - public function buildDayWidget($name, $default = null, $params = null) - { - $id = str_replace(array('[', ']'), array('_', ''), $name); - - $html = '\n"; - } - - /** - * Generates the HTML for a month selection widget. - * - * @param string $name The name of the widget. - * @param integer $default The value to select by default. - * @param string $params Any additional parameters to include in the - * widget. - */ - public function buildMonthWidget($name, $default = null, $params = null) - { - $id = str_replace(array('[', ']'), array('_', ''), $name); - - $html = '\n"; - } - - /** - * Generates the HTML for a year selection widget. - * - * @param integer $name The name of the widget. - * @param integer $years The number of years to include. - * If (+): future years - * If (-): past years - * @param string $default The timestamp to select by default. - * @param string $params Any additional parameters to include in the - * widget. - */ - public function buildYearWidget($name, $years, $default = null, $params = null) - { - $curr_year = date('Y'); - $yearlist = array(); - - $startyear = (!is_null($default) && ($default < $curr_year) && ($years > 0)) ? $default : $curr_year; - $startyear = min($startyear, $startyear + $years); - for ($i = 0; $i <= abs($years); $i++) { - $yearlist[] = $startyear++; - } - if ($years < 0) { - $yearlist = array_reverse($yearlist); - } - - $id = str_replace(array('[', ']'), array('_', ''), $name); - - $html = '\n"; - } - - /** - * Generates the HTML for an hour selection widget. - * - * @param string $name The name of the widget. - * @param integer $default The timestamp to select by default. - * @param string $params Any additional parameters to include in the - * widget. - */ - public function buildHourWidget($name, $default = null, $params = null) - { - global $prefs; - if (!$prefs->getValue('twentyFour')) { - $default = ($default + 24) % 12; - } - - $html = ''; - } - - public function buildAmPmWidget($name, $default = 'am', $amParams = null, $pmParams = null) - { - global $prefs; - if ($prefs->getValue('twentyFour')) { - return; - } - - if (is_numeric($default)) { - $default = date('a', mktime($default)); - } - if ($default == 'am') { - $am = ' checked="checked"'; - $pm = ''; - } else { - $am = ''; - $pm = ' checked="checked"'; - } - - $html = '  '; - $html .= ''; - - return $html; - } - - /** - * Generates the HTML for a minute selection widget. - * - * @param string $name The name of the widget. - * @param integer $increment The increment between minutes. - * @param integer $default The timestamp to select by default. - * @param string $params Any additional parameters to include in the - * widget. - */ - public function buildMinuteWidget($name, $increment = 1, $default = null, - $params = null) - { - $html = '\n"; - } - -} diff --git a/nag/lib/Ui/VarRenderer/Nag.php b/nag/lib/Ui/VarRenderer/Nag.php new file mode 100644 index 000000000..2a893c8ca --- /dev/null +++ b/nag/lib/Ui/VarRenderer/Nag.php @@ -0,0 +1,405 @@ + + * @package Nag + */ +class Horde_Ui_VarRenderer_Nag extends Horde_Ui_VarRenderer_Html +{ + protected function _renderVarInput_nag_method($form, $var, $vars) + { + $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset); + $varvalue = $var->getValue($vars); + if (isset($varvalue['on'])) { + // Submitted form. + $methods = array(); + $types = $vars->get('task_alarms'); + if (!empty($varvalue['on']) && !empty($types)) { + foreach ($types as $type) { + $methods[$type] = array(); + switch ($type){ + case 'notify': + $methods[$type]['sound'] = $vars->get('task_alarms_sound'); + break; + case 'mail': + $methods[$type]['email'] = $vars->get('task_alarms_email'); + break; + case 'popup': + break; + } + } + } + } else { + // Prefilled form. + $methods = $varvalue; + } + + printf('
', + $varname, + $varname, + !empty($methods) ? '' : ' checked="checked"', + $this->_getActionScripts($form, $var), + $varname, + _("Use default notification method")); + printf('', + $varname, + !empty($methods) ? ' checked="checked"' : '', + $this->_getActionScripts($form, $var), + $varname, + _("Use custom notification method")); + + if (!empty($methods)) { + echo '
'; + + global $registry, $prefs; + $pref = 'task_alarms'; + $_prefs = array($pref => array('desc' => '')); + $helplink = ''; + $original_value = $prefs->getValue($pref); + if (!empty($methods)) { + $prefs->setValue($pref, serialize($methods)); + } + include $GLOBALS['registry']->get('templates', 'horde') . '/prefs/alarm.inc'; + if (!empty($methods)) { + $prefs->setValue($pref, $original_value); + } + } + } + + protected function _renderVarInput_nag_start($form, $var, $vars) + { + $var->type->getInfo($vars, $var, $task_start); + if ($task_start == 0) { + $start_date = getdate(time() + 604800); // About a week from now + } else { + $start_date = getdate($task_start); + } + + $javascript_start = 'onchange="document.' . $form->getName() . '.start_date[1].checked = true;"'; + + /* Set up the radio buttons. */ + $no_start_checked = ($task_start == 0) ? 'checked="checked" ' : ''; + $specified_start_checked = ($task_start > 0) ? 'checked="checked" ' : ''; +?> + /> + +
+ + /> + + + + +buildDayWidget('start[day]', $start_date['mday'], $javascript_start) . ' ' . $this->buildMonthWidget('start[month]', $start_date['mon'], $javascript_start) . ' ' . $this->buildYearWidget('start[year]', 3, $start_date['year'], $javascript_start) ?> +hasFeature('javascript')) { +Horde::addScriptFile('open_calendar.js', 'horde', array('direct' => false)); +echo ''; +echo Horde::link('#', _("Select a date"), '', '', 'openCalendar(\'startimg\', \'start\', \'document.' . $form->getName() . '.start_date[1].checked = true;\'); return false;') . Horde::img('calendar.png', _("Calendar"), 'align="top" id="startimg"', $GLOBALS['registry']->getImageDir('horde')) . ''; +} ?> +type->getInfo($vars, $var, $task_due); + if ($task_due == 0) { + $date = '+' . (int)$GLOBALS['prefs']->getValue('default_due_days') . ' days'; + $time = $GLOBALS['prefs']->getValue('default_due_time'); + if ($time == 'now') { + $time = ''; + } else { + $time = ' ' . $time; + } + $due_date = getdate(strtotime($date . $time)); + + // Default to having a due date for new tasks if the + // default_due preference is set. + if (!$vars->exists('task_id') && $GLOBALS['prefs']->getValue('default_due')) { + $task_due = strtotime($date . $time); + } + } else { + $due_date = getdate($task_due); + } + + $javascript_due = 'onchange="document.' . $form->getName() . '.due_type[1].checked = true;"'; + $hour_widget = $this->buildHourWidget('due_hour', $due_date['hours'], $javascript_due); + $minute_widget = $this->buildMinuteWidget('due_minute', 15, $due_date['minutes'], $javascript_due); + $am_pm_widget = $this->buildAmPmWidget('due_am_pm', $due_date['hours'], $javascript_due, $javascript_due); + + /* Set up the radio buttons. */ + $none_checked = ($task_due == 0) ? 'checked="checked" ' : ''; + $specified_checked = ($task_due > 0) ? 'checked="checked" ' : ''; +?> + /> + +
+ + /> + + + + +buildDayWidget('due[day]', $due_date['mday'], $javascript_due) . ' ' . $this->buildMonthWidget('due[month]', $due_date['mon'], $javascript_due) . ' ' . $this->buildYearWidget('due[year]', 3, $due_date['year'], $javascript_due) ?> +hasFeature('javascript')) { +echo ''; +echo Horde::link('#', _("Select a date"), '', '', 'openCalendar(\'dueimg\', \'due\', \'document.' . $form->getName() . '.due_type[1].checked = true;\'); return false;') . Horde::img('calendar.png', _("Calendar"), 'align="top" id="dueimg"', $GLOBALS['registry']->getImageDir('horde')) . ''; +} ?> +
+ + + + + +getVarName(), ENT_QUOTES, $this->_charset); + $value = $var->getValue($vars); + if (!is_array($value)) { + if ($value) { + if ($value % 10080 == 0) { + $value = array('value' => $value / 10080, 'unit' => 10080); + } elseif ($value % 1440 == 0) { + $value = array('value' => $value / 1440, 'unit' => 1440); + } elseif ($value % 60 == 0) { + $value = array('value' => $value / 60, 'unit' => 60); + } else { + $value = array('value' => $value, 'unit' => 1); + } + $value['on'] = true; + } + } + $units = array(1 => _("Minute(s)"), 60 => _("Hour(s)"), + 1440 => _("Day(s)"), 10080 => _("Week(s)")); + $options = ''; + foreach ($units as $unit => $label) { + $options .= ''; + } + + return sprintf('
', + $varname, + $varname, + $value['on'] ? '' : ' checked="checked"', + $varname, + _("None")) + . sprintf('', + $varname, + $value['on'] ? ' checked="checked"' : '') + . sprintf('', + $varname, + $varname, + $value['on'] ? htmlspecialchars($value['value']) : 15) + . sprintf(' ', + $varname, + $varname, + $options); + } + + /** + * Generates the HTML for a day selection widget. + * + * @param string $name The name of the widget. + * @param integer $default The value to select by default. Range: 1-31 + * @param string $params Any additional parameters to include in the + * widget. + */ + public function buildDayWidget($name, $default = null, $params = null) + { + $id = str_replace(array('[', ']'), array('_', ''), $name); + + $html = '\n"; + } + + /** + * Generates the HTML for a month selection widget. + * + * @param string $name The name of the widget. + * @param integer $default The value to select by default. + * @param string $params Any additional parameters to include in the + * widget. + */ + public function buildMonthWidget($name, $default = null, $params = null) + { + $id = str_replace(array('[', ']'), array('_', ''), $name); + + $html = '\n"; + } + + /** + * Generates the HTML for a year selection widget. + * + * @param integer $name The name of the widget. + * @param integer $years The number of years to include. + * If (+): future years + * If (-): past years + * @param string $default The timestamp to select by default. + * @param string $params Any additional parameters to include in the + * widget. + */ + public function buildYearWidget($name, $years, $default = null, $params = null) + { + $curr_year = date('Y'); + $yearlist = array(); + + $startyear = (!is_null($default) && ($default < $curr_year) && ($years > 0)) ? $default : $curr_year; + $startyear = min($startyear, $startyear + $years); + for ($i = 0; $i <= abs($years); $i++) { + $yearlist[] = $startyear++; + } + if ($years < 0) { + $yearlist = array_reverse($yearlist); + } + + $id = str_replace(array('[', ']'), array('_', ''), $name); + + $html = '\n"; + } + + /** + * Generates the HTML for an hour selection widget. + * + * @param string $name The name of the widget. + * @param integer $default The timestamp to select by default. + * @param string $params Any additional parameters to include in the + * widget. + */ + public function buildHourWidget($name, $default = null, $params = null) + { + global $prefs; + if (!$prefs->getValue('twentyFour')) { + $default = ($default + 24) % 12; + } + + $html = ''; + } + + public function buildAmPmWidget($name, $default = 'am', $amParams = null, $pmParams = null) + { + global $prefs; + if ($prefs->getValue('twentyFour')) { + return; + } + + if (is_numeric($default)) { + $default = date('a', mktime($default)); + } + if ($default == 'am') { + $am = ' checked="checked"'; + $pm = ''; + } else { + $am = ''; + $pm = ' checked="checked"'; + } + + $html = '  '; + $html .= ''; + + return $html; + } + + /** + * Generates the HTML for a minute selection widget. + * + * @param string $name The name of the widget. + * @param integer $increment The increment between minutes. + * @param integer $default The timestamp to select by default. + * @param string $params Any additional parameters to include in the + * widget. + */ + public function buildMinuteWidget($name, $increment = 1, $default = null, + $params = null) + { + $html = '\n"; + } +}