Completed
Push — 1.10.x ( 3d9ba2...d7355d )
by
unknown
52:02
created

HTML_QuickForm_date::__construct()   C

Complexity

Conditions 8
Paths 7

Size

Total Lines 26
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 26
rs 5.3846
cc 8
eloc 17
nc 7
nop 4
1
<?php
2
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
3
4
/**
5
 * Class for a group of elements used to input dates (and times).
6
 *
7
 * PHP versions 4 and 5
8
 *
9
 * LICENSE: This source file is subject to version 3.01 of the PHP license
10
 * that is available through the world-wide-web at the following URI:
11
 * http://www.php.net/license/3_01.txt If you did not receive a copy of
12
 * the PHP License and are unable to obtain it through the web, please
13
 * send a note to [email protected] so we can mail you a copy immediately.
14
 *
15
 * @category    HTML
16
 * @package     HTML_QuickForm
17
 * @author      Alexey Borzov <[email protected]>
18
 * @copyright   2001-2009 The PHP Group
19
 * @license     http://www.php.net/license/3_01.txt PHP License 3.01
20
 * @version     CVS: $Id: date.php,v 1.62 2009/04/04 21:34:02 avb Exp $
21
 * @link        http://pear.php.net/package/HTML_QuickForm
22
 */
23
24
/**
25
 * Class for a group of elements used to input dates (and times).
26
 *
27
 * Inspired by original 'date' element but reimplemented as a subclass
28
 * of HTML_QuickForm_group
29
 *
30
 * @category    HTML
31
 * @package     HTML_QuickForm
32
 * @author      Alexey Borzov <[email protected]>
33
 * @version     Release: 3.2.11
34
 * @since       3.1
35
 */
36
class HTML_QuickForm_date extends HTML_QuickForm_group
37
{
38
    // {{{ properties
39
40
   /**
41
    * Various options to control the element's display.
42
    *
43
    * @access   private
44
    * @var      array
45
    */
46
    var $_options = array(
47
        'language'         => 'en',
48
        'format'           => 'dMY',
49
        'minYear'          => 2001,
50
        'maxYear'          => 2090,
51
        'addEmptyOption'   => false,
52
        'emptyOptionValue' => '',
53
        'emptyOptionText'  => '&nbsp;',
54
        'optionIncrement'  => array('i' => 1, 's' => 1)
55
    );
56
57
   /**
58
    * These complement separators, they are appended to the resultant HTML
59
    * @access   private
60
    * @var      array
61
    */
62
    var $_wrap = array('', '');
63
64
   /**
65
    * Options in different languages
66
    *
67
    * Note to potential translators: to avoid encoding problems please send
68
    * your translations with "weird" letters encoded as HTML Unicode entities
69
    *
70
    * @access   private
71
    * @var      array
72
    */
73
    var $_locale = array(
74
        'en' => array (
75
            'weekdays_short'=> array ('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'),
76
            'weekdays_long' => array ('Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'),
77
            'months_short'  => array ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'),
78
            'months_long'   => array ('January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December')
79
        ),
80
        'de' => array (
81
            'weekdays_short'=> array ('So', 'Mon', 'Di', 'Mi', 'Do', 'Fr', 'Sa'),
82
            'weekdays_long' => array ('Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag'),
83
            'months_short'  => array ('Jan', 'Feb', 'M&#xe4;rz', 'April', 'Mai', 'Juni', 'Juli', 'Aug', 'Sept', 'Okt', 'Nov', 'Dez'),
84
            'months_long'   => array ('Januar', 'Februar', 'M&#xe4;rz', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember')
85
        ),
86
        'fr' => array (
87
            'weekdays_short'=> array ('Dim', 'Lun', 'Mar', 'Mer', 'Jeu', 'Ven', 'Sam'),
88
            'weekdays_long' => array ('Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi'),
89
            'months_short'  => array ('Jan', 'F&#xe9;v', 'Mar', 'Avr', 'Mai', 'Juin', 'Juil', 'Ao&#xfb;t', 'Sep', 'Oct', 'Nov', 'D&#xe9;c'),
90
            'months_long'   => array ('Janvier', 'F&#xe9;vrier', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Ao&#xfb;t', 'Septembre', 'Octobre', 'Novembre', 'D&#xe9;cembre')
91
        ),
92
        'hu'    => array (
93
            'weekdays_short'=> array ('V', 'H', 'K', 'Sze', 'Cs', 'P', 'Szo'),
94
            'weekdays_long' => array ('vas&#xe1;rnap', 'h&#xe9;tf&#x151;', 'kedd', 'szerda', 'cs&#xfc;t&#xf6;rt&#xf6;k', 'p&#xe9;ntek', 'szombat'),
95
            'months_short'  => array ('jan', 'feb', 'm&#xe1;rc', '&#xe1;pr', 'm&#xe1;j', 'j&#xfa;n', 'j&#xfa;l', 'aug', 'szept', 'okt', 'nov', 'dec'),
96
            'months_long'   => array ('janu&#xe1;r', 'febru&#xe1;r', 'm&#xe1;rcius', '&#xe1;prilis', 'm&#xe1;jus', 'j&#xfa;nius', 'j&#xfa;lius', 'augusztus', 'szeptember', 'okt&#xf3;ber', 'november', 'december')
97
        ),
98
        'pl'    => array (
99
            'weekdays_short'=> array ('Nie', 'Pn', 'Wt', '&#x15a;r', 'Czw', 'Pt', 'Sob'),
100
            'weekdays_long' => array ('Niedziela', 'Poniedzia&#x142;ek', 'Wtorek', '&#x15a;roda', 'Czwartek', 'Pi&#x105;tek', 'Sobota'),
101
            'months_short'  => array ('Sty', 'Lut', 'Mar', 'Kwi', 'Maj', 'Cze', 'Lip', 'Sie', 'Wrz', 'Pa&#x17a;', 'Lis', 'Gru'),
102
            'months_long'   => array ('Stycze&#x144;', 'Luty', 'Marzec', 'Kwiecie&#x144;', 'Maj', 'Czerwiec', 'Lipiec', 'Sierpie&#x144;', 'Wrzesie&#x144;', 'Pa&#x17a;dziernik', 'Listopad', 'Grudzie&#x144;')
103
        ),
104
        'sl'    => array (
105
            'weekdays_short'=> array ('Ned', 'Pon', 'Tor', 'Sre', 'Cet', 'Pet', 'Sob'),
106
            'weekdays_long' => array ('Nedelja', 'Ponedeljek', 'Torek', 'Sreda', 'Cetrtek', 'Petek', 'Sobota'),
107
            'months_short'  => array ('Jan', 'Feb', 'Mar', 'Apr', 'Maj', 'Jun', 'Jul', 'Avg', 'Sep', 'Okt', 'Nov', 'Dec'),
108
            'months_long'   => array ('Januar', 'Februar', 'Marec', 'April', 'Maj', 'Junij', 'Julij', 'Avgust', 'September', 'Oktober', 'November', 'December')
109
        ),
110
        'ru'    => array (
111
            'weekdays_short'=> array ('&#x412;&#x441;', '&#x41f;&#x43d;', '&#x412;&#x442;', '&#x421;&#x440;', '&#x427;&#x442;', '&#x41f;&#x442;', '&#x421;&#x431;'),
112
            'weekdays_long' => array ('&#x412;&#x43e;&#x441;&#x43a;&#x440;&#x435;&#x441;&#x435;&#x43d;&#x44c;&#x435;', '&#x41f;&#x43e;&#x43d;&#x435;&#x434;&#x435;&#x43b;&#x44c;&#x43d;&#x438;&#x43a;', '&#x412;&#x442;&#x43e;&#x440;&#x43d;&#x438;&#x43a;', '&#x421;&#x440;&#x435;&#x434;&#x430;', '&#x427;&#x435;&#x442;&#x432;&#x435;&#x440;&#x433;', '&#x41f;&#x44f;&#x442;&#x43d;&#x438;&#x446;&#x430;', '&#x421;&#x443;&#x431;&#x431;&#x43e;&#x442;&#x430;'),
113
            'months_short'  => array ('&#x42f;&#x43d;&#x432;', '&#x424;&#x435;&#x432;', '&#x41c;&#x430;&#x440;', '&#x410;&#x43f;&#x440;', '&#x41c;&#x430;&#x439;', '&#x418;&#x44e;&#x43d;', '&#x418;&#x44e;&#x43b;', '&#x410;&#x432;&#x433;', '&#x421;&#x435;&#x43d;', '&#x41e;&#x43a;&#x442;', '&#x41d;&#x43e;&#x44f;', '&#x414;&#x435;&#x43a;'),
114
            'months_long'   => array ('&#x42f;&#x43d;&#x432;&#x430;&#x440;&#x44c;', '&#x424;&#x435;&#x432;&#x440;&#x430;&#x43b;&#x44c;', '&#x41c;&#x430;&#x440;&#x442;', '&#x410;&#x43f;&#x440;&#x435;&#x43b;&#x44c;', '&#x41c;&#x430;&#x439;', '&#x418;&#x44e;&#x43d;&#x44c;', '&#x418;&#x44e;&#x43b;&#x44c;', '&#x410;&#x432;&#x433;&#x443;&#x441;&#x442;', '&#x421;&#x435;&#x43d;&#x442;&#x44f;&#x431;&#x440;&#x44c;', '&#x41e;&#x43a;&#x442;&#x44f;&#x431;&#x440;&#x44c;', '&#x41d;&#x43e;&#x44f;&#x431;&#x440;&#x44c;', '&#x414;&#x435;&#x43a;&#x430;&#x431;&#x440;&#x44c;')
115
        ),
116
        'es'    => array (
117
            'weekdays_short'=> array ('Dom', 'Lun', 'Mar', 'Mi&#xe9;', 'Jue', 'Vie', 'S&#xe1;b'),
118
            'weekdays_long' => array ('Domingo', 'Lunes', 'Martes', 'Mi&#xe9;rcoles', 'Jueves', 'Viernes', 'S&#xe1;bado'),
119
            'months_short'  => array ('Ene', 'Feb', 'Mar', 'Abr', 'May', 'Jun', 'Jul', 'Ago', 'Sep', 'Oct', 'Nov', 'Dic'),
120
            'months_long'   => array ('Enero', 'Febrero', 'Marzo', 'Abril', 'Mayo', 'Junio', 'Julio', 'Agosto', 'Septiembre', 'Octubre', 'Noviembre', 'Diciembre')
121
        ),
122
        'da'    => array (
123
            'weekdays_short'=> array ('S&#xf8;n', 'Man', 'Tir', 'Ons', 'Tor', 'Fre', 'L&#xf8;r'),
124
            'weekdays_long' => array ('S&#xf8;ndag', 'Mandag', 'Tirsdag', 'Onsdag', 'Torsdag', 'Fredag', 'L&#xf8;rdag'),
125
            'months_short'  => array ('Jan', 'Feb', 'Mar', 'Apr', 'Maj', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dec'),
126
            'months_long'   => array ('Januar', 'Februar', 'Marts', 'April', 'Maj', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'December')
127
        ),
128
        'is'    => array (
129
            'weekdays_short'=> array ('Sun', 'M&#xe1;n', '&#xde;ri', 'Mi&#xf0;', 'Fim', 'F&#xf6;s', 'Lau'),
130
            'weekdays_long' => array ('Sunnudagur', 'M&#xe1;nudagur', '&#xde;ri&#xf0;judagur', 'Mi&#xf0;vikudagur', 'Fimmtudagur', 'F&#xf6;studagur', 'Laugardagur'),
131
            'months_short'  => array ('Jan', 'Feb', 'Mar', 'Apr', 'Ma&#xed;', 'J&#xfa;n', 'J&#xfa;l', '&#xc1;g&#xfa;', 'Sep', 'Okt', 'N&#xf3;v', 'Des'),
132
            'months_long'   => array ('Jan&#xfa;ar', 'Febr&#xfa;ar', 'Mars', 'Apr&#xed;l', 'Ma&#xed;', 'J&#xfa;n&#xed;', 'J&#xfa;l&#xed;', '&#xc1;g&#xfa;st', 'September', 'Okt&#xf3;ber', 'N&#xf3;vember', 'Desember')
133
        ),
134
        'it'    => array (
135
            'weekdays_short'=> array ('Dom', 'Lun', 'Mar', 'Mer', 'Gio', 'Ven', 'Sab'),
136
            'weekdays_long' => array ('Domenica', 'Luned&#xec;', 'Marted&#xec;', 'Mercoled&#xec;', 'Gioved&#xec;', 'Venerd&#xec;', 'Sabato'),
137
            'months_short'  => array ('Gen', 'Feb', 'Mar', 'Apr', 'Mag', 'Giu', 'Lug', 'Ago', 'Set', 'Ott', 'Nov', 'Dic'),
138
            'months_long'   => array ('Gennaio', 'Febbraio', 'Marzo', 'Aprile', 'Maggio', 'Giugno', 'Luglio', 'Agosto', 'Settembre', 'Ottobre', 'Novembre', 'Dicembre')
139
        ),
140
        'sk'    => array (
141
            'weekdays_short'=> array ('Ned', 'Pon', 'Uto', 'Str', '&#x8a;tv', 'Pia', 'Sob'),
142
            'weekdays_long' => array ('Nede&#x17e;a', 'Pondelok', 'Utorok', 'Streda', '&#x8a;tvrtok', 'Piatok', 'Sobota'),
143
            'months_short'  => array ('Jan', 'Feb', 'Mar', 'Apr', 'M&#xe1;j', 'J&#xfa;n', 'J&#xfa;l', 'Aug', 'Sep', 'Okt', 'Nov', 'Dec'),
144
            'months_long'   => array ('Janu&#xe1;r', 'Febru&#xe1;r', 'Marec', 'Apr&#xed;l', 'M&#xe1;j', 'J&#xfa;n', 'J&#xfa;l', 'August', 'September', 'Okt&#xf3;ber', 'November', 'December')
145
        ),
146
        'cs'    => array (
147
            'weekdays_short'=> array ('Ne', 'Po', '&#xda;t', 'St', '&#x10c;t', 'P&#xe1;', 'So'),
148
            'weekdays_long' => array ('Ned&#x11b;le', 'Pond&#x11b;l&#xed;', '&#xda;ter&#xfd;', 'St&#x159;eda', '&#x10c;tvrtek', 'P&#xe1;tek', 'Sobota'),
149
            'months_short'  => array ('Led', '&#xda;no', 'B&#x159;e', 'Dub', 'Kv&#x11b;', '&#x10c;en', '&#x10c;ec', 'Srp', 'Z&#xe1;&#x159;', '&#x158;&#xed;j', 'Lis', 'Pro'),
150
            'months_long'   => array ('Leden', '&#xda;nor', 'B&#x159;ezen', 'Duben', 'Kv&#x11b;ten', '&#x10c;erven', '&#x10c;ervenec', 'Srpen', 'Z&#xe1;&#x159;&#xed;', '&#x158;&#xed;jen', 'Listopad', 'Prosinec')
151
        ),
152
        'hy'    => array (
153
            'weekdays_short'=> array ('&#x53f;&#x580;&#x56f;', '&#x535;&#x580;&#x56f;', '&#x535;&#x580;&#x584;', '&#x549;&#x580;&#x584;', '&#x540;&#x576;&#x563;', '&#x548;&#x582;&#x580;', '&#x547;&#x562;&#x569;'),
154
            'weekdays_long' => array ('&#x53f;&#x56b;&#x580;&#x561;&#x56f;&#x56b;', '&#x535;&#x580;&#x56f;&#x578;&#x582;&#x577;&#x561;&#x562;&#x569;&#x56b;', '&#x535;&#x580;&#x565;&#x584;&#x577;&#x561;&#x562;&#x569;&#x56b;', '&#x549;&#x578;&#x580;&#x565;&#x584;&#x577;&#x561;&#x562;&#x569;&#x56b;', '&#x540;&#x56b;&#x576;&#x563;&#x577;&#x561;&#x562;&#x569;&#x56b;', '&#x548;&#x582;&#x580;&#x562;&#x561;&#x569;', '&#x547;&#x561;&#x562;&#x561;&#x569;'),
155
            'months_short'  => array ('&#x540;&#x576;&#x57e;', '&#x553;&#x57f;&#x580;', '&#x544;&#x580;&#x57f;', '&#x531;&#x57a;&#x580;', '&#x544;&#x575;&#x57d;', '&#x540;&#x576;&#x57d;', '&#x540;&#x56c;&#x57d;', '&#x555;&#x563;&#x57d;', '&#x54d;&#x57a;&#x57f;', '&#x540;&#x56f;&#x57f;', '&#x546;&#x575;&#x574;', '&#x534;&#x56f;&#x57f;'),
156
            'months_long'   => array ('&#x540;&#x578;&#x582;&#x576;&#x57e;&#x561;&#x580;', '&#x553;&#x565;&#x57f;&#x580;&#x57e;&#x561;&#x580;', '&#x544;&#x561;&#x580;&#x57f;', '&#x531;&#x57a;&#x580;&#x56b;&#x56c;', '&#x544;&#x561;&#x575;&#x56b;&#x57d;', '&#x540;&#x578;&#x582;&#x576;&#x56b;&#x57d;', '&#x540;&#x578;&#x582;&#x56c;&#x56b;&#x57d;', '&#x555;&#x563;&#x578;&#x57d;&#x57f;&#x578;&#x57d;', '&#x54d;&#x565;&#x57a;&#x57f;&#x565;&#x574;&#x562;&#x565;&#x580;', '&#x540;&#x578;&#x56f;&#x57f;&#x565;&#x574;&#x562;&#x565;&#x580;', '&#x546;&#x578;&#x575;&#x565;&#x574;&#x562;&#x565;&#x580;', '&#x534;&#x565;&#x56f;&#x57f;&#x565;&#x574;&#x562;&#x565;&#x580;')
157
        ),
158
        'nl'    => array (
159
            'weekdays_short'=> array ('Zo', 'Ma', 'Di', 'Wo', 'Do', 'Vr', 'Za'),
160
            'weekdays_long' => array ('Zondag', 'Maandag', 'Dinsdag', 'Woensdag', 'Donderdag', 'Vrijdag', 'Zaterdag'),
161
            'months_short'  => array ('Jan', 'Feb', 'Mar', 'Apr', 'Mei', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dec'),
162
            'months_long'   => array ('Januari', 'Februari', 'Maart', 'April', 'Mei', 'Juni', 'Juli', 'Augustus', 'September', 'Oktober', 'November', 'December')
163
        ),
164
        'et'    => array (
165
            'weekdays_short'=> array ('P', 'E', 'T', 'K', 'N', 'R', 'L'),
166
            'weekdays_long' => array ('P&#xfc;hap&#xe4;ev', 'Esmasp&#xe4;ev', 'Teisip&#xe4;ev', 'Kolmap&#xe4;ev', 'Neljap&#xe4;ev', 'Reede', 'Laup&#xe4;ev'),
167
            'months_short'  => array ('Jaan', 'Veebr', 'M&#xe4;rts', 'Aprill', 'Mai', 'Juuni', 'Juuli', 'Aug', 'Sept', 'Okt', 'Nov', 'Dets'),
168
            'months_long'   => array ('Jaanuar', 'Veebruar', 'M&#xe4;rts', 'Aprill', 'Mai', 'Juuni', 'Juuli', 'August', 'September', 'Oktoober', 'November', 'Detsember')
169
        ),
170
        'tr'    => array (
171
            'weekdays_short'=> array ('Paz', 'Pzt', 'Sal', '&#xc7;ar', 'Per', 'Cum', 'Cts'),
172
            'weekdays_long' => array ('Pazar', 'Pazartesi', 'Sal&#x131;', '&#xc7;ar&#x15f;amba', 'Per&#x15f;embe', 'Cuma', 'Cumartesi'),
173
            'months_short'  => array ('Ock', '&#x15e;bt', 'Mrt', 'Nsn', 'Mys', 'Hzrn', 'Tmmz', 'A&#x11f;st', 'Eyl', 'Ekm', 'Ksm', 'Arlk'),
174
            'months_long'   => array ('Ocak', '&#x15e;ubat', 'Mart', 'Nisan', 'May&#x131;s', 'Haziran', 'Temmuz', 'A&#x11f;ustos', 'Eyl&#xfc;l', 'Ekim', 'Kas&#x131;m', 'Aral&#x131;k')
175
        ),
176
        'no'    => array (
177
            'weekdays_short'=> array ('S&#xf8;n', 'Man', 'Tir', 'Ons', 'Tor', 'Fre', 'L&#xf8;r'),
178
            'weekdays_long' => array ('S&#xf8;ndag', 'Mandag', 'Tirsdag', 'Onsdag', 'Torsdag', 'Fredag', 'L&#xf8;rdag'),
179
            'months_short'  => array ('Jan', 'Feb', 'Mar', 'Apr', 'Mai', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Des'),
180
            'months_long'   => array ('Januar', 'Februar', 'Mars', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Desember')
181
        ),
182
        'eo'    => array (
183
            'weekdays_short'=> array ('Dim', 'Lun', 'Mar', 'Mer', '&#x134;a&#x16D;', 'Ven', 'Sab'),
184
            'weekdays_long' => array ('Diman&#x109;o', 'Lundo', 'Mardo', 'Merkredo', '&#x134;a&#x16D;do', 'Vendredo', 'Sabato'),
185
            'months_short'  => array ('Jan', 'Feb', 'Mar', 'Apr', 'Maj', 'Jun', 'Jul', 'A&#x16D;g', 'Sep', 'Okt', 'Nov', 'Dec'),
186
            'months_long'   => array ('Januaro', 'Februaro', 'Marto', 'Aprilo', 'Majo', 'Junio', 'Julio', 'A&#x16D;gusto', 'Septembro', 'Oktobro', 'Novembro', 'Decembro')
187
        ),
188
        'ua'    => array (
189
            'weekdays_short'=> array('&#x41d;&#x434;&#x43b;', '&#x41f;&#x43d;&#x434;', '&#x412;&#x442;&#x440;', '&#x421;&#x440;&#x434;', '&#x427;&#x442;&#x432;', '&#x41f;&#x442;&#x43d;', '&#x421;&#x431;&#x442;'),
190
            'weekdays_long' => array('&#x41d;&#x435;&#x434;&#x456;&#x43b;&#x44f;', '&#x41f;&#x43e;&#x43d;&#x435;&#x434;&#x456;&#x43b;&#x43e;&#x43a;', '&#x412;&#x456;&#x432;&#x442;&#x43e;&#x440;&#x43e;&#x43a;', '&#x421;&#x435;&#x440;&#x435;&#x434;&#x430;', '&#x427;&#x435;&#x442;&#x432;&#x435;&#x440;', '&#x41f;\'&#x44f;&#x442;&#x43d;&#x438;&#x446;&#x44f;', '&#x421;&#x443;&#x431;&#x43e;&#x442;&#x430;'),
191
            'months_short'  => array('&#x421;&#x456;&#x447;', '&#x41b;&#x44e;&#x442;', '&#x411;&#x435;&#x440;', '&#x41a;&#x432;&#x456;', '&#x422;&#x440;&#x430;', '&#x427;&#x435;&#x440;', '&#x41b;&#x438;&#x43f;', '&#x421;&#x435;&#x440;', '&#x412;&#x435;&#x440;', '&#x416;&#x43e;&#x432;', '&#x41b;&#x438;&#x441;', '&#x413;&#x440;&#x443;'),
192
            'months_long'   => array('&#x421;&#x456;&#x447;&#x435;&#x43d;&#x44c;', '&#x41b;&#x44e;&#x442;&#x438;&#x439;', '&#x411;&#x435;&#x440;&#x435;&#x437;&#x435;&#x43d;&#x44c;', '&#x41a;&#x432;&#x456;&#x442;&#x435;&#x43d;&#x44c;', '&#x422;&#x440;&#x430;&#x432;&#x435;&#x43d;&#x44c;', '&#x427;&#x435;&#x440;&#x432;&#x435;&#x43d;&#x44c;', '&#x41b;&#x438;&#x43f;&#x435;&#x43d;&#x44c;', '&#x421;&#x435;&#x440;&#x43f;&#x435;&#x43d;&#x44c;', '&#x412;&#x435;&#x440;&#x435;&#x441;&#x435;&#x43d;&#x44c;', '&#x416;&#x43e;&#x432;&#x442;&#x435;&#x43d;&#x44c;', '&#x41b;&#x438;&#x441;&#x442;&#x43e;&#x43f;&#x430;&#x434;', '&#x413;&#x440;&#x443;&#x434;&#x435;&#x43d;&#x44c;')
193
        ),
194
        'ro'    => array (
195
            'weekdays_short'=> array ('Dum', 'Lun', 'Mar', 'Mie', 'Joi', 'Vin', 'Sam'),
196
            'weekdays_long' => array ('Duminica', 'Luni', 'Marti', 'Miercuri', 'Joi', 'Vineri', 'Sambata'),
197
            'months_short'  => array ('Ian', 'Feb', 'Mar', 'Apr', 'Mai', 'Iun', 'Iul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'),
198
            'months_long'   => array ('Ianuarie', 'Februarie', 'Martie', 'Aprilie', 'Mai', 'Iunie', 'Iulie', 'August', 'Septembrie', 'Octombrie', 'Noiembrie', 'Decembrie')
199
        ),
200
        'he'    => array (
201
            'weekdays_short'=> array ('&#1512;&#1488;&#1513;&#1493;&#1503;', '&#1513;&#1504;&#1497;', '&#1513;&#1500;&#1497;&#1513;&#1497;', '&#1512;&#1489;&#1497;&#1506;&#1497;', '&#1495;&#1502;&#1497;&#1513;&#1497;', '&#1513;&#1497;&#1513;&#1497;', '&#1513;&#1489;&#1514;'),
202
            'weekdays_long' => array ('&#1497;&#1493;&#1501; &#1512;&#1488;&#1513;&#1493;&#1503;', '&#1497;&#1493;&#1501; &#1513;&#1504;&#1497;', '&#1497;&#1493;&#1501; &#1513;&#1500;&#1497;&#1513;&#1497;', '&#1497;&#1493;&#1501; &#1512;&#1489;&#1497;&#1506;&#1497;', '&#1497;&#1493;&#1501; &#1495;&#1502;&#1497;&#1513;&#1497;', '&#1497;&#1493;&#1501; &#1513;&#1497;&#1513;&#1497;', '&#1513;&#1489;&#1514;'),
203
            'months_short'  => array ('&#1497;&#1504;&#1493;&#1488;&#1512;', '&#1508;&#1489;&#1512;&#1493;&#1488;&#1512;', '&#1502;&#1512;&#1509;', '&#1488;&#1508;&#1512;&#1497;&#1500;', '&#1502;&#1488;&#1497;', '&#1497;&#1493;&#1504;&#1497;', '&#1497;&#1493;&#1500;&#1497;', '&#1488;&#1493;&#1490;&#1493;&#1505;&#1496;', '&#1505;&#1508;&#1496;&#1502;&#1489;&#1512;', '&#1488;&#1493;&#1511;&#1496;&#1493;&#1489;&#1512;', '&#1504;&#1493;&#1489;&#1502;&#1489;&#1512;', '&#1491;&#1510;&#1502;&#1489;&#1512;'),
204
            'months_long'   => array ('&#1497;&#1504;&#1493;&#1488;&#1512;', '&#1508;&#1489;&#1512;&#1493;&#1488;&#1512;', '&#1502;&#1512;&#1509;', '&#1488;&#1508;&#1512;&#1497;&#1500;', '&#1502;&#1488;&#1497;', '&#1497;&#1493;&#1504;&#1497;', '&#1497;&#1493;&#1500;&#1497;', '&#1488;&#1493;&#1490;&#1493;&#1505;&#1496;', '&#1505;&#1508;&#1496;&#1502;&#1489;&#1512;', '&#1488;&#1493;&#1511;&#1496;&#1493;&#1489;&#1512;', '&#1504;&#1493;&#1489;&#1502;&#1489;&#1512;', '&#1491;&#1510;&#1502;&#1489;&#1512;')
205
        ),
206
        'sv'    => array (
207
            'weekdays_short'=> array ('S&#xf6;n', 'M&#xe5;n', 'Tis', 'Ons', 'Tor', 'Fre', 'L&#xf6;r'),
208
            'weekdays_long' => array ('S&#xf6;ndag', 'M&#xe5;ndag', 'Tisdag', 'Onsdag', 'Torsdag', 'Fredag', 'L&#xf6;rdag'),
209
            'months_short'  => array ('Jan', 'Feb', 'Mar', 'Apr', 'Maj', 'Jun', 'Jul', 'Aug', 'Sep', 'Okt', 'Nov', 'Dec'),
210
            'months_long'   => array ('Januari', 'Februari', 'Mars', 'April', 'Maj', 'Juni', 'Juli', 'Augusti', 'September', 'Oktober', 'November', 'December')
211
        ),
212
        'pt'    => array (
213
            'weekdays_short'=> array ('Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'S&aacute;b'),
214
            'weekdays_long' => array ('Domingo', 'Segunda-feira', 'Ter&ccedil;a-feira', 'Quarta-feira', 'Quinta-feira', 'Sexta-feira', 'S&aacute;bado'),
215
            'months_short'  => array ('Jan', 'Fev', 'Mar', 'Abr', 'Mai', 'Jun', 'Jul', 'Ago', 'Set', 'Out', 'Nov', 'Dez'),
216
            'months_long'   => array ('Janeiro', 'Fevereiro', 'Mar&ccedil;o', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro')
217
        ),
218
        'tw'    => array (
219
            'weekdays_short'=> array ('&#36913;&#26085;','&#36913;&#19968;', '&#36913;&#20108;','&#36913;&#19977;', '&#36913;&#22235;','&#36913;&#20116;', '&#36913;&#20845;'),
220
            'weekdays_long' => array ('&#26143;&#26399;&#26085;', '&#26143;&#26399;&#19968;', '&#26143;&#26399;&#20108;', '&#26143;&#26399;&#19977;', '&#26143;&#26399;&#22235;', '&#26143;&#26399;&#20116;', '&#26143;&#26399;&#20845;'),
221
            'months_short'  => array ('&#19968;&#26376;', '&#20108;&#26376;', '&#19977;&#26376;', '&#22235;&#26376;', '&#20116;&#26376;', '&#20845;&#26376;', '&#19971;&#26376;', '&#20843;&#26376;', '&#20061;&#26376;', '&#21313;&#26376;', '&#21313;&#19968;&#26376;', '&#21313;&#20108;&#26376;'),
222
            'months_long'   => array ('&#19968;&#26376;', '&#20108;&#26376;', '&#19977;&#26376;', '&#22235;&#26376;', '&#20116;&#26376;', '&#20845;&#26376;', '&#19971;&#26376;', '&#20843;&#26376;', '&#20061;&#26376;', '&#21313;&#26376;', '&#21313;&#19968;&#26376;', '&#21313;&#20108;&#26376;')
223
        ),
224
        'pt-br' => array (
225
            'weekdays_short'=> array ('Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'S&aacute;b'),
226
            'weekdays_long' => array ('Domingo', 'Segunda', 'Ter&ccedil;a', 'Quarta', 'Quinta', 'Sexta', 'S&aacute;bado'),
227
            'months_short'  => array ('Jan', 'Fev', 'Mar', 'Abr', 'Mai', 'Jun', 'Jul', 'Ago', 'Set', 'Out', 'Nov', 'Dez'),
228
            'months_long'   => array ('Janeiro', 'Fevereiro', 'Mar&ccedil;o', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro')
229
        )
230
    );
231
232
    // }}}
233
    // {{{ constructor
234
235
   /**
236
    * Class constructor
237
    *
238
    * The following keys may appear in $options array:
239
    * - 'language': date language
240
    * - 'format': Format of the date, based on PHP's date() function.
241
    *   The following characters are currently recognised in format string:
242
    *   <pre>
243
    *       D => Short names of days
244
    *       l => Long names of days
245
    *       d => Day numbers
246
    *       M => Short names of months
247
    *       F => Long names of months
248
    *       m => Month numbers
249
    *       Y => Four digit year
250
    *       y => Two digit year
251
    *       h => 12 hour format
252
    *       H => 23 hour  format
253
    *       i => Minutes
254
    *       s => Seconds
255
    *       a => am/pm
256
    *       A => AM/PM
257
    *   </pre>
258
    * - 'minYear': Minimum year in year select
259
    * - 'maxYear': Maximum year in year select
260
    * - 'addEmptyOption': Should an empty option be added to the top of
261
    *    each select box?
262
    * - 'emptyOptionValue': The value passed by the empty option.
263
    * - 'emptyOptionText': The text displayed for the empty option.
264
    * - 'optionIncrement': Step to increase the option values by (works for 'i' and 's')
265
    *
266
    * @access   public
267
    * @param    string  Element's name
268
    * @param    mixed   Label(s) for an element
269
    * @param    array   Options to control the element's display
270
    * @param    mixed   Either a typical HTML attribute string or an associative array
271
    */
272
    public function __construct($elementName = null, $elementLabel = null, $options = array(), $attributes = null)
273
    {
274
        parent::__construct($elementName, $elementLabel, $attributes);
275
        $this->_persistantFreeze = true;
276
        $this->_appendName = true;
277
        $this->_type = 'date';
278
        // Added by Ivan Tcholakov, 16-MAR-2010.
279
        $current_year = intval(api_get_local_time());
280
        $this->_options['minYear'] = $current_year - 9;
281
        $this->_options['maxYear'] = $current_year + 1;
282
        //
283
        // set the options, do not bother setting bogus ones
284
        if (is_array($options)) {
285
            foreach ($options as $name => $value) {
286
                if ('language' == $name) {
287
                    $this->_options['language'] = isset($this->_locale[$value])? $value: 'en';
288
                } elseif (isset($this->_options[$name])) {
289
                    if (is_array($value) && is_array($this->_options[$name])) {
290
                        $this->_options[$name] = @array_merge($this->_options[$name], $value);
291
                    } else {
292
                        $this->_options[$name] = $value;
293
                    }
294
                }
295
            }
296
        }
297
    }
298
299
    function _createElements()
300
    {
301
        $this->_separator = $this->_elements = array();
302
        $separator =  '';
303
        $locale    =& $this->_locale[$this->_options['language']];
304
        $backslash =  false;
305
        // Modified by Ivan Tcholakov, 16-MAR-2010.
306
        for ($i = 0, $length = api_strlen($this->_options['format']); $i < $length; $i++) {
307
            $sign = api_substr($this->_options['format'], $i, 1);
308
        //
309
            if ($backslash) {
310
                $backslash  = false;
311
                $separator .= $sign;
312
            } else {
313
                $loadSelect = true;
314
                switch ($sign) {
315
                    case 'D':
316
                        // Sunday is 0 like with 'w' in date()
317
                        $options = $locale['weekdays_short'];
318
                        break;
319
                    case 'l':
320
                        $options = $locale['weekdays_long'];
321
                        break;
322
                    case 'd':
323
                        $options = $this->_createOptionList(1, 31);
324
                        break;
325
                    case 'M':
326
                        $options = $locale['months_short'];
327
                        array_unshift($options , '');
328
                        unset($options[0]);
329
                        break;
330
                    case 'm':
331
                        $options = $this->_createOptionList(1, 12);
332
                        break;
333
                    case 'F':
334
                        $options = $locale['months_long'];
335
                        array_unshift($options , '');
336
                        unset($options[0]);
337
                        break;
338
                    case 'Y':
339
                        $options = $this->_createOptionList(
340
                            $this->_options['minYear'],
341
                            $this->_options['maxYear'],
342
                            $this->_options['minYear'] > $this->_options['maxYear']? -1: 1
343
                        );
344
                        break;
345
                    case 'y':
346
                        $options = $this->_createOptionList(
347
                            $this->_options['minYear'],
348
                            $this->_options['maxYear'],
349
                            $this->_options['minYear'] > $this->_options['maxYear']? -1: 1
350
                        );
351
                        array_walk($options, create_function('&$v,$k','$v = substr($v,-2);'));
352
                        break;
353
                    case 'h':
354
                        $options = $this->_createOptionList(1, 12);
355
                        break;
356
                    case 'g':
357
                        $options = $this->_createOptionList(1, 12);
358
                        array_walk($options, create_function('&$v,$k', '$v = intval($v);'));
359
                        break;
360
                    case 'H':
361
                        $options = $this->_createOptionList(0, 23);
362
                        break;
363
                    case 'i':
364
                        $options = $this->_createOptionList(0, 59, $this->_options['optionIncrement']['i']);
365
                        break;
366
                    case 's':
367
                        $options = $this->_createOptionList(0, 59, $this->_options['optionIncrement']['s']);
368
                        break;
369
                    case 'a':
370
                        $options = array('am' => 'am', 'pm' => 'pm');
371
                        break;
372
                    case 'A':
373
                        $options = array('AM' => 'AM', 'PM' => 'PM');
374
                        break;
375
                    case 'W':
376
                        $options = $this->_createOptionList(1, 53);
377
                        break;
378
                    case '\\':
379
                        $backslash  = true;
380
                        $loadSelect = false;
381
                        break;
382
                    default:
383
                        $separator .= (' ' == $sign? '&nbsp;': $sign);
384
                        $loadSelect = false;
385
                }
386
387
                if ($loadSelect) {
388
                    if (0 < count($this->_elements)) {
389
                        $this->_separator[] = $separator;
390
                    } else {
391
                        $this->_wrap[0] = $separator;
392
                    }
393
                    $separator = '';
394
                    // Should we add an empty option to the top of the select?
395
                    if (!is_array($this->_options['addEmptyOption']) && $this->_options['addEmptyOption'] ||
396
                        is_array($this->_options['addEmptyOption']) && !empty($this->_options['addEmptyOption'][$sign])) {
397
398
                        // Using '+' array operator to preserve the keys
399
                        if (is_array($this->_options['emptyOptionText']) && !empty($this->_options['emptyOptionText'][$sign])) {
400
                            $options = array($this->_options['emptyOptionValue'] => $this->_options['emptyOptionText'][$sign]) + $options;
401
                        } else {
402
                            $options = array($this->_options['emptyOptionValue'] => $this->_options['emptyOptionText']) + $options;
403
                        }
404
                    }
405
                    $this->_elements[] = new HTML_QuickForm_select($sign, null, $options, $this->getAttributes());
406
                }
407
            }
408
        }
409
        $this->_wrap[1] = $separator . ($backslash? '\\': '');
410
    }
411
412
    // }}}
413
    // {{{ _createOptionList()
414
415
   /**
416
    * Creates an option list containing the numbers from the start number to the end, inclusive
417
    *
418
    * @param    int     The start number
419
    * @param    int     The end number
420
    * @param    int     Increment by this value
421
    * @access   private
422
    * @return   array   An array of numeric options.
423
    */
424
    function _createOptionList($start, $end, $step = 1)
425
    {
426
        for ($i = $start, $options = array(); $start > $end? $i >= $end: $i <= $end; $i += $step) {
427
            $options[$i] = sprintf('%02d', $i);
428
        }
429
        return $options;
430
    }
431
432
    // }}}
433
    // {{{ _trimLeadingZeros()
434
435
   /**
436
    * Trims leading zeros from the (numeric) string
437
    *
438
    * @param    string  A numeric string, possibly with leading zeros
439
    * @return   string  String with leading zeros removed
440
    */
441
    function _trimLeadingZeros($str)
442
    {
443
        if (0 == strcmp($str, $this->_options['emptyOptionValue'])) {
444
            return $str;
445
        }
446
        $trimmed = ltrim($str, '0');
447
        return strlen($trimmed)? $trimmed: '0';
448
    }
449
450
    // }}}
451
    // {{{ setValue()
452
453
    function setValue($value)
454
    {
455
        if (empty($value)) {
456
            $value = array();
457
        } elseif (is_scalar($value)) {
458
            if (!is_numeric($value)) {
459
                $value = strtotime($value);
460
            }
461
            // might be a unix epoch, then we fill all possible values
462
            $arr = explode('-', date('w-j-n-Y-g-G-i-s-a-A-W', (int)$value));
463
            $value = array(
464
                'D' => $arr[0],
465
                'l' => $arr[0],
466
                'd' => $arr[1],
467
                'M' => $arr[2],
468
                'm' => $arr[2],
469
                'F' => $arr[2],
470
                'Y' => $arr[3],
471
                'y' => $arr[3],
472
                'h' => $arr[4],
473
                'g' => $arr[4],
474
                'H' => $arr[5],
475
                'i' => $this->_trimLeadingZeros($arr[6]),
476
                's' => $this->_trimLeadingZeros($arr[7]),
477
                'a' => $arr[8],
478
                'A' => $arr[9],
479
                'W' => $this->_trimLeadingZeros($arr[10])
480
            );
481
        } else {
482
            $value = array_map(array($this, '_trimLeadingZeros'), $value);
483
        }
484
        parent::setValue($value);
485
    }
486
487
    // }}}
488
    // {{{ toHtml()
489
490
    function toHtml()
491
    {
492
        include_once 'HTML/QuickForm/Renderer/Default.php';
493
        $renderer = new HTML_QuickForm_Renderer_Default();
494
        $renderer->setElementTemplate('{element}');
495
        parent::accept($renderer);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (accept() instead of toHtml()). Are you sure this is correct? If so, you might want to change this to $this->accept().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
496
        return $this->_wrap[0] . $renderer->toHtml() . $this->_wrap[1];
497
    }
498
499
    // }}}
500
    // {{{ accept()
501
502
    function accept(&$renderer, $required = false, $error = null)
503
    {
504
        $renderer->renderElement($this, $required, $error);
505
    }
506
507
    // }}}
508
    // {{{ onQuickFormEvent()
509
510
    function onQuickFormEvent($event, $arg, &$caller)
511
    {
512
        if ('updateValue' == $event) {
513
            // we need to call setValue(), 'cause the default/constant value
514
            // may be in fact a timestamp, not an array
515
            return HTML_QuickForm_element::onQuickFormEvent($event, $arg, $caller);
516
        } else {
517
            return parent::onQuickFormEvent($event, $arg, $caller);
518
        }
519
    }
520
}
521