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

Source for file DateSelect.class.php

Documentation is available at DateSelect.class.php

  1. <?php
  2. /**
  3.  * For including this file you have to define the constant "CLASSPATH".
  4.  * Because every include in the framework depends on the CLASSPATH definition.
  5.  * The CLASSPATH means the relative path to the folder that contains the
  6.  * framework GilliGan.
  7.  *
  8.  * @package    forms
  9.  * @subpackage items
  10.  */
  11. if!defined"CLASSPATH" ) )
  12. {
  13.   echo "<h3>You have to define the constant CLASSPATH!</h3>\n";
  14.   echo "Example: define( 'CLASSPATH', '../path/to/classes/' );\n";
  15.   exit();
  16. }
  17.  
  18. /**
  19.  *
  20.  */
  21. require_once CLASSPATH."forms/items/HTMLSelect.class.php";
  22. /**
  23.  *
  24.  */
  25. require_once CLASSPATH."forms/items/ABSTHTMLFormItem.class.php";
  26. /**
  27.  *
  28.  */
  29. require_once CLASSPATH."core/DateFormatter.class.php";
  30. /**
  31.  *
  32.  */
  33. include_once CLASSPATH."core/Numbers.class.php";
  34. /**
  35.  *
  36.  */
  37. include_once CLASSPATH."core/Strings.class.php";
  38.  
  39. /**
  40.  * @package    forms
  41.  * @subpackage items
  42.  * @version    0.4.45
  43.  * @author     Daniel Plücken <daniel@debakel.net>
  44.  * @license    http://www.gnu.org/copyleft/lesser.html
  45.  *              GNU Lesser General Public License
  46.  * @copyright  Copyright (C) 2003 Daniel Plücken <daniel@debakel.net>
  47.  *
  48.  *  This library is free software; you can redistribute it and/or
  49.  *  modify it under the terms of the GNU Lesser General Public
  50.  *  License as published by the Free Software Foundation; either
  51.  *  version 2.1 of the License.
  52.  *
  53.  *  This library is distributed in the hope that it will be useful,
  54.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  55.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  56.  *  GNU Lesser General Public License for more details.
  57.  *
  58.  *  You should have received a copy of the GNU Lesser General
  59.  *  Public License along with this library; if not, write to the
  60.  *  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  61.  *  Boston, MA 02111-1307 USA
  62.  */
  63. class DateSelect extends ABSTHTMLFormItem
  64. {
  65.   /**
  66.    * @var    array   $SETTING 
  67.    * @access private
  68.    */
  69.   var $SETTING;
  70.  
  71.   /**
  72.    * @var    int     $timestamp 
  73.    * @access private
  74.    */
  75.   var $timestamp;
  76.  
  77.   /**
  78.    * @var    string  $standard_date_format 
  79.    * @access private
  80.    */
  81.   var $standard_date_format = "timestamp";
  82.  
  83.   /**
  84.    * @var    HTMLSelect $secondSelect 
  85.    * @access private
  86.    */
  87.   var $secondSelect = null;
  88.   /**
  89.    * @var    HTMLSelect $minuteSelect 
  90.    * @access private
  91.    */
  92.   var $minuteSelect = null;
  93.   /**
  94.    * @var    HTMLSelect $hourSelect 
  95.    * @access private
  96.    */
  97.   var $hourSelect = null;
  98.   /**
  99.    * @var    HTMLSelect $daySelect 
  100.    * @access private
  101.    */
  102.   var $daySelect = null;
  103.   /**
  104.    * @var    HTMLSelect $weekdaySelect 
  105.    * @access private
  106.    */
  107.   var $weekdaySelect = null;
  108.   /**
  109.    * @var    HTMLSelect $weeknumSelect 
  110.    * @access private
  111.    */
  112.   var $weeknumSelect = null;
  113.   /**
  114.    * @var    HTMLSelect $monthSelect 
  115.    * @access private
  116.    */
  117.   var $monthSelect = null;
  118.   /**
  119.    * @var    HTMLSelect $yearSelect 
  120.    * @access private
  121.    */
  122.   var $yearSelect = null;
  123.  
  124.   /**
  125.    * @var    boolean $jscheck 
  126.    * @access private
  127.    */
  128.   var $jscheck = true;
  129.   /**
  130.    * @var    boolean $onlyfuturedates 
  131.    * @access private
  132.    */
  133.   var $onlyfuturedates = false;
  134.   /**
  135.    * @var    string  $onlyfutureJSerrMSG 
  136.    * @access private
  137.    */
  138.   var $onlyfutureJSerrMSG = "Der Termin liegt in der Vergangenheit!";
  139.   /**
  140.    * @var    string  $output_order_str 
  141.    * @access public
  142.    */
  143.   var $output_template_str = "{#WEEKDAY#}\r\n{#DAY#}\r\n{#MONTH#}\r\n{#WEEKNUM#}\r\n{#YEAR#}\r\n{#HOUR#}\r\n{#MINUTE#}\r\n{#SECOND#}\r\n";
  144.  
  145.  
  146.   /**
  147.    * Constructor
  148.    *
  149.    * @version 1.4
  150.    * @since   0.1.0
  151.    * @author  Daniel Plücken <daniel@debakel.net>
  152.    * @access  public
  153.    * @param   string  $name 
  154.    * @param   integer $minuteintervall 
  155.    * @param   integer $secondintervall 
  156.    */
  157.   function DateSelect(
  158.                        $name "",
  159.                        $minuteinterval 5,
  160.                        $secondinterval 15
  161.                      )
  162.   {
  163.     $this->name = $name;
  164.     $this->SETTING["instance"]       $name;
  165.     if!preg_match"!^(?:\d+|0)$!"$minuteinterval ) )
  166.       $minuteinterval 5;
  167.     $this->SETTING["minuteinterval"$minuteinterval;
  168.     if!preg_match"!^(?:\d+|0)$!"$secondinterval ) )
  169.       $secondinterval 15;
  170.     $this->SETTING["secondinterval"$secondinterval;
  171.  
  172.     // stores which items were initialised
  173.     $this->SETTING["implementedSelects"]["SECOND"]   false;
  174.     $this->SETTING["implementedSelects"]["MINUTE"]   false;
  175.     $this->SETTING["implementedSelects"]["HOUR"]     false;
  176.     $this->SETTING["implementedSelects"]["DAY"]      false;
  177.     $this->SETTING["implementedSelects"]["WEEKDAYS"false;
  178.     $this->SETTING["implementedSelects"]["WEEKNUM"]  false;
  179.     $this->SETTING["implementedSelects"]["MONTH"]    false;
  180.     $this->SETTING["implementedSelects"]["YEAR"]     false;
  181.  
  182.     // stores this items who should not appear
  183.     $this->SETTING["hidden"]["SECOND"]   false;
  184.     $this->SETTING["hidden"]["MINUTE"]   false;
  185.     $this->SETTING["hidden"]["HOUR"]     false;
  186.     $this->SETTING["hidden"]["DAY"]      false;
  187.     $this->SETTING["hidden"]["WEEKDAYS"false;
  188.     $this->SETTING["hidden"]["WEEKNUM"]  false;
  189.     $this->SETTING["hidden"]["MONTH"]    false;
  190.     $this->SETTING["hidden"]["YEAR"]     false;
  191.   }
  192.  
  193.  
  194.  
  195.   /**
  196.    * This sets how the selected date should be standardly handled. The Following
  197.    * values are allowed:
  198.    *   - ISO       - Means that the selected value of this widget will be put in
  199.    *                 a database relation in an ISO-Format, if it is a member of
  200.    *                 a DBTfillingForm.
  201.    *   - TIMESTAMP - Means that the selected value of this widget will be put in
  202.    *                 a database relation in an UNIX-Timestamp-Format, if it is a
  203.    *                 member of a DBTfillingForm. This is the first standard if
  204.    *                 no other declaration was made.
  205.    *
  206.    * @version 1.0
  207.    * @since   0.4.3
  208.    * @author  Daniel Plücken <daniel@debakel.net>
  209.    * @access  public
  210.    * @param   string $str_kind 
  211.    * @return  void 
  212.    */
  213.   function setStandardDateFormat$str_kind )
  214.   {
  215.      if preg_match"!^ISO!i"$str_kind ) )
  216.         $this->standard_date_format = "ISO";
  217.      else
  218.         $this->standard_date_format = "TIMESTAMP";
  219.   }
  220.  
  221.  
  222.  
  223.   /**
  224.    * This sets in which order the selects should be output.
  225.    * You can use following placeholders:
  226.    *   - {#WEEKDAY#} - For the weekdays select
  227.    *   - {#DAY#}     - For the days select.
  228.    *   - {#MONTH#}   - For the months select.
  229.    *   - {#YEAR#}    - For the years select.
  230.    *   - {#HOUR#}    - For the hours select.
  231.    *   - {#MINUTE#}  - For the minutes select.
  232.    *   - {#SECOND#}  - For the seconds select.
  233.    *   - {#WEEKNUM#} - For the weeknums select.
  234.    *
  235.    * @version 1.0
  236.    * @since   0.4.4
  237.    * @author  Daniel Plücken <daniel@debakel.net>
  238.    * @access  public
  239.    * @param   string $str_template 
  240.    * @return  void 
  241.    */
  242.   function setOutputTemplate$str_template )
  243.   $this->output_template_str = $str_template}
  244.  
  245.  
  246.  
  247.   /**
  248.    * Sets the values of the select group with the given timestamp.
  249.    *
  250.    * @version 1.01
  251.    * @since   0.1.4
  252.    * @author  Daniel Plücken <daniel@debakel.net>
  253.    * @access  public
  254.    * @param   integer $timestamp 
  255.    * @return  void 
  256.    */
  257.   function setTimestamp$timestamp )
  258.   {
  259.       if $timestamp )
  260.          return;
  261.  
  262.       $fortimes 60 $this->SETTING["secondinterval"];
  263.       # Get the right second to select
  264.       $selectedValue Numbers::getIntervalRoundingOf(
  265.                                             date"s"$timestamp ),
  266.                                             60$fortimes
  267.                                                      );
  268.  
  269.  
  270.       $fortimes2 60 $this->SETTING["minuteinterval"];
  271.       # Get the right minute to select
  272.       $selectedValue2 Numbers::getIntervalRoundingOf(
  273.                                             date"i"$timestamp ),
  274.                                             60$fortimes2
  275.                                                       );
  276.  
  277.       ifis_a$this->secondSelect"HTMLSelect" )  )
  278.         $this->secondSelect->value $selectedValue;
  279.  
  280.       ifis_a$this->minuteSelect"HTMLSelect" )  )
  281.         $this->minuteSelect->value $selectedValue2;
  282.  
  283.       ifis_a$this->hourSelect"HTMLSelect" )  )
  284.         $this->hourSelect->value date"H"$timestamp );
  285.  
  286.       ifis_a$this->daySelect"HTMLSelect" )  )
  287.         $this->daySelect->value date"d"$timestamp );
  288.  
  289.       ifis_a$this->weekdaySelect"HTMLSelect" )  )
  290.         $this->weekdaySelect->value DateFormatter
  291.                                     ::extractWeekDayFromTimestamp$timestamp );
  292.  
  293.       ifis_a$this->weeknumSelect"HTMLSelect" ) )
  294.         $this->weeknumSelect->value DateFormatter
  295.                                     ::extractWeeknumFromTimestamp$timestamp );
  296.  
  297.       ifis_a$this->monthSelect"HTMLSelect" )  )
  298.         $this->monthSelect->value date"m"$timestamp );
  299.  
  300.       ifis_a$this->yearSelect"HTMLSelect" )  )
  301.         $this->yearSelect->value date"Y"$timestamp );
  302.   }
  303.  
  304.  
  305.  
  306.   /**
  307.    * Sets the values of the select group with the given ISO date.
  308.    *
  309.    * @version 1.0
  310.    * @since   0.4.1
  311.    * @author  Daniel Plücken <daniel@debakel.net>
  312.    * @access  public
  313.    * @param   integer $str_iso_date 
  314.    * @return  void 
  315.    */
  316.   function setISODate$str_iso_date )
  317.   {
  318.      $this->setTimestamp(
  319.                  DateFormatter
  320.                  ::getTimestampFromISODate$str_iso_date )
  321.                         );
  322.   }
  323.  
  324.  
  325.  
  326.   /**
  327.    * Returns a clone of this object.
  328.    *
  329.    * @version 1.0
  330.    * @since   0.1.4
  331.    * @author  Daniel Plücken <daniel@debakel.net>
  332.    * @access  public
  333.    * @param   string $newName 
  334.    * @return  object 
  335.    */
  336.   function getClone$newName "" )
  337.   {
  338.       $newInstance new DateSelect(
  339.                                       $newName,
  340.                                       $this->SETTING["minuteinterval"],
  341.                                       $this->SETTING["secondinterval"]
  342.                                    );
  343.  
  344.       $newInstance->SETTING["implementedSelects"]
  345.       = $this->SETTING["implementedSelects"];
  346.  
  347.       ifisset$this->secondSelect ) )
  348.         $newInstance->secondSelect $this->secondSelect->clone(
  349.                                                        'second'.$newName
  350.                                                                );
  351.       ifisset$this->minuteSelect ) )
  352.         $newInstance->minuteSelect $this->minuteSelect->clone(
  353.                                                        'minute'.$newName
  354.                                                                );
  355.       ifisset$this->hourSelect ) )
  356.         $newInstance->hourSelect $this->hourSelect->clone('hour'.$newName);
  357.  
  358.       ifisset$this->daySelect ) )
  359.         $newInstance->daySelect $this->daySelect->clone'day'.$newName );
  360.  
  361.       ifisset$this->weekdaySelect ) )
  362.         $newInstance->weekdaySelect $this->weekdaySelect->clone(
  363.                                                         'weekday'.$newName
  364.                                                                  );
  365.  
  366.       ifisset$this->weeknumSelect ) )
  367.         $newInstance->weeknumSelect $this->weeknumSelect->clone(
  368.                                                         'weeknum'.$newName
  369.                                                                  );
  370.       ifisset$this->monthSelect ) )
  371.         $newInstance->monthSelect $this->monthSelect->clone(
  372.                                                       'month'.$newName
  373.                                                              );
  374.       ifisset$this->yearSelect ) )
  375.         $newInstance->yearSelect $this->yearSelect->clone'year'.$newName );
  376.  
  377.       return $newInstance;
  378.   }
  379.  
  380.  
  381.  
  382.   /**
  383.    * Returns a generated string based on the attributes of this object's
  384.    * second-select.
  385.    *
  386.    * @version 1.2
  387.    * @since   0.1.0
  388.    * @author  Daniel Plücken <daniel@debakel.net>
  389.    * @access  public
  390.    * @return  string 
  391.    */
  392.   function getSecondSelect()
  393.   {
  394.     ifis_a$this->secondSelect"HTMLSelect" )  )
  395.     {
  396.       if!$this->enabled )
  397.         $this->secondSelect->setDisabled();
  398.  
  399.       $out $this->secondSelect->get();
  400.     }
  401.  
  402.     return $out;
  403.   }
  404.  
  405.  
  406.  
  407.  
  408.   /**
  409.    * Returns an iso date from a given timestamp or extracts the iso date from
  410.    * request data of a form component, that was generated with this class. In
  411.    * last case you only have to give in the name you used with the constructor
  412.    * to generate an object of this class. In both upper cases this method can be
  413.    * called statically. If no parameter was given, the method tries to get the
  414.    * date from class variable $timestamp, which can be set by the method
  415.    * setTimestamp() of this class.
  416.    *
  417.    * @access  public
  418.    * @version 1.01
  419.    * @since   0.4.42
  420.    *
  421.    * @param   mixed  $itemname_or_timestamp 
  422.    *
  423.    * @return  string 
  424.    */
  425.   function getISODate$itemname_or_timestamp "" )
  426.   {
  427.       if empty$itemname_or_timestamp ) )
  428.          return date"Y-m-d H:i:s"$this->timestamp );
  429.       if preg_match"!^\d+$!"$itemname_or_timestamp ) )
  430.          return date"Y-m-d H:i:s"$itemname_or_timestamp );
  431.       else
  432.       {
  433.          $day_str $_REQUEST"day".$itemname_or_timestamp ];
  434.          $month_str $_REQUEST"month".$itemname_or_timestamp ];
  435.          $year_str $_REQUEST"year".$itemname_or_timestamp ];
  436.          $hour_str $_REQUEST"hour".$itemname_or_timestamp ];
  437.          $minute_str $_REQUEST"minute".$itemname_or_timestamp ];
  438.          $second_str $_REQUEST"second".$itemname_or_timestamp ];
  439.  
  440.          return $year_str."-"
  441.                .Strings::leadingChar"0"$month_str)."-"
  442.                .Strings::leadingChar"0"$day_str)." "
  443.                .Strings::leadingChar"0"$hour_str).":"
  444.                .Strings::leadingChar"0"$minute_str).":"
  445.                .Strings::leadingChar"0"$second_str);
  446.  
  447.       }
  448.   }
  449.  
  450.  
  451.  
  452.   /**
  453.    * Returns the timestamp value that can compute from the values of the
  454.    * selects.
  455.    *
  456.    * @version 1.0
  457.    * @since   0.4.2
  458.    * @author  Daniel Plücken <daniel@debakel.net>
  459.    * @access  public
  460.    * @return  integer 
  461.    */
  462.   function getTimestamp()
  463.   {
  464.  
  465.       if (
  466.            !is_a$this->weekdaySelect"HTMLSelect" )
  467.         && !is_a$this->weeknumSelect"HTMLSelect" )
  468.          )
  469.       {
  470.         // normal case
  471.         $s 0;
  472.         if is_a$this->secondSelect"HTMLSelect" ) )
  473.            $s $this->secondSelect->getValue();
  474.  
  475.         $m 0;
  476.         if is_a$this->minuteSelect"HTMLSelect" ) )
  477.            $m $this->minuteSelect->getValue();
  478.  
  479.         $h 0;
  480.         if is_a$this->hourSelect"HTMLSelect" ) )
  481.            $h $this->hourSelect->getValue();
  482.  
  483.         $d 1;
  484.         if is_a$this->daySelect"HTMLSelect" ) )
  485.            $d $this->daySelect->getValue();
  486.  
  487.         $mt 1;
  488.         if is_a$this->monthSelect"HTMLSelect" ) )
  489.            $mt $this->monthSelect->getValue();
  490.  
  491.         $y 70;
  492.         if is_a$this->yearSelect"HTMLSelect" )  )
  493.            $y $this->yearSelect->getValue();
  494.  
  495.         return mktime$h$m$s$mt$d$y );
  496.       }
  497.   }
  498.  
  499.  
  500.  
  501.   /**
  502.    * Returns a generated string based on the attributes of this object's
  503.    * minute-select.
  504.    *
  505.    * @version 1.2
  506.    * @since   0.1.0
  507.    * @author  Daniel Plücken <daniel@debakel.net>
  508.    * @access  public
  509.    * @return  string 
  510.    */
  511.   function getMinuteSelect()
  512.   {
  513.       ifis_a$this->minuteSelect"HTMLSelect" ) )
  514.       {
  515.         if!$this->enabled )
  516.           $this->minuteSelect->setDisabled();
  517.  
  518.         $out $this->minuteSelect->get();
  519.       }
  520.  
  521.       return $out;
  522.   }
  523.  
  524.  
  525.  
  526.   /**
  527.    * Returns a generated string based on the attributes of this object's
  528.    * hour-select.
  529.    *
  530.    * @version 1.2
  531.    * @since   0.1.0
  532.    * @author  Daniel Plücken <daniel@debakel.net>
  533.    * @access  public
  534.    * @return  string 
  535.    */
  536.   function getHourSelect()
  537.   {
  538.     ifis_a$this->hourSelect"HTMLSelect" ) )
  539.     {
  540.       if!$this->enabled )
  541.         $this->hourSelect->setDisabled();
  542.  
  543.       $out $this->hourSelect->get();
  544.     }
  545.  
  546.     return $out;
  547.   }
  548.  
  549.  
  550.  
  551.   /**
  552.    * Returns a generated string based on the attributes of this object's
  553.    * day-select.
  554.    *
  555.    * @version 1.2
  556.    * @since   0.1.0
  557.    * @author  Daniel Plücken <daniel@debakel.net>
  558.    * @access  public
  559.    * @return  string 
  560.    */
  561.   function getDaySelect()
  562.   {
  563.     ifis_a$this->daySelect"HTMLSelect" ) )
  564.     {
  565.       if!$this->enabled )
  566.         $this->daySelect->setDisabled();
  567.  
  568.       $out $this->daySelect->get();
  569.     }
  570.  
  571.     return $out;
  572.   }
  573.  
  574.  
  575.  
  576.   /**
  577.    * Returns a generated string based on the attributes of this object's
  578.    * weekday-select.
  579.    *
  580.    * @version 1.2
  581.    * @since   0.1.0
  582.    * @author  Daniel Plücken <daniel@debakel.net>
  583.    * @access  public
  584.    * @return  string 
  585.    */
  586.   function getWeekDaySelect()
  587.   {
  588.     ifis_a$this->weekdaySelect"HTMLSelect" ) )
  589.     {
  590.       if!$this->enabled )
  591.         $this->weekdaySelect->setDisabled();
  592.  
  593.       $out $this->weekdaySelect->get();
  594.     }
  595.  
  596.     return $out;
  597.   }
  598.  
  599.  
  600.  
  601.   /**
  602.    * Returns a generated string based on the attributes of this object's
  603.    * minute-select.
  604.    *
  605.    * @version 1.1
  606.    * @since   0.1.0
  607.    * @author  Daniel Plücken <daniel@debakel.net>
  608.    * @access  public
  609.    * @return  string 
  610.    */
  611.   function getWeeknumSelect()
  612.   {
  613.     ifisset$this->weeknumSelect ) )
  614.     {
  615.       if!$this->enabled )
  616.         $this->weeknumSelect->setDisabled();
  617.  
  618.       $out $this->weeknumSelect->get();
  619.     }
  620.  
  621.     return $out;
  622.   }
  623.  
  624.  
  625.  
  626.   /**
  627.    * Returns a generated string based on the attributes of this object's
  628.    * minute-select.
  629.    *
  630.    * @version 1.1
  631.    * @since   0.1.0
  632.    * @author  Daniel Plücken <daniel@debakel.net>
  633.    * @access  public
  634.    * @return  string 
  635.    */
  636.   function getMonthSelect()
  637.   {
  638.     ifis_a$this->monthSelect"HTMLSelect" ) )
  639.     {
  640.       if!$this->enabled )
  641.         $this->monthSelect->setDisabled();
  642.  
  643.       $out $this->monthSelect->get();
  644.     }
  645.  
  646.     return $out;
  647.   }
  648.  
  649.  
  650.  
  651.   /**
  652.    * Returns a generated string based on the attributes of this object's
  653.    * minute-select.
  654.    *
  655.    * @version 1.2
  656.    * @since   0.1.0
  657.    * @author  Daniel Plücken <daniel@debakel.net>
  658.    * @access  public
  659.    * @return  string 
  660.    */
  661.   function getYearSelect()
  662.   {
  663.     ifis_a$this->yearSelect"HTMLSelect" ) )
  664.     {
  665.       if!$this->enabled )
  666.         $this->yearSelect->setDisabled();
  667.  
  668.       $out $this->yearSelect->get();
  669.     }
  670.  
  671.     return $out;
  672.   }
  673.  
  674.  
  675.  
  676.   /**
  677.    * With this method you can disable the checkup of guilty dates by
  678.    * javascript.
  679.    *
  680.    * @version 1.0
  681.    * @since   0.1.4
  682.    * @author  Daniel Plücken <daniel@debakel.net>
  683.    * @access  public
  684.    * @return  void 
  685.    */
  686.   function disableJSCheck()
  687.   $this->jscheck = false}
  688.  
  689.  
  690.  
  691.   /**
  692.    * With this method you can set the checkup of guilty dates in the future by
  693.    * javascript.
  694.    *
  695.    * @version 1.0
  696.    * @since   0.1.4
  697.    * @author  Daniel Plücken <daniel@debakel.net>
  698.    * @access  public
  699.    * @return  void 
  700.    */
  701.   function setOnlyFutureDates()
  702.   $this->onlyfuturedates = true}
  703.  
  704.  
  705.  
  706.   /**
  707.    * With this method you can set the message that should appear if the given
  708.    * date isn't a date in the future.
  709.    *
  710.    * @version 1.0
  711.    * @since   0.1.4
  712.    * @author  Daniel Plücken <daniel@debakel.net>
  713.    * @access  public
  714.    * @param   string $string 
  715.    * @return  void 
  716.    */
  717.   function setOnlyFutureErrMSG$string )
  718.   $this->onlyfutureJSerrMSG = rawurlencode$string )}
  719.  
  720.  
  721.  
  722.   /**
  723.    * Returns the name suffix of this select group.
  724.    *
  725.    * @version 1.0
  726.    * @since   0.1.4
  727.    * @author  Daniel Plücken <daniel@debakel.net>
  728.    * @access  public
  729.    * @return  string 
  730.    */
  731.   function getName()
  732.   return $this->SETTING["instance"]}
  733.  
  734.  
  735.  
  736.   /**
  737.    * Sets up the item to selecting the second of a date.
  738.    *
  739.    * @version 1.4
  740.    * @since   0.1.0
  741.    * @author  Daniel Plücken <daniel@debakel.net>
  742.    * @access  public
  743.    * @param   string  $selectedValue 
  744.    * @param   boolean $hidden 
  745.    * @param   boolean $show_emptylabel 
  746.    * @return  string 
  747.    */
  748.   function setSecondSelect(
  749.                             $selectedValue   "",
  750.                             $hidden          false,
  751.                             $show_emptylabel false
  752.                           )
  753.   {
  754.     $tmp_len 0;
  755.     if$show_emptylabel )
  756.     {
  757.       $valueArr[0"--";
  758.       $labelArr[0"--";
  759.       $tmp_len 1;
  760.     }
  761.  
  762.     $fortimes 60 $this->SETTING["secondinterval"];
  763.     for$i 0$i $fortimes $tmp_len$i++ )
  764.     {
  765.       $valueArr[$i"".($i $this->SETTING["secondinterval"]);
  766.       $labelArr[$i$valueArr[$i10 )
  767.                       ? "0".$valueArr[$i$valueArr[$i];
  768.     }
  769.  
  770.     # compute the right minute
  771.     ifpreg_match"!^(?:[0-5][0-9]|[0-9])$!"$selectedValue ) )
  772.       $selectedValue Numbers
  773.                      ::getIntervalRoundingOf$selectedValue60$fortimes );
  774.     else
  775.       $selectedValue "";
  776.  
  777.     ifis_bool$hidden ) )
  778.       $this->SETTING["hidden"]["SECOND"$hidden;
  779.  
  780.     $this->SETTING["implementedSelects"]["SECOND"true;
  781.     $onChangeOrder (
  782.                        $this->onlyfuturedates
  783.                     && $this->jscheck
  784.                      )
  785.                      ? "try { onlyFutureDate( this.name ); } "
  786.                       ."catch (e) {} finally {}"
  787.                      : "";
  788.  
  789.     $this->secondSelect = new HTMLSelect(
  790.                                             'second'.$this->SETTING["instance"],
  791.                                             $labelArr,
  792.                                             $valueArr,
  793.                                             $selectedValue,
  794.                                             $onChangeOrder,
  795.                                             false
  796.                                         );
  797.   }
  798.  
  799.  
  800.  
  801.   /**
  802.    * Sets up the item to selecting the minute of a date.
  803.    *
  804.    * @version 1.4
  805.    * @since   0.1.0
  806.    * @author  Daniel Plücken <daniel@debakel.net>
  807.    * @access  public
  808.    * @param   string  $selectedValue 
  809.    * @param   boolean $hidden 
  810.    * @param   boolean $show_emptylabel 
  811.    * @return  string 
  812.    */
  813.   function setMinuteSelect(
  814.                             $selectedValue   "",
  815.                             $hidden          false,
  816.                             $show_emptylabel false
  817.                           )
  818.   {
  819.     $tmp_len 0;
  820.     if$show_emptylabel )
  821.     {
  822.       $valueArr[0"--";
  823.       $labelArr[0"--";
  824.       $tmp_len 1;
  825.     }
  826.  
  827.     $fortimes 60 $this->SETTING["minuteinterval"];
  828.     for$i $tmp_len$i $fortimes $tmp_len$i++ )
  829.     {
  830.       $valueArr[$i"".(( $i $tmp_len $this->SETTING["minuteinterval"]);
  831.       $labelArr[$i$valueArr[$i10
  832.                       ? "0".$valueArr[$i]
  833.                       : $valueArr[$i];
  834.     }
  835.  
  836.     # compute the right minute
  837.     ifpreg_match"!^(?:[0-5][0-9]|[0-9])$!"$selectedValue ) )
  838.       $selectedValue Numbers
  839.                      ::getIntervalRoundingOf$selectedValue60$fortimes );
  840.     else
  841.       $selectedValue "";
  842.  
  843.     ifis_bool$hidden ) )
  844.       $this->SETTING["hidden"]["MINUTE"$hidden;
  845.  
  846.     $this->SETTING["implementedSelects"]["MINUTE"true;
  847.     $onChangeOrder (
  848.                        $this->onlyfuturedates
  849.                     && $this->jscheck
  850.                      )
  851.                      ? "try { onlyFutureDate( this.name ); } "
  852.                       ."catch (e) {} finally {}"
  853.                      : "";
  854.  
  855.     $this->minuteSelect = new HTMLSelect(
  856.                                             "minute".$this->SETTING["instance"],
  857.                                             $labelArr,
  858.                                             $valueArr,
  859.                                             $selectedValue,
  860.                                             $onChangeOrder,
  861.                                             false
  862.                                         );
  863.   }
  864.  
  865.  
  866.  
  867.   /**
  868.    * Sets up the item to selecting the hour of a date.
  869.    *
  870.    * @version 1.5
  871.    * @since   0.1.0
  872.    * @author  Daniel Plücken <daniel@debakel.net>
  873.    * @access  public
  874.    * @param   string  $selectedValue 
  875.    * @param   boolean $hidden 
  876.    * @param   boolean $show_emptylabel 
  877.    * @param   integer $begin 
  878.    * @param   integer $end 
  879.    * @return  string 
  880.    */
  881.   function setHourSelect(
  882.                           $selectedValue   "",
  883.                           $hidden          false,
  884.                           $show_emptylabel false,
  885.                           $begin           0,
  886.                           $end             23
  887.                         )
  888.   {
  889.     $tmp_len 0;
  890.     if$show_emptylabel )
  891.     {
  892.       $valueArr[0"--";
  893.       $labelArr[0"--";
  894.       $tmp_len 1;
  895.     }
  896.  
  897.     while$begin <= $end )
  898.     {
  899.       $tmp $begin $tmp_len;
  900.       $valueArr[$tmp"".$begin;
  901.       $labelArr[$tmp$valueArr[$tmp10
  902.                         ? "0".$valueArr[$tmp]
  903.                         : $valueArr[$tmp];
  904.       $begin++;
  905.     }
  906.  
  907.     # probe whether the hour is in the right range of values.
  908.     if!preg_match"!^(?:[01]?[0-9]|2[0-3])$!"$selectedValue ) )
  909.       $selectedValue "";
  910.  
  911.     ifis_bool$hidden ) )
  912.       $this->SETTING["hidden"]["HOUR"$hidden;
  913.  
  914.     $this->SETTING["implementedSelects"]["HOUR"true;
  915.     $onChangeOrder $this->onlyfuturedates
  916.                     && $this->jscheck )
  917.                      ? "try { onlyFutureDate( this.name ); } "
  918.                       ."catch (e) {} finally {}"
  919.                      : "";
  920.  
  921.     $this->hourSelect = new HTMLSelect(
  922.                                           'hour'.$this->SETTING["instance"],
  923.                                           $labelArr,
  924.                                           $valueArr,
  925.                                           $selectedValue,
  926.                                           $onChangeOrder,
  927.                                           false
  928.                                       );
  929.   }
  930.  
  931.  
  932.  
  933.   /**
  934.    * Sets up the item to selecting the day of a date.
  935.    *
  936.    * @version 1.4
  937.    * @since   0.1.0
  938.    * @author  Daniel Plücken <daniel@debakel.net>
  939.    * @access  public
  940.    * @param   string  $selectedValue 
  941.    * @param   boolean $hidden 
  942.    * @return  string 
  943.    */
  944.   function setDaySelect(
  945.                           $selectedValue "",
  946.                           $hidden        false
  947.                        )
  948.   {
  949.     for$i 0$i 31$i++ )
  950.     {
  951.       $valueArr[$i$i 1;
  952.       $labelArr[$i$valueArr[$i10
  953.                       ? "0".$valueArr[$i$valueArr[$i];
  954.     }
  955.  
  956.     ifis_bool$hidden ) )
  957.       $this->SETTING["hidden"]["DAY"$hidden;
  958.  
  959.     $this->SETTING["implementedSelects"]["DAY"true;
  960.     $onChangeOrder $this->jscheck )
  961.                      ? "try { checkDay( this.name ); "
  962.                       .$this->onlyfuturedates
  963.                          ? "onlyFutureDate( this.name ); "
  964.                          : ""
  965.                        )
  966.                          ."} catch (e) {} finally {}"
  967.                      : "";
  968.  
  969.                          $this->daySelect = new HTMLSelect(
  970.                          'day'.$this->SETTING["instance"],
  971.                          $labelArr,
  972.                          $valueArr,
  973.                          $selectedValue,
  974.                          $onChangeOrder,
  975.                          false
  976.                          );
  977.   }
  978.  
  979.  
  980.  
  981.   /**
  982.    * Sets up the item to selecting the weekday of a date.
  983.    *
  984.    * @version 1.4
  985.    * @since   0.1.0
  986.    * @author  Daniel Plücken <daniel@debakel.net>
  987.    * @access  public
  988.    * @param   string  $selectedValue 
  989.    * @param   boolean $hidden 
  990.    * @param   boolean $show_emptylabel 
  991.    * @return  string 
  992.    */
  993.   function setWeekDaySelect(
  994.                               $selectedValue   "",
  995.                               $kind            "NAMES",
  996.                               $hidden          false,
  997.                               $show_emptylabel false
  998.                            )
  999.   {
  1000.       global $dayNames;
  1001.  
  1002.       for$i 0$i 7$i++ )
  1003.       {
  1004.           $valueArr[$i$i;
  1005.           if strtoupper$kind == "DIGITS" )
  1006.              $labelArr[$i$valueArr[$i10 )
  1007.                              ? "0".$valueArr[$i)
  1008.                              : "".$valueArr[$i);
  1009.           else
  1010.           if LANG == "de" )
  1011.              $labelArr[$iutf8_decode$dayNames[$i);
  1012.           else
  1013.              $labelArr[$i$dayNames[$i];
  1014.       }
  1015.  
  1016.       if !preg_match"!^[0-6]$!"$selectedValue ) )
  1017.          $selectedValue "";
  1018.  
  1019.       if is_bool$hidden ) )
  1020.          $this->SETTING["hidden"]["WEEKDAYS"$hidden;
  1021.  
  1022.       $this->SETTING["implementedSelects"]["WEEKDAYS"true;
  1023.  
  1024.       $onChangeOrder (
  1025.                          $this->onlyfuturedates
  1026.                       && $this->jscheck
  1027.                        )
  1028.                        ? "try { onlyFutureDate( this.name ); "
  1029.                             ."} catch (e) {} finally {}"
  1030.                        : "";
  1031.  
  1032.       $this->weekdaySelect = new HTMLSelect(
  1033.                                        'weekday'.$this->SETTING["instance"],
  1034.                                        $labelArr,
  1035.                                        $valueArr,
  1036.                                        $selectedValue,
  1037.                                        $onChangeOrder,
  1038.                                        false
  1039.                                            );
  1040.       // doesn't function in all php versions
  1041.       // $this->weekdaySelect->setCharset( "UTF-8" );
  1042.   }
  1043.  
  1044.  
  1045.  
  1046.   /**
  1047.    * Sets up the item to selecting the weeknum of a given year.
  1048.    *
  1049.    * @version 1.2
  1050.    * @since   0.1.2
  1051.    * @author  Daniel Plücken <daniel@debakel.net>
  1052.    * @access  public
  1053.    * @param   string  $selectedValue 
  1054.    * @param   integer $year 
  1055.    * @param   boolean $hidden 
  1056.    * @return  string 
  1057.    */
  1058.   function setWeeknumSelect(
  1059.                              $selectedValue  "",
  1060.                              $year           "",
  1061.                              $hidden         false
  1062.                            )
  1063.   {
  1064.     if!empty$year ) )
  1065.       $weeknumCount DateFormatter::getWeeknumCountOfYear$year );
  1066.     else
  1067.       $weeknumCount 53;
  1068.  
  1069.     for$i 1$i <= $weeknumCount$i++ )
  1070.     {
  1071.       $valueArr[$i;
  1072.       $labelArr[$valueArr[$i 110
  1073.                     ? "0".$valueArr[$i 1]
  1074.                     : "".$valueArr[$i 1];
  1075.     }
  1076.  
  1077.     if!preg_match"!^(?:[0-4]?[0-9]|5[0-3])$!"$selectedValue ) )
  1078.       $selectedValue "";
  1079.  
  1080.     ifis_bool$hidden ) )
  1081.       $this->SETTING["hidden"]["WEEKNUM"$hidden;
  1082.  
  1083.     $this->SETTING["implementedSelects"]["WEEKNUM"true;
  1084.     $onChangeOrder $this->onlyfuturedates
  1085.                     && $this->jscheck )
  1086.                      ? "try { onlyFutureDate( this.name ); "
  1087.                           ."} catch (e) {} finally {}"
  1088.                      : "";
  1089.     $this->weeknumSelect = new HTMLSelect(
  1090.                                    'weeknum'.$this->SETTING["instance"],
  1091.                                    $labelArr,
  1092.                                    $valueArr,
  1093.                                    $selectedValue,
  1094.                                    '',
  1095.                                    false
  1096.                                          );
  1097.   }
  1098.  
  1099.  
  1100.  
  1101.   /**
  1102.    * Sets up the item to selecting the month of a given year.
  1103.    *
  1104.    * @version 1.2
  1105.    * @since   0.1.0
  1106.    * @author  Daniel Plücken <daniel@debakel.net>
  1107.    * @access  public
  1108.    * @param   string  $selectedValue 
  1109.    * @param   boolean $year 
  1110.    * @return  string 
  1111.    */
  1112.   function setMonthSelect(
  1113.                            $selectedValue   "",
  1114.                            $kind            "NAMES",
  1115.                            $hidden          false,
  1116.                            $show_emptylabel false
  1117.                          )
  1118.   {
  1119.     global $monthNames;
  1120.  
  1121.     for$i 0$i 12$i++ )
  1122.     {
  1123.       $valueArr[$i$i 1;
  1124.       ifstrtoupper$kind == "DIGITS" )
  1125.         $labelArr[$i$valueArr[$i10 )
  1126.                         ? "0".$valueArr[$i]
  1127.                         : "".$valueArr[$i];
  1128.       else
  1129.       if LANG == "de" )
  1130.          $labelArr[$iutf8_decode$monthNames[$i);
  1131.       else
  1132.          $labelArr[$i$monthNames[$i];
  1133.     }
  1134.  
  1135.     if!preg_match"!^(?:0?[1-9]|1[0-2])$!"$selectedValue ) )
  1136.       $selectedValue "";
  1137.  
  1138.     ifis_bool$hidden ) )
  1139.       $this->SETTING["hidden"]["MONTH"$hidden;
  1140.  
  1141.     $this->SETTING["implementedSelects"]["MONTH"true;
  1142.     $onChangeOrder $this->jscheck )
  1143.                      ? "try { checkDay( this.name ); "
  1144.                       .$this->onlyfuturedates
  1145.                          ? "onlyFutureDate( this.name ); "
  1146.                          : ""
  1147.                        )
  1148.                       ."} catch (e) {} finally {}"
  1149.                      : "";
  1150.  
  1151.     $this->monthSelect =new HTMLSelect(
  1152.                                           'month'.$this->SETTING["instance"],
  1153.                                           $labelArr,
  1154.                                           $valueArr,
  1155.                                           $selectedValue,
  1156.                                           $onChangeOrder,
  1157.                                           false
  1158.                                         );
  1159.     // doesn't function in all php versions
  1160.     // $this->monthSelect->setCharset( "UTF-8" );
  1161.   }
  1162.  
  1163.  
  1164.  
  1165.   /**
  1166.    * Sets up the item to selecting the year of a date. You have to define the
  1167.    * value on which it should start and this one on which it should end.
  1168.    *
  1169.    * @version 1.2
  1170.    * @since   0.1.0
  1171.    * @author  Daniel Plücken <daniel@debakel.net>
  1172.    * @access  public
  1173.    * @param   integer $yearBegin 
  1174.    * @param   integer $yearEnd 
  1175.    * @param   string  $selectedValue 
  1176.    * @param   boolean $hidden 
  1177.    * @return  string 
  1178.    */
  1179.   function setYearSelect(
  1180.                           $yearBegin,
  1181.                           $yearEnd,
  1182.                           $selectedValue "",
  1183.                           $hidden        false
  1184.                         )
  1185.   {
  1186.     for$i $yearBegin$i <= $yearEnd$i++ )
  1187.       $labvalArr[$i;
  1188.  
  1189.     ifis_bool$hidden ) )
  1190.       $this->SETTING["hidden"]["YEAR"$hidden;
  1191.  
  1192.     $this->SETTING["implementedSelects"]["YEAR"true;
  1193.     $onChangeOrder (
  1194.                        $this->onlyfuturedates
  1195.                     && $this->jscheck
  1196.                      )
  1197.                      ? "try { onlyFutureDate( this.name ); } "
  1198.                       ."catch (e) {} finally {}"
  1199.                      : "";
  1200.  
  1201.     $this->yearSelect = new HTMLSelect(
  1202.                                           'year'.$this->SETTING["instance"],
  1203.                                           $labvalArr,
  1204.                                           $labvalArr,
  1205.                                           $selectedValue,
  1206.                                           $onChangeOrder,
  1207.                                           false
  1208.                                       );
  1209.   }
  1210.  
  1211.  
  1212.  
  1213.   /**
  1214.    * Sets up the item to selecting the year of date. It will start on tree
  1215.    * years ago and two years int he future
  1216.    *
  1217.    * @version 1.2
  1218.    * @since   0.1.0
  1219.    * @author  Daniel Plücken <daniel@debakel.net>
  1220.    * @access  public
  1221.    * @param   string  $selectedValue 
  1222.    * @param   boolean $hidden 
  1223.    * @return  string 
  1224.    */
  1225.   function setStandardYearSelect(
  1226.                                   $selectedIndex "",
  1227.                                   $hidden false
  1228.                                 )
  1229.   {
  1230.     $this->setYearSelect(
  1231.                               date"Y" 3,
  1232.                               date"Y" 2,
  1233.                               (
  1234.                                 !empty$selectedIndex ) )
  1235.                                 ? $selectedIndex
  1236.                                 : date"Y" )
  1237.                               ),
  1238.                               $hidden
  1239.                         );
  1240.   }
  1241.  
  1242.  
  1243.  
  1244.   /**
  1245.    * Gets the second of a given timestamp and rounds it to the nearest value of
  1246.    * the second select.
  1247.    *
  1248.    * @version 1.2
  1249.    * @since   0.1.0
  1250.    * @author  Daniel Plücken <daniel@debakel.net>
  1251.    * @access  public
  1252.    * @param   string  $selectedValue 
  1253.    * @param   boolean $hidden 
  1254.    * @return  string 
  1255.    */
  1256.   function extractSecondFromTimestamp$timestamp )
  1257.   {
  1258.     $SETTING $this->getSettingsArray();
  1259.     $temp date"s"$timestamp );
  1260.  
  1261.     return Numbers
  1262.         :: getIntervalRoundingOf(
  1263.                            $temp60,
  1264.                            (60 $SETTING["secondintervall"])
  1265.                                 );
  1266.   }
  1267.  
  1268.  
  1269.  
  1270.   /**
  1271.    * Gets the minute of a given timestamp and rounds it to the nearest value of
  1272.    * the minute select.
  1273.    *
  1274.    * @version 1.2
  1275.    * @since   0.1.0
  1276.    * @author  Daniel Plücken <daniel@debakel.net>
  1277.    * @access  public
  1278.    * @param   string  $selectedValue 
  1279.    * @param   boolean $hidden 
  1280.    * @return  string 
  1281.    */
  1282.   function extractMinuteFromTimestamp$timestamp )
  1283.   {
  1284.     $SETTING $this->getSettingsArray();
  1285.     $temp date"i"$timestamp );
  1286.  
  1287.     return Numbers
  1288.         :: getIntervalRoundingOf(
  1289.                            $temp60,
  1290.                            (60 $SETTING["minuteintervall"])
  1291.                                 );
  1292.   }
  1293.  
  1294.  
  1295.  
  1296.   /**
  1297.    * Returns a generated string based on the attributes of this object.
  1298.    *
  1299.    * @version 1.45
  1300.    * @since   0.1.0
  1301.    * @author  Daniel Plücken <daniel@debakel.net>
  1302.    * @access  public
  1303.    * @return  string 
  1304.    */
  1305.   function get$str_format "" )
  1306.   {
  1307.      if empty$str_format ) )
  1308.      {  $out $this->output_template_str}
  1309.      else
  1310.      {  $out $str_format}
  1311.  
  1312.  
  1313.      if $this->SETTING["hidden"]["WEEKDAYS")
  1314.      {  $out str_replace"{#WEEKDAY#}"""$out )}
  1315.      else
  1316.      {  $out str_replace"{#WEEKDAY#}"$this->getweekdaySelect()$out )}
  1317.  
  1318.  
  1319.      if $this->SETTING["hidden"]["DAY")
  1320.      {  $out str_replace"{#DAY#}"""$out )}
  1321.      else
  1322.      {  $out str_replace"{#DAY#}"$this->getDaySelect()$out )}
  1323.  
  1324.  
  1325.      if $this->SETTING["hidden"]["MONTH")
  1326.      {  $out str_replace"{#MONTH#}"""$out )}
  1327.      else
  1328.      {  $out str_replace"{#MONTH#}"$this->getMonthSelect()$out )}
  1329.  
  1330.  
  1331.      if $this->SETTING["hidden"]["WEEKNUM")
  1332.      {  $out str_replace"{#WEEKNUM#}"""$out )}
  1333.      else
  1334.      {  $out str_replace"{#WEEKNUM#}"$this->getWeeknumSelect()$out )}
  1335.  
  1336.  
  1337.      if $this->SETTING["hidden"]["YEAR")
  1338.      {  $out str_replace"{#YEAR#}"""$out )}
  1339.      else
  1340.      {  $out str_replace"{#YEAR#}"$this->getYearSelect()$out )}
  1341.  
  1342.  
  1343.      if $this->SETTING["hidden"]["HOUR")
  1344.      {  $out str_replace"{#HOUR#}"""$out )}
  1345.      else
  1346.      {  $out str_replace"{#HOUR#}"$this->getHourSelect()$out )}
  1347.  
  1348.  
  1349.      if $this->SETTING["hidden"]["MINUTE")
  1350.      {  $out str_replace"{#MINUTE#}"""$out )}
  1351.      else
  1352.      {  $out str_replace"{#MINUTE#}"$this->getMinuteSelect()$out )}
  1353.  
  1354.  
  1355.      if $this->SETTING["hidden"]["SECOND")
  1356.      {  $out str_replace"{#SECOND#}"""$out )}
  1357.      else
  1358.      {  $out str_replace"{#SECOND#}"$this->getSecondSelect()$out )}
  1359.  
  1360.      # use label as fieldset
  1361.      if is_object$this->label_obj ) )
  1362.      {
  1363.          $str_style "";
  1364.          if !empty$this->label_obj->style_class ) )
  1365.          {  $str_style .= " class=\"{$this->label_obj->style_class}\""}
  1366.          if !empty$this->label_obj->freestyle ) )
  1367.          {  $str_style .= " style=\"{$this->label_obj->freestyle}\""}
  1368.  
  1369.          $out "<fieldset{$str_style}>"
  1370.                ."<legend>{$this->label_obj->str_body}</legend>".$out
  1371.                ."</fieldset>";
  1372.      }
  1373.  
  1374.      $out $this->getJSFunctionsToCheckDate().$out;
  1375.  
  1376.  
  1377.      return  preg_replace"![\r\n]+!""\r\n"$out );
  1378.   }
  1379.  
  1380.  
  1381.  
  1382.   /**
  1383.    * Creates javascript-functions to verify the date choosen by an user.
  1384.    *
  1385.    * @version 1.1
  1386.    * @since   0.2.3
  1387.    * @author  Daniel Plücken <daniel@debakel.net>
  1388.    * @access  public
  1389.    * @return  string 
  1390.    */
  1391.   {
  1392.     static $JSOutputted 0;
  1393.     static $JSFutureOutputted 0;
  1394.  
  1395.     $out "";
  1396.     if(
  1397.         $this->onlyfuturedates
  1398.      && $JSFutureOutputted 1
  1399.      && $this->SETTING["implementedSelects"]["DAY"]
  1400.      && $this->SETTING["implementedSelects"]["MONTH"]
  1401.      && $this->SETTING["implementedSelects"]["YEAR"]
  1402.       )
  1403.     {
  1404.       $out .= "\r\n\r\n<script language=\"javascript\">\r\n";
  1405.       $out .= "<!--\r\n\r\n";
  1406.       $out .= "   function onlyFutureDate( callerSelectName )\r\n";
  1407.       $out .= "   {\r\n";
  1408.       $out .= "     var second = 0;\r\n";
  1409.       $out .= "     var minute = 0;\r\n";
  1410.       $out .= "     var hour   = 0;\r\n";
  1411.       $out .= "     var day    = 0;\r\n";
  1412.       $out .= "     var month  = -1;\r\n";
  1413.       $out .= "     var year   = 0;\r\n\r\n";
  1414.  
  1415.       $out .= "     callerSelectName = callerSelectName."
  1416.                                      ."replace( /second/, \"\" );\r\n";
  1417.       $out .= "     callerSelectName = callerSelectName."
  1418.                                      ."replace( /minute/, \"\" );\r\n";
  1419.       $out .= "     callerSelectName = callerSelectName."
  1420.                                      ."replace( /hour/,   \"\" );\r\n";
  1421.       $out .= "     callerSelectName = callerSelectName."
  1422.                                      ."replace( /day/,    \"\" );\r\n";
  1423.       $out .= "     callerSelectName = callerSelectName."
  1424.                                      ."replace( /month/,  \"\" );\r\n";
  1425.       $out .= "     callerSelectName = callerSelectName."
  1426.                                      ."replace( /year/,   \"\" );\r\n\r\n";
  1427.  
  1428.       $out .= "     for( i = 0; i < document.forms.length; i++ )\r\n";
  1429.       $out .= "     {\r\n";
  1430.       $out .= "       if( eval('document.forms[' + i + '].second' "
  1431.                             ."+ callerSelectName ) "
  1432.                      ."&& eval('document.forms[' + i + '].second' "
  1433.                             ."+ callerSelectName ).value != '' )\r\n";
  1434.       $out .= "         second = parseInt( eval('document.forms[' + i + ']."
  1435.                                ."second' + callerSelectName ).value );\r\n";
  1436.  
  1437.       $out .= "       if( eval('document.forms[' + i + '].minute' "
  1438.                             ."+ callerSelectName ) "
  1439.                      ."&& eval('document.forms[' + i + '].minute' "
  1440.                             ."+ callerSelectName ).value != '' )\r\n";
  1441.       $out .= "         minute = parseInt( eval('document.forms[' + i + ']."
  1442.                                ."minute' + callerSelectName ).value );\r\n";
  1443.  
  1444.       $out .= "       if( eval('document.forms[' + i + '].hour' "
  1445.                             ."+ callerSelectName ) "
  1446.                      ."&& eval('document.forms[' + i + '].hour' "
  1447.                             ."+ callerSelectName ).value != '' )\r\n";
  1448.       $out .= "         hour = parseInt( eval('document.forms[' + i + ']."
  1449.                              ."hour' + callerSelectName ).value );\r\n";
  1450.  
  1451.       $out .= "       if( eval('document.forms[' + i + '].day' "
  1452.                             ."+ callerSelectName ) )\r\n";
  1453.       $out .= "         day = parseInt( eval('document.forms[' + i + ']."
  1454.                             ."day' + callerSelectName ).value );\r\n";
  1455.  
  1456.       $out .= "       if( eval('document.forms[' + i + '].month' "
  1457.                             ."+ callerSelectName ) )\r\n";
  1458.       $out .= "         month = parseInt( eval('document.forms[' + i + ']."
  1459.                               ."month' + callerSelectName ).value ) - 1;\r\n";
  1460.  
  1461.       $out .= "       if( eval('document.forms[' + i + '].year' "
  1462.                             ."+ callerSelectName ) )\r\n";
  1463.       $out .= "         year = parseInt( eval('document.forms[' + i + ']."
  1464.                              ."year' + callerSelectName ).value );\r\n";
  1465.       $out .= "     }\r\n";
  1466.  
  1467.       $out .= "     var now = new Date();\r\n";
  1468.       $out .= "     var now_unix = now.getTime();\r\n";
  1469.       $out .= "     var choosendate = new Date( year, month, day, "
  1470.                                               ."hour, minute, second );\r\n";
  1471.       $out .= "     var choosendate_unix = choosendate.getTime();\r\n\r\n";
  1472.  
  1473.       $out .= "     if( now_unix < choosendate_unix )\r\n";
  1474.       $out .= "       return true;\r\n";
  1475.       $out .= "     else\r\n";
  1476.       $out .= "     {\r\n";
  1477.       $out .= "       alert( unescape( '".$this
  1478.                                         ->onlyfutureJSerrMSG."' ) );\r\n";
  1479.       $out .= "       return false;\r\n";
  1480.       $out .= "     }\r\n";
  1481.       $out .= "   }\r\n\r\n";
  1482.       $out .= "// -->\r\n";
  1483.       $out .= "</script>\r\n\r\n\r\n";
  1484.     }
  1485.  
  1486.  
  1487.  
  1488.  
  1489.     $INSTANCE $this->SETTING["instance"];
  1490.  
  1491.     if$this->SETTING["implementedSelects"]["DAY"]
  1492.      && $this->SETTING["implementedSelects"]["MONTH"]
  1493.      && $JSOutputted )
  1494.     {
  1495.       $JSOutputted ++;
  1496.  
  1497.       $out .= "\r\n\r\n<script language=\"javascript\">\r\n";
  1498.       $out .= "<!--\r\n\r\n";
  1499.       $out .= "   function isLeapYear(y)\r\n";
  1500.       $out .= "   { return ((y % 4 == 0) "
  1501.                       ."&& ((y % 100!= 0) "
  1502.                        ."|| (y % 400 == 0))); }\r\n\r\n";
  1503.  
  1504.       $out .= "   function check30DaysMonth( month, day, "
  1505.                                            ."callerSelectName, k )\r\n";
  1506.       $out .= "   {\r\n";
  1507.       $out .= "      // Monate mit 30 Tagen\r\n";
  1508.       $out .= "      var errMonth = \"\";\r\n";
  1509.       $out .= "      switch( month )\r\n";
  1510.       $out .= "      {\r\n";
  1511.       $out .= "        case 4:\r\n";
  1512.       $out .= "          if( day > 30 )\r\n";
  1513.       $out .= "            errMonth = \"April\";\r\n";
  1514.       $out .= "        break;\r\n";
  1515.       $out .= "        case 6:\r\n";
  1516.       $out .= "          if( day > 30 )\r\n";
  1517.       $out .= "            errMonth = \"Juni\";\r\n";
  1518.       $out .= "          break;\r\n";
  1519.       $out .= "        case 9:\r\n";
  1520.       $out .= "          if( day > 30 )\r\n";
  1521.       $out .= "            errMonth = \"September\";\r\n";
  1522.       $out .= "          break;\r\n";
  1523.       $out .= "        case 11:\r\n";
  1524.       $out .= "          if( day > 30 )\r\n";
  1525.       $out .= "            errMonth = \"November\";\r\n";
  1526.       $out .= "          break;\r\n";
  1527.       $out .= "      }\r\n\r\n";
  1528.       $out .= "      if( errMonth != \"\" )\r\n";
  1529.       $out .= "      {\r\n";
  1530.       $out .= "         alert( unescape( 'Der Monat ' + errMonth + ' hat maximal 30 Tage, "
  1531.                                         ."daher wird\\r\\n"
  1532.                                         ."der Wert der Tag-Auswahl auf 30 zur%FCckgestellt.\\t\\t' ) );\r\n";
  1533.       $out .= "         eval('document.forms[' + k + '].day' + callerSelectName ).value = 30;\r\n";
  1534.       $out .= "         return false;\r\n";
  1535.       $out .= "      }\r\n";
  1536.       $out .= "      return true;\r\n";
  1537.       $out .= "   }\r\n\r\n";
  1538.  
  1539.       $out .= "   function checkDay( callerSelectName )\r\n";
  1540.       $out .= "   {\r\n";
  1541.       $out .= "     callerSelectName = callerSelectName."
  1542.                                      ."replace( /day/,   \"\" );\r\n";
  1543.       $out .= "     callerSelectName = callerSelectName."
  1544.                                      ."replace( /month/, \"\" );\r\n";
  1545.       $out .= "     callerSelectName = callerSelectName."
  1546.                                      ."replace( /year/,  \"\" );\r\n\r\n";
  1547.  
  1548.       $out .= "     for( h = 0; h < document.forms.length; h++ )\r\n";
  1549.       $out .= "       if( document.forms[h]\r\n";
  1550.       $out .= "        && eval('document.forms[' + h + '].day' "
  1551.                             ."+ callerSelectName )\r\n";
  1552.       $out .= "        && eval('document.forms[' + h + '].month' "
  1553.                             ."+ callerSelectName ) )\r\n";
  1554.       $out .= "       {\r\n\r\n";
  1555.       $out .= "         var day   = parseInt( eval('document.forms[' + h + ']."
  1556.                                   ."day' + callerSelectName ).value );\r\n";
  1557.       $out .= "         var month = parseInt( eval('document.forms[' + h + ']."
  1558.                                   ."month' + callerSelectName ).value );\r\n\r\n";
  1559.       $out .= "         if( eval('document.forms[' + h + '].year' "
  1560.                               ."+ callerSelectName ) )\r\n";
  1561.       $out .= "         {\r\n";
  1562.       $out .= "            var year = parseInt( eval('document.forms[' + h + ']."
  1563.                                                     ."year' + callerSelectName ).value );\r\n\r\n";
  1564.       $out .= "            // Schaltjahr (gregorianisch, 27 Sekunden pro Jahr ist durchaus verkraftbar)\r\n";
  1565.       $out .= "            if( isLeapYear( year )\r\n";
  1566.       $out .= "             && ( month == 2 )\r\n";
  1567.       $out .= "             && ( day > 29 ) )\r\n";
  1568.       $out .= "            {\r\n";
  1569.       $out .= "               alert( unescape ( 'Der Monat Febuar hat(te) im Jahre ' + year "
  1570.                                             ."+ ' maximal 29 Tage,\\r\\n"
  1571.                                                 ."daher wird der Wert der Tag-Auswahl auf "
  1572.                                                 ."29 zur%FCckgestellt.\\t\\t' ) );\r\n";
  1573.       $out .= "               eval('document.forms[' + h + '].day' + callerSelectName ).value = 29;\r\n";
  1574.       $out .= "               return false;\r\n";
  1575.       $out .= "            }\r\n";
  1576.       $out .= "            else if( !isLeapYear( year )\r\n";
  1577.       $out .= "                  && month == 2 && day > 28 )\r\n";
  1578.       $out .= "            {\r\n";
  1579.       $out .= "               alert( unescape( 'Der Monat Febuar hat(te) im Jahre ' + year "
  1580.                                            ."+ ' maximal 28 Tage,\\r\\n"
  1581.                                                ."daher wird der Wert der Tag-Auswahl auf "
  1582.                                                ."28 zur%FCckgestellt.\\t\\t' ) );\r\n";
  1583.       $out .= "               eval('document.forms[' + h + '].day' + callerSelectName ).value = 28;\r\n";
  1584.       $out .= "               return false;\r\n";
  1585.       $out .= "            }\r\n";
  1586.       $out .= "            else\r\n";
  1587.       $out .= "               return check30DaysMonth( month, day, "
  1588.                                                      ."callerSelectName, h );\r\n";
  1589.       $out .= "         }\r\n";
  1590.       $out .= "         else\r\n";
  1591.       $out .= "         {\r\n";
  1592.       $out .= "            if( month == 2 && day > 29 )\r\n";
  1593.       $out .= "            {\r\n";
  1594.       $out .= "              alert( unescape( 'Der Monat Febuar hat maximal 29 Tage, daher wird\\r\\n"
  1595.                                               ."der Wert der Tag-Auswahl auf 29 zur%FCckgestellt.\\t\\t' ) );\r\n";
  1596.       $out .= "              eval('document.forms[' + h + '].day' + callerSelectName ).value = 29;\r\n";
  1597.       $out .= "              return false;\r\n";
  1598.       $out .= "            }\r\n";
  1599.       $out .= "            else\r\n";
  1600.       $out .= "               return check30DaysMonth( month, day, "
  1601.                                                      ."callerSelectName, h );\r\n";
  1602.       $out .= "         }\r\n";
  1603.       $out .= "       }\r\n";
  1604.       $out .= "     return true;\r\n";
  1605.       $out .= "   }\r\n\r\n";
  1606.       $out .= "// -->\r\n";
  1607.       $out .= "</script>\r\n\r\n\r\n";
  1608.  
  1609.       return $out;
  1610.     }
  1611.   }
  1612. // END of class DateSelect
  1613. ?>

Documentation generated on Thu, 05 Jun 2008 19:10:55 +0200 by phpDocumentor 1.4.1