X-Git-Url: https://git.llucax.com/mecon/meconlib.git/blobdiff_plain/aab66e2f0b826254876b271267fd1081c5a989c2..1f832da2160a81b79a66d97871b8ef61fecc0d7e:/HTML/php/QuickForm/mdate.php diff --git a/HTML/php/QuickForm/mdate.php b/HTML/php/QuickForm/mdate.php index d169549..751830d 100644 --- a/HTML/php/QuickForm/mdate.php +++ b/HTML/php/QuickForm/mdate.php @@ -28,6 +28,8 @@ require_once('HTML/QuickForm/date.php'); +require_once('Date.php'); +require_once('Validate.php'); /** * Class to dynamically create HTML Select elements from a date @@ -50,11 +52,14 @@ class HTML_QuickForm_mdate extends HTML_QuickForm_date */ function HTML_QuickForm_mdate($elementName=null, $elementLabel=null, $options=array(), $attributes=null) { - foreach ($this->_options as $opts) { - foreach ($opts as $opp) { - array_push($op,'--'); - } - } + $this->_options = array ('es' => array ( + 'weekdays_short'=> array ('--' => '--', 'Dom', 'Lun', 'Mar', 'Mié', 'Jue', 'Vie', 'Sáb'), + 'weekdays_long' => array ('--' => '--', 'Domingo', 'Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado'), + 'months_short' => array ('--' => '--', 'Ene', 'Feb', 'Mar', 'Abr', 'May', 'Jun', 'Jul', 'Ago', 'Sep', 'Oct', 'Nov', 'Dic'), + 'months_long' => array ('--' => '--', 'Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septimbre', 'Octubre', 'Noviembre', 'Diciembre') + ) + ); + parent::HTML_QuickForm_date($elementName, $elementLabel, $options, $attributes); } //end constructor @@ -73,11 +78,47 @@ class HTML_QuickForm_mdate extends HTML_QuickForm_date function _createNumericOptionList($start, $end) { $options = array(); + //TODO + //Verificar que esto este funcionando bien. + $options['--'] = '--'; + //Hasta aca for ($i = $start; $i <= $end; $i++) { $options[$i] = sprintf('%02d', $i); } - array_push($options,'--'); + return $options; } // end func _createNumericOptionList + + /** + * Devuelve un objeto date + * + * + * @access public + * @return object Date. + */ + function &getValue() + { + if ($this->_selectedDate['Y'] != 00) { + return new Date (sprintf("%04d-%02d-%02d 00:00:00",$this->_selectedDate['Y'],$this->_selectedDate['F'],$this->_selectedDate['d'])); + } + else { + return null; + } + } // end func getValue + + /** + * Verifica que una fecha sea valida. + * + * Verifica que una fecha sea valida. El formato siempre debe ser + * '%Y-%m-%d' + * + * @access public + * @return bool + */ + function validate($fecha) + { + return Validate::date($fecha, array('format' => '%Y-%m-%d')) + } // end func validate +} ?>