コード例 #1
0
 /**
  * returns a dropdown with months. Starting with current month 
  * and then last month ... etc.  
  * @param string $name name of form element
  * @param int $selected the selected month
  * @return string $html the clean html select element
  */
 public static function monthOffsetDropdown($name = 'month', $start = null, $selected = null, $extra = array())
 {
     if (!$start) {
         $start = date::getCurrentYear() . '-' . date::getCurrentMonth();
     } else {
         $ary = explode('-', $start);
         $start = $ary[0] . '-' . $ary[1];
     }
     if (!$selected) {
         $selected = date::getCurrentYear() . '-' . date::getCurrentMonth();
     } else {
         $ary = explode('-', $selected);
         $selected = $ary[0] . '-' . $ary[1];
     }
     $months = self::last12Months($start);
     foreach ($months as $key => $val) {
         $months[$key] = array('id' => $val['year'] . '-' . $val['month'], 'value' => date::getMonthName($val['month']));
     }
     return html::selectClean($name, $months, 'value', 'id', $selected, $extra);
 }
コード例 #2
0
 /**
  * method that creates birthday dropdown
  * access of the submitted data can be found in the _POST['birth_day'],
  * $_POST['birth_month'], $_POST['birth_year']
  * @param string $name name of the form element
  * @param array $init the init array 
  * @return array $ary array with select elements in array ('day', 'month', 'year')
  */
 public static function birthdayDropdown($name = 'birth', $init = array())
 {
     for ($i = 1; $i <= 31; $i++) {
         $days[$i] = array('id' => $i, 'value' => $i);
     }
     for ($i = 1; $i <= 12; $i++) {
         $months[$i] = array('id' => $i, 'value' => dateGetMonthName($i));
     }
     $currentYear = date::getCurrentYear();
     $goBack = 120;
     //for ($i = $goBack; $goBack < $currentYear;  $currentYear-- ) {
     while ($goBack) {
         $years[$currentYear] = array('id' => $currentYear, 'value' => $currentYear);
         $currentYear--;
         $goBack--;
     }
     $day = html::selectClean('birth_day', $days, 'id', 'value');
     $month = html::selectClean('birth_month', $months, 'id', 'value');
     $year = html::selectClean('birth_year', $years, 'id', 'value');
     $ret = array('day' => $day, 'month' => $month, 'year' => $year, 'day_options' => $days, 'month_options' => $months, 'year_options' => $years);
     return $ret;
 }