3
* This file contains all Horde_Core_Ui_VarRenderer extensions required for
6
* See the enclosed file COPYING for license information (GPL). If you
7
* did not receive this file, see http://www.horde.org/licenses/gpl.
13
* The Horde_Core_Ui_VarRenderer_Nag class provides additional methods for
14
* rendering Nag specific fields.
16
* @todo Clean this hack up with Horde_Form/H4
17
* @author Jan Schneider <jan@horde.org>
20
class Horde_Core_Ui_VarRenderer_Nag extends Horde_Core_Ui_VarRenderer_Html
22
protected function _renderVarInput_NagMethod($form, $var, $vars)
24
$varname = htmlspecialchars($var->getVarName());
25
$varvalue = $var->getValue($vars);
26
$on = !empty($varvalue) &&
27
(!isset($varvalue['on']) || !empty($varvalue['on']));
29
printf('<input id="%soff" type="radio" class="radio" name="%s[on]" value="0"%s %s/><label for="%soff"> %s</label><br />',
32
$on ? '' : ' checked="checked"',
33
$this->_getActionScripts($form, $var),
35
_("Use default notification method"));
36
printf('<input type="radio" class="radio" name="%s[on]" value="1"%s %s/><label for="%soff"> %s</label>',
38
$on ? ' checked="checked"' : '',
39
$this->_getActionScripts($form, $var),
41
_("Use custom notification method"));
45
Horde_Core_Prefs_Ui_Widgets::alarmInit();
46
$params = array('pref' => 'task_alarms', 'label' => '');
47
if ((!empty($varvalue) && !isset($varvalue['on'])) ||
48
$form->isSubmitted()) {
49
$params['value'] = $varvalue;
51
echo Horde_Core_Prefs_Ui_Widgets::alarm($params);
55
protected function _renderVarInput_NagStart($form, $var, $vars)
57
$var->type->getInfo($vars, $var, $task_start);
58
$start_dt = ($task_start == 0)
59
// About a week from now
63
$start_date = strftime('%x', $start_dt);
65
/* Set up the radio buttons. */
66
$no_start_checked = ($task_start == 0) ? 'checked="checked" ' : '';
67
$specified_start_checked = ($task_start > 0) ? 'checked="checked" ' : '';
69
<input id="start_date_none" name="start_date" type="radio" class="radio" value="none" <?php echo $no_start_checked ?> />
70
<?php echo Horde::label('start_date_none', _("No delay")) ?>
73
<input id="start_date_specified" name="start_date" type="radio" class="radio" value="specified" <?php echo $specified_start_checked ?> />
74
<label for="start_date_specified" class="hidden"><?php echo _("Start date specified.") ?></label>
75
<label for="start_date" class="hidden"><?php echo _("Date") ?></label>
76
<input type="text" name="start[date]" id="start_date" size="10" value="<?php echo htmlspecialchars($start_date) ?>">
78
if ($GLOBALS['browser']->hasFeature('javascript')) {
79
Horde_Core_Ui_JsCalendar::init(array(
80
'full_weekdays' => true
82
$GLOBALS['page_output']->addScriptFile('calendar.js');
83
echo '<span id="start_wday"></span>' .
84
Horde::img('calendar.png', _("Calendar"), 'id="startimg"');
88
protected function _renderVarInput_NagDue($form, $var, $vars)
90
$var->type->getInfo($vars, $var, $task_due);
92
$date = '+' . (int)$GLOBALS['prefs']->getValue('default_due_days') . ' days';
93
$time = $GLOBALS['prefs']->getValue('default_due_time');
99
$due_dt = strtotime($date . $time);
101
// Default to having a due date for new tasks if the
102
// default_due preference is set.
103
if (!$vars->exists('task_id') && $GLOBALS['prefs']->getValue('default_due')) {
104
$task_due = strtotime($date . $time);
110
$due_date = strftime('%x', $due_dt);
111
$time_format = $GLOBALS['prefs']->getValue('twentyFour') ? 'H:i' : 'h:i a';
112
$due_time = date($time_format, $due_dt);
114
/* Set up the radio buttons. */
115
$none_checked = ($task_due == 0) ? 'checked="checked" ' : '';
116
$specified_checked = ($task_due > 0) ? 'checked="checked" ' : '';
118
<input id="due_type_none" name="due_type" type="radio" class="radio" value="none" <?php echo $none_checked ?> />
119
<?php echo Horde::label('due_type_none', _("No due date.")) ?>
122
<input id="due_type_specified" name="due_type" type="radio" class="radio" value="specified" <?php echo $specified_checked ?> />
123
<label for="due_type_specified" class="hidden"><?php echo _("Due date specified.") ?></label>
124
<label for="due_date" class="hidden"><?php echo _("Date") ?></label>
125
<input type="text" name="due[date]" id="due_date" size="10" value="<?php echo htmlspecialchars($due_date) ?>">
128
if ($GLOBALS['browser']->hasFeature('javascript')) {
129
Horde_Core_Ui_JsCalendar::init(array(
130
'full_weekdays' => true
132
$GLOBALS['page_output']->addScriptFile('calendar.js');
133
echo '<span id="due_wday"></span>' .
134
Horde::img('calendar.png', _("Calendar"), 'id="dueimg"');
138
<?php echo _("at") ?>
139
<label for="due_time" class="hidden"><?php echo _("Time") ?></label>
140
<input type="text" name="due[time]" id="due_time" size="8" value="<?php echo htmlspecialchars($due_time) ?>">
145
protected function _renderVarInput_NagAlarm($form, $var, $vars)
147
$varname = htmlspecialchars($var->getVarName());
148
$value = $var->getValue($vars);
149
if (!is_array($value)) {
151
if ($value % 10080 == 0) {
152
$value = array('value' => $value / 10080, 'unit' => 10080);
153
} elseif ($value % 1440 == 0) {
154
$value = array('value' => $value / 1440, 'unit' => 1440);
155
} elseif ($value % 60 == 0) {
156
$value = array('value' => $value / 60, 'unit' => 60);
158
$value = array('value' => $value, 'unit' => 1);
163
$units = array(1 => _("Minute(s)"), 60 => _("Hour(s)"),
164
1440 => _("Day(s)"), 10080 => _("Week(s)"));
166
foreach ($units as $unit => $label) {
167
$options .= '<option value="' . $unit;
168
if ($value && $value['on'] && $value['unit'] == $unit) {
169
$options .= '" selected="selected';
171
$options .= '">' . $label . '</option>';
174
return sprintf('<input id="%soff" type="radio" class="radio" name="%s[on]" value="0"%s /><label for="%soff"> %s</label><br />',
177
$value['on'] ? '' : ' checked="checked"',
180
. sprintf('<input id="%son" type="radio" class="radio" name="%s[on]" value="1"%s />',
183
$value['on'] ? ' checked="checked"' : '')
184
. sprintf('<input type="text" size="2" name="%s[value]" id="%s_value" value="%s" />',
187
$value['on'] ? htmlspecialchars($value['value']) : 15)
188
. sprintf(' <select name="%s[unit]" id="%s_unit">%s</select>',
197
protected function _renderVarInput_NagTags($form, $var, $vars)
199
$varname = htmlspecialchars($var->getVarName());
200
$value = $var->getValue($vars);
202
$html = sprintf('<input id="%s" type="text" name="%s" value="%s" />', $varname, $varname, $value);
203
$html .= sprintf('<span id="%s_loading_img" style="display:none;">%s</span>',
205
Horde::img('loading.gif', _("Loading...")));
207
$GLOBALS['injector']->getInstance('Horde_Core_Factory_Imple')->create('Nag_Ajax_Imple_TagAutoCompleter', array('id' => $varname));
212
* Render the search due date fields
214
public function _renderVarInput_NagSearchDue($form, $var, $vars)
217
_("%s %s days of %s"),
218
Horde::label('due_within', _("Is due within")),
219
'<input id="due_within" name="due_within" type="number" size="2" value="' . $vars->get('due_within') . '" />',
220
'<input id="due_of" name="due_of" type="text" value="' . $vars->get('due_of') . '" />')
221
. '<div class="horde-form-field-description">' . _("E.g., Is due within 2 days of today") . '</div>';