HTML_QuickForm
[ class tree: HTML_QuickForm ] [ index: HTML_QuickForm ] [ all elements ]

Source for file date.php

Documentation is available at date.php

  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. //
  21. // $Id: date.php,v 1.55 2005/08/04 20:39:05 avb Exp $
  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. {
  36.     // {{{ properties
  37.  
  38.    /**
  39.     * Various options to control the element's display.
  40.     * 
  41.     * Currently known options are
  42.     * 'language': date language
  43.     * 'format': Format of the date, based on PHP's date() function.
  44.     *     The following characters are recognised in format string:
  45.     *       D => Short names of days
  46.     *       l => Long names of days
  47.     *       d => Day numbers
  48.     *       M => Short names of months
  49.     *       F => Long names of months
  50.     *       m => Month numbers
  51.     *       Y => Four digit year
  52.     *       y => Two digit year
  53.     *       h => 12 hour format
  54.     *       H => 23 hour  format
  55.     *       i => Minutes
  56.     *       s => Seconds
  57.     *       a => am/pm
  58.     *       A => AM/PM
  59.     * 'minYear': Minimum year in year select
  60.     * 'maxYear': Maximum year in year select
  61.     * 'addEmptyOption': Should an empty option be added to the top of
  62.     *     each select box?
  63.     * 'emptyOptionValue': The value passed by the empty option.
  64.     * 'emptyOptionText': The text displayed for the empty option.
  65.     * 'optionIncrement': Step to increase the option values by (works for 'i' and 's')
  66.     * 
  67.     * @access   private
  68.     * @var      array 
  69.     */
  70.     var $_options = array(
  71.         'language'         => 'en',
  72.         'format'           => 'dMY',
  73.         'minYear'          => 2001,
  74.         'maxYear'          => 2010,
  75.         'addEmptyOption'   => false,
  76.         'emptyOptionValue' => '',
  77.         'emptyOptionText'  => '&nbsp;',
  78.         'optionIncrement'  => array('i' => 1's' => 1)
  79.     );
  80.  
  81.    /**
  82.     * These complement separators, they are appended to the resultant HTML
  83.     * @access   private
  84.     * @var      array 
  85.     */
  86.     var $_wrap = array('''');
  87.  
  88.    /**
  89.     * Options in different languages
  90.     * 
  91.     * Note to potential translators: to avoid encoding problems please send
  92.     * your translations with "weird" letters encoded as HTML Unicode entities
  93.     * 
  94.     * @access   private
  95.     * @var      array 
  96.     */
  97.     var $_locale = array(
  98.         'en'    => array (
  99.             'weekdays_short'=> array ('Sun''Mon''Tue''Wed''Thu''Fri''Sat'),
  100.             'weekdays_long' => array ('Sunday''Monday''Tuesday''Wednesday''Thursday''Friday''Saturday'),
  101.             'months_short'  => array ('Jan''Feb''Mar''Apr''May''Jun''Jul''Aug''Sep''Oct''Nov''Dec'),
  102.             'months_long'   => array ('January''February''March''April''May''June''July''August''September''October''November''December')
  103.         ),
  104.         'de'    => array (
  105.             'weekdays_short'=> array ('So''Mon''Di''Mi''Do''Fr''Sa'),
  106.             'weekdays_long' => array ('Sonntag''Montag''Dienstag''Mittwoch''Donnerstag''Freitag''Samstag'),
  107.             'months_short'  => array ('Jan''Feb''M&#xe4;rz''April''Mai''Juni''Juli''Aug''Sept''Okt''Nov''Dez'),
  108.             'months_long'   => array ('Januar''Februar''M&#xe4;rz''April''Mai''Juni''Juli''August''September''Oktober''November''Dezember')
  109.         ),
  110.         'fr'    => array (
  111.             'weekdays_short'=> array ('Dim''Lun''Mar''Mer''Jeu''Ven''Sam'),
  112.             'weekdays_long' => array ('Dimanche''Lundi''Mardi''Mercredi''Jeudi''Vendredi''Samedi'),
  113.             'months_short'  => array ('Jan''F&#xe9;v''Mar''Avr''Mai''Juin''Juil''Ao&#xfb;t''Sep''Oct''Nov''D&#xe9;c'),
  114.             'months_long'   => array ('Janvier''F&#xe9;vrier''Mars''Avril''Mai''Juin''Juillet''Ao&#xfb;t''Septembre''Octobre''Novembre''D&#xe9;cembre')
  115.         ),
  116.         'hu'    => array (
  117.             'weekdays_short'=> array ('V''H''K''Sze''Cs''P''Szo'),
  118.             'weekdays_long' => array ('vas&#xe1;rnap''h&#xe9;tf&#x151;''kedd''szerda''cs&#xfc;t&#xf6;rt&#xf6;k''p&#xe9;ntek''szombat'),
  119.             'months_short'  => array ('jan''feb''m&#xe1;rc''&#xe1;pr''m&#xe1;j''j&#xfa;n''j&#xfa;l''aug''szept''okt''nov''dec'),
  120.             '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')
  121.         ),
  122.         'pl'    => array (
  123.             'weekdays_short'=> array ('Nie''Pn''Wt''&#x15a;r''Czw''Pt''Sob'),
  124.             'weekdays_long' => array ('Niedziela''Poniedzia&#x142;ek''Wtorek''&#x15a;roda''Czwartek''Pi&#x105;tek''Sobota'),
  125.             'months_short'  => array ('Sty''Lut''Mar''Kwi''Maj''Cze''Lip''Sie''Wrz''Pa&#x17a;''Lis''Gru'),
  126.             'months_long'   => array ('Stycze&#x144;''Luty''Marzec''Kwiecie&#x144;''Maj''Czerwiec''Lipiec''Sierpie&#x144;''Wrzesie&#x144;''Pa&#x17a;dziernik''Listopad''Grudzie&#x144;')
  127.         ),
  128.         'sl'    => array (
  129.             'weekdays_short'=> array ('Ned''Pon''Tor''Sre''Cet''Pet''Sob'),
  130.             'weekdays_long' => array ('Nedelja''Ponedeljek''Torek''Sreda''Cetrtek''Petek''Sobota'),
  131.             'months_short'  => array ('Jan''Feb''Mar''Apr''Maj''Jun''Jul''Avg''Sep''Okt''Nov''Dec'),
  132.             'months_long'   => array ('Januar''Februar''Marec''April''Maj''Junij''Julij''Avgust''September''Oktober''November''December')
  133.         ),
  134.         'ru'    => array (
  135.             'weekdays_short'=> array ('&#x412;&#x441;''&#x41f;&#x43d;''&#x412;&#x442;''&#x421;&#x440;''&#x427;&#x442;''&#x41f;&#x442;''&#x421;&#x431;'),
  136.             '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;'),
  137.             '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;'),
  138.             '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;')
  139.         ),
  140.         'es'    => array (
  141.             'weekdays_short'=> array ('Dom''Lun''Mar''Mi&#xe9;''Jue''Vie''S&#xe1;b'),
  142.             'weekdays_long' => array ('Domingo''Lunes''Martes''Mi&#xe9;rcoles''Jueves''Viernes''S&#xe1;bado'),
  143.             'months_short'  => array ('Ene''Feb''Mar''Abr''May''Jun''Jul''Ago''Sep''Oct''Nov''Dic'),
  144.             'months_long'   => array ('Enero''Febrero''Marzo''Abril''Mayo''Junio''Julio''Agosto''Septiembre''Octubre''Noviembre''Diciembre')
  145.         ),
  146.         'da'    => array (
  147.             'weekdays_short'=> array ('S&#xf8;n''Man''Tir''Ons''Tor''Fre''L&#xf8;r'),
  148.             'weekdays_long' => array ('S&#xf8;ndag''Mandag''Tirsdag''Onsdag''Torsdag''Fredag''L&#xf8;rdag'),
  149.             'months_short'  => array ('Jan''Feb''Mar''Apr''Maj''Jun''Jul''Aug''Sep''Okt''Nov''Dec'),
  150.             'months_long'   => array ('Januar''Februar''Marts''April''Maj''Juni''Juli''August''September''Oktober''November''December')
  151.         ),
  152.         'is'    => array (
  153.             'weekdays_short'=> array ('Sun''M&#xe1;n''&#xde;ri''Mi&#xf0;''Fim''F&#xf6;s''Lau'),
  154.             'weekdays_long' => array ('Sunnudagur''M&#xe1;nudagur''&#xde;ri&#xf0;judagur''Mi&#xf0;vikudagur''Fimmtudagur''F&#xf6;studagur''Laugardagur'),
  155.             'months_short'  => array ('Jan''Feb''Mar''Apr''Ma&#xed;''J&#xfa;n''J&#xfa;l''&#xc1;g&#xfa;''Sep''Okt''N&#xf3;v''Des'),
  156.             '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')
  157.         ),
  158.         'it'    => array (
  159.             'weekdays_short'=> array ('Dom''Lun''Mar''Mer''Gio''Ven''Sab'),
  160.             'weekdays_long' => array ('Domenica''Luned&#xec;''Marted&#xec;''Mercoled&#xec;''Gioved&#xec;''Venerd&#xec;''Sabato'),
  161.             'months_short'  => array ('Gen''Feb''Mar''Apr''Mag''Giu''Lug''Ago''Set''Ott''Nov''Dic'),
  162.             'months_long'   => array ('Gennaio''Febbraio''Marzo''Aprile''Maggio''Giugno''Luglio''Agosto''Settembre''Ottobre''Novembre''Dicembre')
  163.         ),
  164.         'sk'    => array (
  165.             'weekdays_short'=> array ('Ned''Pon''Uto''Str''&#x8a;tv''Pia''Sob'),
  166.             'weekdays_long' => array ('Nede&#x17e;a''Pondelok''Utorok''Streda''&#x8a;tvrtok''Piatok''Sobota'),
  167.             'months_short'  => array ('Jan''Feb''Mar''Apr''M&#xe1;j''J&#xfa;n''J&#xfa;l''Aug''Sep''Okt''Nov''Dec'),
  168.             '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')
  169.         ),
  170.         'cs'    => array (
  171.             'weekdays_short'=> array ('Ne''Po''&#xda;t''St''&#x10c;t''P&#xe1;''So'),
  172.             'weekdays_long' => array ('Ned&#x11b;le''Pond&#x11b;l&#xed;''&#xda;ter&#xfd;''St&#x159;eda''&#x10c;tvrtek''P&#xe1;tek''Sobota'),
  173.             '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'),
  174.             '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')
  175.         ),
  176.         'hy'    => array (
  177.             'weekdays_short'=> array ('&#x53f;&#x580;&#x56f;''&#x535;&#x580;&#x56f;''&#x535;&#x580;&#x584;''&#x549;&#x580;&#x584;''&#x540;&#x576;&#x563;''&#x548;&#x582;&#x580;''&#x547;&#x562;&#x569;'),
  178.             '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;'),
  179.             '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;'),
  180.             '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;')
  181.         ),
  182.         'nl'    => array (
  183.             'weekdays_short'=> array ('Zo''Ma''Di''Wo''Do''Vr''Za'),
  184.             'weekdays_long' => array ('Zondag''Maandag''Dinsdag''Woensdag''Donderdag''Vrijdag''Zaterdag'),
  185.             'months_short'  => array ('Jan''Feb''Mar''Apr''Mei''Jun''Jul''Aug''Sep''Okt''Nov''Dec'),
  186.             'months_long'   => array ('Januari''Februari''Maart''April''Mei''Juni''Juli''Augustus''September''Oktober''November''December')
  187.         ),
  188.         'et'    => array (
  189.             'weekdays_short'=> array ('P''E''T''K''N''R''L'),
  190.             'weekdays_long' => array ('P&#xfc;hap&#xe4;ev''Esmasp&#xe4;ev''Teisip&#xe4;ev''Kolmap&#xe4;ev''Neljap&#xe4;ev''Reede''Laup&#xe4;ev'),
  191.             'months_short'  => array ('Jaan''Veebr''M&#xe4;rts''Aprill''Mai''Juuni''Juuli''Aug''Sept''Okt''Nov''Dets'),
  192.             'months_long'   => array ('Jaanuar''Veebruar''M&#xe4;rts''Aprill''Mai''Juuni''Juuli''August''September''Oktoober''November''Detsember')
  193.         ),
  194.         'tr'    => array (
  195.             'weekdays_short'=> array ('Paz''Pzt''Sal''&#xc7;ar''Per''Cum''Cts'),
  196.             'weekdays_long' => array ('Pazar''Pazartesi''Sal&#x131;''&#xc7;ar&#x15f;amba''Per&#x15f;embe''Cuma''Cumartesi'),
  197.             'months_short'  => array ('Ock''&#x15e;bt''Mrt''Nsn''Mys''Hzrn''Tmmz''A&#x11f;st''Eyl''Ekm''Ksm''Arlk'),
  198.             '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')
  199.         ),
  200.         'no'    => array (
  201.             'weekdays_short'=> array ('S&#xf8;n''Man''Tir''Ons''Tor''Fre''L&#xf8;r'),
  202.             'weekdays_long' => array ('S&#xf8;ndag''Mandag''Tirsdag''Onsdag''Torsdag''Fredag''L&#xf8;rdag'),
  203.             'months_short'  => array ('Jan''Feb''Mar''Apr''Mai''Jun''Jul''Aug''Sep''Okt''Nov''Des'),
  204.             'months_long'   => array ('Januar''Februar''Mars''April''Mai''Juni''Juli''August''September''Oktober''November''Desember')
  205.         ),
  206.         'eo'    => array (
  207.             'weekdays_short'=> array ('Dim''Lun''Mar''Mer''&#x134;a&#x16D;''Ven''Sab'),
  208.             'weekdays_long' => array ('Diman&#x109;o''Lundo''Mardo''Merkredo''&#x134;a&#x16D;do''Vendredo''Sabato'),
  209.             'months_short'  => array ('Jan''Feb''Mar''Apr''Maj''Jun''Jul''A&#x16D;g''Sep''Okt''Nov''Dec'),
  210.             'months_long'   => array ('Januaro''Februaro''Marto''Aprilo''Majo''Junio''Julio''A&#x16D;gusto''Septembro''Oktobro''Novembro''Decembro')
  211.         ),
  212.         'ua'    => array (
  213.             'weekdays_short'=> array('&#x41d;&#x434;&#x43b;''&#x41f;&#x43d;&#x434;''&#x412;&#x442;&#x440;''&#x421;&#x440;&#x434;''&#x427;&#x442;&#x432;''&#x41f;&#x442;&#x43d;''&#x421;&#x431;&#x442;'),
  214.             '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;'),
  215.             '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;'),
  216.             '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;')
  217.         ),
  218.         'ro'    => array (
  219.             'weekdays_short'=> array ('Dum''Lun''Mar''Mie''Joi''Vin''Sam'),
  220.             'weekdays_long' => array ('Duminica''Luni''Marti''Miercuri''Joi''Vineri''Sambata'),
  221.             'months_short'  => array ('Ian''Feb''Mar''Apr''Mai''Iun''Iul''Aug''Sep''Oct''Nov''Dec'),
  222.             'months_long'   => array ('Ianuarie''Februarie''Martie''Aprilie''Mai''Iunie''Iulie''August''Septembrie''Octombrie''Noiembrie''Decembrie')
  223.         ),
  224.         'he'    => array (
  225.             '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;'),
  226.             '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;'),
  227.             '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;'),
  228.             '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;')
  229.         ),
  230.         'sv'    => array (
  231.             'weekdays_short'=> array ('S&#xf6;n''M&#xe5;n''Tis''Ons''Tor''Fre''L&#xf6;r'),
  232.             'weekdays_long' => array ('S&#xf6;ndag''M&#xe5;ndag''Tisdag''Onsdag''Torsdag''Fredag''L&#xf6;rdag'),
  233.             'months_short'  => array ('Jan''Feb''Mar''Apr''Maj''Jun''Jul''Aug''Sep''Okt''Nov''Dec'),
  234.             'months_long'   => array ('Januari''Februari''Mars''April''Maj''Juni''Juli''Augusti''September''Oktober''November''December')
  235.         ),
  236.         'pt'    => array (
  237.             'weekdays_short'=> array ('Dom''Seg''Ter''Qua''Qui''Sex''S&aacute;b'),
  238.             'weekdays_long' => array ('Domingo''Segunda-feira''Ter&ccedil;a-feira''Quarta-feira''Quinta-feira''Sexta-feira''S&aacute;bado'),
  239.             'months_short'  => array ('Jan''Fev''Mar''Abr''Mai''Jun''Jul''Ago''Set''Out''Nov''Dez'),
  240.             'months_long'   => array ('Janeiro''Fevereiro''Mar&ccedil;o''Abril''Maio''Junho''Julho''Agosto''Setembro''Outubro''Novembro''Dezembro')
  241.         )    
  242.     );
  243.  
  244.     // }}}
  245.     // {{{ constructor
  246.  
  247.    /**
  248.     * Class constructor
  249.     * 
  250.     * @access   public
  251.     * @param    string  Element's name
  252.     * @param    mixed   Label(s) for an element
  253.     * @param    array   Options to control the element's display
  254.     * @param    mixed   Either a typical HTML attribute string or an associative array
  255.     */
  256.     function HTML_QuickForm_date($elementName = null$elementLabel = null$options = array()$attributes = null)
  257.     {
  258.         $this->HTML_QuickForm_element($elementName$elementLabel$attributes);
  259.         $this->_persistantFreeze = true;
  260.         $this->_appendName = true;
  261.         $this->_type 'date';
  262.         // set the options, do not bother setting bogus ones
  263.         if (is_array($options)) {
  264.             foreach ($options as $name => $value{
  265.                 if ('language' == $name{
  266.                     $this->_options['language'= isset($this->_locale[$value])$value'en';
  267.                 elseif (isset($this->_options[$name])) {
  268.                     if (is_array($value)) {
  269.                         $this->_options[$name@array_merge($this->_options[$name]$value);
  270.                     else {
  271.                         $this->_options[$name$value;
  272.                     }
  273.                 }
  274.             }
  275.         }
  276.     }
  277.  
  278.     // }}}
  279.     // {{{ _createElements()
  280.  
  281.     function _createElements()
  282.     {
  283.         $this->_separator $this->_elements = array();
  284.         $separator =  '';
  285.         $locale    =$this->_locale[$this->_options['language']];
  286.         $backslash =  false;
  287.         for ($i = 0$length strlen($this->_options['format'])$i $length$i++{
  288.             $sign $this->_options['format']{$i};
  289.             if ($backslash{
  290.                 $backslash  = false;
  291.                 $separator .= $sign;
  292.             else {
  293.                 $loadSelect = true;
  294.                 switch ($sign{
  295.                     case 'D':
  296.                         // Sunday is 0 like with 'w' in date()
  297.                         $options $locale['weekdays_short'];
  298.                         break;
  299.                     case 'l':
  300.                         $options $locale['weekdays_long'];
  301.                         break;
  302.                     case 'd':
  303.                         $options $this->_createOptionList(131);
  304.                         break;
  305.                     case 'M':
  306.                         $options $locale['months_short'];
  307.                         array_unshift($options '');
  308.                         unset($options[0]);
  309.                         break;
  310.                     case 'm':
  311.                         $options $this->_createOptionList(112);
  312.                         break;
  313.                     case 'F':
  314.                         $options $locale['months_long'];
  315.                         array_unshift($options '');
  316.                         unset($options[0]);
  317.                         break;
  318.                     case 'Y':
  319.                         $options $this->_createOptionList(
  320.                             $this->_options['minYear'],
  321.                             $this->_options['maxYear']
  322.                             $this->_options['minYear'$this->_options['maxYear']? -1: 1
  323.                         );
  324.                         break;
  325.                     case 'y':
  326.                         $options $this->_createOptionList(
  327.                             $this->_options['minYear'],
  328.                             $this->_options['maxYear'],
  329.                             $this->_options['minYear'$this->_options['maxYear']? -1: 1
  330.                         );
  331.                         array_walk($optionscreate_function('&$v,$k','$v = substr($v,-2);'))
  332.                         break;
  333.                     case 'h':
  334.                         $options $this->_createOptionList(112);
  335.                         break;
  336.                     case 'g':
  337.                         $options $this->_createOptionList(112);
  338.                         array_walk($optionscreate_function('&$v,$k''$v = intval($v);'));
  339.                         break;
  340.                     case 'H':
  341.                         $options $this->_createOptionList(023);
  342.                         break;
  343.                     case 'i':
  344.                         $options $this->_createOptionList(059$this->_options['optionIncrement']['i']);
  345.                         break;
  346.                     case 's':
  347.                         $options $this->_createOptionList(059$this->_options['optionIncrement']['s']);
  348.                         break;
  349.                     case 'a':
  350.                         $options = array('am' => 'am''pm' => 'pm');
  351.                         break;
  352.                     case 'A':
  353.                         $options = array('AM' => 'AM''PM' => 'PM');
  354.                         break;
  355.                     case 'W':
  356.                         $options $this->_createOptionList(153);
  357.                         break;
  358.                     case '\\':
  359.                         $backslash  = true;
  360.                         $loadSelect = false;
  361.                         break;
  362.                     default:
  363.                         $separator .= (' ' == $sign'&nbsp;'$sign);
  364.                         $loadSelect = false;
  365.                 }
  366.     
  367.                 if ($loadSelect{
  368.                     if (0 < count($this->_elements)) {
  369.                         $this->_separator[$separator;
  370.                     else {
  371.                         $this->_wrap[0$separator;
  372.                     }
  373.                     $separator '';
  374.                     // Should we add an empty option to the top of the select?
  375.                     if (!is_array($this->_options['addEmptyOption']&& $this->_options['addEmptyOption'|| 
  376.                         is_array($this->_options['addEmptyOption']&& !empty($this->_options['addEmptyOption'][$sign])) {
  377.  
  378.                         // Using '+' array operator to preserve the keys
  379.                         if (is_array($this->_options['emptyOptionText']&& !empty($this->_options['emptyOptionText'][$sign])) {
  380.                             $options = array($this->_options['emptyOptionValue'=> $this->_options['emptyOptionText'][$sign]$options;
  381.                         else {
  382.                             $options = array($this->_options['emptyOptionValue'=> $this->_options['emptyOptionText']$options;
  383.                         }
  384.                     }
  385.                     $this->_elements[=new HTML_QuickForm_select($signnull$options$this->getAttributes());
  386.                 }
  387.             }
  388.         }
  389.         $this->_wrap[1$separator ($backslash'\\''');
  390.     }
  391.  
  392.     // }}}
  393.     // {{{ _createOptionList()
  394.  
  395.    /**
  396.     * Creates an option list containing the numbers from the start number to the end, inclusive
  397.     *
  398.     * @param    int     The start number
  399.     * @param    int     The end number
  400.     * @param    int     Increment by this value
  401.     * @access   private
  402.     * @return   array   An array of numeric options.
  403.     */
  404.     function _createOptionList($start$end$step = 1)
  405.     {
  406.         for ($i $start$options = array()$start $end$i >= $end$i <= $end$i += $step{
  407.             $options[$isprintf('%02d'$i);
  408.         }
  409.         return $options;
  410.     }
  411.  
  412.     // }}}
  413.     // {{{ setValue()
  414.  
  415.     function setValue($value)
  416.     {
  417.         if (empty($value)) {
  418.             $value = array();
  419.         elseif (is_scalar($value)) {
  420.             if (!is_numeric($value)) {
  421.                 $value strtotime($value);
  422.             }
  423.             // might be a unix epoch, then we fill all possible values
  424.             $arr explode('-'date('w-d-n-Y-h-H-i-s-a-A-W'(int)$value));
  425.             $value = array(
  426.                 'D' => $arr[0],
  427.                 'l' => $arr[0],
  428.                 'd' => $arr[1],
  429.                 'M' => $arr[2],
  430.                 'm' => $arr[2],
  431.                 'F' => $arr[2],
  432.                 'Y' => $arr[3],
  433.                 'y' => $arr[3],
  434.                 'h' => $arr[4],
  435.                 'g' => $arr[4],
  436.                 'H' => $arr[5],
  437.                 'i' => $arr[6],
  438.                 's' => $arr[7],
  439.                 'a' => $arr[8],
  440.                 'A' => $arr[9],
  441.                 'W' => $arr[10]
  442.             );
  443.         }
  444.         parent::setValue($value);
  445.     }
  446.  
  447.     // }}}
  448.     // {{{ toHtml()
  449.  
  450.     function toHtml()
  451.     {
  452.         include_once('HTML/QuickForm/Renderer/Default.php');
  453.         $renderer =new HTML_QuickForm_Renderer_Default();
  454.         $renderer->setElementTemplate('{element}');
  455.         parent::accept($renderer);
  456.         return $this->_wrap[0$renderer->toHtml($this->_wrap[1];
  457.     }
  458.  
  459.     // }}}
  460.     // {{{ accept()
  461.  
  462.     function accept(&$renderer$required = false$error = null)
  463.     {
  464.         $renderer->renderElement($this$required$error);
  465.     }
  466.  
  467.     // }}}
  468.     // {{{ onQuickFormEvent()
  469.  
  470.     function onQuickFormEvent($event$arg&$caller)
  471.     {
  472.         if ('updateValue' == $event{
  473.             // we need to call setValue(), 'cause the default/constant value
  474.             // may be in fact a timestamp, not an array
  475.             return HTML_QuickForm_element::onQuickFormEvent($event$arg$caller);
  476.         else {
  477.             return parent::onQuickFormEvent($event$arg$caller);
  478.         }
  479.     }
  480.  
  481.     // }}}
  482. }
  483. ?>

Documentation generated on Mon, 11 Mar 2019 14:16:31 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.