📄 date.php
字号:
case 'Y': $options = $this->_createOptionList( $this->_options['minYear'], $this->_options['maxYear'], $this->_options['minYear'] > $this->_options['maxYear']? -1: 1 ); break; case 'y': $options = $this->_createOptionList( $this->_options['minYear'], $this->_options['maxYear'], $this->_options['minYear'] > $this->_options['maxYear']? -1: 1 ); array_walk($options, create_function('&$v,$k','$v = substr($v,-2);')); break; case 'h': $options = $this->_createOptionList(1, 12); break; case 'g': $options = $this->_createOptionList(1, 12); array_walk($options, create_function('&$v,$k', '$v = intval($v);')); break; case 'H': $options = $this->_createOptionList(0, 23); break; case 'i': $options = $this->_createOptionList(0, 59, $this->_options['optionIncrement']['i']); break; case 's': $options = $this->_createOptionList(0, 59, $this->_options['optionIncrement']['s']); break; case 'a': $options = array('am' => 'am', 'pm' => 'pm'); break; case 'A': $options = array('AM' => 'AM', 'PM' => 'PM'); break; case 'W': $options = $this->_createOptionList(1, 53); break; case '\\': $backslash = true; $loadSelect = false; break; default: $separator .= (' ' == $sign? ' ': $sign); $loadSelect = false; } if ($loadSelect) { if (0 < count($this->_elements)) { $this->_separator[] = $separator; } else { $this->_wrap[0] = $separator; } $separator = ''; // Should we add an empty option to the top of the select? if (!is_array($this->_options['addEmptyOption']) && $this->_options['addEmptyOption'] || is_array($this->_options['addEmptyOption']) && !empty($this->_options['addEmptyOption'][$sign])) { // Using '+' array operator to preserve the keys if (is_array($this->_options['emptyOptionText']) && !empty($this->_options['emptyOptionText'][$sign])) { $options = array($this->_options['emptyOptionValue'] => $this->_options['emptyOptionText'][$sign]) + $options; } else { $options = array($this->_options['emptyOptionValue'] => $this->_options['emptyOptionText']) + $options; } } $this->_elements[] = new HTML_QuickForm_select($sign, null, $options, $this->getAttributes()); } } } $this->_wrap[1] = $separator . ($backslash? '\\': ''); } // }}} // {{{ _createOptionList() /** * Creates an option list containing the numbers from the start number to the end, inclusive * * @param int The start number * @param int The end number * @param int Increment by this value * @access private * @return array An array of numeric options. */ function _createOptionList($start, $end, $step = 1) { for ($i = $start, $options = array(); $start > $end? $i >= $end: $i <= $end; $i += $step) { $options[$i] = sprintf('%02d', $i); } return $options; } // }}} // {{{ setValue() function setValue($value) { $trimLeadingZeros = create_function('$a', '$b = ltrim($a, \'0\'); return strlen($b)? $b: \'0\';'); if (empty($value)) { $value = array(); } elseif (is_scalar($value)) { if (!is_numeric($value)) { $value = strtotime($value); } // might be a unix epoch, then we fill all possible values $arr = explode('-', date('w-j-n-Y-g-G-i-s-a-A-W', (int)$value)); $value = array( 'D' => $arr[0], 'l' => $arr[0], 'd' => $arr[1], 'M' => $arr[2], 'm' => $arr[2], 'F' => $arr[2], 'Y' => $arr[3], 'y' => $arr[3], 'h' => $arr[4], 'g' => $arr[4], 'H' => $arr[5], 'i' => $trimLeadingZeros($arr[6]), 's' => $trimLeadingZeros($arr[7]), 'a' => $arr[8], 'A' => $arr[9], 'W' => $trimLeadingZeros($arr[10]) ); } else { $value = array_map($trimLeadingZeros, $value); } parent::setValue($value); } // }}} // {{{ toHtml() function toHtml() { include_once('HTML/QuickForm/Renderer/Default.php'); $renderer = new HTML_QuickForm_Renderer_Default(); $renderer->setElementTemplate('{element}'); parent::accept($renderer); return $this->_wrap[0] . $renderer->toHtml() . $this->_wrap[1]; } // }}} // {{{ accept() function accept(&$renderer, $required = false, $error = null) { $renderer->renderElement($this, $required, $error); } // }}} // {{{ onQuickFormEvent() function onQuickFormEvent($event, $arg, &$caller) { if ('updateValue' == $event) { // we need to call setValue(), 'cause the default/constant value // may be in fact a timestamp, not an array return HTML_QuickForm_element::onQuickFormEvent($event, $arg, $caller); } else { return parent::onQuickFormEvent($event, $arg, $caller); } } // }}}}?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -