Author: Jason M. Felice (jason.m.felice@gmail.com)
Exemplo n.º 1
0
 /**
  * Construct a new Horde_Form_Renderer::.
  *
  * @param array $params  This is a hash of renderer-specific parameters.
  *                       Possible keys:
  *                       - 'varrenderer_driver': specifies the driver
  *                         parameter to Horde_Core_Ui_VarRenderer::factory().
  *                       - 'encode_title': @see $_encodeTitle
  */
 function Horde_Form_Renderer($params = array())
 {
     global $registry;
     if (isset($registry) && is_a($registry, 'Registry')) {
         /* Registry available, so use a pretty image. */
         $this->_requiredMarker = Horde::img('required.png', '*');
     } else {
         /* No registry available, use something plain. */
         $this->_requiredMarker = '*';
     }
     if (isset($params['encode_title'])) {
         $this->encodeTitle($params['encode_title']);
     }
     $driver = 'html';
     if (isset($params['varrenderer_driver'])) {
         $driver = $params['varrenderer_driver'];
     }
     $this->_varRenderer = Horde_Core_Ui_VarRenderer::factory($driver, $params);
 }
Exemplo n.º 2
0
 public function html($property)
 {
     global $prefs;
     $options = array();
     $attributes = '';
     $sel = false;
     $label = '';
     switch ($property) {
         case 'start[year]':
             return '<label for="' . $this->_formIDEncode($property) . '" class="hidden">' . _("Start Year") . '</label>' . '<input name="' . $property . '" value="' . $this->start->year . '" type="text"' . ' id="' . $this->_formIDEncode($property) . '" size="4" maxlength="4" />';
         case 'start[month]':
             $sel = $this->start->month;
             for ($i = 1; $i < 13; ++$i) {
                 $options[$i] = strftime('%b', mktime(1, 1, 1, $i, 1));
             }
             $label = _("Start Month");
             break;
         case 'start[day]':
             $sel = $this->start->mday;
             for ($i = 1; $i < 32; ++$i) {
                 $options[$i] = $i;
             }
             $label = _("Start Day");
             break;
         case 'start_hour':
             $sel = $this->start->format($prefs->getValue('twentyFour') ? 'G' : 'g');
             $hour_min = $prefs->getValue('twentyFour') ? 0 : 1;
             $hour_max = $prefs->getValue('twentyFour') ? 24 : 13;
             for ($i = $hour_min; $i < $hour_max; ++$i) {
                 $options[$i] = $i;
             }
             $label = _("Start Hour");
             break;
         case 'start_min':
             $sel = sprintf('%02d', $this->start->min);
             for ($i = 0; $i < 12; ++$i) {
                 $min = sprintf('%02d', $i * 5);
                 $options[$min] = $min;
             }
             $label = _("Start Minute");
             break;
         case 'end[year]':
             return '<label for="' . $this->_formIDEncode($property) . '" class="hidden">' . _("End Year") . '</label>' . '<input name="' . $property . '" value="' . $this->end->year . '" type="text"' . ' id="' . $this->_formIDEncode($property) . '" size="4" maxlength="4" />';
         case 'end[month]':
             $sel = $this->end ? $this->end->month : $this->start->month;
             for ($i = 1; $i < 13; ++$i) {
                 $options[$i] = strftime('%b', mktime(1, 1, 1, $i, 1));
             }
             $label = _("End Month");
             break;
         case 'end[day]':
             $sel = $this->end ? $this->end->mday : $this->start->mday;
             for ($i = 1; $i < 32; ++$i) {
                 $options[$i] = $i;
             }
             $label = _("End Day");
             break;
         case 'end_hour':
             $sel = $this->end ? $this->end->format($prefs->getValue('twentyFour') ? 'G' : 'g') : $this->start->format($prefs->getValue('twentyFour') ? 'G' : 'g') + 1;
             $hour_min = $prefs->getValue('twentyFour') ? 0 : 1;
             $hour_max = $prefs->getValue('twentyFour') ? 24 : 13;
             for ($i = $hour_min; $i < $hour_max; ++$i) {
                 $options[$i] = $i;
             }
             $label = _("End Hour");
             break;
         case 'end_min':
             $sel = $this->end ? $this->end->min : $this->start->min;
             $sel = sprintf('%02d', $sel);
             for ($i = 0; $i < 12; ++$i) {
                 $min = sprintf('%02d', $i * 5);
                 $options[$min] = $min;
             }
             $label = _("End Minute");
             break;
         case 'dur_day':
             $dur = $this->getDuration();
             return '<label for="' . $property . '" class="hidden">' . _("Duration Day") . '</label>' . '<input name="' . $property . '" value="' . $dur->day . '" type="text"' . ' id="' . $property . '" size="4" maxlength="4" />';
         case 'dur_hour':
             $dur = $this->getDuration();
             $sel = $dur->hour;
             for ($i = 0; $i < 24; ++$i) {
                 $options[$i] = $i;
             }
             $label = _("Duration Hour");
             break;
         case 'dur_min':
             $dur = $this->getDuration();
             $sel = $dur->min;
             for ($i = 0; $i < 13; ++$i) {
                 $min = sprintf('%02d', $i * 5);
                 $options[$min] = $min;
             }
             $label = _("Duration Minute");
             break;
         case 'recur_end[year]':
             if ($this->end) {
                 $end = $this->recurs() && $this->recurrence->hasRecurEnd() ? $this->recurrence->recurEnd->year : $this->end->year;
             } else {
                 $end = $this->start->year;
             }
             return '<label for="' . $this->_formIDEncode($property) . '" class="hidden">' . _("Recurrence End Year") . '</label>' . '<input name="' . $property . '" value="' . $end . '" type="text"' . ' id="' . $this->_formIDEncode($property) . '" size="4" maxlength="4" />';
         case 'recur_end[month]':
             if ($this->end) {
                 $sel = $this->recurs() && $this->recurrence->hasRecurEnd() ? $this->recurrence->recurEnd->month : $this->end->month;
             } else {
                 $sel = $this->start->month;
             }
             for ($i = 1; $i < 13; ++$i) {
                 $options[$i] = strftime('%b', mktime(1, 1, 1, $i, 1));
             }
             $label = _("Recurrence End Month");
             break;
         case 'recur_end[day]':
             if ($this->end) {
                 $sel = $this->recurs() && $this->recurrence->hasRecurEnd() ? $this->recurrence->recurEnd->mday : $this->end->mday;
             } else {
                 $sel = $this->start->mday;
             }
             for ($i = 1; $i < 32; ++$i) {
                 $options[$i] = $i;
             }
             $label = _("Recurrence End Day");
             break;
     }
     if (!$this->_varRenderer) {
         $this->_varRenderer = Horde_Core_Ui_VarRenderer::factory('Html');
     }
     return '<label for="' . $this->_formIDEncode($property) . '" class="hidden">' . $label . '</label>' . '<select name="' . $property . '"' . $attributes . ' id="' . $this->_formIDEncode($property) . '">' . $this->_varRenderer->selectOptions($options, $sel) . '</select>';
 }
Exemplo n.º 3
0
 /**
  * Constructs a new Turba_View_List object.
  *
  * @param Turba_List $list  List of contacts to display.
  * @param array $controls   Which icons to display
  * @param array $columns    The list of columns to display
  *
  * @return Turba_View_List
  */
 public function __construct($list, array $controls = null, array $columns = null)
 {
     if (is_null($controls)) {
         $controls = array('Mark' => true, 'Edit' => true, 'Vcard' => true, 'Group' => true, 'Sort' => true);
     }
     $this->columns = $columns;
     $this->list = $list;
     $this->setControls($controls);
     $this->renderer = Horde_Core_Ui_VarRenderer::factory(array('turba', 'turba'));
     $this->vars = new Horde_Variables();
 }