baser/views/helpers/form_ex.php
/**
 * Generates option lists for common <select /> menus
 *
 * @param string $name
 * @param array $options
 * @return array option lists
 * @access private
 */
Generates option lists for common  menus
@param string $name
@param array $options
@return array option lists
@access private
Generates option lists for common menus @param string $name @param array $options @return array option lists @access private
function __generateOptions($name, $options = array()) {
		if (!empty($this->options[$name])) {
			return $this->options[$name];
		}
		$data = array();
		switch ($name) {
			case 'minute':
				if (isset($options['interval'])) {
					$interval = $options['interval'];
				} else {
					$interval = 1;
				}
				$i = 0;
				while ($i < 60) {
					$data[$i] = sprintf('%02d', $i);
					$i += $interval;
				}
			break;
			case 'hour':
				for ($i = 1; $i <= 12; $i++) {
					$data[sprintf('%02d', $i)] = $i;
				}
			break;
			case 'hour24':
				for ($i = 0; $i <= 23; $i++) {
					$data[sprintf('%02d', $i)] = $i;
				}
			break;
			case 'meridian':
				$data = array('am' => 'am', 'pm' => 'pm');
			break;
			case 'day':
				$min = 1;
				$max = 31;
				if (isset($options['min'])) {
					$min = $options['min'];
				}
				if (isset($options['max'])) {
					$max = $options['max'];
				}
				for ($i = $min; $i <= $max; $i++) {
					$data[sprintf('%02d', $i)] = $i;
				}
			break;
			case 'month':
				if ($options['monthNames']) {
					$data['01'] = __('January', true);
					$data['02'] = __('February', true);
					$data['03'] = __('March', true);
					$data['04'] = __('April', true);
					$data['05'] = __('May', true);
					$data['06'] = __('June', true);
					$data['07'] = __('July', true);
					$data['08'] = __('August', true);
					$data['09'] = __('September', true);
					$data['10'] = __('October', true);
					$data['11'] = __('November', true);
					$data['12'] = __('December', true);
				} else {
					for ($m = 1; $m <= 12; $m++) {
						$data[sprintf("%02s", $m)] = strftime("%m", mktime(1, 1, 1, $m, 1, 1999));
					}
				}
			break;
			case 'year':
				$current = intval(date('Y'));
				if (!isset($options['min'])) {
					$min = $current - 20;
				} else {
					$min = $options['min'];
				}
				if (!isset($options['max'])) {
					$max = $current + 20;
				} else {
					$max = $options['max'];
				}
				if ($min > $max) {
					list($min, $max) = array($max, $min);
				}
				for ($i = $min; $i <= $max; $i++) {
					$data[$i] = $i;
				}
				$data = array_reverse($data, true);
			break;
			case 'wyear':
				$current = intval(date('Y'));
				if (!isset($options['min'])) {
					$min = $current - 20;
				} else {
					$min = $options['min'];
				}
				if (!isset($options['max'])) {
					$max = $current + 20;
				} else {
					$max = $options['max'];
				}
				if ($min > $max) {
					list($min, $max) = array($max, $min);
				}
				for ($i = $min; $i <= $max; $i++) {
					$wyears = $this->BcTime->convertToWarekiYear($i);
					if($wyears) {
						foreach($wyears as $value) {
							list($w,$year) = split('-', $value);
							$data[$value] = $this->BcTime->nengo($w).' '.$year;
						}
					}
				}
				$data = array_reverse($data, true);
				break;
		}
		$this->__options[$name] = $data;
		return $this->__options[$name];
	}
function __generateOptions ( $ name , $ options = array ( ) ) { if ( ! empty ( $ this -> options [ $ name ] ) ) { return $ this -> options [ $ name ] ; } $ data = array ( ) ; switch ( $ name ) { case 'minute' : if ( isset ( $ options [ 'interval' ] ) ) { $ interval = $ options [ 'interval' ] ; } else { $ interval = 1 ; } $ i = 0 ; while ( $ i < 60 ) { $ data [ $ i ] = sprintf ( '%02d' , $ i ) ; $ i += $ interval ; } break ; case 'hour' : for ( $ i = 1 ; $ i <= 12 ; $ i ++ ) { $ data [ sprintf ( '%02d' , $ i ) ] = $ i ; } break ; case 'hour24' : for ( $ i = 0 ; $ i <= 23 ; $ i ++ ) { $ data [ sprintf ( '%02d' , $ i ) ] = $ i ; } break ; case 'meridian' : $ data = array ( 'am' => 'am' , 'pm' => 'pm' ) ; break ; case 'day' : $ min = 1 ; $ max = 31 ; if ( isset ( $ options [ 'min' ] ) ) { $ min = $ options [ 'min' ] ; } if ( isset ( $ options [ 'max' ] ) ) { $ max = $ options [ 'max' ] ; } for ( $ i = $ min ; $ i <= $ max ; $ i ++ ) { $ data [ sprintf ( '%02d' , $ i ) ] = $ i ; } break ; case 'month' : if ( $ options [ 'monthNames' ] ) { $ data [ '01' ] = __ ( 'January' , true ) ; $ data [ '02' ] = __ ( 'February' , true ) ; $ data [ '03' ] = __ ( 'March' , true ) ; $ data [ '04' ] = __ ( 'April' , true ) ; $ data [ '05' ] = __ ( 'May' , true ) ; $ data [ '06' ] = __ ( 'June' , true ) ; $ data [ '07' ] = __ ( 'July' , true ) ; $ data [ '08' ] = __ ( 'August' , true ) ; $ data [ '09' ] = __ ( 'September' , true ) ; $ data [ '10' ] = __ ( 'October' , true ) ; $ data [ '11' ] = __ ( 'November' , true ) ; $ data [ '12' ] = __ ( 'December' , true ) ; } else { for ( $ m = 1 ; $ m <= 12 ; $ m ++ ) { $ data [ sprintf ( " %02s " , $ m ) ] = strftime ( " %m " , mktime ( 1 , 1 , 1 , $ m , 1 , 1999 ) ) ; } } break ; case 'year' : $ current = intval ( date ( 'Y' ) ) ; if ( ! isset ( $ options [ 'min' ] ) ) { $ min = $ current - 20 ; } else { $ min = $ options [ 'min' ] ; } if ( ! isset ( $ options [ 'max' ] ) ) { $ max = $ current + 20 ; } else { $ max = $ options [ 'max' ] ; } if ( $ min > $ max ) { list ( $ min , $ max ) = array ( $ max , $ min ) ; } for ( $ i = $ min ; $ i <= $ max ; $ i ++ ) { $ data [ $ i ] = $ i ; } $ data = array_reverse ( $ data , true ) ; break ; case 'wyear' : $ current = intval ( date ( 'Y' ) ) ; if ( ! isset ( $ options [ 'min' ] ) ) { $ min = $ current - 20 ; } else { $ min = $ options [ 'min' ] ; } if ( ! isset ( $ options [ 'max' ] ) ) { $ max = $ current + 20 ; } else { $ max = $ options [ 'max' ] ; } if ( $ min > $ max ) { list ( $ min , $ max ) = array ( $ max , $ min ) ; } for ( $ i = $ min ; $ i <= $ max ; $ i ++ ) { $ wyears = $ this -> BcTime -> convertToWarekiYear ( $ i ) ; if ( $ wyears ) { foreach ( $ wyears as $ value ) { list ( $ w , $ year ) = split ( '-' , $ value ) ; $ data [ $ value ] = $ this -> BcTime -> nengo ( $ w ) . ' ' . $ year ; } } } $ data = array_reverse ( $ data , true ) ; break ; } $ this -> __options [ $ name ] = $ data ; return $ this -> __options [ $ name ] ; }
Generates option lists for common <select /> menus
 @param string $name
 @param array $options
 @return array option lists
 @access private
Generates option lists for common <select / > menus @param string $name @param array $options @return array option lists @access private
// >>> CUSTOMIZE ADD 2011/01/11 ryuring	和暦対応 // <<<