Beispiel #1
0
 /**
  * Creates a group of dropdown boxes for date selection
  * 
  * @param	string		comma seperated list of parts to be included
  * @param	string		form element name prefix example: user_
  * @param	array		variables to be used within the function
  * @return	string		html for specified elements
  */
 public static function date_dropdown($parts = 'month,day,year,time', $prefix = '', $other = array(), $selected = array())
 {
     if (!is_array($parts)) {
         $parts = explode(',', $parts);
     }
     // Blank HTML string.
     $html = '';
     foreach ($parts as $part) {
         switch ($part) {
             case 'month':
                 if (!isset($selected['month'])) {
                     $selected['month'] = date('n');
                 }
                 $html .= form::dropdown($prefix . 'month', date::months(), $selected['month']);
                 break;
             case 'day':
                 if (!isset($selected['month'])) {
                     $selected['day'] = date('j');
                 }
                 $html .= form::dropdown($prefix . 'day', date::days(date('n')), $selected['day']);
                 break;
             case 'year':
                 if (!isset($selected['year'])) {
                     $selected['year'] = date('Y');
                 }
                 if (!isset($other['year']['start'])) {
                     $other['year']['start'] = false;
                 }
                 if (!isset($other['year']['end'])) {
                     $other['year']['end'] = false;
                 }
                 $html .= form::dropdown($prefix . 'year', date::years($other['year']['start'], $other['year']['end']), $selected['year']);
                 break;
             case 'time':
                 if (!isset($selected['hour'])) {
                     $selected['hour'] = date('g');
                 }
                 $html .= form::dropdown($prefix . 'hour', date::hours(), $selected['hour']);
                 if (!isset($selected['min'])) {
                     $selected['min'] = date('i');
                 }
                 $html .= form::dropdown($prefix . 'min', date::minutes(1), $selected['min']);
                 if (!isset($selected['ampm'])) {
                     $selected['ampm'] = date('a');
                 }
                 $html .= form::dropdown($prefix . 'ampm', array('am' => 'am', 'pm' => 'pm'), $selected['ampm']);
         }
     }
     return $html;
 }
Beispiel #2
0
     echo form::select($field, $values, $value, $attributes);
     break;
 case 'select':
     $values = @$fieldData['values'];
     if (!$values) {
         $values = array();
     }
     $values[-1] = "";
     asort($values);
     //$attributes['class'] .= ' block';
     echo form::select($field, $values, $value, $attributes);
     break;
 case 'date':
     $months[-1] = '';
     ### Generate list of years
     foreach (date::months() as $month) {
         $months[$month] = __('calendar.' . strtolower(date('F', mktime(0, 0, 0, $month, 1))));
     }
     $year = '';
     $month = '';
     $day = '';
     /* Deal with cases where we feed in a UNIX timestamp value instead - Steve does this a lot (feed DB rows directly in as_array) */
     if ($value && is_numeric($value)) {
         $year = date('Y', $value);
         $month = date('n', $value);
         $day = date('d', $value);
     } else {
         if ($value && $value != '0000-00-00') {
             $date = strtotime($value);
             $year = date('Y', $date);
             $month = date('n', $date);