320 |
jpm |
1 |
<?php
|
|
|
2 |
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
|
|
3 |
// +----------------------------------------------------------------------+
|
|
|
4 |
// | PHP Version 4 |
|
|
|
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: Alexey Borzov <avb@php.net> |
|
|
|
17 |
// | Adam Daniel <adaniel1@eesus.jnj.com> |
|
|
|
18 |
// | Bertrand Mansion <bmansion@mamasam.com> |
|
|
|
19 |
// +----------------------------------------------------------------------+
|
|
|
20 |
//
|
443 |
ddelon |
21 |
// $Id: date.php,v 1.2 2005-09-20 17:01:22 ddelon Exp $
|
320 |
jpm |
22 |
|
|
|
23 |
require_once 'HTML/QuickForm/group.php';
|
|
|
24 |
require_once 'HTML/QuickForm/select.php';
|
|
|
25 |
|
|
|
26 |
/**
|
|
|
27 |
* Class for a group of elements used to input dates (and times).
|
|
|
28 |
*
|
|
|
29 |
* Inspired by original 'date' element but reimplemented as a subclass
|
|
|
30 |
* of HTML_QuickForm_group
|
|
|
31 |
*
|
|
|
32 |
* @author Alexey Borzov <avb@php.net>
|
|
|
33 |
* @access public
|
|
|
34 |
*/
|
|
|
35 |
class HTML_QuickForm_date extends HTML_QuickForm_group
|
|
|
36 |
{
|
|
|
37 |
// {{{ properties
|
|
|
38 |
|
|
|
39 |
/**
|
|
|
40 |
* Various options to control the element's display.
|
|
|
41 |
*
|
|
|
42 |
* Currently known options are
|
|
|
43 |
* 'language': date language
|
|
|
44 |
* 'format': Format of the date, based on PHP's date() function.
|
|
|
45 |
* The following characters are recognised in format string:
|
|
|
46 |
* D => Short names of days
|
|
|
47 |
* l => Long names of days
|
|
|
48 |
* d => Day numbers
|
|
|
49 |
* M => Short names of months
|
|
|
50 |
* F => Long names of months
|
|
|
51 |
* m => Month numbers
|
|
|
52 |
* Y => Four digit year
|
|
|
53 |
* y => Two digit year
|
|
|
54 |
* h => 12 hour format
|
|
|
55 |
* H => 23 hour format
|
|
|
56 |
* i => Minutes
|
|
|
57 |
* s => Seconds
|
|
|
58 |
* a => am/pm
|
|
|
59 |
* A => AM/PM
|
|
|
60 |
* 'minYear': Minimum year in year select
|
|
|
61 |
* 'maxYear': Maximum year in year select
|
|
|
62 |
* 'addEmptyOption': Should an empty option be added to the top of
|
|
|
63 |
* each select box?
|
|
|
64 |
* 'emptyOptionValue': The value passed by the empty option.
|
|
|
65 |
* 'emptyOptionText': The text displayed for the empty option.
|
|
|
66 |
* 'optionIncrement': Step to increase the option values by (works for 'i' and 's')
|
|
|
67 |
*
|
|
|
68 |
* @access private
|
|
|
69 |
* @var array
|
|
|
70 |
*/
|
|
|
71 |
var $_options = array(
|
|
|
72 |
'language' => 'en',
|
|
|
73 |
'format' => 'dMY',
|
|
|
74 |
'minYear' => 2001,
|
|
|
75 |
'maxYear' => 2010,
|
|
|
76 |
'addEmptyOption' => false,
|
|
|
77 |
'emptyOptionValue' => '',
|
|
|
78 |
'emptyOptionText' => ' ',
|
|
|
79 |
'optionIncrement' => array('i' => 1, 's' => 1)
|
|
|
80 |
);
|
|
|
81 |
|
|
|
82 |
/**
|
|
|
83 |
* These complement separators, they are appended to the resultant HTML
|
|
|
84 |
* @access private
|
|
|
85 |
* @var array
|
|
|
86 |
*/
|
|
|
87 |
var $_wrap = array('', '');
|
|
|
88 |
|
|
|
89 |
/**
|
|
|
90 |
* Options in different languages
|
|
|
91 |
*
|
|
|
92 |
* Note to potential translators: to avoid encoding problems please send
|
|
|
93 |
* your translations with "weird" letters encoded as HTML Unicode entities
|
|
|
94 |
*
|
|
|
95 |
* @access private
|
|
|
96 |
* @var array
|
|
|
97 |
*/
|
|
|
98 |
var $_locale = array(
|
|
|
99 |
'en' => array (
|
|
|
100 |
'weekdays_short'=> array ('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'),
|
|
|
101 |
'weekdays_long' => array ('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'),
|
|
|
102 |
'months_short' => array ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'),
|
|
|
103 |
'months_long' => array ('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December')
|
|
|
104 |
),
|
|
|
105 |
'de' => array (
|
|
|
106 |
'weekdays_short'=> array ('So', 'Mon', 'Di', 'Mi', 'Do', 'Fr', 'Sa'),
|
|
|
107 |
'weekdays_long' => array ('Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag'),
|
|
|
108 |
'months_short' => array ('Jan', 'Feb', 'März', 'April', 'Mai', 'Juni', 'Juli', 'Aug', 'Sept', 'Okt', 'Nov', 'Dez'),
|
|
|
109 |
'months_long' => array ('Januar', 'Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember')
|
|
|
110 |
),
|
|
|
111 |
'fr' => array (
|
|
|
112 |
'weekdays_short'=> array ('Dim', 'Lun', 'Mar', 'Mer', 'Jeu', 'Ven', 'Sam'),
|
|
|
113 |
'weekdays_long' => array ('Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi'),
|
443 |
ddelon |
114 |
'months_short' => array ('Jan', 'Fév', 'Mar', 'Avr', 'Mai', 'Juin', 'Juil', 'Août', 'Sep', 'Oct', 'Nov', 'Déc'),
|
320 |
jpm |
115 |
'months_long' => array ('Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre')
|
|
|
116 |
),
|
|
|
117 |
'hu' => array (
|
|
|
118 |
'weekdays_short'=> array ('V', 'H', 'K', 'Sze', 'Cs', 'P', 'Szo'),
|
|
|
119 |
'weekdays_long' => array ('vasárnap', 'hétfő', 'kedd', 'szerda', 'csütörtök', 'péntek', 'szombat'),
|
|
|
120 |
'months_short' => array ('jan', 'feb', 'márc', 'ápr', 'máj', 'jún', 'júl', 'aug', 'szept', 'okt', 'nov', 'dec'),
|
|
|
121 |
'months_long' => array ('január', 'február', 'március', 'április', 'május', 'június', 'július', 'augusztus', 'szeptember', 'október', 'november', 'december')
|
|
|
122 |
),
|
|
|
123 |
'pl' => array (
|
|
|
124 |
'weekdays_short'=> array ('Nie', 'Pn', 'Wt', 'Śr', 'Czw', 'Pt', 'Sob'),
|
|
|
125 |
'weekdays_long' => array ('Niedziela', 'Poniedziałek', 'Wtorek', 'Środa', 'Czwartek', 'Piątek', 'Sobota'),
|
|
|
126 |
'months_short' => array ('Sty', 'Lut', 'Mar', 'Kwi', 'Maj', 'Cze', 'Lip', 'Sie', 'Wrz', 'Paź', 'Lis', 'Gru'),
|
|
|
127 |
'months_long' => array ('Styczeń', 'Luty', 'Marzec', 'Kwiecień', 'Maj', 'Czerwiec', 'Lipiec', 'Sierpień', 'Wrzesień', 'Październik', 'Listopad', 'Grudzień')
|
|
|
128 |
),
|
|
|
129 |
'sl' => array (
|
|
|
130 |
'weekdays_short'=> array ('Ned', 'Pon', 'Tor', 'Sre', 'Cet', 'Pet', 'Sob'),
|
|
|
131 |
'weekdays_long' => array ('Nedelja', 'Ponedeljek', 'Torek', 'Sreda', 'Cetrtek', 'Petek', 'Sobota'),
|
|
|
132 |
'months_short' => array ('Jan', 'Feb', 'Mar', 'Apr', 'Maj', 'Jun', 'Jul', 'Avg', 'Sep', 'Okt', 'Nov', 'Dec'),
|
|
|
133 |
'months_long' => array ('Januar', 'Februar', 'Marec', 'April', 'Maj', 'Junij', 'Julij', 'Avgust', 'September', 'Oktober', 'November', 'December')
|
|
|
134 |
),
|
|
|
135 |
'ru' => array (
|
|
|
136 |
'weekdays_short'=> array ('Вс', 'Пн', 'Вт', 'Ср', 'Чт', 'Пт', 'Сб'),
|
|
|
137 |
'weekdays_long' => array ('Воскресенье', 'Понедельник', 'Вторник', 'Среда', 'Четверг', 'Пятница', 'Суббота'),
|
|
|
138 |
'months_short' => array ('Янв', 'Фев', 'Мар', 'Апр', 'Май', 'Июн', 'Июл', 'Авг', 'Сен', 'Окт', 'Ноя', 'Дек'),
|
|
|
139 |
'months_long' => array ('Январь', 'Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь')
|
|
|
140 |
),
|
|
|
141 |
'es' => array (
|
|
|
142 |
'weekdays_short'=> array ('Dom', 'Lun', 'Mar', 'Mié', 'Jue', 'Vie', 'Sáb'),
|
|
|
143 |
'weekdays_long' => array ('Domingo', 'Lunes', 'Martes', 'Miércoles', 'Jueves', 'Viernes', 'Sábado'),
|
|
|
144 |
'months_short' => array ('Ene', 'Feb', 'Mar', 'Abr', 'May', 'Jun', 'Jul', 'Ago', 'Sep', 'Oct', 'Nov', 'Dic'),
|
443 |
ddelon |
145 |
'months_long' => array ('Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre')
|
320 |
jpm |
146 |
),
|
|
|
147 |
'da' => array (
|
|
|
148 |
'weekdays_short'=> array ('Søn', 'Man', 'Tir', 'Ons', 'Tor', 'Fre', 'Lør'),
|
|
|
149 |
'weekdays_long' => array ('Søndag', 'Mandag', 'Tirsdag', 'Onsdag', 'Torsdag', 'Fredag', 'Lørdag'),
|
|
|
150 |
'months_short' => array ('Jan', 'Feb', 'Mar', 'Apr', 'Maj', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dec'),
|
|
|
151 |
'months_long' => array ('Januar', 'Februar', 'Marts', 'April', 'Maj', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'December')
|
|
|
152 |
),
|
|
|
153 |
'is' => array (
|
|
|
154 |
'weekdays_short'=> array ('Sun', 'Mán', 'Þri', 'Mið', 'Fim', 'Fös', 'Lau'),
|
|
|
155 |
'weekdays_long' => array ('Sunnudagur', 'Mánudagur', 'Þriðjudagur', 'Miðvikudagur', 'Fimmtudagur', 'Föstudagur', 'Laugardagur'),
|
|
|
156 |
'months_short' => array ('Jan', 'Feb', 'Mar', 'Apr', 'Maí', 'Jún', 'Júl', 'Ágú', 'Sep', 'Okt', 'Nóv', 'Des'),
|
|
|
157 |
'months_long' => array ('Janúar', 'Febrúar', 'Mars', 'Apríl', 'Maí', 'Júní', 'Júlí', 'Ágúst', 'September', 'Október', 'Nóvember', 'Desember')
|
|
|
158 |
),
|
|
|
159 |
'it' => array (
|
|
|
160 |
'weekdays_short'=> array ('Dom', 'Lun', 'Mar', 'Mer', 'Gio', 'Ven', 'Sab'),
|
|
|
161 |
'weekdays_long' => array ('Domenica', 'Lunedì', 'Martedì', 'Mercoledì', 'Giovedì', 'Venerdì', 'Sabato'),
|
|
|
162 |
'months_short' => array ('Gen', 'Feb', 'Mar', 'Apr', 'Mag', 'Giu', 'Lug', 'Ago', 'Set', 'Ott', 'Nov', 'Dic'),
|
|
|
163 |
'months_long' => array ('Gennaio', 'Febbraio', 'Marzo', 'Aprile', 'Maggio', 'Giugno', 'Luglio', 'Agosto', 'Settembre', 'Ottobre', 'Novembre', 'Dicembre')
|
|
|
164 |
),
|
|
|
165 |
'sk' => array (
|
|
|
166 |
'weekdays_short'=> array ('Ned', 'Pon', 'Uto', 'Str', 'Štv', 'Pia', 'Sob'),
|
|
|
167 |
'weekdays_long' => array ('Nedeža', 'Pondelok', 'Utorok', 'Streda', 'Štvrtok', 'Piatok', 'Sobota'),
|
|
|
168 |
'months_short' => array ('Jan', 'Feb', 'Mar', 'Apr', 'Máj', 'Jún', 'Júl', 'Aug', 'Sep', 'Okt', 'Nov', 'Dec'),
|
|
|
169 |
'months_long' => array ('Január', 'Február', 'Marec', 'Apríl', 'Máj', 'Jún', 'Júl', 'August', 'September', 'Október', 'November', 'December')
|
|
|
170 |
),
|
|
|
171 |
'cs' => array (
|
|
|
172 |
'weekdays_short'=> array ('Ne', 'Po', 'Út', 'St', 'Čt', 'Pá', 'So'),
|
|
|
173 |
'weekdays_long' => array ('Neděle', 'Pondělí', 'Úterý', 'Středa', 'Čtvrtek', 'Pátek', 'Sobota'),
|
|
|
174 |
'months_short' => array ('Led', 'Úno', 'Bře', 'Dub', 'Kvě', 'Čen', 'Čec', 'Srp', 'Zář', 'Říj', 'Lis', 'Pro'),
|
|
|
175 |
'months_long' => array ('Leden', 'Únor', 'Březen', 'Duben', 'Květen', 'Červen', 'Červenec', 'Srpen', 'Září', 'Říjen', 'Listopad', 'Prosinec')
|
|
|
176 |
),
|
|
|
177 |
'hy' => array (
|
|
|
178 |
'weekdays_short'=> array ('Կրկ', 'Երկ', 'Երք', 'Չրք', 'Հնգ', 'Ուր', 'Շբթ'),
|
|
|
179 |
'weekdays_long' => array ('Կիրակի', 'Երկուշաբթի', 'Երեքշաբթի', 'Չորեքշաբթի', 'Հինգշաբթի', 'Ուրբաթ', 'Շաբաթ'),
|
|
|
180 |
'months_short' => array ('Հնվ', 'Փտր', 'Մրտ', 'Ապր', 'Մյս', 'Հնս', 'Հլս', 'Օգս', 'Սպտ', 'Հկտ', 'Նյմ', 'Դկտ'),
|
|
|
181 |
'months_long' => array ('Հունվար', 'Փետրվար', 'Մարտ', 'Ապրիլ', 'Մայիս', 'Հունիս', 'Հուլիս', 'Օգոստոս', 'Սեպտեմբեր', 'Հոկտեմբեր', 'Նոյեմբեր', 'Դեկտեմբեր')
|
|
|
182 |
),
|
|
|
183 |
'nl' => array (
|
|
|
184 |
'weekdays_short'=> array ('Zo', 'Ma', 'Di', 'Wo', 'Do', 'Vr', 'Za'),
|
|
|
185 |
'weekdays_long' => array ('Zondag', 'Maandag', 'Dinsdag', 'Woensdag', 'Donderdag', 'Vrijdag', 'Zaterdag'),
|
|
|
186 |
'months_short' => array ('Jan', 'Feb', 'Mar', 'Apr', 'Mei', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dec'),
|
|
|
187 |
'months_long' => array ('Januari', 'Februari', 'Maart', 'April', 'Mei', 'Juni', 'Juli', 'Augustus', 'September', 'Oktober', 'November', 'December')
|
|
|
188 |
),
|
|
|
189 |
'et' => array (
|
|
|
190 |
'weekdays_short'=> array ('P', 'E', 'T', 'K', 'N', 'R', 'L'),
|
|
|
191 |
'weekdays_long' => array ('Pühapäev', 'Esmaspäev', 'Teisipäev', 'Kolmapäev', 'Neljapäev', 'Reede', 'Laupäev'),
|
|
|
192 |
'months_short' => array ('Jaan', 'Veebr', 'Märts', 'Aprill', 'Mai', 'Juuni', 'Juuli', 'Aug', 'Sept', 'Okt', 'Nov', 'Dets'),
|
|
|
193 |
'months_long' => array ('Jaanuar', 'Veebruar', 'Märts', 'Aprill', 'Mai', 'Juuni', 'Juuli', 'August', 'September', 'Oktoober', 'November', 'Detsember')
|
|
|
194 |
),
|
|
|
195 |
'tr' => array (
|
|
|
196 |
'weekdays_short'=> array ('Paz', 'Pzt', 'Sal', 'Çar', 'Per', 'Cum', 'Cts'),
|
|
|
197 |
'weekdays_long' => array ('Pazar', 'Pazartesi', 'Salı', 'Çarşamba', 'Perşembe', 'Cuma', 'Cumartesi'),
|
|
|
198 |
'months_short' => array ('Ock', 'Şbt', 'Mrt', 'Nsn', 'Mys', 'Hzrn', 'Tmmz', 'Ağst', 'Eyl', 'Ekm', 'Ksm', 'Arlk'),
|
|
|
199 |
'months_long' => array ('Ocak', 'Şubat', 'Mart', 'Nisan', 'Mayıs', 'Haziran', 'Temmuz', 'Ağustos', 'Eylül', 'Ekim', 'Kasım', 'Aralık')
|
|
|
200 |
),
|
|
|
201 |
'no' => array (
|
|
|
202 |
'weekdays_short'=> array ('Søn', 'Man', 'Tir', 'Ons', 'Tor', 'Fre', 'Lør'),
|
|
|
203 |
'weekdays_long' => array ('Søndag', 'Mandag', 'Tirsdag', 'Onsdag', 'Torsdag', 'Fredag', 'Lørdag'),
|
|
|
204 |
'months_short' => array ('Jan', 'Feb', 'Mar', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Des'),
|
|
|
205 |
'months_long' => array ('Januar', 'Februar', 'Mars', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Desember')
|
|
|
206 |
),
|
|
|
207 |
'eo' => array (
|
|
|
208 |
'weekdays_short'=> array ('Dim', 'Lun', 'Mar', 'Mer', 'Ĵaŭ', 'Ven', 'Sab'),
|
|
|
209 |
'weekdays_long' => array ('Dimanĉo', 'Lundo', 'Mardo', 'Merkredo', 'Ĵaŭdo', 'Vendredo', 'Sabato'),
|
|
|
210 |
'months_short' => array ('Jan', 'Feb', 'Mar', 'Apr', 'Maj', 'Jun', 'Jul', 'Aŭg', 'Sep', 'Okt', 'Nov', 'Dec'),
|
|
|
211 |
'months_long' => array ('Januaro', 'Februaro', 'Marto', 'Aprilo', 'Majo', 'Junio', 'Julio', 'Aŭgusto', 'Septembro', 'Oktobro', 'Novembro', 'Decembro')
|
|
|
212 |
),
|
|
|
213 |
'ua' => array (
|
|
|
214 |
'weekdays_short'=> array('Ндл', 'Пнд', 'Втр', 'Срд', 'Чтв', 'Птн', 'Сбт'),
|
|
|
215 |
'weekdays_long' => array('Неділя', 'Понеділок', 'Вівторок', 'Середа', 'Четвер', 'П\'ятниця', 'Субота'),
|
|
|
216 |
'months_short' => array('Січ', 'Лют', 'Бер', 'Кві', 'Тра', 'Чер', 'Лип', 'Сер', 'Вер', 'Жов', 'Лис', 'Гру'),
|
|
|
217 |
'months_long' => array('Січень', 'Лютий', 'Березень', 'Квітень', 'Травень', 'Червень', 'Липень', 'Серпень', 'Вересень', 'Жовтень', 'Листопад', 'Грудень')
|
443 |
ddelon |
218 |
),
|
|
|
219 |
'ro' => array (
|
|
|
220 |
'weekdays_short'=> array ('Dum', 'Lun', 'Mar', 'Mie', 'Joi', 'Vin', 'Sam'),
|
|
|
221 |
'weekdays_long' => array ('Duminica', 'Luni', 'Marti', 'Miercuri', 'Joi', 'Vineri', 'Sambata'),
|
|
|
222 |
'months_short' => array ('Ian', 'Feb', 'Mar', 'Apr', 'Mai', 'Iun', 'Iul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'),
|
|
|
223 |
'months_long' => array ('Ianuarie', 'Februarie', 'Martie', 'Aprilie', 'Mai', 'Iunie', 'Iulie', 'August', 'Septembrie', 'Octombrie', 'Noiembrie', 'Decembrie')
|
|
|
224 |
),
|
|
|
225 |
'he' => array (
|
|
|
226 |
'weekdays_short'=> array ('ראשון', 'שני', 'שלישי', 'רביעי', 'חמישי', 'שישי', 'שבת'),
|
|
|
227 |
'weekdays_long' => array ('יום ראשון', 'יום שני', 'יום שלישי', 'יום רביעי', 'יום חמישי', 'יום שישי', 'שבת'),
|
|
|
228 |
'months_short' => array ('ינואר', 'פברואר', 'מרץ', 'אפריל', 'מאי', 'יוני', 'יולי', 'אוגוסט', 'ספטמבר', 'אוקטובר', 'נובמבר', 'דצמבר'),
|
|
|
229 |
'months_long' => array ('ינואר', 'פברואר', 'מרץ', 'אפריל', 'מאי', 'יוני', 'יולי', 'אוגוסט', 'ספטמבר', 'אוקטובר', 'נובמבר', 'דצמבר')
|
|
|
230 |
),
|
|
|
231 |
'sv' => array (
|
|
|
232 |
'weekdays_short'=> array ('Sön', 'Mån', 'Tis', 'Ons', 'Tor', 'Fre', 'Lör'),
|
|
|
233 |
'weekdays_long' => array ('Söndag', 'Måndag', 'Tisdag', 'Onsdag', 'Torsdag', 'Fredag', 'Lördag'),
|
|
|
234 |
'months_short' => array ('Jan', 'Feb', 'Mar', 'Apr', 'Maj', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dec'),
|
|
|
235 |
'months_long' => array ('Januari', 'Februari', 'Mars', 'April', 'Maj', 'Juni', 'Juli', 'Augusti', 'September', 'Oktober', 'November', 'December')
|
|
|
236 |
),
|
|
|
237 |
'pt' => array (
|
|
|
238 |
'weekdays_short'=> array ('Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sáb'),
|
|
|
239 |
'weekdays_long' => array ('Domingo', 'Segunda-feira', 'Terça-feira', 'Quarta-feira', 'Quinta-feira', 'Sexta-feira', 'Sábado'),
|
|
|
240 |
'months_short' => array ('Jan', 'Fev', 'Mar', 'Abr', 'Mai', 'Jun', 'Jul', 'Ago', 'Set', 'Out', 'Nov', 'Dez'),
|
|
|
241 |
'months_long' => array ('Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro')
|
|
|
242 |
)
|
320 |
jpm |
243 |
);
|
|
|
244 |
|
|
|
245 |
// }}}
|
|
|
246 |
// {{{ constructor
|
|
|
247 |
|
|
|
248 |
/**
|
|
|
249 |
* Class constructor
|
|
|
250 |
*
|
|
|
251 |
* @access public
|
|
|
252 |
* @param string Element's name
|
|
|
253 |
* @param mixed Label(s) for an element
|
|
|
254 |
* @param array Options to control the element's display
|
|
|
255 |
* @param mixed Either a typical HTML attribute string or an associative array
|
|
|
256 |
*/
|
|
|
257 |
function HTML_QuickForm_date($elementName = null, $elementLabel = null, $options = array(), $attributes = null)
|
|
|
258 |
{
|
|
|
259 |
$this->HTML_QuickForm_element($elementName, $elementLabel, $attributes);
|
|
|
260 |
$this->_persistantFreeze = true;
|
|
|
261 |
$this->_appendName = true;
|
|
|
262 |
$this->_type = 'date';
|
|
|
263 |
// set the options, do not bother setting bogus ones
|
|
|
264 |
if (is_array($options)) {
|
|
|
265 |
foreach ($options as $name => $value) {
|
|
|
266 |
if ('language' == $name) {
|
|
|
267 |
$this->_options['language'] = isset($this->_locale[$value])? $value: 'en';
|
|
|
268 |
} elseif (isset($this->_options[$name])) {
|
|
|
269 |
if (is_array($value)) {
|
|
|
270 |
$this->_options[$name] = @array_merge($this->_options[$name], $value);
|
|
|
271 |
} else {
|
|
|
272 |
$this->_options[$name] = $value;
|
|
|
273 |
}
|
|
|
274 |
}
|
|
|
275 |
}
|
|
|
276 |
}
|
|
|
277 |
}
|
|
|
278 |
|
|
|
279 |
// }}}
|
|
|
280 |
// {{{ _createElements()
|
|
|
281 |
|
|
|
282 |
function _createElements()
|
|
|
283 |
{
|
|
|
284 |
$this->_separator = $this->_elements = array();
|
|
|
285 |
$separator = '';
|
|
|
286 |
$locale =& $this->_locale[$this->_options['language']];
|
|
|
287 |
$backslash = false;
|
|
|
288 |
for ($i = 0, $length = strlen($this->_options['format']); $i < $length; $i++) {
|
|
|
289 |
$sign = $this->_options['format']{$i};
|
|
|
290 |
if ($backslash) {
|
|
|
291 |
$backslash = false;
|
|
|
292 |
$separator .= $sign;
|
|
|
293 |
} else {
|
|
|
294 |
$loadSelect = true;
|
|
|
295 |
switch ($sign) {
|
|
|
296 |
case 'D':
|
|
|
297 |
// Sunday is 0 like with 'w' in date()
|
|
|
298 |
$options = $locale['weekdays_short'];
|
|
|
299 |
break;
|
|
|
300 |
case 'l':
|
|
|
301 |
$options = $locale['weekdays_long'];
|
|
|
302 |
break;
|
|
|
303 |
case 'd':
|
|
|
304 |
$options = $this->_createOptionList(1, 31);
|
|
|
305 |
break;
|
|
|
306 |
case 'M':
|
|
|
307 |
$options = $locale['months_short'];
|
|
|
308 |
array_unshift($options , '');
|
|
|
309 |
unset($options[0]);
|
|
|
310 |
break;
|
|
|
311 |
case 'm':
|
|
|
312 |
$options = $this->_createOptionList(1, 12);
|
|
|
313 |
break;
|
|
|
314 |
case 'F':
|
|
|
315 |
$options = $locale['months_long'];
|
|
|
316 |
array_unshift($options , '');
|
|
|
317 |
unset($options[0]);
|
|
|
318 |
break;
|
|
|
319 |
case 'Y':
|
|
|
320 |
$options = $this->_createOptionList(
|
|
|
321 |
$this->_options['minYear'],
|
|
|
322 |
$this->_options['maxYear'],
|
|
|
323 |
$this->_options['minYear'] > $this->_options['maxYear']? -1: 1
|
|
|
324 |
);
|
|
|
325 |
break;
|
|
|
326 |
case 'y':
|
|
|
327 |
$options = $this->_createOptionList(
|
|
|
328 |
$this->_options['minYear'],
|
|
|
329 |
$this->_options['maxYear'],
|
|
|
330 |
$this->_options['minYear'] > $this->_options['maxYear']? -1: 1
|
|
|
331 |
);
|
|
|
332 |
array_walk($options, create_function('&$v,$k','$v = substr($v,-2);'));
|
|
|
333 |
break;
|
|
|
334 |
case 'h':
|
|
|
335 |
$options = $this->_createOptionList(1, 12);
|
|
|
336 |
break;
|
443 |
ddelon |
337 |
case 'g':
|
|
|
338 |
$options = $this->_createOptionList(1, 12);
|
|
|
339 |
array_walk($options, create_function('&$v,$k', '$v = intval($v);'));
|
|
|
340 |
break;
|
320 |
jpm |
341 |
case 'H':
|
|
|
342 |
$options = $this->_createOptionList(0, 23);
|
|
|
343 |
break;
|
|
|
344 |
case 'i':
|
|
|
345 |
$options = $this->_createOptionList(0, 59, $this->_options['optionIncrement']['i']);
|
|
|
346 |
break;
|
|
|
347 |
case 's':
|
|
|
348 |
$options = $this->_createOptionList(0, 59, $this->_options['optionIncrement']['s']);
|
|
|
349 |
break;
|
|
|
350 |
case 'a':
|
|
|
351 |
$options = array('am' => 'am', 'pm' => 'pm');
|
|
|
352 |
break;
|
|
|
353 |
case 'A':
|
|
|
354 |
$options = array('AM' => 'AM', 'PM' => 'PM');
|
|
|
355 |
break;
|
443 |
ddelon |
356 |
case 'W':
|
|
|
357 |
$options = $this->_createOptionList(1, 53);
|
|
|
358 |
break;
|
320 |
jpm |
359 |
case '\\':
|
|
|
360 |
$backslash = true;
|
|
|
361 |
$loadSelect = false;
|
|
|
362 |
break;
|
|
|
363 |
default:
|
|
|
364 |
$separator .= (' ' == $sign? ' ': $sign);
|
|
|
365 |
$loadSelect = false;
|
|
|
366 |
}
|
|
|
367 |
|
|
|
368 |
if ($loadSelect) {
|
|
|
369 |
if (0 < count($this->_elements)) {
|
|
|
370 |
$this->_separator[] = $separator;
|
|
|
371 |
} else {
|
|
|
372 |
$this->_wrap[0] = $separator;
|
|
|
373 |
}
|
|
|
374 |
$separator = '';
|
|
|
375 |
// Should we add an empty option to the top of the select?
|
443 |
ddelon |
376 |
if (!is_array($this->_options['addEmptyOption']) && $this->_options['addEmptyOption'] ||
|
|
|
377 |
is_array($this->_options['addEmptyOption']) && !empty($this->_options['addEmptyOption'][$sign])) {
|
|
|
378 |
|
|
|
379 |
// Using '+' array operator to preserve the keys
|
|
|
380 |
if (is_array($this->_options['emptyOptionText']) && !empty($this->_options['emptyOptionText'][$sign])) {
|
|
|
381 |
$options = array($this->_options['emptyOptionValue'] => $this->_options['emptyOptionText'][$sign]) + $options;
|
|
|
382 |
} else {
|
|
|
383 |
$options = array($this->_options['emptyOptionValue'] => $this->_options['emptyOptionText']) + $options;
|
|
|
384 |
}
|
320 |
jpm |
385 |
}
|
|
|
386 |
$this->_elements[] =& new HTML_QuickForm_select($sign, null, $options, $this->getAttributes());
|
|
|
387 |
}
|
|
|
388 |
}
|
|
|
389 |
}
|
|
|
390 |
$this->_wrap[1] = $separator . ($backslash? '\\': '');
|
|
|
391 |
}
|
|
|
392 |
|
|
|
393 |
// }}}
|
|
|
394 |
// {{{ _createOptionList()
|
|
|
395 |
|
|
|
396 |
/**
|
|
|
397 |
* Creates an option list containing the numbers from the start number to the end, inclusive
|
|
|
398 |
*
|
|
|
399 |
* @param int The start number
|
|
|
400 |
* @param int The end number
|
|
|
401 |
* @param int Increment by this value
|
|
|
402 |
* @access private
|
|
|
403 |
* @return array An array of numeric options.
|
|
|
404 |
*/
|
|
|
405 |
function _createOptionList($start, $end, $step = 1)
|
|
|
406 |
{
|
|
|
407 |
for ($i = $start, $options = array(); $start > $end? $i >= $end: $i <= $end; $i += $step) {
|
|
|
408 |
$options[$i] = sprintf('%02d', $i);
|
|
|
409 |
}
|
|
|
410 |
return $options;
|
|
|
411 |
}
|
|
|
412 |
|
|
|
413 |
// }}}
|
|
|
414 |
// {{{ setValue()
|
|
|
415 |
|
|
|
416 |
function setValue($value)
|
|
|
417 |
{
|
|
|
418 |
if (empty($value)) {
|
|
|
419 |
$value = array();
|
|
|
420 |
} elseif (is_scalar($value)) {
|
|
|
421 |
if (!is_numeric($value)) {
|
|
|
422 |
$value = strtotime($value);
|
|
|
423 |
}
|
|
|
424 |
// might be a unix epoch, then we fill all possible values
|
443 |
ddelon |
425 |
$arr = explode('-', date('w-d-n-Y-h-H-i-s-a-A-W', (int)$value));
|
320 |
jpm |
426 |
$value = array(
|
|
|
427 |
'D' => $arr[0],
|
|
|
428 |
'l' => $arr[0],
|
|
|
429 |
'd' => $arr[1],
|
|
|
430 |
'M' => $arr[2],
|
|
|
431 |
'm' => $arr[2],
|
|
|
432 |
'F' => $arr[2],
|
|
|
433 |
'Y' => $arr[3],
|
|
|
434 |
'y' => $arr[3],
|
|
|
435 |
'h' => $arr[4],
|
443 |
ddelon |
436 |
'g' => $arr[4],
|
320 |
jpm |
437 |
'H' => $arr[5],
|
|
|
438 |
'i' => $arr[6],
|
|
|
439 |
's' => $arr[7],
|
|
|
440 |
'a' => $arr[8],
|
443 |
ddelon |
441 |
'A' => $arr[9],
|
|
|
442 |
'W' => $arr[10]
|
320 |
jpm |
443 |
);
|
|
|
444 |
}
|
|
|
445 |
parent::setValue($value);
|
|
|
446 |
}
|
|
|
447 |
|
|
|
448 |
// }}}
|
|
|
449 |
// {{{ toHtml()
|
|
|
450 |
|
|
|
451 |
function toHtml()
|
|
|
452 |
{
|
|
|
453 |
include_once('HTML/QuickForm/Renderer/Default.php');
|
|
|
454 |
$renderer =& new HTML_QuickForm_Renderer_Default();
|
443 |
ddelon |
455 |
$renderer->setElementTemplate('{element}');
|
320 |
jpm |
456 |
parent::accept($renderer);
|
443 |
ddelon |
457 |
return $this->_wrap[0] . $renderer->toHtml() . $this->_wrap[1];
|
320 |
jpm |
458 |
}
|
|
|
459 |
|
|
|
460 |
// }}}
|
|
|
461 |
// {{{ accept()
|
|
|
462 |
|
|
|
463 |
function accept(&$renderer, $required = false, $error = null)
|
|
|
464 |
{
|
|
|
465 |
$renderer->renderElement($this, $required, $error);
|
|
|
466 |
}
|
|
|
467 |
|
|
|
468 |
// }}}
|
|
|
469 |
// {{{ onQuickFormEvent()
|
|
|
470 |
|
|
|
471 |
function onQuickFormEvent($event, $arg, &$caller)
|
|
|
472 |
{
|
|
|
473 |
if ('updateValue' == $event) {
|
|
|
474 |
// we need to call setValue(), 'cause the default/constant value
|
|
|
475 |
// may be in fact a timestamp, not an array
|
|
|
476 |
return HTML_QuickForm_element::onQuickFormEvent($event, $arg, $caller);
|
|
|
477 |
} else {
|
|
|
478 |
return parent::onQuickFormEvent($event, $arg, $caller);
|
|
|
479 |
}
|
|
|
480 |
}
|
|
|
481 |
|
|
|
482 |
// }}}
|
|
|
483 |
}
|
|
|
484 |
?>
|