2 /* vim: set expandtab tabstop=4 shiftwidth=4: */
3 // +----------------------------------------------------------------------+
5 // +----------------------------------------------------------------------+
6 // | Copyright (c) 1997-2003 The PHP Group |
7 // +----------------------------------------------------------------------+
8 // | This source file is subject to version 2.0 of the PHP license, |
9 // | that is bundled with this package in the file LICENSE, and is |
10 // | available at through the world-wide-web at |
11 // | http://www.php.net/license/2_02.txt. |
12 // | If you did not receive a copy of the PHP license and are unable to |
13 // | obtain it through the world-wide-web, please send a note to |
14 // | license@php.net so we can mail you a copy immediately. |
15 // +----------------------------------------------------------------------+
16 // | Authors: Martin Marrese
17 // | Date: jue jun 5 17:59:44 ART 2003
18 // +----------------------------------------------------------------------+
30 require_once 'HTML/QuickForm/date.php';
31 require_once 'Date.php';
32 require_once 'Validate.php';
35 * Class to dynamically create HTML Select elements from a date
36 * Modificado para que cumpla con los requisitos de mecon
39 class HTML_QuickForm_mdate extends HTML_QuickForm_date
46 * @param string $elementName (optional)Input field name attribute
47 * @param string $value (optional)Input field value
48 * @param mixed $attributes (optional)Either a typical HTML attribute string
49 * or an associative array. Date format is passed along the attributes.
53 function HTML_QuickForm_mdate($elementName=null, $elementLabel=null, $options=array(), $attributes=null)
55 $this->_options = array ('es' => array (
56 'weekdays_short'=> array ('' => '--', 'Dom', 'Lun', 'Mar', 'Mié', 'Jue', 'Vie', 'Sáb'),
57 'weekdays_long' => array ('' => '--', 'Domingo', 'Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado'),
58 'months_short' => array ('' => '--', 'Ene', 'Feb', 'Mar', 'Abr', 'May', 'Jun', 'Jul', 'Ago', 'Sep', 'Oct', 'Nov', 'Dic'),
59 'months_long' => array ('' => '--', 'Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septimbre', 'Octubre', 'Noviembre', 'Diciembre')
63 parent::HTML_QuickForm_date($elementName, $elementLabel, $options, $attributes);
67 // {{{ _createNumericOptionList()
70 * Creates a numeric option list based on a start number and end number
72 * @param int $start The start number
73 * @param int $end The end number
76 * @return array An array of numeric options.
78 function _createNumericOptionList($start, $end)
82 //Verificar que esto este funcionando bien.
85 for ($i = $start; $i <= $end; $i++) {
86 $options[$i] = sprintf('%02d', $i);
91 } // end func _createNumericOptionList
94 * Devuelve un objeto date
98 * @return object Date.
102 if ($this->_selectedDate['Y'] != 00) {
103 return new Date (sprintf("%04d-%02d-%02d 00:00:00",$this->_selectedDate['Y'],$this->_selectedDate['F'],$this->_selectedDate['d']));
108 } // end func getValue
111 * Verifica que una fecha sea valida.
113 * Verifica que una fecha sea valida. El formato siempre debe ser
119 function validate($valor, $nombre, $formato = '')
121 // Si viene completamente lleno, se valida con el paquete Validate.
122 if ($valor['Y'] and $valor['d'] and $valor['F']) {
123 $str = sprintf('%4d-%02d-%02d', $valor['Y'], $valor['F'], $valor['d']);
124 return Validate::date($str, array('format' => '%Y-%m-%d'));
125 // Si viene completamente vacio, es valido.
126 } elseif (!$valor['Y'] and !$valor['d'] and !$valor['F']) {
128 // Si viene a medio completar, es invalido.
132 } // end func validate