|
|
|
@ -1,33 +1,33 @@ |
|
|
|
|
<?php |
|
|
|
|
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ |
|
|
|
|
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Class for a group of elements used to input dates (and times). |
|
|
|
|
* |
|
|
|
|
* PHP versions 4 and 5 |
|
|
|
|
* |
|
|
|
|
* LICENSE: This source file is subject to version 3.01 of the PHP license |
|
|
|
|
* that is available through the world-wide-web at the following URI: |
|
|
|
|
* http://www.php.net/license/3_01.txt If you did not receive a copy of |
|
|
|
|
* the PHP License and are unable to obtain it through the web, please |
|
|
|
|
* send a note to license@php.net so we can mail you a copy immediately. |
|
|
|
|
* |
|
|
|
|
* @category HTML |
|
|
|
|
* @package HTML_QuickForm |
|
|
|
|
* @author Alexey Borzov <avb@php.net> |
|
|
|
|
* @copyright 2001-2009 The PHP Group |
|
|
|
|
* @license http://www.php.net/license/3_01.txt PHP License 3.01 |
|
|
|
|
* @version CVS: $Id: date.php,v 1.62 2009/04/04 21:34:02 avb Exp $ |
|
|
|
|
* @link http://pear.php.net/package/HTML_QuickForm |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Class for a group of form elements |
|
|
|
|
*/ |
|
|
|
|
/** |
|
|
|
|
* Class for a group of elements used to input dates (and times). |
|
|
|
|
* |
|
|
|
|
* PHP versions 4 and 5 |
|
|
|
|
* |
|
|
|
|
* LICENSE: This source file is subject to version 3.01 of the PHP license |
|
|
|
|
* that is available through the world-wide-web at the following URI: |
|
|
|
|
* http://www.php.net/license/3_01.txt If you did not receive a copy of |
|
|
|
|
* the PHP License and are unable to obtain it through the web, please |
|
|
|
|
* send a note to license@php.net so we can mail you a copy immediately. |
|
|
|
|
* |
|
|
|
|
* @category HTML |
|
|
|
|
* @package HTML_QuickForm |
|
|
|
|
* @author Alexey Borzov <avb@php.net> |
|
|
|
|
* @copyright 2001-2009 The PHP Group |
|
|
|
|
* @license http://www.php.net/license/3_01.txt PHP License 3.01 |
|
|
|
|
* @version CVS: $Id: date.php,v 1.62 2009/04/04 21:34:02 avb Exp $ |
|
|
|
|
* @link http://pear.php.net/package/HTML_QuickForm |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Class for a group of form elements |
|
|
|
|
*/ |
|
|
|
|
require_once 'HTML/QuickForm/group.php'; |
|
|
|
|
/** |
|
|
|
|
* Class for <select></select> elements |
|
|
|
|
*/ |
|
|
|
|
/** |
|
|
|
|
* Class for <select></select> elements |
|
|
|
|
*/ |
|
|
|
|
require_once 'HTML/QuickForm/select.php'; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -36,11 +36,11 @@ require_once 'HTML/QuickForm/select.php'; |
|
|
|
|
* Inspired by original 'date' element but reimplemented as a subclass |
|
|
|
|
* of HTML_QuickForm_group |
|
|
|
|
* |
|
|
|
|
* @category HTML |
|
|
|
|
* @package HTML_QuickForm |
|
|
|
|
* @author Alexey Borzov <avb@php.net> |
|
|
|
|
* @version Release: 3.2.11 |
|
|
|
|
* @since 3.1 |
|
|
|
|
* @category HTML |
|
|
|
|
* @package HTML_QuickForm |
|
|
|
|
* @author Alexey Borzov <avb@php.net> |
|
|
|
|
* @version Release: 3.2.11 |
|
|
|
|
* @since 3.1 |
|
|
|
|
*/ |
|
|
|
|
class HTML_QuickForm_date extends HTML_QuickForm_group |
|
|
|
|
{ |
|
|
|
@ -80,19 +80,19 @@ class HTML_QuickForm_date extends HTML_QuickForm_group |
|
|
|
|
* @var array |
|
|
|
|
*/ |
|
|
|
|
var $_locale = array( |
|
|
|
|
'en' => array ( |
|
|
|
|
'en' => array ( |
|
|
|
|
'weekdays_short'=> array ('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'), |
|
|
|
|
'weekdays_long' => array ('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'), |
|
|
|
|
'months_short' => array ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'), |
|
|
|
|
'months_long' => array ('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December') |
|
|
|
|
), |
|
|
|
|
'de' => array ( |
|
|
|
|
'de' => array ( |
|
|
|
|
'weekdays_short'=> array ('So', 'Mon', 'Di', 'Mi', 'Do', 'Fr', 'Sa'), |
|
|
|
|
'weekdays_long' => array ('Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag'), |
|
|
|
|
'months_short' => array ('Jan', 'Feb', 'März', 'April', 'Mai', 'Juni', 'Juli', 'Aug', 'Sept', 'Okt', 'Nov', 'Dez'), |
|
|
|
|
'months_long' => array ('Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember') |
|
|
|
|
), |
|
|
|
|
'fr' => array ( |
|
|
|
|
'fr' => array ( |
|
|
|
|
'weekdays_short'=> array ('Dim', 'Lun', 'Mar', 'Mer', 'Jeu', 'Ven', 'Sam'), |
|
|
|
|
'weekdays_long' => array ('Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi'), |
|
|
|
|
'months_short' => array ('Jan', 'Fév', 'Mar', 'Avr', 'Mai', 'Juin', 'Juil', 'Août', 'Sep', 'Oct', 'Nov', 'Déc'), |
|
|
|
@ -244,34 +244,34 @@ class HTML_QuickForm_date extends HTML_QuickForm_group |
|
|
|
|
/** |
|
|
|
|
* Class constructor |
|
|
|
|
* |
|
|
|
|
* The following keys may appear in $options array: |
|
|
|
|
* - 'language': date language |
|
|
|
|
* - 'format': Format of the date, based on PHP's date() function. |
|
|
|
|
* The following characters are currently recognised in format string: |
|
|
|
|
* <pre> |
|
|
|
|
* D => Short names of days |
|
|
|
|
* l => Long names of days |
|
|
|
|
* d => Day numbers |
|
|
|
|
* M => Short names of months |
|
|
|
|
* F => Long names of months |
|
|
|
|
* m => Month numbers |
|
|
|
|
* Y => Four digit year |
|
|
|
|
* y => Two digit year |
|
|
|
|
* h => 12 hour format |
|
|
|
|
* H => 23 hour format |
|
|
|
|
* i => Minutes |
|
|
|
|
* s => Seconds |
|
|
|
|
* a => am/pm |
|
|
|
|
* A => AM/PM |
|
|
|
|
* </pre> |
|
|
|
|
* - 'minYear': Minimum year in year select |
|
|
|
|
* - 'maxYear': Maximum year in year select |
|
|
|
|
* - 'addEmptyOption': Should an empty option be added to the top of |
|
|
|
|
* each select box? |
|
|
|
|
* - 'emptyOptionValue': The value passed by the empty option. |
|
|
|
|
* - 'emptyOptionText': The text displayed for the empty option. |
|
|
|
|
* - 'optionIncrement': Step to increase the option values by (works for 'i' and 's') |
|
|
|
|
* |
|
|
|
|
* The following keys may appear in $options array: |
|
|
|
|
* - 'language': date language |
|
|
|
|
* - 'format': Format of the date, based on PHP's date() function. |
|
|
|
|
* The following characters are currently recognised in format string: |
|
|
|
|
* <pre> |
|
|
|
|
* D => Short names of days |
|
|
|
|
* l => Long names of days |
|
|
|
|
* d => Day numbers |
|
|
|
|
* M => Short names of months |
|
|
|
|
* F => Long names of months |
|
|
|
|
* m => Month numbers |
|
|
|
|
* Y => Four digit year |
|
|
|
|
* y => Two digit year |
|
|
|
|
* h => 12 hour format |
|
|
|
|
* H => 23 hour format |
|
|
|
|
* i => Minutes |
|
|
|
|
* s => Seconds |
|
|
|
|
* a => am/pm |
|
|
|
|
* A => AM/PM |
|
|
|
|
* </pre> |
|
|
|
|
* - 'minYear': Minimum year in year select |
|
|
|
|
* - 'maxYear': Maximum year in year select |
|
|
|
|
* - 'addEmptyOption': Should an empty option be added to the top of |
|
|
|
|
* each select box? |
|
|
|
|
* - 'emptyOptionValue': The value passed by the empty option. |
|
|
|
|
* - 'emptyOptionText': The text displayed for the empty option. |
|
|
|
|
* - 'optionIncrement': Step to increase the option values by (works for 'i' and 's') |
|
|
|
|
* |
|
|
|
|
* @access public |
|
|
|
|
* @param string Element's name |
|
|
|
|
* @param mixed Label(s) for an element |
|
|
|
@ -305,9 +305,6 @@ class HTML_QuickForm_date extends HTML_QuickForm_group |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// }}} |
|
|
|
|
// {{{ _createElements() |
|
|
|
|
|
|
|
|
|
function _createElements() |
|
|
|
|
{ |
|
|
|
|
$this->_separator = $this->_elements = array(); |
|
|
|
@ -315,8 +312,6 @@ class HTML_QuickForm_date extends HTML_QuickForm_group |
|
|
|
|
$locale =& $this->_locale[$this->_options['language']]; |
|
|
|
|
$backslash = false; |
|
|
|
|
// Modified by Ivan Tcholakov, 16-MAR-2010. |
|
|
|
|
//for ($i = 0, $length = strlen($this->_options['format']); $i < $length; $i++) { |
|
|
|
|
// $sign = $this->_options['format']{$i}; |
|
|
|
|
for ($i = 0, $length = api_strlen($this->_options['format']); $i < $length; $i++) { |
|
|
|
|
$sign = api_substr($this->_options['format'], $i, 1); |
|
|
|
|
// |
|
|
|
@ -444,24 +439,24 @@ class HTML_QuickForm_date extends HTML_QuickForm_group |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// }}} |
|
|
|
|
// {{{ _trimLeadingZeros() |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Trims leading zeros from the (numeric) string |
|
|
|
|
* |
|
|
|
|
* @param string A numeric string, possibly with leading zeros |
|
|
|
|
* @return string String with leading zeros removed |
|
|
|
|
*/ |
|
|
|
|
function _trimLeadingZeros($str) |
|
|
|
|
{ |
|
|
|
|
if (0 == strcmp($str, $this->_options['emptyOptionValue'])) { |
|
|
|
|
return $str; |
|
|
|
|
} |
|
|
|
|
$trimmed = ltrim($str, '0'); |
|
|
|
|
return strlen($trimmed)? $trimmed: '0'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// }}} |
|
|
|
|
// {{{ _trimLeadingZeros() |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* Trims leading zeros from the (numeric) string |
|
|
|
|
* |
|
|
|
|
* @param string A numeric string, possibly with leading zeros |
|
|
|
|
* @return string String with leading zeros removed |
|
|
|
|
*/ |
|
|
|
|
function _trimLeadingZeros($str) |
|
|
|
|
{ |
|
|
|
|
if (0 == strcmp($str, $this->_options['emptyOptionValue'])) { |
|
|
|
|
return $str; |
|
|
|
|
} |
|
|
|
|
$trimmed = ltrim($str, '0'); |
|
|
|
|
return strlen($trimmed)? $trimmed: '0'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// }}} |
|
|
|
|
// {{{ setValue() |
|
|
|
|
|
|
|
|
|
function setValue($value) |
|
|
|
@ -473,7 +468,7 @@ class HTML_QuickForm_date extends HTML_QuickForm_group |
|
|
|
|
$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)); |
|
|
|
|
$arr = explode('-', date('w-j-n-Y-g-G-i-s-a-A-W', (int)$value)); |
|
|
|
|
$value = array( |
|
|
|
|
'D' => $arr[0], |
|
|
|
|
'l' => $arr[0], |
|
|
|
@ -486,14 +481,14 @@ class HTML_QuickForm_date extends HTML_QuickForm_group |
|
|
|
|
'h' => $arr[4], |
|
|
|
|
'g' => $arr[4], |
|
|
|
|
'H' => $arr[5], |
|
|
|
|
'i' => $this->_trimLeadingZeros($arr[6]), |
|
|
|
|
's' => $this->_trimLeadingZeros($arr[7]), |
|
|
|
|
'i' => $this->_trimLeadingZeros($arr[6]), |
|
|
|
|
's' => $this->_trimLeadingZeros($arr[7]), |
|
|
|
|
'a' => $arr[8], |
|
|
|
|
'A' => $arr[9], |
|
|
|
|
'W' => $this->_trimLeadingZeros($arr[10]) |
|
|
|
|
'W' => $this->_trimLeadingZeros($arr[10]) |
|
|
|
|
); |
|
|
|
|
} else { |
|
|
|
|
$value = array_map(array($this, '_trimLeadingZeros'), $value); |
|
|
|
|
} else { |
|
|
|
|
$value = array_map(array($this, '_trimLeadingZeros'), $value); |
|
|
|
|
} |
|
|
|
|
parent::setValue($value); |
|
|
|
|
} |
|
|
|
@ -503,7 +498,7 @@ class HTML_QuickForm_date extends HTML_QuickForm_group |
|
|
|
|
|
|
|
|
|
function toHtml() |
|
|
|
|
{ |
|
|
|
|
include_once('HTML/QuickForm/Renderer/Default.php'); |
|
|
|
|
include_once 'HTML/QuickForm/Renderer/Default.php'; |
|
|
|
|
$renderer = new HTML_QuickForm_Renderer_Default(); |
|
|
|
|
$renderer->setElementTemplate('{element}'); |
|
|
|
|
parent::accept($renderer); |
|
|
|
@ -531,7 +526,4 @@ class HTML_QuickForm_date extends HTML_QuickForm_group |
|
|
|
|
return parent::onQuickFormEvent($event, $arg, $caller); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// }}} |
|
|
|
|
} |
|
|
|
|
?> |