1 <?php /* vim: set binary expandtab tabstop=4 shiftwidth=4 textwidth=80:
2 -------------------------------------------------------------------------------
5 -------------------------------------------------------------------------------
6 This file is part of meconlib.
8 meconlib is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 2 of the License, or (at your option)
13 meconlib is distributed in the hope that it will be useful, but WITHOUT
14 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15 FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License; if not,
18 write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
19 Boston, MA 02111-1307 USA
20 -------------------------------------------------------------------------------
21 Creado: jue jun 5 17:59:44 ART 2003
22 Autor: Martin Marrese <mmarre@mecon.gov.ar>
23 -------------------------------------------------------------------------------
25 -----------------------------------------------------------------------------*/
27 require_once 'HTML/QuickForm/date.php';
28 require_once 'Date.php';
29 require_once 'Validate.php';
32 * Class to dynamically create HTML Select elements from a date
33 * Modificado para que cumpla con los requisitos de mecon
36 class HTML_QuickForm_mdate extends HTML_QuickForm_date
43 * @param string $elementName (optional)Input field name attribute
44 * @param string $value (optional)Input field value
45 * @param mixed $attributes (optional)Either a typical HTML attribute string
46 * or an associative array. Date format is passed along the attributes.
50 function HTML_QuickForm_mdate($elementName=null, $elementLabel=null, $options=array(), $attributes=null)
52 $this->_options = array ('es' => array (
53 'weekdays_short'=> array ('' => '--', 'Dom', 'Lun', 'Mar', 'Mié', 'Jue', 'Vie', 'Sáb'),
54 'weekdays_long' => array ('' => '--', 'Domingo', 'Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado'),
55 'months_short' => array ('' => '--', 'Ene', 'Feb', 'Mar', 'Abr', 'May', 'Jun', 'Jul', 'Ago', 'Sep', 'Oct', 'Nov', 'Dic'),
56 'months_long' => array ('' => '--', 'Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septimbre', 'Octubre', 'Noviembre', 'Diciembre')
60 parent::HTML_QuickForm_date($elementName, $elementLabel,
61 array_merge(array('language'=>'es','format'=>'d F Y'), $options),
66 // {{{ _createNumericOptionList()
69 * Creates a numeric option list based on a start number and end number
71 * @param int $start The start number
72 * @param int $end The end number
75 * @return array An array of numeric options.
77 function _createNumericOptionList($start, $end)
81 //Verificar que esto este funcionando bien.
84 for ($i = $start; $i <= $end; $i++) {
85 $options[$i] = sprintf('%02d', $i);
90 } // end func _createNumericOptionList
93 * Devuelve un objeto date
97 * @return object Date.
101 if ($this->_selectedDate['Y']) {
102 return new Date (sprintf("%04d-%02d-%02d 00:00:00",$this->_selectedDate['Y'],$this->_selectedDate['F'],$this->_selectedDate['d']));
107 } // end func getValue
110 * Verifica que una fecha sea valida.
112 * Verifica que una fecha sea valida. El formato siempre debe ser
118 function validate($valor, $nombre, $formato = '')
120 // Si viene completamente lleno, se valida con el paquete Validate.
121 if ($valor['Y'] and $valor['d'] and $valor['F']) {
122 $str = sprintf('%4d-%02d-%02d', $valor['Y'], $valor['F'], $valor['d']);
123 return Validate::date($str, array('format' => '%Y-%m-%d'));
124 // Si viene completamente vacio, es valido.
125 } elseif (!$valor['Y'] and !$valor['d'] and !$valor['F']) {
127 // Si viene a medio completar, es invalido.
131 } // end func validate