Overview

Packages

  • Nag
  • None

Classes

  • Horde_Core_Ui_VarRenderer_Nag
  • Nag
  • Nag_Ajax_Application
  • Nag_Api
  • Nag_Driver
  • Nag_Driver_Kolab
  • Nag_Driver_Sql
  • Nag_Exception
  • Nag_Factory_Tasklists
  • Nag_Form_CreateTaskList
  • Nag_Form_DeleteTaskList
  • Nag_Form_EditTaskList
  • Nag_Form_Renderer_Task
  • Nag_Form_Task
  • Nag_Form_Type_NagAlarm
  • Nag_Form_Type_NagDue
  • Nag_Form_Type_NagMethod
  • Nag_Form_Type_NagStart
  • Nag_Task
  • Nag_Tasklists_Base
  • Nag_Tasklists_Default
  • Nag_Tasklists_Kolab
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * This file contains all Horde_Core_Ui_VarRenderer extensions required for
  4:  * editing tasks.
  5:  *
  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.
  8:  *
  9:  * @package Nag
 10:  */
 11: 
 12: /**
 13:  * The Horde_Core_Ui_VarRenderer_Nag class provides additional methods for
 14:  * rendering Nag specific fields.
 15:  *
 16:  * @todo    Clean this hack up with Horde_Form/H4
 17:  * @author  Jan Schneider <jan@horde.org>
 18:  * @package Nag
 19:  */
 20: class Horde_Core_Ui_VarRenderer_Nag extends Horde_Core_Ui_VarRenderer_Html
 21: {
 22:     protected function _renderVarInput_NagMethod($form, $var, $vars)
 23:     {
 24:         $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
 25:         $varvalue = $var->getValue($vars);
 26:         $on = !empty($varvalue) &&
 27:             (!isset($varvalue['on']) || !empty($varvalue['on']));
 28: 
 29:         printf('<input id="%soff" type="radio" class="radio" name="%s[on]" value="0"%s %s/><label for="%soff">&nbsp;%s</label><br />',
 30:                $varname,
 31:                $varname,
 32:                $on ? '' : ' checked="checked"',
 33:                $this->_getActionScripts($form, $var),
 34:                $varname,
 35:                _("Use default notification method"));
 36:         printf('<input type="radio" class="radio" name="%s[on]" value="1"%s %s/><label for="%soff">&nbsp;%s</label>',
 37:                $varname,
 38:                $on ? ' checked="checked"' : '',
 39:                $this->_getActionScripts($form, $var),
 40:                $varname,
 41:                _("Use custom notification method"));
 42: 
 43:         if ($on) {
 44:             echo '<br />';
 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;
 50:             }
 51:             echo Horde_Core_Prefs_Ui_Widgets::alarm($params);
 52:         }
 53:     }
 54: 
 55:     protected function _renderVarInput_NagStart($form, $var, $vars)
 56:     {
 57:         $var->type->getInfo($vars, $var, $task_start);
 58:         $start_dt = ($task_start == 0)
 59:             // About a week from now
 60:             ? time() + 604800
 61:             : $task_start;
 62: 
 63:         $start_date = strftime('%x', $start_dt);
 64: 
 65:         /* Set up the radio buttons. */
 66:         $no_start_checked = ($task_start == 0) ? 'checked="checked" ' : '';
 67:         $specified_start_checked = ($task_start > 0) ? 'checked="checked" ' : '';
 68: ?>
 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")) ?>
 71: <br />
 72: 
 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) ?>">
 77: <?php
 78:         if ($GLOBALS['browser']->hasFeature('javascript')) {
 79:             Horde_Core_Ui_JsCalendar::init(array(
 80:                 'full_weekdays' => true
 81:             ));
 82:             Horde::addScriptFile('calendar.js', 'nag');
 83:             echo '<span id="start_wday"></span>' .
 84:                 Horde::img('calendar.png', _("Calendar"), 'id="startimg"');
 85:         }
 86:     }
 87: 
 88:     protected function _renderVarInput_NagDue($form, $var, $vars)
 89:     {
 90:         $var->type->getInfo($vars, $var, $task_due);
 91:         if ($task_due == 0) {
 92:             $date = '+' . (int)$GLOBALS['prefs']->getValue('default_due_days') . ' days';
 93:             $time = $GLOBALS['prefs']->getValue('default_due_time');
 94:             if ($time == 'now') {
 95:                 $time = '';
 96:             } else {
 97:                 $time = ' ' . $time;
 98:             }
 99:             $due_dt = strtotime($date . $time);
100: 
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);
105:             }
106:         } else {
107:             $due_dt = $task_due;
108:         }
109: 
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);
113: 
114:         /* Set up the radio buttons. */
115:         $none_checked = ($task_due == 0) ? 'checked="checked" ' : '';
116:         $specified_checked = ($task_due > 0) ? 'checked="checked" ' : '';
117: ?>
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.")) ?>
120: <br />
121: 
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) ?>">
126: 
127: <?php
128:         if ($GLOBALS['browser']->hasFeature('javascript')) {
129:             Horde_Core_Ui_JsCalendar::init(array(
130:                 'full_weekdays' => true
131:             ));
132:             Horde::addScriptFile('calendar.js', 'nag');
133:             echo '<span id="due_wday"></span>' .
134:                 Horde::img('calendar.png', _("Calendar"), 'id="dueimg"');
135:         }
136: ?>
137: 
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) ?>">
141: 
142: <?php
143:     }
144: 
145:     protected function _renderVarInput_NagAlarm($form, $var, $vars)
146:     {
147:         $varname = @htmlspecialchars($var->getVarName(), ENT_QUOTES, $this->_charset);
148:         $value = $var->getValue($vars);
149:         if (!is_array($value)) {
150:             if ($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);
157:                 } else {
158:                     $value = array('value' => $value, 'unit' => 1);
159:                 }
160:                 $value['on'] = true;
161:             }
162:         }
163:         $units = array(1 => _("Minute(s)"), 60 => _("Hour(s)"),
164:                        1440 => _("Day(s)"), 10080 => _("Week(s)"));
165:         $options = '';
166:         foreach ($units as $unit => $label) {
167:             $options .= '<option value="' . $unit;
168:             if ($value['on'] && $value['unit'] == $unit) {
169:                 $options .= '" selected="selected';
170:             }
171:             $options .= '">' . $label . '</option>';
172:         }
173: 
174:         return sprintf('<input id="%soff" type="radio" class="radio" name="%s[on]" value="0"%s /><label for="%soff">&nbsp;%s</label><br />',
175:                        $varname,
176:                        $varname,
177:                        $value['on'] ? '' : ' checked="checked"',
178:                        $varname,
179:                        _("None"))
180:             . sprintf('<input id="%son" type="radio" class="radio" name="%s[on]" value="1"%s />',
181:                       $varname,
182:                       $varname,
183:                       $value['on'] ? ' checked="checked"' : '')
184:             . sprintf('<input type="text" size="2" name="%s[value]" id="%s_value" value="%s" />',
185:                       $varname,
186:                       $varname,
187:                       $value['on'] ? htmlspecialchars($value['value']) : 15)
188:             . sprintf(' <select name="%s[unit]" id="%s_unit">%s</select>',
189:                       $varname,
190:                       $varname,
191:                       $options);
192:     }
193: }
194: 
API documentation generated by ApiGen