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

Source for file Driver.php

Documentation is available at Driver.php

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3. // +----------------------------------------------------------------------+
  4. // | PHP Version 4                                                        |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1997-2002 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:   Carsten Lucke <luckec@tool-garage.de>                     |
  17. // +----------------------------------------------------------------------+
  18. //
  19. //    $Id: Driver.php,v 1.24 2004/12/18 23:59:14 luckec Exp $s
  20.  
  21. /**
  22.  * uses PEAR_Errorstack
  23.  */
  24. require_once 'PEAR/ErrorStack.php';
  25.  
  26. /**
  27.  * invalid internal name
  28.  *
  29.  * @access  public
  30.  */
  31. define('DATE_HOLIDAYS_INVALID_INTERNAL_NAME'51);
  32.  
  33. /**
  34.  * title for a holiday is not available
  35.  *
  36.  * @access  public
  37.  */
  38. define('DATE_HOLIDAYS_TITLE_UNAVAILABLE'52);
  39.  
  40. /**
  41.  * date could not be converted into a PEAR::Date object
  42.  *
  43.  * date was neither a timestamp nor a string
  44.  *
  45.  * @access  public
  46.  * @deprecated   will certainly be removed
  47.  */
  48. define('DATE_HOLIDAYS_INVALID_DATE'53);
  49.  
  50. /**
  51.  * string that represents a date has wrong format
  52.  *
  53.  * format must be YYYY-MM-DD
  54.  *
  55.  * @access  public
  56.  * @deprecated   will certainly be removed
  57.  */
  58. define('DATE_HOLIDAYS_INVALID_DATE_FORMAT'54);
  59.  
  60. /**
  61.  * date for a holiday is not available
  62.  *
  63.  * @access  public
  64.  */
  65. define('DATE_HOLIDAYS_DATE_UNAVAILABLE'55);
  66.  
  67. /**
  68.  * language-file doesn't exist
  69.  *
  70.  * @access  public
  71.  */
  72. define('DATE_HOLIDAYS_LANGUAGEFILE_NOT_FOUND'56);
  73.  
  74. /**
  75.  * class that helps you to locate holidays for a year
  76.  *
  77.  * @abstract
  78.  * @category    Date
  79.  * @package     Date_Holidays
  80.  * @version     $Id: Driver.php,v 1.24 2004/12/18 23:59:14 luckec Exp $
  81.  * @author      Carsten Lucke <luckec@tool-garage.de>
  82.  */
  83. {
  84.    /**
  85.     * locale setting for output
  86.     *
  87.     * @access   protected
  88.     * @var      string 
  89.     */
  90.     var $_locale;
  91.     
  92.    /**
  93.     * locales for which translations of holiday titles are available
  94.     *
  95.     * @access   private
  96.     * @var      array 
  97.     */
  98.     var $_availableLocales = array('C');
  99.     
  100.    /**
  101.     * object's current year
  102.     *
  103.     * @access   protected
  104.     * @var      int 
  105.     */
  106.     var $_year;
  107.     
  108.    /**
  109.     * internal names for the available holidays
  110.     *
  111.     * @access   protected
  112.     * @var      array 
  113.     */
  114.     var $_internalNames = array();
  115.     
  116.    /**
  117.     * dates of the available holidays
  118.     *
  119.     * @access   protected
  120.     * @var      array 
  121.     */
  122.     var $_dates = array();
  123.     
  124.    /**
  125.     * array of the available holidays indexed by date
  126.     *
  127.     * @access   protected
  128.     * @var      array 
  129.     */
  130.     var $_holidays = array();
  131.  
  132.    /**
  133.     * localized names of the available holidays
  134.     *
  135.     * @access   protected
  136.     * @var      array 
  137.     */
  138.     var $_titles = array();
  139.     
  140.    /**
  141.     * Constructor
  142.     *
  143.     * Use the Date_Holidays::factory() method to construct an object of a certain driver
  144.     *
  145.     * @access   protected
  146.     */
  147.     function Date_Holidays_Driver()
  148.     {
  149.     }
  150.     
  151.    /**
  152.     * Sets the driver's current year
  153.     *
  154.     * Calling this method forces the object to rebuild the holidays
  155.     *
  156.     * @access   public
  157.     * @param    int     $year   year
  158.     * @return   boolean true on success, otherwise a PEAR_ErrorStack object
  159.     * @throws   object PEAR_ErrorStack
  160.     * @uses     _buildHolidays()
  161.     */
  162.     function setYear($year)
  163.     {
  164.         $this->_year    =   $year;
  165.         return $this->_buildHolidays();
  166.     }
  167.     
  168.    /**
  169.     * Returns the driver's current year
  170.     *
  171.     * @access   public
  172.     * @return   int     current year
  173.     */
  174.     function getYear()
  175.     {
  176.         return $this->_year;
  177.     }
  178.     
  179.    /**
  180.     * Build the internal arrays that contain data about the calculated holidays
  181.     *
  182.     * @abstract
  183.     * @access   protected
  184.     * @return   boolean true on success, otherwise a PEAR_ErrorStack object
  185.     * @throws   object PEAR_ErrorStack
  186.     */
  187.     function _buildHolidays()
  188.     {
  189.     }
  190.     
  191.    /**
  192.     * Add a driver component
  193.     *
  194.     *
  195.     *
  196.     * @abstract
  197.     * @access   public
  198.     * @param    object Date_Holidays_Driver $driver driver-object
  199.     */
  200.     function addDriver($driver)
  201.     {
  202.     }
  203.     
  204.    /**
  205.     * Remove a driver component
  206.     *
  207.     * @abstract
  208.     * @access   public
  209.     * @param    object Date_Holidays_Driver $driver driver-object
  210.     * @return   boolean true on success, otherwise a PEAR_Error object
  211.     * @throws   object PEAR_Error   DATE_HOLIDAYS_DRIVER_NOT_FOUND
  212.     */
  213.     function removeDriver($driver)
  214.     {
  215.     }
  216.     
  217.    /**
  218.     * Returns the internal names of holidays that were calculated
  219.     *
  220.     * @access   public
  221.     * @return   array 
  222.     */
  223.     function getInternalHolidayNames()
  224.     {
  225.         return $this->_internalNames;
  226.     }
  227.     
  228.    /**
  229.     * Returns localized titles of all holidays or those specififed in $restrict array
  230.     *
  231.     * @access   public
  232.     * @param    array   $restrict   internal names of desired holidays
  233.     * @param    string  $locale     locale setting that shall be used by this method
  234.     * @return   array with localized holiday titles on success, otherwise a PEAR_Error object
  235.     * @throws   object PEAR_Error   DATE_HOLIDAYS_INVALID_INTERNAL_NAME
  236.     * @uses     getHolidayTitle()
  237.     */
  238.     function getHolidayTitles($restrict = array()$locale = null)
  239.     {
  240.         if (empty($restrict)) {
  241.             $restrict   $this->_internalNames;
  242.         }
  243.         
  244.         $titles =   array();
  245.         foreach ($restrict as $internalName{
  246.             $title  $this->getHolidayTitle($internalName$locale);
  247.             if (Date_Holidays::isError($title)) {
  248.                 return $title;
  249.             }
  250.             $titles[$internalName]  $title;
  251.         }
  252.         return $titles;
  253.     }
  254.     
  255.    /**
  256.     * Returns localized title for a holiday
  257.     *
  258.     * @access   public
  259.     * @param    string  $internalName   internal name for holiday
  260.     * @param    string  $locale         locale setting that shall be used by this method
  261.     * @return   string  title on success, otherwise a PEAR_Error object
  262.     * @throws   object PEAR_Error   DATE_HOLIDAYS_INVALID_INTERNAL_NAME, DATE_HOLIDAYS_TITLE_UNAVAILABLE
  263.     */
  264.     function getHolidayTitle($internalName$locale = null)
  265.     {
  266.         if (in_array($internalName$this->_internalNames)) {
  267.             return Date_Holidays::raiseError(DATE_HOLIDAYS_INVALID_INTERNAL_NAME'Invalid internal name: ' $internalName);
  268.         }
  269.         
  270.         if (is_null($locale)) {
  271.             $locale =   $this->_findBestLocale($this->_locale);
  272.         else {
  273.             $locale =   $this->_findBestLocale($locale);
  274.         }
  275.         
  276.         if (isset($this->_titles[$locale][$internalName])) {
  277.             if (Date_Holidays::staticGetProperty('DIE_ON_MISSING_LOCALE')) {
  278.                 return Date_Holidays::raiseError(DATE_HOLIDAYS_TITLE_UNAVAILABLE'The internal name (' $internalName 
  279.                     ') for the holiday was correct but no localized title could be found');
  280.             }
  281.         }
  282.  
  283.         return isset($this->_titles[$locale][$internalName]
  284.             $this->_titles[$locale][$internalName$this->_titles['C'][$internalName];
  285.     }
  286.     
  287.    /**
  288.     * Returns all holidays that the driver knows.
  289.     *
  290.     * You can limit the holidays by setting the $restrict array, then only those
  291.     * will be returned, whose internal name occurrs in this array.
  292.     *
  293.     * Return format:
  294.     * <pre>
  295.     *   array(
  296.     *       'easter'        =>  object of type Date_Holidays_Holiday,
  297.     *       'eastermonday'  =>  object of type Date_Holidays_Holiday,
  298.     *       ...
  299.     *   )
  300.     * </pre>
  301.     *
  302.     * @access   public
  303.     * @param    array   $restrict   internal names of desired holidays
  304.     * @return   array   numeric array containing objects of Date_Holidays_Holiday on success, otherwise a PEAR_Error object
  305.     * @throws   object PEAR_Error   DATE_HOLIDAYS_INVALID_INTERNAL_NAME
  306.     * @see      getHoliday()
  307.     * @uses     getHoliday()
  308.     */
  309.     function getHolidays($restrict = array())
  310.     {
  311.         if (empty($restrict)) {
  312.             $restrict   $this->_internalNames;
  313.         }
  314.         
  315.         $holidays       = array();
  316.         foreach ($restrict as $internalName{
  317.             if (in_array($internalName$this->_internalNames)) {
  318.                 return Date_Holidays::raiseError(DATE_HOLIDAYS_INVALID_INTERNAL_NAME'Invalid internal name: ' $internalName);
  319.             }
  320.             $holidays[$internalName]    &$this->getHoliday($internalName);
  321.         }
  322.         return $holidays;
  323.     }
  324.     
  325.    /**
  326.     * Returns the specified holiday
  327.     *
  328.     * Return format:
  329.     * <pre>
  330.     *   array(
  331.     *       'title' =>  'Easter Sunday'
  332.     *       'date'  =>  '2004-04-11'
  333.     *   )
  334.     * </pre>
  335.     *
  336.     * @access   public
  337.     * @param    string  $internalName   internal name of the holiday
  338.     * @param    string  $locale         locale setting that shall be used by this method
  339.     * @return   object Date_Holidays_Holiday    holiday's information on success, otherwise a PEAR_Error object
  340.     * @throws   object PEAR_Error       DATE_HOLIDAYS_INVALID_INTERNAL_NAME
  341.     * @uses     getHolidayTitle()
  342.     * @uses     getHolidayDate()
  343.     */
  344.     function getHoliday($internalName$locale = null)
  345.     {
  346.         if (in_array($internalName$this->_internalNames)) {
  347.                 'Invalid internal name: ' $internalName);
  348.         }
  349.         if (is_null($locale)) {
  350.             $locale $this->_locale;
  351.         }
  352.         
  353.         $title      $this->getHolidayTitle($internalName$locale);
  354.         if (Date_Holidays::isError($title)) {
  355.             return $title;
  356.         }
  357.         $date       &$this->getHolidayDate($internalName);
  358.         if (Date_Holidays::isError($date)) {
  359.             return $date;
  360.         }
  361.         
  362.         return new Date_Holidays_Holiday($internalName$title$date);
  363.     }
  364.     
  365.    /**
  366.     * Determines whether a date represents a holiday or not
  367.     *
  368.     * @access   public
  369.     * @param    mixed   $date       date (can be a timestamp, string or PEAR::Date object)
  370.     * @param    array   $restrict   internal-names of holidays to limit search on
  371.     * @return   boolean true if date represents a holiday, otherwise false
  372.     * @throws   object PEAR_Error   DATE_HOLIDAYS_INVALID_DATE, DATE_HOLIDAYS_INVALID_DATE_FORMAT
  373.     */
  374.     function isHoliday($date$restrict = array())
  375.     {
  376.         if (is_a($date'Date')) {
  377.             $date   =$this->_convertDate($date);
  378.             if (Date_Holidays::isError($date)) {
  379.                 return $date;
  380.             }
  381.         }
  382.  
  383.         if (empty($restrict)) {
  384.             $restrict $this->_internalNames;
  385.         }
  386.         
  387.         foreach (array_keys($this->_datesas $internalName{
  388.             if (in_array($internalName$restrict)) {
  389.                 if ($date->compare($date$this->_dates[$internalName]!= 0{
  390.                     continue;
  391.                 }
  392.                 return true;
  393.             }
  394.         }
  395.         return false;
  396.     }
  397.     
  398.    /**
  399.     * Returns the title of the holiday, if any was found, matching the specified date.
  400.     *
  401.     * Normally the method will return the title/data for the first holiday matching the date.
  402.     * If you want the mthod to continue searching holidays for the specified date, set the 4th param to true
  403.     * If multiple holidays match your date, the return value will be an array of the titles/data.
  404.     * <pre>
  405.     * array(
  406.     *   array(
  407.     *       'title' => 'New Year',
  408.     *       'date'  => Object of type Date
  409.     *   ),
  410.     *   array(
  411.     *       'title' => 'Circumcision of Jesus',
  412.     *       'date'  => Object of type Date
  413.     *   )
  414.     * )
  415.     * </pre>
  416.     *
  417.     * @access   public
  418.     * @param    mixed   $date       date (timestamp | string | PEAR::Date object)
  419.     * @param    string  $locale     locale setting that shall be used by this method
  420.     * @param    boolean $multiple 
  421.     * @return   object  object of type Date_Holidays_Holiday on success
  422.     *                    (numeric array of those on multiple search),
  423.     *                    if no holiday was found, matching this date, null is returned
  424.     * @throws   object PEAR_Error   DATE_HOLIDAYS_INVALID_DATE, DATE_HOLIDAYS_INVALID_DATE_FORMAT
  425.     * @uses     getHoliday()
  426.     * @uses     getHolidayTitle()
  427.     * @see      getHoliday()
  428.     ***/
  429.     function getHolidayForDate($date$locale = null$multiple = false)
  430.     {
  431.         if (!is_a($date'Date')) {
  432.             $date &$this->_convertDate($date);
  433.             if (Date_Holidays::isError($date)) {
  434.                 return $date;
  435.             }
  436.         }
  437.         $isodate $date->format('%Y-%m-%d');
  438.         unset($date);
  439.         if (is_null($locale)) {
  440.             $locale $this->_locale;
  441.         }
  442.         if (array_key_exists($isodate$this->_holidays)) {
  443.             if (!$multiple{
  444.                 //get only the first feast for this day
  445.                 $internalName $this->_holidays[$isodate][0];
  446.                 $result &$this->getHoliday($internalName$locale);
  447.                 return Date_Holidays::isError($result? null : $result;
  448.             }
  449.             // array that collects data, if multiple searching is done
  450.             $data = array();
  451.             foreach($this->_holidays[$isodateas $internalName{
  452.                 $result &$this->getHoliday($internalName$locale);
  453.                 if (Date_Holidays::isError($result)) {
  454.                     continue;
  455.                 }
  456.                 $data[=$result;
  457.             }
  458.             return $data;
  459.         }
  460.         return null;
  461.     }
  462.     
  463.    /**
  464.     * Converts timestamp or date-string into da PEAR::Date object
  465.     *
  466.     * @static
  467.     * @access   private
  468.     * @param    mixed   $date   date
  469.     * @return   object PEAR_Date 
  470.     * @throws   object PEAR_Error   DATE_HOLIDAYS_INVALID_DATE, DATE_HOLIDAYS_INVALID_DATE_FORMAT
  471.     */
  472.     function _convertDate($date)
  473.     {
  474.         if (is_string($date)) {
  475.             if (preg_match('/^[0-9]{4}-[0-9]{2}-[0-9]{2}/'$date)) {
  476.                 return Date_Holidays::raiseError(DATE_HOLIDAYS_INVALID_DATE_FORMAT
  477.                     'Date-string has wrong format (must be YYYY-MM-DD)');
  478.             }
  479.             return new Date($date);
  480.         }
  481.         
  482.         if (is_int($date)) {
  483.             return new Date($date);
  484.         }
  485.         
  486.             'The date you specified is invalid');
  487.     }
  488.     
  489.    /**
  490.     * Adds all holidays in the array to the driver's internal list of holidays.
  491.     * 
  492.     * Format of the array:
  493.     * <pre>
  494.     *   array(
  495.     *       'newYearsDay'   => array(
  496.     *           'date'          => '01-01',
  497.     *           'title'         => 'New Year\'s Day',
  498.     *           'translations'  => array(
  499.     *               'de_DE' =>  'Neujahr',
  500.     *               'en_EN' =>  'New Year\'s Day'
  501.     *           )
  502.     *       ),
  503.     *       'valentinesDay' => array(
  504.     *           ...
  505.     *       )
  506.     *   );
  507.     * </pre>
  508.     * 
  509.     * @access   protected
  510.     * @param    array       $holidays   static holidays' data
  511.     * @uses     _addHoliday()
  512.     * @uses     _addTranslationForHoliday()
  513.     */
  514.     function _addStaticHolidays($holidays)
  515.     {
  516.         foreach ($holidays as $internalName => $holiday{
  517.             // add the holiday's basic data
  518.             $this->_addHoliday($internalName$this->_year . '-' $holiday['date']$holiday['title']);
  519.         }
  520.     }
  521.     
  522.    /**
  523.     * Adds a holiday to the driver's holidays
  524.     *
  525.     * @access   protected
  526.     * @param    string  $internalName   internal name - must not contain characters that aren't allowed as variable-names
  527.     * @param    mixed   $date           date (timestamp | string | PEAR::Date object)
  528.     * @param    string  $title          holiday title
  529.     */
  530.     function _addHoliday($internalName$date$title)
  531.     {
  532.         if (is_a($date'Date')) {
  533.             $date   =&  new Date($date);
  534.         }
  535.         
  536.         $this->_dates[$internalName]        &$date;
  537.         $this->_titles['C'][$internalName]  $title;
  538.         $isodate $date->format('%Y-%m-%d');
  539.         if (!isset($this->_holidays[$isodate])) {
  540.             $this->_holidays[$isodate= array();
  541.         }
  542.         array_push($this->_holidays[$isodate]$internalName);
  543.         array_push($this->_internalNames$internalName);
  544.     }
  545.     
  546.    /**
  547.     * Add a localized translation for a holiday's title
  548.     *
  549.     * @access   protected
  550.     * @param    string  $internalName   internal name of an existing holiday
  551.     * @param    string  $locale         locale setting that shall be used by this method
  552.     * @param    string  $title          title
  553.     * @return   true on success, otherwise a PEAR_Error object
  554.     * @throws   object PEAR_Error       DATE_HOLIDAYS_INVALID_INTERNAL_NAME
  555.     */
  556.     function _addTranslationForHoliday($internalName$locale$title)
  557.     {
  558.         if (in_array($internalName$this->_internalNames)) {
  559.                 'Couldn\'t add translation (' $locale ') for holiday with this internal name: ' $internalName);
  560.         }
  561.         
  562.         if (in_array($locale$this->_availableLocales)) {
  563.             array_push($this->_availableLocales$locale);
  564.         }
  565.         $this->_titles[$locale][$internalName]  $title;
  566.         return true;
  567.     }
  568.     
  569.    /**
  570.     * Add a translation-file's content
  571.     * 
  572.     * The translation-file's content will be parsed and translations for
  573.     * holidays will be made available with the specified locale.
  574.     * 
  575.     * @access   public
  576.     * @param    string  $file   filename of the language file
  577.     * @param    string  $locale locale-code of the translation
  578.     * @return   boolean true on success, otherwise a PEAR_ErrorStack object
  579.     * @throws   object PEAR_Errorstack
  580.     */
  581.     function addTranslationFile($file$locale)
  582.     {
  583.         if (file_exists($file)) {
  584.             Date_Holidays::raiseError(DATE_HOLIDAYS_LANGUAGEFILE_NOT_FOUND'Language-file not found');
  585.             return Date_Holidays::getErrorStack();
  586.         }
  587.         
  588.         $content    parse_ini_file($file);
  589.         foreach ($content as $internalName => $translation{
  590.             $this->_addTranslationForHoliday($internalName$locale$translation);
  591.         }
  592.         
  593.         if (Date_Holidays::errorsOccurred()) {
  594.             return Date_Holidays::getErrorStack();
  595.         }
  596.         return true;
  597.     }
  598.     
  599.    /**
  600.     * Remove a holiday from internal storage
  601.     *
  602.     * This method should be used within driver classes to unset holidays that were inherited from
  603.     * parent-drivers
  604.     *
  605.     * @access   protected
  606.     * @param    $string     $internalName   internal name
  607.     * @return   boolean     true on success, otherwise a PEAR_Error object
  608.     * @throws   object PEAR_Error   DATE_HOLIDAYS_INVALID_INTERNAL_NAME
  609.     */
  610.     function _removeHoliday($internalName)
  611.     {
  612.         if (in_array($internalName$this->_internalNames)) {
  613.                 'Couldn\'t remove holiday with this internal name: ' $internalName);
  614.         }
  615.         
  616.         if (isset($this->_dates[$internalName])) {
  617.             unset($this->_dates[$internalName]);
  618.         }
  619.         $locales    array_keys($this->_titles);
  620.         foreach ($locales as $locale{
  621.             if (isset($this->_titles[$locale][$internalName])) {
  622.                 unset($this->_titles[$locale][$internalName]);
  623.             }
  624.         }
  625.         $index      array_search($internalName$this->_internalNames);
  626.         if (is_null($index)) {
  627.             unset($this->_internalNames[$index]);
  628.         }
  629.         return true;
  630.     }
  631.     
  632.    /**
  633.     * Finds the best internally available locale for the specified one
  634.     *
  635.     * @access   protected
  636.     * @param    string  $locale locale
  637.     * @return   string  best locale available
  638.     */
  639.     function _findBestLocale($locale)
  640.     {
  641.         /* exact locale is available */
  642.         if (in_array($locale$this->_availableLocales)) {
  643.             return $locale;
  644.         }
  645.         
  646.         /* first two letter are equal */
  647.         foreach ($this->_availableLocales as $aLocale{
  648.             if (strncasecmp($aLocale$locale2== 0{
  649.                 return $aLocale;
  650.             }
  651.         }
  652.         
  653.         /* no appropriate locale available, will use driver's internal locale */
  654.         return 'C';
  655.     }
  656.     
  657.    /**
  658.     * Returns date of a holiday
  659.     *
  660.     * @access   public
  661.     * @param    string  $internalName   internal name for holiday
  662.     * @return   object Date             date of the holiday as PEAR::Date object on success, otherwise a PEAR_Error object
  663.     * @throws   object PEAR_Error       DATE_HOLIDAYS_INVALID_INTERNAL_NAME, DATE_HOLIDAYS_DATE_UNAVAILABLE
  664.     */
  665.     function getHolidayDate($internalName)
  666.     {
  667.         if (in_array($internalName$this->_internalNames)) {
  668.             return Date_Holidays::raiseError(DATE_HOLIDAYS_INVALID_INTERNAL_NAME'Invalid internal name: ' $internalName);
  669.         }
  670.         
  671.         if (isset($this->_dates[$internalName])) {
  672.             return Date_Holidays::raiseError(DATE_HOLIDAYS_DATE_UNAVAILABLE'Date for holiday with internal name ' $internalName 
  673.                 ' is not available');
  674.         }
  675.         
  676.         return $this->_dates[$internalName];
  677.     }
  678.     
  679.    /**
  680.     * Returns dates of all holidays or those specififed in $restrict array
  681.     *
  682.     * Structure of the returned array:
  683.     * <pre>
  684.     * array(
  685.     *   'internalNameFoo' => object of type date,
  686.     *   'internalNameBar' => object of type date
  687.     * )
  688.     * </pre>
  689.     *
  690.     * @access   public
  691.     * @param    array   $restrict   internal names of desired holidays
  692.     * @return   array with holidays' dates on success, otherwise a PEAR_Error object
  693.     * @throws   object PEAR_Error   DATE_HOLIDAYS_INVALID_INTERNAL_NAME
  694.     * @uses     getHolidayDate()
  695.     */
  696.     function getHolidayDates($restrict = array())
  697.     {
  698.         if (empty($restrict)) {
  699.             $restrict               $this->_internalNames;
  700.         }
  701.         
  702.         $dates                      =   array();
  703.         foreach ($restrict as $internalName{
  704.             $date                   &$this->getHolidayDate($internalName);
  705.             if (Date_Holidays::isError($date)) {
  706.                 return $date;
  707.             }
  708.             $dates[$internalName]   &$this->getHolidayDate($internalName);
  709.         }
  710.         return $dates;
  711.     }
  712.     
  713.    /**
  714.     * Sets the driver's locale
  715.     *
  716.     * @access   public
  717.     * @param    string  $locale locale
  718.     */
  719.     function setLocale($locale)
  720.     {
  721.         $this->_locale  =   $locale;
  722.     }
  723. }
  724. ?>

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