mirror of
https://github.com/ACSPRI/queXS
synced 2024-04-02 12:12:16 +00:00
Updated PEAR Calendar class to resolve PHP Strict notices
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,197 +1,232 @@
|
|||||||
<?php
|
<?php
|
||||||
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
||||||
//
|
|
||||||
// +----------------------------------------------------------------------+
|
/**
|
||||||
// | PHP Version 4 |
|
* Contains the Calendar_Day class
|
||||||
// +----------------------------------------------------------------------+
|
*
|
||||||
// | Copyright (c) 1997-2002 The PHP Group |
|
* PHP versions 4 and 5
|
||||||
// +----------------------------------------------------------------------+
|
*
|
||||||
// | This source file is subject to version 2.02 of the PHP license, |
|
* LICENSE: Redistribution and use in source and binary forms, with or without
|
||||||
// | that is bundled with this package in the file LICENSE, and is |
|
* modification, are permitted provided that the following conditions are met:
|
||||||
// | available at through the world-wide-web at |
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
// | http://www.php.net/license/3_0.txt. |
|
* notice, this list of conditions and the following disclaimer.
|
||||||
// | If you did not receive a copy of the PHP license and are unable to |
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
// | obtain it through the world-wide-web, please send a note to |
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
// | license@php.net so we can mail you a copy immediately. |
|
* documentation and/or other materials provided with the distribution.
|
||||||
// +----------------------------------------------------------------------+
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
// | Authors: Harry Fuecks <hfuecks@phppatterns.com> |
|
* derived from this software without specific prior written permission.
|
||||||
// +----------------------------------------------------------------------+
|
*
|
||||||
//
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||||
// $Id: Day.php,v 1.1 2004/05/24 22:25:42 quipo Exp $
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
//
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
/**
|
* IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
* @package Calendar
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* @version $Id: Day.php,v 1.1 2004/05/24 22:25:42 quipo Exp $
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
*/
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
/**
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
* Allows Calendar include path to be redefined
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
* @ignore
|
*
|
||||||
*/
|
* @category Date and Time
|
||||||
if (!defined('CALENDAR_ROOT')) {
|
* @package Calendar
|
||||||
define('CALENDAR_ROOT', 'Calendar'.DIRECTORY_SEPARATOR);
|
* @author Harry Fuecks <hfuecks@phppatterns.com>
|
||||||
}
|
* @copyright 2003-2007 Harry Fuecks
|
||||||
|
* @license http://www.debian.org/misc/bsd.license BSD License (3 Clause)
|
||||||
/**
|
* @version CVS: $Id: Day.php 300729 2010-06-24 12:05:53Z quipo $
|
||||||
* Load Calendar base class
|
* @link http://pear.php.net/package/Calendar
|
||||||
*/
|
*/
|
||||||
require_once CALENDAR_ROOT.'Calendar.php';
|
|
||||||
|
/**
|
||||||
/**
|
* Allows Calendar include path to be redefined
|
||||||
* Represents a Day and builds Hours.
|
* @ignore
|
||||||
* <code>
|
*/
|
||||||
* require_once 'Calendar'.DIRECTORY_SEPARATOR.'Day.php';
|
if (!defined('CALENDAR_ROOT')) {
|
||||||
* $Day = & new Calendar_Day(2003, 10, 21); // Oct 21st 2003
|
define('CALENDAR_ROOT', 'Calendar'.DIRECTORY_SEPARATOR);
|
||||||
* while ($Hour = & $Day->fetch()) {
|
}
|
||||||
* echo $Hour->thisHour().'<br />';
|
|
||||||
* }
|
/**
|
||||||
* </code>
|
* Load Calendar base class
|
||||||
* @package Calendar
|
*/
|
||||||
* @access public
|
require_once CALENDAR_ROOT.'Calendar.php';
|
||||||
*/
|
|
||||||
class Calendar_Day extends Calendar
|
/**
|
||||||
{
|
* Represents a Day and builds Hours.
|
||||||
/**
|
* <code>
|
||||||
* Marks the Day at the beginning of a week
|
* require_once 'Calendar/Day.php';
|
||||||
* @access private
|
* $Day = new Calendar_Day(2003, 10, 21); // Oct 21st 2003
|
||||||
* @var boolean
|
* while ($Hour = & $Day->fetch()) {
|
||||||
*/
|
* echo $Hour->thisHour().'<br />';
|
||||||
var $first = false;
|
* }
|
||||||
|
* </code>
|
||||||
/**
|
*
|
||||||
* Marks the Day at the end of a week
|
* @category Date and Time
|
||||||
* @access private
|
* @package Calendar
|
||||||
* @var boolean
|
* @author Harry Fuecks <hfuecks@phppatterns.com>
|
||||||
*/
|
* @copyright 2003-2007 Harry Fuecks
|
||||||
var $last = false;
|
* @license http://www.debian.org/misc/bsd.license BSD License (3 Clause)
|
||||||
|
* @link http://pear.php.net/package/Calendar
|
||||||
|
* @access public
|
||||||
/**
|
*/
|
||||||
* Used for tabular calendars
|
class Calendar_Day extends Calendar
|
||||||
* @access private
|
{
|
||||||
* @var boolean
|
/**
|
||||||
*/
|
* Marks the Day at the beginning of a week
|
||||||
var $empty = false;
|
* @access private
|
||||||
|
* @var boolean
|
||||||
/**
|
*/
|
||||||
* Constructs Calendar_Day
|
var $first = false;
|
||||||
* @param int year e.g. 2003
|
|
||||||
* @param int month e.g. 8
|
/**
|
||||||
* @param int day e.g. 15
|
* Marks the Day at the end of a week
|
||||||
* @access public
|
* @access private
|
||||||
*/
|
* @var boolean
|
||||||
function Calendar_Day($y, $m, $d)
|
*/
|
||||||
{
|
var $last = false;
|
||||||
Calendar::Calendar($y, $m, $d);
|
|
||||||
}
|
|
||||||
|
/**
|
||||||
/**
|
* Used for tabular calendars
|
||||||
* Builds the Hours of the Day
|
* @access private
|
||||||
* @param array (optional) Caledar_Hour objects representing selected dates
|
* @var boolean
|
||||||
* @return boolean
|
*/
|
||||||
* @access public
|
var $empty = false;
|
||||||
*/
|
|
||||||
function build($sDates = array())
|
/**
|
||||||
{
|
* Constructs Calendar_Day
|
||||||
require_once CALENDAR_ROOT.'Hour.php';
|
*
|
||||||
|
* @param int $y year e.g. 2003
|
||||||
$hID = $this->cE->getHoursInDay($this->year, $this->month, $this->day);
|
* @param int $m month e.g. 8
|
||||||
for ($i=0; $i < $hID; $i++) {
|
* @param int $d day e.g. 15
|
||||||
$this->children[$i]=
|
*
|
||||||
new Calendar_Hour($this->year, $this->month, $this->day, $i);
|
* @access public
|
||||||
}
|
*/
|
||||||
if (count($sDates) > 0) {
|
function Calendar_Day($y, $m, $d)
|
||||||
$this->setSelection($sDates);
|
{
|
||||||
}
|
parent::Calendar($y, $m, $d);
|
||||||
return true;
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
/**
|
* Builds the Hours of the Day
|
||||||
* Called from build()
|
*
|
||||||
* @param array
|
* @param array $sDates (optional) Caledar_Hour objects representing selected dates
|
||||||
* @return void
|
*
|
||||||
* @access private
|
* @return boolean
|
||||||
*/
|
* @access public
|
||||||
function setSelection($sDates)
|
*/
|
||||||
{
|
function build($sDates = array())
|
||||||
foreach ($sDates as $sDate) {
|
{
|
||||||
if ($this->year == $sDate->thisYear()
|
include_once CALENDAR_ROOT.'Hour.php';
|
||||||
&& $this->month == $sDate->thisMonth()
|
|
||||||
&& $this->day == $sDate->thisDay())
|
$hID = $this->cE->getHoursInDay($this->year, $this->month, $this->day);
|
||||||
{
|
for ($i=0; $i < $hID; $i++) {
|
||||||
$key = (int)$sDate->thisHour();
|
$this->children[$i] =
|
||||||
if (isset($this->children[$key])) {
|
new Calendar_Hour($this->year, $this->month, $this->day, $i);
|
||||||
$sDate->setSelected();
|
}
|
||||||
$this->children[$key] = $sDate;
|
if (count($sDates) > 0) {
|
||||||
}
|
$this->setSelection($sDates);
|
||||||
}
|
}
|
||||||
}
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines Day object as first in a week
|
* Called from build()
|
||||||
* Only used by Calendar_Month_Weekdays::build()
|
*
|
||||||
* @param boolean state
|
* @param array $sDates dates to be selected
|
||||||
* @return void
|
*
|
||||||
* @access private
|
* @return void
|
||||||
*/
|
* @access private
|
||||||
function setFirst ($state = true)
|
*/
|
||||||
{
|
function setSelection($sDates)
|
||||||
$this->first = $state;
|
{
|
||||||
}
|
foreach ($sDates as $sDate) {
|
||||||
|
if ($this->year == $sDate->thisYear()
|
||||||
/**
|
&& $this->month == $sDate->thisMonth()
|
||||||
* Defines Day object as last in a week
|
&& $this->day == $sDate->thisDay())
|
||||||
* Used only following Calendar_Month_Weekdays::build()
|
{
|
||||||
* @param boolean state
|
$key = (int)$sDate->thisHour();
|
||||||
* @return void
|
if (isset($this->children[$key])) {
|
||||||
* @access private
|
$sDate->setSelected();
|
||||||
*/
|
$this->children[$key] = $sDate;
|
||||||
function setLast($state = true)
|
}
|
||||||
{
|
}
|
||||||
$this->last = $state;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if Day object is first in a Week
|
* Defines Day object as first in a week
|
||||||
* Only relevant when Day is created by Calendar_Month_Weekdays::build()
|
* Only used by Calendar_Month_Weekdays::build()
|
||||||
* @return boolean
|
*
|
||||||
* @access public
|
* @param boolean $state set this day as first in week
|
||||||
*/
|
*
|
||||||
function isFirst() {
|
* @return void
|
||||||
return $this->first;
|
* @access private
|
||||||
}
|
*/
|
||||||
|
function setFirst($state = true)
|
||||||
/**
|
{
|
||||||
* Returns true if Day object is last in a Week
|
$this->first = $state;
|
||||||
* Only relevant when Day is created by Calendar_Month_Weekdays::build()
|
}
|
||||||
* @return boolean
|
|
||||||
* @access public
|
/**
|
||||||
*/
|
* Defines Day object as last in a week
|
||||||
function isLast()
|
* Used only following Calendar_Month_Weekdays::build()
|
||||||
{
|
*
|
||||||
return $this->last;
|
* @param boolean $state set this day as last in week
|
||||||
}
|
*
|
||||||
|
* @return void
|
||||||
/**
|
* @access private
|
||||||
* Defines Day object as empty
|
*/
|
||||||
* Only used by Calendar_Month_Weekdays::build()
|
function setLast($state = true)
|
||||||
* @param boolean state
|
{
|
||||||
* @return void
|
$this->last = $state;
|
||||||
* @access private
|
}
|
||||||
*/
|
|
||||||
function setEmpty ($state = true)
|
/**
|
||||||
{
|
* Returns true if Day object is first in a Week
|
||||||
$this->empty = $state;
|
* Only relevant when Day is created by Calendar_Month_Weekdays::build()
|
||||||
}
|
*
|
||||||
|
* @return boolean
|
||||||
/**
|
* @access public
|
||||||
* @return boolean
|
*/
|
||||||
* @access public
|
function isFirst()
|
||||||
*/
|
{
|
||||||
function isEmpty()
|
return $this->first;
|
||||||
{
|
}
|
||||||
return $this->empty;
|
|
||||||
}
|
/**
|
||||||
}
|
* Returns true if Day object is last in a Week
|
||||||
|
* Only relevant when Day is created by Calendar_Month_Weekdays::build()
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function isLast()
|
||||||
|
{
|
||||||
|
return $this->last;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Defines Day object as empty
|
||||||
|
* Only used by Calendar_Month_Weekdays::build()
|
||||||
|
*
|
||||||
|
* @param boolean $state set this day as empty
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
function setEmpty ($state = true)
|
||||||
|
{
|
||||||
|
$this->empty = $state;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if this day is empty
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function isEmpty()
|
||||||
|
{
|
||||||
|
return $this->empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,169 +1,208 @@
|
|||||||
<?php
|
<?php
|
||||||
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
||||||
//
|
|
||||||
// +----------------------------------------------------------------------+
|
/**
|
||||||
// | PHP Version 4 |
|
* Contains the Calendar_Decorator_Wrapper class
|
||||||
// +----------------------------------------------------------------------+
|
*
|
||||||
// | Copyright (c) 1997-2002 The PHP Group |
|
* PHP versions 4 and 5
|
||||||
// +----------------------------------------------------------------------+
|
*
|
||||||
// | This source file is subject to version 2.02 of the PHP license, |
|
* LICENSE: Redistribution and use in source and binary forms, with or without
|
||||||
// | that is bundled with this package in the file LICENSE, and is |
|
* modification, are permitted provided that the following conditions are met:
|
||||||
// | available at through the world-wide-web at |
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
// | http://www.php.net/license/3_0.txt. |
|
* notice, this list of conditions and the following disclaimer.
|
||||||
// | If you did not receive a copy of the PHP license and are unable to |
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
// | obtain it through the world-wide-web, please send a note to |
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
// | license@php.net so we can mail you a copy immediately. |
|
* documentation and/or other materials provided with the distribution.
|
||||||
// +----------------------------------------------------------------------+
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
// | Authors: Harry Fuecks <hfuecks@phppatterns.com> |
|
* derived from this software without specific prior written permission.
|
||||||
// | Lorenzo Alberton <l dot alberton at quipo dot it> |
|
*
|
||||||
// +----------------------------------------------------------------------+
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||||
//
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
// $Id: Textual.php,v 1.3 2004/08/16 13:02:44 hfuecks Exp $
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
//
|
* IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
/**
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* @package Calendar
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
* @version $Id: Textual.php,v 1.3 2004/08/16 13:02:44 hfuecks Exp $
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
*/
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
/**
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
* Allows Calendar include path to be redefined
|
*
|
||||||
* @ignore
|
* @category Date and Time
|
||||||
*/
|
* @package Calendar
|
||||||
if (!defined('CALENDAR_ROOT')) {
|
* @author Harry Fuecks <hfuecks@phppatterns.com>
|
||||||
define('CALENDAR_ROOT', 'Calendar'.DIRECTORY_SEPARATOR);
|
* @author Lorenzo Alberton <l.alberton@quipo.it>
|
||||||
}
|
* @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton
|
||||||
|
* @license http://www.debian.org/misc/bsd.license BSD License (3 Clause)
|
||||||
/**
|
* @version CVS: $Id: Textual.php 246907 2007-11-24 11:04:24Z quipo $
|
||||||
* Load Calendar decorator base class
|
* @link http://pear.php.net/package/Calendar
|
||||||
*/
|
*/
|
||||||
require_once CALENDAR_ROOT.'Decorator.php';
|
|
||||||
|
/**
|
||||||
/**
|
* Allows Calendar include path to be redefined
|
||||||
* Load the Uri utility
|
* @ignore
|
||||||
*/
|
*/
|
||||||
require_once CALENDAR_ROOT.'Util'.DIRECTORY_SEPARATOR.'Textual.php';
|
if (!defined('CALENDAR_ROOT')) {
|
||||||
|
define('CALENDAR_ROOT', 'Calendar'.DIRECTORY_SEPARATOR);
|
||||||
/**
|
}
|
||||||
* Decorator to help with fetching textual representations of months and
|
|
||||||
* days of the week.
|
/**
|
||||||
* <b>Note:</b> for performance you should prefer Calendar_Util_Textual unless you
|
* Load Calendar decorator base class
|
||||||
* have a specific need to use a decorator
|
*/
|
||||||
* @package Calendar
|
require_once CALENDAR_ROOT.'Decorator.php';
|
||||||
* @access public
|
|
||||||
*/
|
/**
|
||||||
class Calendar_Decorator_Textual extends Calendar_Decorator
|
* Load the Uri utility
|
||||||
{
|
*/
|
||||||
/**
|
require_once CALENDAR_ROOT.'Util'.DIRECTORY_SEPARATOR.'Textual.php';
|
||||||
* Constructs Calendar_Decorator_Textual
|
|
||||||
* @param object subclass of Calendar
|
/**
|
||||||
* @access public
|
* Decorator to help with fetching textual representations of months and
|
||||||
*/
|
* days of the week.
|
||||||
function Calendar_Decorator_Textual(&$Calendar)
|
* <b>Note:</b> for performance you should prefer Calendar_Util_Textual unless you
|
||||||
{
|
* have a specific need to use a decorator
|
||||||
parent::Calendar_Decorator($Calendar);
|
*
|
||||||
}
|
* @category Date and Time
|
||||||
|
* @package Calendar
|
||||||
/**
|
* @author Harry Fuecks <hfuecks@phppatterns.com>
|
||||||
* Returns an array of 12 month names (first index = 1)
|
* @author Lorenzo Alberton <l.alberton@quipo.it>
|
||||||
* @param string (optional) format of returned months (one,two,short or long)
|
* @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton
|
||||||
* @return array
|
* @license http://www.debian.org/misc/bsd.license BSD License (3 Clause)
|
||||||
* @access public
|
* @link http://pear.php.net/package/Calendar
|
||||||
* @static
|
* @access public
|
||||||
*/
|
*/
|
||||||
function monthNames($format='long')
|
class Calendar_Decorator_Textual extends Calendar_Decorator
|
||||||
{
|
{
|
||||||
return Calendar_Util_Textual::monthNames($format);
|
/**
|
||||||
}
|
* Constructs Calendar_Decorator_Textual
|
||||||
|
*
|
||||||
/**
|
* @param object &$Calendar subclass of Calendar
|
||||||
* Returns an array of 7 week day names (first index = 0)
|
*
|
||||||
* @param string (optional) format of returned days (one,two,short or long)
|
* @access public
|
||||||
* @return array
|
*/
|
||||||
* @access public
|
function Calendar_Decorator_Textual(&$Calendar)
|
||||||
* @static
|
{
|
||||||
*/
|
parent::Calendar_Decorator($Calendar);
|
||||||
function weekdayNames($format='long')
|
}
|
||||||
{
|
|
||||||
return Calendar_Util_Textual::weekdayNames($format);
|
/**
|
||||||
}
|
* Returns an array of 12 month names (first index = 1)
|
||||||
|
*
|
||||||
/**
|
* @param string $format (optional) format of returned months (one|two|short|long)
|
||||||
* Returns textual representation of the previous month of the decorated calendar object
|
*
|
||||||
* @param string (optional) format of returned months (one,two,short or long)
|
* @return array
|
||||||
* @return string
|
* @access public
|
||||||
* @access public
|
* @static
|
||||||
*/
|
*/
|
||||||
function prevMonthName($format='long')
|
function monthNames($format = 'long')
|
||||||
{
|
{
|
||||||
return Calendar_Util_Textual::prevMonthName($this->calendar,$format);
|
return Calendar_Util_Textual::monthNames($format);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns textual representation of the month of the decorated calendar object
|
* Returns an array of 7 week day names (first index = 0)
|
||||||
* @param string (optional) format of returned months (one,two,short or long)
|
*
|
||||||
* @return string
|
* @param string $format (optional) format of returned days (one|two|short|long)
|
||||||
* @access public
|
*
|
||||||
*/
|
* @return array
|
||||||
function thisMonthName($format='long')
|
* @access public
|
||||||
{
|
* @static
|
||||||
return Calendar_Util_Textual::thisMonthName($this->calendar,$format);
|
*/
|
||||||
}
|
function weekdayNames($format = 'long')
|
||||||
|
{
|
||||||
/**
|
return Calendar_Util_Textual::weekdayNames($format);
|
||||||
* Returns textual representation of the next month of the decorated calendar object
|
}
|
||||||
* @param string (optional) format of returned months (one,two,short or long)
|
|
||||||
* @return string
|
/**
|
||||||
* @access public
|
* Returns textual representation of the previous month of the decorated calendar object
|
||||||
*/
|
*
|
||||||
function nextMonthName($format='long')
|
* @param string $format (optional) format of returned months (one|two|short|long)
|
||||||
{
|
*
|
||||||
return Calendar_Util_Textual::nextMonthName($this->calendar,$format);
|
* @return string
|
||||||
}
|
* @access public
|
||||||
|
*/
|
||||||
/**
|
function prevMonthName($format = 'long')
|
||||||
* Returns textual representation of the previous day of week of the decorated calendar object
|
{
|
||||||
* @param string (optional) format of returned months (one,two,short or long)
|
return Calendar_Util_Textual::prevMonthName($this->calendar, $format);
|
||||||
* @return string
|
}
|
||||||
* @access public
|
|
||||||
*/
|
/**
|
||||||
function prevDayName($format='long')
|
* Returns textual representation of the month of the decorated calendar object
|
||||||
{
|
*
|
||||||
return Calendar_Util_Textual::prevDayName($this->calendar,$format);
|
* @param string $format (optional) format of returned months (one|two|short|long)
|
||||||
}
|
*
|
||||||
|
* @return string
|
||||||
/**
|
* @access public
|
||||||
* Returns textual representation of the day of week of the decorated calendar object
|
*/
|
||||||
* @param string (optional) format of returned months (one,two,short or long)
|
function thisMonthName($format = 'long')
|
||||||
* @return string
|
{
|
||||||
* @access public
|
return Calendar_Util_Textual::thisMonthName($this->calendar, $format);
|
||||||
*/
|
}
|
||||||
function thisDayName($format='long')
|
|
||||||
{
|
/**
|
||||||
return Calendar_Util_Textual::thisDayName($this->calendar,$format);
|
* Returns textual representation of the next month of the decorated calendar object
|
||||||
}
|
*
|
||||||
|
* @param string $format (optional) format of returned months (one|two|short|long)
|
||||||
/**
|
*
|
||||||
* Returns textual representation of the next day of week of the decorated calendar object
|
* @return string
|
||||||
* @param string (optional) format of returned months (one,two,short or long)
|
* @access public
|
||||||
* @return string
|
*/
|
||||||
* @access public
|
function nextMonthName($format = 'long')
|
||||||
*/
|
{
|
||||||
function nextDayName($format='long')
|
return Calendar_Util_Textual::nextMonthName($this->calendar, $format);
|
||||||
{
|
}
|
||||||
return Calendar_Util_Textual::nextDayName($this->calendar,$format);
|
|
||||||
}
|
/**
|
||||||
|
* Returns textual representation of the previous day of week of the decorated calendar object
|
||||||
/**
|
*
|
||||||
* Returns the days of the week using the order defined in the decorated
|
* @param string $format (optional) format of returned months (one|two|short|long)
|
||||||
* calendar object. Only useful for Calendar_Month_Weekdays, Calendar_Month_Weeks
|
*
|
||||||
* and Calendar_Week. Otherwise the returned array will begin on Sunday
|
* @return string
|
||||||
* @param string (optional) format of returned months (one,two,short or long)
|
* @access public
|
||||||
* @return array ordered array of week day names
|
*/
|
||||||
* @access public
|
function prevDayName($format = 'long')
|
||||||
*/
|
{
|
||||||
function orderedWeekdays($format='long')
|
return Calendar_Util_Textual::prevDayName($this->calendar, $format);
|
||||||
{
|
}
|
||||||
return Calendar_Util_Textual::orderedWeekdays($this->calendar,$format);
|
|
||||||
}
|
/**
|
||||||
}
|
* Returns textual representation of the day of week of the decorated calendar object
|
||||||
|
*
|
||||||
|
* @param string $format (optional) format of returned months (one|two|short|long)
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function thisDayName($format = 'long')
|
||||||
|
{
|
||||||
|
return Calendar_Util_Textual::thisDayName($this->calendar, $format);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns textual representation of the next day of week of the decorated calendar object
|
||||||
|
*
|
||||||
|
* @param string $format (optional) format of returned months (one|two|short|long)
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function nextDayName($format = 'long')
|
||||||
|
{
|
||||||
|
return Calendar_Util_Textual::nextDayName($this->calendar, $format);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the days of the week using the order defined in the decorated
|
||||||
|
* calendar object. Only useful for Calendar_Month_Weekdays, Calendar_Month_Weeks
|
||||||
|
* and Calendar_Week. Otherwise the returned array will begin on Sunday
|
||||||
|
*
|
||||||
|
* @param string $format (optional) format of returned months (one|two|short|long)
|
||||||
|
*
|
||||||
|
* @return array ordered array of week day names
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function orderedWeekdays($format = 'long')
|
||||||
|
{
|
||||||
|
return Calendar_Util_Textual::orderedWeekdays($this->calendar, $format);
|
||||||
|
}
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
@@ -1,151 +1,183 @@
|
|||||||
<?php
|
<?php
|
||||||
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
||||||
//
|
|
||||||
// +----------------------------------------------------------------------+
|
/**
|
||||||
// | PHP Version 4 |
|
* Contains the Calendar_Decorator_Uri class
|
||||||
// +----------------------------------------------------------------------+
|
*
|
||||||
// | Copyright (c) 1997-2002 The PHP Group |
|
* PHP versions 4 and 5
|
||||||
// +----------------------------------------------------------------------+
|
*
|
||||||
// | This source file is subject to version 2.02 of the PHP license, |
|
* LICENSE: Redistribution and use in source and binary forms, with or without
|
||||||
// | that is bundled with this package in the file LICENSE, and is |
|
* modification, are permitted provided that the following conditions are met:
|
||||||
// | available at through the world-wide-web at |
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
// | http://www.php.net/license/3_0.txt. |
|
* notice, this list of conditions and the following disclaimer.
|
||||||
// | If you did not receive a copy of the PHP license and are unable to |
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
// | obtain it through the world-wide-web, please send a note to |
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
// | license@php.net so we can mail you a copy immediately. |
|
* documentation and/or other materials provided with the distribution.
|
||||||
// +----------------------------------------------------------------------+
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
// | Authors: Harry Fuecks <hfuecks@phppatterns.com> |
|
* derived from this software without specific prior written permission.
|
||||||
// | Lorenzo Alberton <l dot alberton at quipo dot it> |
|
*
|
||||||
// +----------------------------------------------------------------------+
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||||
//
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
// $Id: Uri.php,v 1.3 2004/08/16 09:04:20 hfuecks Exp $
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
//
|
* IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
/**
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* @package Calendar
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
* @version $Id: Uri.php,v 1.3 2004/08/16 09:04:20 hfuecks Exp $
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
*/
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
/**
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
* Allows Calendar include path to be redefined
|
*
|
||||||
* @ignore
|
* @category Date and Time
|
||||||
*/
|
* @package Calendar
|
||||||
if (!defined('CALENDAR_ROOT')) {
|
* @author Harry Fuecks <hfuecks@phppatterns.com>
|
||||||
define('CALENDAR_ROOT', 'Calendar'.DIRECTORY_SEPARATOR);
|
* @author Lorenzo Alberton <l.alberton@quipo.it>
|
||||||
}
|
* @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton
|
||||||
|
* @license http://www.debian.org/misc/bsd.license BSD License (3 Clause)
|
||||||
/**
|
* @version CVS: $Id: Uri.php 300729 2010-06-24 12:05:53Z quipo $
|
||||||
* Load Calendar decorator base class
|
* @link http://pear.php.net/package/Calendar
|
||||||
*/
|
*/
|
||||||
require_once CALENDAR_ROOT.'Decorator.php';
|
|
||||||
|
/**
|
||||||
/**
|
* Allows Calendar include path to be redefined
|
||||||
* Load the Uri utility
|
* @ignore
|
||||||
*/
|
*/
|
||||||
require_once CALENDAR_ROOT.'Util'.DIRECTORY_SEPARATOR.'Uri.php';
|
if (!defined('CALENDAR_ROOT')) {
|
||||||
|
define('CALENDAR_ROOT', 'Calendar'.DIRECTORY_SEPARATOR);
|
||||||
/**
|
}
|
||||||
* Decorator to help with building HTML links for navigating the calendar<br />
|
|
||||||
* <b>Note:</b> for performance you should prefer Calendar_Util_Uri unless you
|
/**
|
||||||
* have a specific need to use a decorator
|
* Load Calendar decorator base class
|
||||||
* <code>
|
*/
|
||||||
* $Day = new Calendar_Day(2003, 10, 23);
|
require_once CALENDAR_ROOT.'Decorator.php';
|
||||||
* $Uri = & new Calendar_Decorator_Uri($Day);
|
|
||||||
* $Uri->setFragments('year', 'month', 'day');
|
/**
|
||||||
* echo $Uri->getPrev(); // Displays year=2003&month=10&day=22
|
* Load the Uri utility
|
||||||
* </code>
|
*/
|
||||||
* @see Calendar_Util_Uri
|
require_once CALENDAR_ROOT.'Util'.DIRECTORY_SEPARATOR.'Uri.php';
|
||||||
* @package Calendar
|
|
||||||
* @access public
|
/**
|
||||||
*/
|
* Decorator to help with building HTML links for navigating the calendar<br />
|
||||||
class Calendar_Decorator_Uri extends Calendar_Decorator
|
* <b>Note:</b> for performance you should prefer Calendar_Util_Uri unless you
|
||||||
{
|
* have a specific need to use a decorator
|
||||||
|
* <code>
|
||||||
/**
|
* $Day = new Calendar_Day(2003, 10, 23);
|
||||||
* @var Calendar_Util_Uri
|
* $Uri = new Calendar_Decorator_Uri($Day);
|
||||||
* @access private
|
* $Uri->setFragments('year', 'month', 'day');
|
||||||
*/
|
* echo $Uri->getPrev(); // Displays year=2003&month=10&day=22
|
||||||
var $Uri;
|
* </code>
|
||||||
|
*
|
||||||
/**
|
* @category Date and Time
|
||||||
* Constructs Calendar_Decorator_Uri
|
* @package Calendar
|
||||||
* @param object subclass of Calendar
|
* @author Harry Fuecks <hfuecks@phppatterns.com>
|
||||||
* @access public
|
* @author Lorenzo Alberton <l.alberton@quipo.it>
|
||||||
*/
|
* @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton
|
||||||
function Calendar_Decorator_Uri(&$Calendar)
|
* @license http://www.debian.org/misc/bsd.license BSD License (3 Clause)
|
||||||
{
|
* @link http://pear.php.net/package/Calendar
|
||||||
parent::Calendar_Decorator($Calendar);
|
* @see Calendar_Util_Uri
|
||||||
}
|
* @access public
|
||||||
|
*/
|
||||||
/**
|
class Calendar_Decorator_Uri extends Calendar_Decorator
|
||||||
* Sets the URI fragment names
|
{
|
||||||
* @param string URI fragment for year
|
|
||||||
* @param string (optional) URI fragment for month
|
/**
|
||||||
* @param string (optional) URI fragment for day
|
* @var Calendar_Util_Uri
|
||||||
* @param string (optional) URI fragment for hour
|
* @access private
|
||||||
* @param string (optional) URI fragment for minute
|
*/
|
||||||
* @param string (optional) URI fragment for second
|
var $Uri;
|
||||||
* @return void
|
|
||||||
* @access public
|
/**
|
||||||
*/
|
* Constructs Calendar_Decorator_Uri
|
||||||
function setFragments($y, $m=null, $d=null, $h=null, $i=null, $s=null) {
|
*
|
||||||
$this->Uri = & new Calendar_Util_Uri($y, $m, $d, $h, $i, $s);
|
* @param object &$Calendar subclass of Calendar
|
||||||
}
|
*
|
||||||
|
* @access public
|
||||||
/**
|
*/
|
||||||
* Sets the separator string between fragments
|
function Calendar_Decorator_Uri(&$Calendar)
|
||||||
* @param string separator e.g. /
|
{
|
||||||
* @return void
|
parent::Calendar_Decorator($Calendar);
|
||||||
* @access public
|
}
|
||||||
*/
|
|
||||||
function setSeparator($separator)
|
/**
|
||||||
{
|
* Sets the URI fragment names
|
||||||
$this->Uri->separator = $separator;
|
*
|
||||||
}
|
* @param string $y URI fragment for year
|
||||||
|
* @param string $m (optional) URI fragment for month
|
||||||
/**
|
* @param string $d (optional) URI fragment for day
|
||||||
* Puts Uri decorator into "scalar mode" - URI variable names are not
|
* @param string $h (optional) URI fragment for hour
|
||||||
* returned
|
* @param string $i (optional) URI fragment for minute
|
||||||
* @param boolean (optional)
|
* @param string $s (optional) URI fragment for second
|
||||||
* @return void
|
*
|
||||||
* @access public
|
* @return void
|
||||||
*/
|
* @access public
|
||||||
function setScalar($state=true)
|
*/
|
||||||
{
|
function setFragments($y, $m = null, $d = null, $h = null, $i = null, $s = null)
|
||||||
$this->Uri->scalar = $state;
|
{
|
||||||
}
|
$this->Uri = new Calendar_Util_Uri($y, $m, $d, $h, $i, $s);
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Gets the URI string for the previous calendar unit
|
/**
|
||||||
* @param string calendar unit to fetch uri for (year,month,week or day etc)
|
* Sets the separator string between fragments
|
||||||
* @return string
|
*
|
||||||
* @access public
|
* @param string $separator url fragment separator e.g. /
|
||||||
*/
|
*
|
||||||
function prev($method)
|
* @return void
|
||||||
{
|
* @access public
|
||||||
return $this->Uri->prev($this, $method);
|
*/
|
||||||
}
|
function setSeparator($separator)
|
||||||
|
{
|
||||||
/**
|
$this->Uri->separator = $separator;
|
||||||
* Gets the URI string for the current calendar unit
|
}
|
||||||
* @param string calendar unit to fetch uri for (year,month,week or day etc)
|
|
||||||
* @return string
|
/**
|
||||||
* @access public
|
* Puts Uri decorator into "scalar mode" - URI variable names are not returned
|
||||||
*/
|
*
|
||||||
function this($method)
|
* @param boolean $state (optional)
|
||||||
{
|
*
|
||||||
return $this->Uri->this($this, $method);
|
* @return void
|
||||||
}
|
* @access public
|
||||||
|
*/
|
||||||
/**
|
function setScalar($state = true)
|
||||||
* Gets the URI string for the next calendar unit
|
{
|
||||||
* @param string calendar unit to fetch uri for (year,month,week or day etc)
|
$this->Uri->scalar = $state;
|
||||||
* @return string
|
}
|
||||||
* @access public
|
|
||||||
*/
|
/**
|
||||||
function next($method)
|
* Gets the URI string for the previous calendar unit
|
||||||
{
|
*
|
||||||
return $this->Uri->next($this, $method);
|
* @param string $method calendar unit to fetch uri for (year, month, week or day etc)
|
||||||
}
|
*
|
||||||
|
* @return string
|
||||||
}
|
* @access public
|
||||||
|
*/
|
||||||
|
function prev($method)
|
||||||
|
{
|
||||||
|
return $this->Uri->prev($this, $method);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the URI string for the current calendar unit
|
||||||
|
*
|
||||||
|
* @param string $method calendar unit to fetch uri for (year,month,week or day etc)
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function this($method)
|
||||||
|
{
|
||||||
|
return $this->Uri->this($this, $method);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the URI string for the next calendar unit
|
||||||
|
*
|
||||||
|
* @param string $method calendar unit to fetch uri for (year,month,week or day etc)
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function next($method)
|
||||||
|
{
|
||||||
|
return $this->Uri->next($this, $method);
|
||||||
|
}
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
@@ -1,148 +1,195 @@
|
|||||||
<?php
|
<?php
|
||||||
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
||||||
//
|
|
||||||
// +----------------------------------------------------------------------+
|
/**
|
||||||
// | PHP Version 4 |
|
* Contains the Calendar_Decorator_Weekday class
|
||||||
// +----------------------------------------------------------------------+
|
*
|
||||||
// | Copyright (c) 1997-2002 The PHP Group |
|
* PHP versions 4 and 5
|
||||||
// +----------------------------------------------------------------------+
|
*
|
||||||
// | This source file is subject to version 2.02 of the PHP license, |
|
* LICENSE: Redistribution and use in source and binary forms, with or without
|
||||||
// | that is bundled with this package in the file LICENSE, and is |
|
* modification, are permitted provided that the following conditions are met:
|
||||||
// | available at through the world-wide-web at |
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
// | http://www.php.net/license/3_0.txt. |
|
* notice, this list of conditions and the following disclaimer.
|
||||||
// | If you did not receive a copy of the PHP license and are unable to |
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
// | obtain it through the world-wide-web, please send a note to |
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
// | license@php.net so we can mail you a copy immediately. |
|
* documentation and/or other materials provided with the distribution.
|
||||||
// +----------------------------------------------------------------------+
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
// | Authors: Harry Fuecks <hfuecks@phppatterns.com> |
|
* derived from this software without specific prior written permission.
|
||||||
// | Lorenzo Alberton <l dot alberton at quipo dot it> |
|
*
|
||||||
// +----------------------------------------------------------------------+
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||||
//
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
// $Id: Weekday.php,v 1.3 2004/08/16 12:25:15 hfuecks Exp $
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
//
|
* IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
/**
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* @package Calendar
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
* @version $Id: Weekday.php,v 1.3 2004/08/16 12:25:15 hfuecks Exp $
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
*/
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
/**
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
* Allows Calendar include path to be redefined
|
*
|
||||||
* @ignore
|
* @category Date and Time
|
||||||
*/
|
* @package Calendar
|
||||||
if (!defined('CALENDAR_ROOT')) {
|
* @author Harry Fuecks <hfuecks@phppatterns.com>
|
||||||
define('CALENDAR_ROOT', 'Calendar'.DIRECTORY_SEPARATOR);
|
* @author Lorenzo Alberton <l.alberton@quipo.it>
|
||||||
}
|
* @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton
|
||||||
|
* @license http://www.debian.org/misc/bsd.license BSD License (3 Clause)
|
||||||
/**
|
* @version CVS: $Id: Weekday.php 300729 2010-06-24 12:05:53Z quipo $
|
||||||
* Load Calendar decorator base class
|
* @link http://pear.php.net/package/Calendar
|
||||||
*/
|
*/
|
||||||
require_once CALENDAR_ROOT.'Decorator.php';
|
|
||||||
|
/**
|
||||||
/**
|
* Allows Calendar include path to be redefined
|
||||||
* Load a Calendar_Day
|
* @ignore
|
||||||
*/
|
*/
|
||||||
require_once CALENDAR_ROOT.'Day.php';
|
if (!defined('CALENDAR_ROOT')) {
|
||||||
/**
|
define('CALENDAR_ROOT', 'Calendar'.DIRECTORY_SEPARATOR);
|
||||||
* Decorator for fetching the day of the week
|
}
|
||||||
* <code>
|
|
||||||
* $Day = new Calendar_Day(2003, 10, 23);
|
/**
|
||||||
* $Weekday = & new Calendar_Decorator_Weekday($Day);
|
* Load Calendar decorator base class
|
||||||
* $Weekday->setFirstDay(0); // Set first day of week to Sunday (default Mon)
|
*/
|
||||||
* echo $Weekday->thisWeekDay(); // Displays 5 - fifth day of week relative to Sun
|
require_once CALENDAR_ROOT.'Decorator.php';
|
||||||
* </code>
|
|
||||||
* @package Calendar
|
/**
|
||||||
* @access public
|
* Load a Calendar_Day
|
||||||
*/
|
*/
|
||||||
class Calendar_Decorator_Weekday extends Calendar_Decorator
|
require_once CALENDAR_ROOT.'Day.php';
|
||||||
{
|
/**
|
||||||
/**
|
* Decorator for fetching the day of the week
|
||||||
* First day of week
|
* <code>
|
||||||
* @var int (default = 1 for Monday)
|
* $Day = new Calendar_Day(2003, 10, 23);
|
||||||
* @access private
|
* $Weekday = new Calendar_Decorator_Weekday($Day);
|
||||||
*/
|
* $Weekday->setFirstDay(0); // Set first day of week to Sunday (default Mon)
|
||||||
var $firstDay = 1;
|
* echo $Weekday->thisWeekDay(); // Displays 5 - fifth day of week relative to Sun
|
||||||
|
* </code>
|
||||||
/**
|
*
|
||||||
* Constructs Calendar_Decorator_Weekday
|
* @category Date and Time
|
||||||
* @param object subclass of Calendar
|
* @package Calendar
|
||||||
* @access public
|
* @author Harry Fuecks <hfuecks@phppatterns.com>
|
||||||
*/
|
* @author Lorenzo Alberton <l.alberton@quipo.it>
|
||||||
function Calendar_Decorator_Weekday(& $Calendar)
|
* @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton
|
||||||
{
|
* @license http://www.debian.org/misc/bsd.license BSD License (3 Clause)
|
||||||
parent::Calendar_Decorator($Calendar);
|
* @link http://pear.php.net/package/Calendar
|
||||||
}
|
* @access public
|
||||||
|
*/
|
||||||
/**
|
class Calendar_Decorator_Weekday extends Calendar_Decorator
|
||||||
* Sets the first day of the week (0 = Sunday, 1 = Monday (default) etc)
|
{
|
||||||
* @param int first day of week
|
/**
|
||||||
* @return void
|
* First day of week
|
||||||
* @access public
|
* @var int (default = 1 for Monday)
|
||||||
*/
|
* @access private
|
||||||
function setFirstDay($firstDay) {
|
*/
|
||||||
$this->firstDay = (int)$firstDay;
|
var $firstDay = 1;
|
||||||
}
|
|
||||||
|
/**
|
||||||
/**
|
* Constructs Calendar_Decorator_Weekday
|
||||||
* Returns the previous weekday
|
*
|
||||||
* @param string (default = 'int') return value format
|
* @param object &$Calendar subclass of Calendar
|
||||||
* @return int numeric day of week or timestamp
|
*
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function prevWeekDay($format = 'int')
|
function Calendar_Decorator_Weekday(&$Calendar)
|
||||||
{
|
{
|
||||||
$ts = $this->calendar->prevDay('timestamp');
|
parent::Calendar_Decorator($Calendar);
|
||||||
$Day = new Calendar_Day(2000,1,1);
|
}
|
||||||
$Day->setTimeStamp($ts);
|
|
||||||
$day = $this->calendar->cE->getDayOfWeek($Day->thisYear(),$Day->thisMonth(),$Day->thisDay());
|
/**
|
||||||
$day = $this->adjustWeekScale($day);
|
* Sets the first day of the week (0 = Sunday, 1 = Monday (default) etc)
|
||||||
return $this->returnValue('Day', $format, $ts, $day);
|
*
|
||||||
}
|
* @param int $firstDay first day of week
|
||||||
|
*
|
||||||
/**
|
* @return void
|
||||||
* Returns the current weekday
|
* @access public
|
||||||
* @param string (default = 'int') return value format
|
*/
|
||||||
* @return int numeric day of week or timestamp
|
function setFirstDay($firstDay)
|
||||||
* @access public
|
{
|
||||||
*/
|
$this->firstDay = (int)$firstDay;
|
||||||
function thisWeekDay($format = 'int')
|
}
|
||||||
{
|
|
||||||
$ts = $this->calendar->thisDay('timestamp');
|
/**
|
||||||
$day = $this->calendar->cE->getDayOfWeek($this->calendar->year,$this->calendar->month,$this->calendar->day);
|
* Returns the previous weekday
|
||||||
$day = $this->adjustWeekScale($day);
|
*
|
||||||
return $this->returnValue('Day', $format, $ts, $day);
|
* @param string $format (default = 'int') return value format
|
||||||
}
|
*
|
||||||
|
* @return int $format numeric day of week or timestamp
|
||||||
/**
|
* @access public
|
||||||
* Returns the next weekday
|
*/
|
||||||
* @param string (default = 'int') return value format
|
function prevWeekDay($format = 'int')
|
||||||
* @return int numeric day of week or timestamp
|
{
|
||||||
* @access public
|
$ts = $this->calendar->prevDay('timestamp');
|
||||||
*/
|
$Day = new Calendar_Day(2000, 1, 1);
|
||||||
function nextWeekDay($format = 'int')
|
$Day->setTimeStamp($ts);
|
||||||
{
|
$day = $this->calendar->cE->getDayOfWeek(
|
||||||
$ts = $this->calendar->nextDay('timestamp');
|
$Day->thisYear(),
|
||||||
$Day = new Calendar_Day(2000,1,1);
|
$Day->thisMonth(),
|
||||||
$Day->setTimeStamp($ts);
|
$Day->thisDay()
|
||||||
$day = $this->calendar->cE->getDayOfWeek($Day->thisYear(),$Day->thisMonth(),$Day->thisDay());
|
);
|
||||||
$day = $this->adjustWeekScale($day);
|
$day = $this->adjustWeekScale($day);
|
||||||
return $this->returnValue('Day', $format, $ts, $day);
|
return $this->returnValue('Day', $format, $ts, $day);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Adjusts the day of the week relative to the first day of the week
|
* Returns the current weekday
|
||||||
* @param int day of week calendar from Calendar_Engine
|
*
|
||||||
* @return int day of week adjusted to first day
|
* @param string $format (default = 'int') return value format
|
||||||
* @access private
|
*
|
||||||
*/
|
* @return int numeric day of week or timestamp
|
||||||
function adjustWeekScale($dayOfWeek) {
|
* @access public
|
||||||
$dayOfWeek = $dayOfWeek - $this->firstDay;
|
*/
|
||||||
if ( $dayOfWeek >= 0 ) {
|
function thisWeekDay($format = 'int')
|
||||||
return $dayOfWeek;
|
{
|
||||||
} else {
|
$ts = $this->calendar->thisDay('timestamp');
|
||||||
return $this->calendar->cE->getDaysInWeek(
|
$day = $this->calendar->cE->getDayOfWeek(
|
||||||
$this->calendar->year,$this->calendar->month,$this->calendar->day
|
$this->calendar->year,
|
||||||
) + $dayOfWeek;
|
$this->calendar->month,
|
||||||
}
|
$this->calendar->day
|
||||||
}
|
);
|
||||||
}
|
$day = $this->adjustWeekScale($day);
|
||||||
|
return $this->returnValue('Day', $format, $ts, $day);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the next weekday
|
||||||
|
*
|
||||||
|
* @param string $format (default = 'int') return value format
|
||||||
|
*
|
||||||
|
* @return int numeric day of week or timestamp
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function nextWeekDay($format = 'int')
|
||||||
|
{
|
||||||
|
$ts = $this->calendar->nextDay('timestamp');
|
||||||
|
$Day = new Calendar_Day(2000, 1, 1);
|
||||||
|
$Day->setTimeStamp($ts);
|
||||||
|
$day = $this->calendar->cE->getDayOfWeek(
|
||||||
|
$Day->thisYear(),
|
||||||
|
$Day->thisMonth(),
|
||||||
|
$Day->thisDay()
|
||||||
|
);
|
||||||
|
$day = $this->adjustWeekScale($day);
|
||||||
|
return $this->returnValue('Day', $format, $ts, $day);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adjusts the day of the week relative to the first day of the week
|
||||||
|
*
|
||||||
|
* @param int $dayOfWeek day of week calendar from Calendar_Engine
|
||||||
|
*
|
||||||
|
* @return int day of week adjusted to first day
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
function adjustWeekScale($dayOfWeek)
|
||||||
|
{
|
||||||
|
$dayOfWeek = $dayOfWeek - $this->firstDay;
|
||||||
|
if ($dayOfWeek >= 0) {
|
||||||
|
return $dayOfWeek;
|
||||||
|
} else {
|
||||||
|
return $this->calendar->cE->getDaysInWeek(
|
||||||
|
$this->calendar->year,
|
||||||
|
$this->calendar->month,
|
||||||
|
$this->calendar->day
|
||||||
|
) + $dayOfWeek;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
@@ -1,90 +1,115 @@
|
|||||||
<?php
|
<?php
|
||||||
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
||||||
//
|
|
||||||
// +----------------------------------------------------------------------+
|
/**
|
||||||
// | PHP Version 4 |
|
* Contains the Calendar_Decorator_Wrapper class
|
||||||
// +----------------------------------------------------------------------+
|
*
|
||||||
// | Copyright (c) 1997-2002 The PHP Group |
|
* PHP versions 4 and 5
|
||||||
// +----------------------------------------------------------------------+
|
*
|
||||||
// | This source file is subject to version 2.02 of the PHP license, |
|
* LICENSE: Redistribution and use in source and binary forms, with or without
|
||||||
// | that is bundled with this package in the file LICENSE, and is |
|
* modification, are permitted provided that the following conditions are met:
|
||||||
// | available at through the world-wide-web at |
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
// | http://www.php.net/license/3_0.txt. |
|
* notice, this list of conditions and the following disclaimer.
|
||||||
// | If you did not receive a copy of the PHP license and are unable to |
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
// | obtain it through the world-wide-web, please send a note to |
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
// | license@php.net so we can mail you a copy immediately. |
|
* documentation and/or other materials provided with the distribution.
|
||||||
// +----------------------------------------------------------------------+
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
// | Authors: Harry Fuecks <hfuecks@phppatterns.com> |
|
* derived from this software without specific prior written permission.
|
||||||
// | Lorenzo Alberton <l dot alberton at quipo dot it> |
|
*
|
||||||
// +----------------------------------------------------------------------+
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||||
//
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
// $Id: Wrapper.php,v 1.2 2005/11/03 20:35:03 quipo Exp $
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
//
|
* IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
/**
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* @package Calendar
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
* @version $Id: Wrapper.php,v 1.2 2005/11/03 20:35:03 quipo Exp $
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
*/
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
/**
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
* Allows Calendar include path to be redefined
|
*
|
||||||
* @ignore
|
* @category Date and Time
|
||||||
*/
|
* @package Calendar
|
||||||
if (!defined('CALENDAR_ROOT')) {
|
* @author Harry Fuecks <hfuecks@phppatterns.com>
|
||||||
define('CALENDAR_ROOT', 'Calendar'.DIRECTORY_SEPARATOR);
|
* @author Lorenzo Alberton <l.alberton@quipo.it>
|
||||||
}
|
* @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton
|
||||||
|
* @license http://www.debian.org/misc/bsd.license BSD License (3 Clause)
|
||||||
/**
|
* @version CVS: $Id: Wrapper.php 300729 2010-06-24 12:05:53Z quipo $
|
||||||
* Load Calendar decorator base class
|
* @link http://pear.php.net/package/Calendar
|
||||||
*/
|
*/
|
||||||
require_once CALENDAR_ROOT.'Decorator.php';
|
|
||||||
|
/**
|
||||||
/**
|
* Allows Calendar include path to be redefined
|
||||||
* Decorator to help with wrapping built children in another decorator
|
* @ignore
|
||||||
* @package Calendar
|
*/
|
||||||
* @access public
|
if (!defined('CALENDAR_ROOT')) {
|
||||||
*/
|
define('CALENDAR_ROOT', 'Calendar'.DIRECTORY_SEPARATOR);
|
||||||
class Calendar_Decorator_Wrapper extends Calendar_Decorator
|
}
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* Constructs Calendar_Decorator_Wrapper
|
* Load Calendar decorator base class
|
||||||
* @param object subclass of Calendar
|
*/
|
||||||
* @access public
|
require_once CALENDAR_ROOT.'Decorator.php';
|
||||||
*/
|
|
||||||
function Calendar_Decorator_Wrapper(&$Calendar)
|
/**
|
||||||
{
|
* Decorator to help with wrapping built children in another decorator
|
||||||
parent::Calendar_Decorator($Calendar);
|
*
|
||||||
}
|
* @category Date and Time
|
||||||
|
* @package Calendar
|
||||||
/**
|
* @author Harry Fuecks <hfuecks@phppatterns.com>
|
||||||
* Wraps objects returned from fetch in the named Decorator class
|
* @author Lorenzo Alberton <l.alberton@quipo.it>
|
||||||
* @param string name of Decorator class to wrap with
|
* @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton
|
||||||
* @return object instance of named decorator
|
* @license http://www.debian.org/misc/bsd.license BSD License (3 Clause)
|
||||||
* @access public
|
* @link http://pear.php.net/package/Calendar
|
||||||
*/
|
* @access public
|
||||||
function & fetch($decorator)
|
*/
|
||||||
{
|
class Calendar_Decorator_Wrapper extends Calendar_Decorator
|
||||||
$Calendar = parent::fetch();
|
{
|
||||||
if ($Calendar) {
|
/**
|
||||||
$ret =& new $decorator($Calendar);
|
* Constructs Calendar_Decorator_Wrapper
|
||||||
} else {
|
*
|
||||||
$ret = false;
|
* @param object &$Calendar subclass of Calendar
|
||||||
}
|
*
|
||||||
return $ret;
|
* @access public
|
||||||
}
|
*/
|
||||||
|
function Calendar_Decorator_Wrapper(&$Calendar)
|
||||||
/**
|
{
|
||||||
* Wraps the returned calendar objects from fetchAll in the named decorator
|
parent::Calendar_Decorator($Calendar);
|
||||||
* @param string name of Decorator class to wrap with
|
}
|
||||||
* @return array
|
|
||||||
* @access public
|
/**
|
||||||
*/
|
* Wraps objects returned from fetch in the named Decorator class
|
||||||
function fetchAll($decorator)
|
*
|
||||||
{
|
* @param string $decorator name of Decorator class to wrap with
|
||||||
$children = parent::fetchAll();
|
*
|
||||||
foreach ($children as $key => $Calendar) {
|
* @return object instance of named decorator
|
||||||
$children[$key] = & new $decorator($Calendar);
|
* @access public
|
||||||
}
|
*/
|
||||||
return $children;
|
function & fetch($decorator)
|
||||||
}
|
{
|
||||||
}
|
$Calendar = parent::fetch();
|
||||||
|
if ($Calendar) {
|
||||||
|
$ret = new $decorator($Calendar);
|
||||||
|
} else {
|
||||||
|
$ret = false;
|
||||||
|
}
|
||||||
|
return $ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wraps the returned calendar objects from fetchAll in the named decorator
|
||||||
|
*
|
||||||
|
* @param string $decorator name of Decorator class to wrap with
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function fetchAll($decorator)
|
||||||
|
{
|
||||||
|
$children = parent::fetchAll();
|
||||||
|
foreach ($children as $key => $Calendar) {
|
||||||
|
$children[$key] = new $decorator($Calendar);
|
||||||
|
}
|
||||||
|
return $children;
|
||||||
|
}
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
@@ -1,293 +1,377 @@
|
|||||||
<?php
|
<?php
|
||||||
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
||||||
//
|
|
||||||
// +----------------------------------------------------------------------+
|
/**
|
||||||
// | PHP Version 4 |
|
* Contains the Calendar_Engine_Interface class (interface)
|
||||||
// +----------------------------------------------------------------------+
|
*
|
||||||
// | Copyright (c) 1997-2002 The PHP Group |
|
* PHP versions 4 and 5
|
||||||
// +----------------------------------------------------------------------+
|
*
|
||||||
// | This source file is subject to version 2.02 of the PHP license, |
|
* LICENSE: Redistribution and use in source and binary forms, with or without
|
||||||
// | that is bundled with this package in the file LICENSE, and is |
|
* modification, are permitted provided that the following conditions are met:
|
||||||
// | available at through the world-wide-web at |
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
// | http://www.php.net/license/3_0.txt. |
|
* notice, this list of conditions and the following disclaimer.
|
||||||
// | If you did not receive a copy of the PHP license and are unable to |
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
// | obtain it through the world-wide-web, please send a note to |
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
// | license@php.net so we can mail you a copy immediately. |
|
* documentation and/or other materials provided with the distribution.
|
||||||
// +----------------------------------------------------------------------+
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
// | Authors: Harry Fuecks <hfuecks@phppatterns.com> |
|
* derived from this software without specific prior written permission.
|
||||||
// +----------------------------------------------------------------------+
|
*
|
||||||
//
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||||
// $Id: Interface.php,v 1.5 2004/08/16 12:29:18 hfuecks Exp $
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
//
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
/**
|
* IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
* @package Calendar
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* @version $Id: Interface.php,v 1.5 2004/08/16 12:29:18 hfuecks Exp $
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
*/
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
/**
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
* The methods the classes implementing the Calendar_Engine must implement.
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
* Note this class is not used but simply to help development
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
* @package Calendar
|
*
|
||||||
* @access protected
|
* @category Date and Time
|
||||||
*/
|
* @package Calendar
|
||||||
class Calendar_Engine_Interface
|
* @author Harry Fuecks <hfuecks@phppatterns.com>
|
||||||
{
|
* @author Lorenzo Alberton <l.alberton@quipo.it>
|
||||||
/**
|
* @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton
|
||||||
* Provides a mechansim to make sure parsing of timestamps
|
* @license http://www.debian.org/misc/bsd.license BSD License (3 Clause)
|
||||||
* into human dates is only performed once per timestamp.
|
* @version CVS: $Id: Interface.php 269074 2008-11-15 21:21:42Z quipo $
|
||||||
* Typically called "internally" by methods like stampToYear.
|
* @link http://pear.php.net/package/Calendar
|
||||||
* Return value can vary, depending on the specific implementation
|
*/
|
||||||
* @param int timestamp (depending on implementation)
|
|
||||||
* @return mixed
|
/**
|
||||||
* @access protected
|
* The methods the classes implementing the Calendar_Engine must implement.
|
||||||
*/
|
* Note this class is not used but simply to help development
|
||||||
function stampCollection($stamp)
|
*
|
||||||
{
|
* @category Date and Time
|
||||||
}
|
* @package Calendar
|
||||||
|
* @author Harry Fuecks <hfuecks@phppatterns.com>
|
||||||
/**
|
* @author Lorenzo Alberton <l.alberton@quipo.it>
|
||||||
* Returns a numeric year given a timestamp
|
* @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton
|
||||||
* @param int timestamp (depending on implementation)
|
* @license http://www.debian.org/misc/bsd.license BSD License (3 Clause)
|
||||||
* @return int year (e.g. 2003)
|
* @link http://pear.php.net/package/Calendar
|
||||||
* @access protected
|
* @access protected
|
||||||
*/
|
*/
|
||||||
function stampToYear($stamp)
|
class Calendar_Engine_Interface
|
||||||
{
|
{
|
||||||
}
|
/**
|
||||||
|
* Provides a mechansim to make sure parsing of timestamps
|
||||||
/**
|
* into human dates is only performed once per timestamp.
|
||||||
* Returns a numeric month given a timestamp
|
* Typically called "internally" by methods like stampToYear.
|
||||||
* @param int timestamp (depending on implementation)
|
* Return value can vary, depending on the specific implementation
|
||||||
* @return int month (e.g. 9)
|
*
|
||||||
* @access protected
|
* @param int $stamp timestamp (depending on implementation)
|
||||||
*/
|
*
|
||||||
function stampToMonth($stamp)
|
* @return mixed
|
||||||
{
|
* @access protected
|
||||||
}
|
*/
|
||||||
|
function stampCollection($stamp)
|
||||||
/**
|
{
|
||||||
* Returns a numeric day given a timestamp
|
}
|
||||||
* @param int timestamp (depending on implementation)
|
|
||||||
* @return int day (e.g. 15)
|
/**
|
||||||
* @access protected
|
* Returns a numeric year given a timestamp
|
||||||
*/
|
*
|
||||||
function stampToDay($stamp)
|
* @param int $stamp timestamp (depending on implementation)
|
||||||
{
|
*
|
||||||
}
|
* @return int year (e.g. 2003)
|
||||||
|
* @access protected
|
||||||
/**
|
*/
|
||||||
* Returns a numeric hour given a timestamp
|
function stampToYear($stamp)
|
||||||
* @param int timestamp (depending on implementation)
|
{
|
||||||
* @return int hour (e.g. 13)
|
}
|
||||||
* @access protected
|
|
||||||
*/
|
/**
|
||||||
function stampToHour($stamp)
|
* Returns a numeric month given a timestamp
|
||||||
{
|
*
|
||||||
}
|
* @param int $stamp timestamp (depending on implementation)
|
||||||
|
*
|
||||||
/**
|
* @return int month (e.g. 9)
|
||||||
* Returns a numeric minute given a timestamp
|
* @access protected
|
||||||
* @param int timestamp (depending on implementation)
|
*/
|
||||||
* @return int minute (e.g. 34)
|
function stampToMonth($stamp)
|
||||||
* @access protected
|
{
|
||||||
*/
|
}
|
||||||
function stampToMinute($stamp)
|
|
||||||
{
|
/**
|
||||||
}
|
* Returns a numeric day given a timestamp
|
||||||
|
*
|
||||||
/**
|
* @param int $stamp timestamp (depending on implementation)
|
||||||
* Returns a numeric second given a timestamp
|
*
|
||||||
* @param int timestamp (depending on implementation)
|
* @return int day (e.g. 15)
|
||||||
* @return int second (e.g. 51)
|
* @access protected
|
||||||
* @access protected
|
*/
|
||||||
*/
|
function stampToDay($stamp)
|
||||||
function stampToSecond($stamp)
|
{
|
||||||
{
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
/**
|
* Returns a numeric hour given a timestamp
|
||||||
* Returns a timestamp. Can be worth "caching" generated
|
*
|
||||||
* timestamps in a static variable, identified by the
|
* @param int $stamp timestamp (depending on implementation)
|
||||||
* params this method accepts, to timestamp will only
|
*
|
||||||
* be calculated once.
|
* @return int hour (e.g. 13)
|
||||||
* @param int year (e.g. 2003)
|
* @access protected
|
||||||
* @param int month (e.g. 9)
|
*/
|
||||||
* @param int day (e.g. 13)
|
function stampToHour($stamp)
|
||||||
* @param int hour (e.g. 13)
|
{
|
||||||
* @param int minute (e.g. 34)
|
}
|
||||||
* @param int second (e.g. 53)
|
|
||||||
* @return int (depends on implementation)
|
/**
|
||||||
* @access protected
|
* Returns a numeric minute given a timestamp
|
||||||
*/
|
*
|
||||||
function dateToStamp($y,$m,$d,$h,$i,$s)
|
* @param int $stamp timestamp (depending on implementation)
|
||||||
{
|
*
|
||||||
}
|
* @return int minute (e.g. 34)
|
||||||
|
* @access protected
|
||||||
/**
|
*/
|
||||||
* The upper limit on years that the Calendar Engine can work with
|
function stampToMinute($stamp)
|
||||||
* @return int (e.g. 2037)
|
{
|
||||||
* @access protected
|
}
|
||||||
*/
|
|
||||||
function getMaxYears()
|
/**
|
||||||
{
|
* Returns a numeric second given a timestamp
|
||||||
}
|
*
|
||||||
|
* @param int $stamp timestamp (depending on implementation)
|
||||||
/**
|
*
|
||||||
* The lower limit on years that the Calendar Engine can work with
|
* @return int second (e.g. 51)
|
||||||
* @return int (e.g 1902)
|
* @access protected
|
||||||
* @access protected
|
*/
|
||||||
*/
|
function stampToSecond($stamp)
|
||||||
function getMinYears()
|
{
|
||||||
{
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
/**
|
* Returns a timestamp. Can be worth "caching" generated timestamps in a
|
||||||
* Returns the number of months in a year
|
* static variable, identified by the params this method accepts,
|
||||||
* @param int (optional) year to get months for
|
* to timestamp will only be calculated once.
|
||||||
* @return int (e.g. 12)
|
*
|
||||||
* @access protected
|
* @param int $y year (e.g. 2003)
|
||||||
*/
|
* @param int $m month (e.g. 9)
|
||||||
function getMonthsInYear($y=null)
|
* @param int $d day (e.g. 13)
|
||||||
{
|
* @param int $h hour (e.g. 13)
|
||||||
}
|
* @param int $i minute (e.g. 34)
|
||||||
|
* @param int $s second (e.g. 53)
|
||||||
/**
|
*
|
||||||
* Returns the number of days in a month, given year and month
|
* @return int (depends on implementation)
|
||||||
* @param int year (e.g. 2003)
|
* @access protected
|
||||||
* @param int month (e.g. 9)
|
*/
|
||||||
* @return int days in month
|
function dateToStamp($y, $m, $d, $h, $i, $s)
|
||||||
* @access protected
|
{
|
||||||
*/
|
}
|
||||||
function getDaysInMonth($y, $m)
|
|
||||||
{
|
/**
|
||||||
}
|
* The upper limit on years that the Calendar Engine can work with
|
||||||
|
*
|
||||||
/**
|
* @return int (e.g. 2037)
|
||||||
* Returns numeric representation of the day of the week in a month,
|
* @access protected
|
||||||
* given year and month
|
*/
|
||||||
* @param int year (e.g. 2003)
|
function getMaxYears()
|
||||||
* @param int month (e.g. 9)
|
{
|
||||||
* @return int
|
}
|
||||||
* @access protected
|
|
||||||
*/
|
/**
|
||||||
function getFirstDayInMonth ($y, $m)
|
* The lower limit on years that the Calendar Engine can work with
|
||||||
{
|
*
|
||||||
}
|
* @return int (e.g 1902)
|
||||||
|
* @access protected
|
||||||
/**
|
*/
|
||||||
* Returns the number of days in a week
|
function getMinYears()
|
||||||
* @param int year (2003)
|
{
|
||||||
* @param int month (9)
|
}
|
||||||
* @param int day (4)
|
|
||||||
* @return int (e.g. 7)
|
/**
|
||||||
* @access protected
|
* Returns the number of months in a year
|
||||||
*/
|
*
|
||||||
function getDaysInWeek($y=NULL, $m=NULL, $d=NULL)
|
* @param int $y (optional) year to get months for
|
||||||
{
|
*
|
||||||
}
|
* @return int (e.g. 12)
|
||||||
|
* @access protected
|
||||||
/**
|
*/
|
||||||
* Returns the number of the week in the year (ISO-8601), given a date
|
function getMonthsInYear($y=null)
|
||||||
* @param int year (2003)
|
{
|
||||||
* @param int month (9)
|
}
|
||||||
* @param int day (4)
|
|
||||||
* @return int week number
|
/**
|
||||||
* @access protected
|
* Returns the number of days in a month, given year and month
|
||||||
*/
|
*
|
||||||
function getWeekNInYear($y, $m, $d)
|
* @param int $y year (e.g. 2003)
|
||||||
{
|
* @param int $m month (e.g. 9)
|
||||||
}
|
*
|
||||||
|
* @return int days in month
|
||||||
/**
|
* @access protected
|
||||||
* Returns the number of the week in the month, given a date
|
*/
|
||||||
* @param int year (2003)
|
function getDaysInMonth($y, $m)
|
||||||
* @param int month (9)
|
{
|
||||||
* @param int day (4)
|
}
|
||||||
* @param int first day of the week (default: 1 - monday)
|
|
||||||
* @return int week number
|
/**
|
||||||
* @access protected
|
* Returns numeric representation of the day of the week in a month,
|
||||||
*/
|
* given year and month
|
||||||
function getWeekNInMonth($y, $m, $d, $firstDay=1)
|
*
|
||||||
{
|
* @param int $y year (e.g. 2003)
|
||||||
}
|
* @param int $m month (e.g. 9)
|
||||||
|
*
|
||||||
/**
|
* @return int
|
||||||
* Returns the number of weeks in the month
|
* @access protected
|
||||||
* @param int year (2003)
|
*/
|
||||||
* @param int month (9)
|
function getFirstDayInMonth ($y, $m)
|
||||||
* @param int first day of the week (default: 1 - monday)
|
{
|
||||||
* @return int weeks number
|
}
|
||||||
* @access protected
|
|
||||||
*/
|
/**
|
||||||
function getWeeksInMonth($y, $m)
|
* Returns the number of days in a week
|
||||||
{
|
*
|
||||||
}
|
* @param int $y year (2003)
|
||||||
|
* @param int $m month (9)
|
||||||
/**
|
* @param int $d day (4)
|
||||||
* Returns the number of the day of the week (0=sunday, 1=monday...)
|
*
|
||||||
* @param int year (2003)
|
* @return int (e.g. 7)
|
||||||
* @param int month (9)
|
* @access protected
|
||||||
* @param int day (4)
|
*/
|
||||||
* @return int weekday number
|
function getDaysInWeek($y=null, $m=null, $d=null)
|
||||||
* @access protected
|
{
|
||||||
*/
|
}
|
||||||
function getDayOfWeek($y, $m, $d)
|
|
||||||
{
|
/**
|
||||||
}
|
* Returns the number of the week in the year (ISO-8601), given a date
|
||||||
|
*
|
||||||
/**
|
* @param int $y year (2003)
|
||||||
* Returns the numeric values of the days of the week.
|
* @param int $m month (9)
|
||||||
* @param int year (2003)
|
* @param int $d day (4)
|
||||||
* @param int month (9)
|
*
|
||||||
* @param int day (4)
|
* @return int week number
|
||||||
* @return array list of numeric values of days in week, beginning 0
|
* @access protected
|
||||||
* @access protected
|
*/
|
||||||
*/
|
function getWeekNInYear($y, $m, $d)
|
||||||
function getWeekDays($y=NULL, $m=NULL, $d=NULL)
|
{
|
||||||
{
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
/**
|
* Returns the number of the week in the month, given a date
|
||||||
* Returns the default first day of the week as an integer. Must be a
|
*
|
||||||
* member of the array returned from getWeekDays
|
* @param int $y year (2003)
|
||||||
* @param int year (2003)
|
* @param int $m month (9)
|
||||||
* @param int month (9)
|
* @param int $d day (4)
|
||||||
* @param int day (4)
|
* @param int $firstDay first day of the week (default: 1 - monday)
|
||||||
* @return int (e.g. 1 for Monday)
|
*
|
||||||
* @see getWeekDays
|
* @return int week number
|
||||||
* @access protected
|
* @access protected
|
||||||
*/
|
*/
|
||||||
function getFirstDayOfWeek($y=NULL, $m=NULL, $d=NULL)
|
function getWeekNInMonth($y, $m, $d, $firstDay=1)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of hours in a day<br>
|
* Returns the number of weeks in the month
|
||||||
* @param int (optional) day to get hours for
|
*
|
||||||
* @return int (e.g. 24)
|
* @param int $y year (2003)
|
||||||
* @access protected
|
* @param int $m month (9)
|
||||||
*/
|
*
|
||||||
function getHoursInDay($y=null,$m=null,$d=null)
|
* @return int weeks number
|
||||||
{
|
* @access protected
|
||||||
}
|
*/
|
||||||
|
function getWeeksInMonth($y, $m)
|
||||||
/**
|
{
|
||||||
* Returns the number of minutes in an hour
|
}
|
||||||
* @param int (optional) hour to get minutes for
|
|
||||||
* @return int
|
/**
|
||||||
* @access protected
|
* Returns the number of the day of the week (0=sunday, 1=monday...)
|
||||||
*/
|
*
|
||||||
function getMinutesInHour($y=null,$m=null,$d=null,$h=null)
|
* @param int $y year (2003)
|
||||||
{
|
* @param int $m month (9)
|
||||||
}
|
* @param int $d day (4)
|
||||||
|
*
|
||||||
/**
|
* @return int weekday number
|
||||||
* Returns the number of seconds in a minutes
|
* @access protected
|
||||||
* @param int (optional) minute to get seconds for
|
*/
|
||||||
* @return int
|
function getDayOfWeek($y, $m, $d)
|
||||||
* @access protected
|
{
|
||||||
*/
|
}
|
||||||
function getSecondsInMinute($y=null,$m=null,$d=null,$h=null,$i=null)
|
|
||||||
{
|
/**
|
||||||
}
|
* Returns the numeric values of the days of the week.
|
||||||
}
|
*
|
||||||
|
* @param int $y year (2003)
|
||||||
|
* @param int $m month (9)
|
||||||
|
* @param int $d day (4)
|
||||||
|
*
|
||||||
|
* @return array list of numeric values of days in week, beginning 0
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
|
function getWeekDays($y=null, $m=null, $d=null)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the default first day of the week as an integer. Must be a
|
||||||
|
* member of the array returned from getWeekDays
|
||||||
|
*
|
||||||
|
* @param int $y year (2003)
|
||||||
|
* @param int $m month (9)
|
||||||
|
* @param int $d day (4)
|
||||||
|
*
|
||||||
|
* @return int (e.g. 1 for Monday)
|
||||||
|
* @see getWeekDays
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
|
function getFirstDayOfWeek($y=null, $m=null, $d=null)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the number of hours in a day
|
||||||
|
*
|
||||||
|
* @param int $y year (2003)
|
||||||
|
* @param int $m month (9)
|
||||||
|
* @param int $d day (4)
|
||||||
|
*
|
||||||
|
* @return int (e.g. 24)
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
|
function getHoursInDay($y=null,$m=null,$d=null)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the number of minutes in an hour
|
||||||
|
*
|
||||||
|
* @param int $y year (2003)
|
||||||
|
* @param int $m month (9)
|
||||||
|
* @param int $d day (4)
|
||||||
|
* @param int $h hour
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
|
function getMinutesInHour($y=null,$m=null,$d=null,$h=null)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the number of seconds in a minutes
|
||||||
|
*
|
||||||
|
* @param int $y year (2003)
|
||||||
|
* @param int $m month (9)
|
||||||
|
* @param int $d day (4)
|
||||||
|
* @param int $h hour
|
||||||
|
* @param int $i minute
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
|
function getSecondsInMinute($y=null,$m=null,$d=null,$h=null,$i=null)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the given day is the current day
|
||||||
|
*
|
||||||
|
* @param int timestamp (depending on implementation)
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
|
function isToday($stamp)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
@@ -1,407 +1,509 @@
|
|||||||
<?php
|
<?php
|
||||||
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
||||||
//
|
|
||||||
// +----------------------------------------------------------------------+
|
/**
|
||||||
// | PHP Version 4 |
|
* Contains the Calendar_Engine_PearDate class
|
||||||
// +----------------------------------------------------------------------+
|
*
|
||||||
// | Copyright (c) 1997-2002 The PHP Group |
|
* PHP versions 4 and 5
|
||||||
// +----------------------------------------------------------------------+
|
*
|
||||||
// | This source file is subject to version 2.02 of the PHP license, |
|
* LICENSE: Redistribution and use in source and binary forms, with or without
|
||||||
// | that is bundled with this package in the file LICENSE, and is |
|
* modification, are permitted provided that the following conditions are met:
|
||||||
// | available at through the world-wide-web at |
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
// | http://www.php.net/license/3_0.txt. |
|
* notice, this list of conditions and the following disclaimer.
|
||||||
// | If you did not receive a copy of the PHP license and are unable to |
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
// | obtain it through the world-wide-web, please send a note to |
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
// | license@php.net so we can mail you a copy immediately. |
|
* documentation and/or other materials provided with the distribution.
|
||||||
// +----------------------------------------------------------------------+
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
// | Authors: Lorenzo Alberton <l dot alberton at quipo dot it> |
|
* derived from this software without specific prior written permission.
|
||||||
// +----------------------------------------------------------------------+
|
*
|
||||||
//
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||||
// $Id: PearDate.php,v 1.8 2004/08/20 20:00:55 quipo Exp $
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
//
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
/**
|
* IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
* @package Calendar
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* @version $Id: PearDate.php,v 1.8 2004/08/20 20:00:55 quipo Exp $
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
*/
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
/**
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
* Load PEAR::Date class
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
*/
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
require_once 'Date.php';
|
*
|
||||||
|
* @category Date and Time
|
||||||
/**
|
* @package Calendar
|
||||||
* Performs calendar calculations based on the PEAR::Date class
|
* @author Lorenzo Alberton <l.alberton@quipo.it>
|
||||||
* Timestamps are in the ISO-8601 format (YYYY-MM-DD HH:MM:SS)
|
* @copyright 2003-2007 Lorenzo Alberton
|
||||||
* @package Calendar
|
* @license http://www.debian.org/misc/bsd.license BSD License (3 Clause)
|
||||||
* @access protected
|
* @version CVS: $Id: PearDate.php 269076 2008-11-15 21:41:38Z quipo $
|
||||||
*/
|
* @link http://pear.php.net/package/Calendar
|
||||||
class Calendar_Engine_PearDate /* implements Calendar_Engine_Interface */
|
*/
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* Makes sure a given timestamp is only ever parsed once
|
* Load PEAR::Date class
|
||||||
* Uses a static variable to prevent date() being used twice
|
*/
|
||||||
* for a date which is already known
|
require_once 'Date.php';
|
||||||
* @param mixed Any timestamp format recognized by Pear::Date
|
|
||||||
* @return object Pear::Date object
|
/**
|
||||||
* @access protected
|
* Performs calendar calculations based on the PEAR::Date class
|
||||||
*/
|
* Timestamps are in the ISO-8601 format (YYYY-MM-DD HH:MM:SS)
|
||||||
function stampCollection($stamp)
|
*
|
||||||
{
|
* @category Date and Time
|
||||||
static $stamps = array();
|
* @package Calendar
|
||||||
if (!isset($stamps[$stamp])) {
|
* @author Lorenzo Alberton <l.alberton@quipo.it>
|
||||||
$stamps[$stamp] = new Date($stamp);
|
* @copyright 2003-2007 Lorenzo Alberton
|
||||||
}
|
* @license http://www.debian.org/misc/bsd.license BSD License (3 Clause)
|
||||||
return $stamps[$stamp];
|
* @link http://pear.php.net/package/Calendar
|
||||||
}
|
* @access protected
|
||||||
|
*/
|
||||||
/**
|
class Calendar_Engine_PearDate /* implements Calendar_Engine_Interface */
|
||||||
* Returns a numeric year given a iso-8601 datetime
|
{
|
||||||
* @param string iso-8601 datetime (YYYY-MM-DD HH:MM:SS)
|
/**
|
||||||
* @return int year (e.g. 2003)
|
* Makes sure a given timestamp is only ever parsed once
|
||||||
* @access protected
|
* Uses a static variable to prevent date() being used twice
|
||||||
*/
|
* for a date which is already known
|
||||||
function stampToYear($stamp)
|
*
|
||||||
{
|
* @param mixed $stamp Any timestamp format recognized by Pear::Date
|
||||||
$date = Calendar_Engine_PearDate::stampCollection($stamp);
|
*
|
||||||
return (int)$date->year;
|
* @return object Pear::Date object
|
||||||
}
|
* @access protected
|
||||||
|
*/
|
||||||
/**
|
function stampCollection($stamp)
|
||||||
* Returns a numeric month given a iso-8601 datetime
|
{
|
||||||
* @param string iso-8601 datetime (YYYY-MM-DD HH:MM:SS)
|
static $stamps = array();
|
||||||
* @return int month (e.g. 9)
|
if (!isset($stamps[$stamp])) {
|
||||||
* @access protected
|
$stamps[$stamp] = new Date($stamp);
|
||||||
*/
|
}
|
||||||
function stampToMonth($stamp)
|
return $stamps[$stamp];
|
||||||
{
|
}
|
||||||
$date = Calendar_Engine_PearDate::stampCollection($stamp);
|
|
||||||
return (int)$date->month;
|
/**
|
||||||
}
|
* Returns a numeric year given a iso-8601 datetime
|
||||||
|
*
|
||||||
/**
|
* @param string $stamp iso-8601 datetime (YYYY-MM-DD HH:MM:SS)
|
||||||
* Returns a numeric day given a iso-8601 datetime
|
*
|
||||||
* @param string iso-8601 datetime (YYYY-MM-DD HH:MM:SS)
|
* @return int year (e.g. 2003)
|
||||||
* @return int day (e.g. 15)
|
* @access protected
|
||||||
* @access protected
|
*/
|
||||||
*/
|
function stampToYear($stamp)
|
||||||
function stampToDay($stamp)
|
{
|
||||||
{
|
$date = Calendar_Engine_PearDate::stampCollection($stamp);
|
||||||
$date = Calendar_Engine_PearDate::stampCollection($stamp);
|
return (int)$date->year;
|
||||||
return (int)$date->day;
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
/**
|
* Returns a numeric month given a iso-8601 datetime
|
||||||
* Returns a numeric hour given a iso-8601 datetime
|
*
|
||||||
* @param string iso-8601 datetime (YYYY-MM-DD HH:MM:SS)
|
* @param string $stamp iso-8601 datetime (YYYY-MM-DD HH:MM:SS)
|
||||||
* @return int hour (e.g. 13)
|
*
|
||||||
* @access protected
|
* @return int month (e.g. 9)
|
||||||
*/
|
* @access protected
|
||||||
function stampToHour($stamp)
|
*/
|
||||||
{
|
function stampToMonth($stamp)
|
||||||
$date = Calendar_Engine_PearDate::stampCollection($stamp);
|
{
|
||||||
return (int)$date->hour;
|
$date = Calendar_Engine_PearDate::stampCollection($stamp);
|
||||||
}
|
return (int)$date->month;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Returns a numeric minute given a iso-8601 datetime
|
/**
|
||||||
* @param string iso-8601 datetime (YYYY-MM-DD HH:MM:SS)
|
* Returns a numeric day given a iso-8601 datetime
|
||||||
* @return int minute (e.g. 34)
|
*
|
||||||
* @access protected
|
* @param string $stamp iso-8601 datetime (YYYY-MM-DD HH:MM:SS)
|
||||||
*/
|
*
|
||||||
function stampToMinute($stamp)
|
* @return int day (e.g. 15)
|
||||||
{
|
* @access protected
|
||||||
$date = Calendar_Engine_PearDate::stampCollection($stamp);
|
*/
|
||||||
return (int)$date->minute;
|
function stampToDay($stamp)
|
||||||
}
|
{
|
||||||
|
$date = Calendar_Engine_PearDate::stampCollection($stamp);
|
||||||
/**
|
return (int)$date->day;
|
||||||
* Returns a numeric second given a iso-8601 datetime
|
}
|
||||||
* @param string iso-8601 datetime (YYYY-MM-DD HH:MM:SS)
|
|
||||||
* @return int second (e.g. 51)
|
/**
|
||||||
* @access protected
|
* Returns a numeric hour given a iso-8601 datetime
|
||||||
*/
|
*
|
||||||
function stampToSecond($stamp)
|
* @param string $stamp iso-8601 datetime (YYYY-MM-DD HH:MM:SS)
|
||||||
{
|
*
|
||||||
$date = Calendar_Engine_PearDate::stampCollection($stamp);
|
* @return int hour (e.g. 13)
|
||||||
return (int)$date->second;
|
* @access protected
|
||||||
}
|
*/
|
||||||
|
function stampToHour($stamp)
|
||||||
/**
|
{
|
||||||
* Returns a iso-8601 datetime
|
$date = Calendar_Engine_PearDate::stampCollection($stamp);
|
||||||
* @param int year (2003)
|
return (int)$date->hour;
|
||||||
* @param int month (9)
|
}
|
||||||
* @param int day (13)
|
|
||||||
* @param int hour (13)
|
/**
|
||||||
* @param int minute (34)
|
* Returns a numeric minute given a iso-8601 datetime
|
||||||
* @param int second (53)
|
*
|
||||||
* @return string iso-8601 datetime
|
* @param string $stamp iso-8601 datetime (YYYY-MM-DD HH:MM:SS)
|
||||||
* @access protected
|
*
|
||||||
*/
|
* @return int minute (e.g. 34)
|
||||||
function dateToStamp($y, $m, $d, $h=0, $i=0, $s=0)
|
* @access protected
|
||||||
{
|
*/
|
||||||
$r = array();
|
function stampToMinute($stamp)
|
||||||
Calendar_Engine_PearDate::adjustDate($y, $m, $d, $h, $i, $s);
|
{
|
||||||
$key = $y.$m.$d.$h.$i.$s;
|
$date = Calendar_Engine_PearDate::stampCollection($stamp);
|
||||||
if (!isset($r[$key])) {
|
return (int)$date->minute;
|
||||||
$r[$key] = sprintf("%04d-%02d-%02d %02d:%02d:%02d",
|
}
|
||||||
$y, $m, $d, $h, $i, $s);
|
|
||||||
}
|
/**
|
||||||
return $r[$key];
|
* Returns a numeric second given a iso-8601 datetime
|
||||||
}
|
*
|
||||||
|
* @param string $stamp iso-8601 datetime (YYYY-MM-DD HH:MM:SS)
|
||||||
/**
|
*
|
||||||
* Set the correct date values (useful for math operations on dates)
|
* @return int second (e.g. 51)
|
||||||
* @param int year (2003)
|
* @access protected
|
||||||
* @param int month (9)
|
*/
|
||||||
* @param int day (13)
|
function stampToSecond($stamp)
|
||||||
* @param int hour (13)
|
{
|
||||||
* @param int minute (34)
|
$date = Calendar_Engine_PearDate::stampCollection($stamp);
|
||||||
* @param int second (53)
|
return (int)$date->second;
|
||||||
* @access protected
|
}
|
||||||
*/
|
|
||||||
function adjustDate(&$y, &$m, &$d, &$h, &$i, &$s)
|
/**
|
||||||
{
|
* Returns a iso-8601 datetime
|
||||||
if ($s < 0) {
|
*
|
||||||
$m -= floor($s / 60);
|
* @param int $y year (2003)
|
||||||
$s = -$s % 60;
|
* @param int $m month (9)
|
||||||
}
|
* @param int $d day (13)
|
||||||
if ($s > 60) {
|
* @param int $h hour (13)
|
||||||
$m += floor($s / 60);
|
* @param int $i minute (34)
|
||||||
$s %= 60;
|
* @param int $s second (53)
|
||||||
}
|
*
|
||||||
if ($i < 0) {
|
* @return string iso-8601 datetime
|
||||||
$h -= floor($i / 60);
|
* @access protected
|
||||||
$i = -$i % 60;
|
*/
|
||||||
}
|
function dateToStamp($y, $m, $d, $h=0, $i=0, $s=0)
|
||||||
if ($i > 60) {
|
{
|
||||||
$h += floor($i / 60);
|
$r = array();
|
||||||
$i %= 60;
|
Calendar_Engine_PearDate::adjustDate($y, $m, $d, $h, $i, $s);
|
||||||
}
|
$key = $y.$m.$d.$h.$i.$s;
|
||||||
if ($h < 0) {
|
if (!isset($r[$key])) {
|
||||||
$d -= floor($h / 24);
|
$r[$key] = sprintf("%04d-%02d-%02d %02d:%02d:%02d",
|
||||||
$h = -$h % 24;
|
$y, $m, $d, $h, $i, $s);
|
||||||
}
|
}
|
||||||
if ($h > 24) {
|
return $r[$key];
|
||||||
$d += floor($h / 24);
|
}
|
||||||
$h %= 24;
|
|
||||||
}
|
/**
|
||||||
for(; $m < 1; $y--, $m+=12);
|
* Set the correct date values (useful for math operations on dates)
|
||||||
for(; $m > 12; $y++, $m-=12);
|
*
|
||||||
|
* @param int &$y year (2003)
|
||||||
while ($d < 1) {
|
* @param int &$m month (9)
|
||||||
if ($m > 1) {
|
* @param int &$d day (13)
|
||||||
$m--;
|
* @param int &$h hour (13)
|
||||||
} else {
|
* @param int &$i minute (34)
|
||||||
$m = 12;
|
* @param int &$s second (53)
|
||||||
$y--;
|
*
|
||||||
}
|
* @return void
|
||||||
$d += Date_Calc::daysInMonth($m, $y);
|
* @access protected
|
||||||
}
|
*/
|
||||||
for ($max_days = Date_Calc::daysInMonth($m, $y); $d > $max_days; ) {
|
function adjustDate(&$y, &$m, &$d, &$h, &$i, &$s)
|
||||||
$d -= $max_days;
|
{
|
||||||
if ($m < 12) {
|
if ($s < 0) {
|
||||||
$m++;
|
$m -= floor($s / 60);
|
||||||
} else {
|
$s = -$s % 60;
|
||||||
$m = 1;
|
}
|
||||||
$y++;
|
if ($s > 60) {
|
||||||
}
|
$m += floor($s / 60);
|
||||||
}
|
$s %= 60;
|
||||||
}
|
}
|
||||||
|
if ($i < 0) {
|
||||||
/**
|
$h -= floor($i / 60);
|
||||||
* The upper limit on years that the Calendar Engine can work with
|
$i = -$i % 60;
|
||||||
* @return int 9999
|
}
|
||||||
* @access protected
|
if ($i > 60) {
|
||||||
*/
|
$h += floor($i / 60);
|
||||||
function getMaxYears()
|
$i %= 60;
|
||||||
{
|
}
|
||||||
return 9999;
|
if ($h < 0) {
|
||||||
}
|
$d -= floor($h / 24);
|
||||||
|
$h = -$h % 24;
|
||||||
/**
|
}
|
||||||
* The lower limit on years that the Calendar Engine can work with
|
if ($h > 24) {
|
||||||
* @return int 0
|
$d += floor($h / 24);
|
||||||
* @access protected
|
$h %= 24;
|
||||||
*/
|
}
|
||||||
function getMinYears()
|
for(; $m < 1; $y--, $m+=12);
|
||||||
{
|
for(; $m > 12; $y++, $m-=12);
|
||||||
return 0;
|
|
||||||
}
|
while ($d < 1) {
|
||||||
|
if ($m > 1) {
|
||||||
/**
|
$m--;
|
||||||
* Returns the number of months in a year
|
} else {
|
||||||
* @return int (12)
|
$m = 12;
|
||||||
* @access protected
|
$y--;
|
||||||
*/
|
}
|
||||||
function getMonthsInYear($y=null)
|
$d += Date_Calc::daysInMonth($m, $y);
|
||||||
{
|
}
|
||||||
return 12;
|
for ($max_days = Date_Calc::daysInMonth($m, $y); $d > $max_days; ) {
|
||||||
}
|
$d -= $max_days;
|
||||||
|
if ($m < 12) {
|
||||||
/**
|
$m++;
|
||||||
* Returns the number of days in a month, given year and month
|
} else {
|
||||||
* @param int year (2003)
|
$m = 1;
|
||||||
* @param int month (9)
|
$y++;
|
||||||
* @return int days in month
|
}
|
||||||
* @access protected
|
}
|
||||||
*/
|
}
|
||||||
function getDaysInMonth($y, $m)
|
|
||||||
{
|
/**
|
||||||
return (int)Date_Calc::daysInMonth($m, $y);
|
* The upper limit on years that the Calendar Engine can work with
|
||||||
}
|
*
|
||||||
|
* @return int 9999
|
||||||
/**
|
* @access protected
|
||||||
* Returns numeric representation of the day of the week in a month,
|
*/
|
||||||
* given year and month
|
function getMaxYears()
|
||||||
* @param int year (2003)
|
{
|
||||||
* @param int month (9)
|
return 9999;
|
||||||
* @return int from 0 to 7
|
}
|
||||||
* @access protected
|
|
||||||
*/
|
/**
|
||||||
function getFirstDayInMonth($y, $m)
|
* The lower limit on years that the Calendar Engine can work with
|
||||||
{
|
*
|
||||||
return (int)Date_Calc::dayOfWeek(1, $m, $y);
|
* @return int 0
|
||||||
}
|
* @access protected
|
||||||
|
*/
|
||||||
/**
|
function getMinYears()
|
||||||
* Returns the number of days in a week
|
{
|
||||||
* @param int year (2003)
|
return 0;
|
||||||
* @param int month (9)
|
}
|
||||||
* @param int day (4)
|
|
||||||
* @return int (7)
|
/**
|
||||||
* @access protected
|
* Returns the number of months in a year
|
||||||
*/
|
*
|
||||||
function getDaysInWeek($y=NULL, $m=NULL, $d=NULL)
|
* @param int $y year
|
||||||
{
|
*
|
||||||
return 7;
|
* @return int (12)
|
||||||
}
|
* @access protected
|
||||||
|
*/
|
||||||
/**
|
function getMonthsInYear($y=null)
|
||||||
* Returns the number of the week in the year (ISO-8601), given a date
|
{
|
||||||
* @param int year (2003)
|
return 12;
|
||||||
* @param int month (9)
|
}
|
||||||
* @param int day (4)
|
|
||||||
* @return int week number
|
/**
|
||||||
* @access protected
|
* Returns the number of days in a month, given year and month
|
||||||
*/
|
*
|
||||||
function getWeekNInYear($y, $m, $d)
|
* @param int $y year (2003)
|
||||||
{
|
* @param int $m month (9)
|
||||||
return Date_Calc::weekOfYear($d, $m, $y); //beware, Date_Calc doesn't follow ISO-8601 standard!
|
*
|
||||||
}
|
* @return int days in month
|
||||||
|
* @access protected
|
||||||
/**
|
*/
|
||||||
* Returns the number of the week in the month, given a date
|
function getDaysInMonth($y, $m)
|
||||||
* @param int year (2003)
|
{
|
||||||
* @param int month (9)
|
return (int)Date_Calc::daysInMonth($m, $y);
|
||||||
* @param int day (4)
|
}
|
||||||
* @param int first day of the week (default: monday)
|
|
||||||
* @return int week number
|
/**
|
||||||
* @access protected
|
* Returns numeric representation of the day of the week in a month,
|
||||||
*/
|
* given year and month
|
||||||
function getWeekNInMonth($y, $m, $d, $firstDay=1)
|
*
|
||||||
{
|
* @param int $y year (2003)
|
||||||
$weekEnd = ($firstDay == 0) ? $this->getDaysInWeek()-1 : $firstDay-1;
|
* @param int $m month (9)
|
||||||
$end_of_week = (int)Date_Calc::nextDayOfWeek($weekEnd, 1, $m, $y, '%e', true);
|
*
|
||||||
$w = 1;
|
* @return int from 0 to 7
|
||||||
while ($d > $end_of_week) {
|
* @access protected
|
||||||
++$w;
|
*/
|
||||||
$end_of_week += $this->getDaysInWeek();
|
function getFirstDayInMonth($y, $m)
|
||||||
}
|
{
|
||||||
return $w;
|
return (int)Date_Calc::dayOfWeek(1, $m, $y);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the number of weeks in the month
|
* Returns the number of days in a week
|
||||||
* @param int year (2003)
|
*
|
||||||
* @param int month (9)
|
* @param int $y year (2003)
|
||||||
* @param int first day of the week (default: monday)
|
* @param int $m month (9)
|
||||||
* @return int weeks number
|
* @param int $d day (4)
|
||||||
* @access protected
|
*
|
||||||
*/
|
* @return int (7)
|
||||||
function getWeeksInMonth($y, $m, $firstDay=1)
|
* @access protected
|
||||||
{
|
*/
|
||||||
$FDOM = Date_Calc::firstOfMonthWeekday($m, $y);
|
function getDaysInWeek($y=null, $m=null, $d=null)
|
||||||
if ($FDOM == 0) {
|
{
|
||||||
$FDOM = $this->getDaysInWeek();
|
return 7;
|
||||||
}
|
}
|
||||||
if ($FDOM > $firstDay) {
|
|
||||||
$daysInTheFirstWeek = $this->getDaysInWeek() - $FDOM + $firstDay;
|
/**
|
||||||
$weeks = 1;
|
* Returns the number of the week in the year (ISO-8601), given a date
|
||||||
} else {
|
*
|
||||||
$daysInTheFirstWeek = $firstDay - $FDOM;
|
* @param int $y year (2003)
|
||||||
$weeks = 0;
|
* @param int $m month (9)
|
||||||
}
|
* @param int $d day (4)
|
||||||
$daysInTheFirstWeek %= $this->getDaysInWeek();
|
*
|
||||||
return (int)(ceil(($this->getDaysInMonth($y, $m) - $daysInTheFirstWeek) /
|
* @return int week number
|
||||||
$this->getDaysInWeek()) + $weeks);
|
* @access protected
|
||||||
}
|
*/
|
||||||
|
function getWeekNInYear($y, $m, $d)
|
||||||
/**
|
{
|
||||||
* Returns the number of the day of the week (0=sunday, 1=monday...)
|
//return Date_Calc::weekOfYear($d, $m, $y); //beware, Date_Calc doesn't follow ISO-8601 standard!
|
||||||
* @param int year (2003)
|
list($nYear, $nWeek) = Date_Calc::weekOfYear4th($d, $m, $y);
|
||||||
* @param int month (9)
|
return $nWeek;
|
||||||
* @param int day (4)
|
}
|
||||||
* @return int weekday number
|
|
||||||
* @access protected
|
/**
|
||||||
*/
|
* Returns the number of the week in the month, given a date
|
||||||
function getDayOfWeek($y, $m, $d)
|
*
|
||||||
{
|
* @param int $y year (2003)
|
||||||
return Date_Calc::dayOfWeek($d, $m, $y);
|
* @param int $m month (9)
|
||||||
}
|
* @param int $d day (4)
|
||||||
|
* @param int $firstDay first day of the week (default: monday)
|
||||||
/**
|
*
|
||||||
* Returns a list of integer days of the week beginning 0
|
* @return int week number
|
||||||
* @param int year (2003)
|
* @access protected
|
||||||
* @param int month (9)
|
*/
|
||||||
* @param int day (4)
|
function getWeekNInMonth($y, $m, $d, $firstDay=1)
|
||||||
* @return array (0, 1, 2, 3, 4, 5, 6) 1 = Monday
|
{
|
||||||
* @access protected
|
$weekEnd = ($firstDay == 0) ? $this->getDaysInWeek()-1 : $firstDay-1;
|
||||||
*/
|
$end_of_week = (int)Date_Calc::nextDayOfWeek($weekEnd, 1, $m, $y, '%e', true);
|
||||||
function getWeekDays($y=NULL, $m=NULL, $d=NULL)
|
$w = 1;
|
||||||
{
|
while ($d > $end_of_week) {
|
||||||
return array(0, 1, 2, 3, 4, 5, 6);
|
++$w;
|
||||||
}
|
$end_of_week += $this->getDaysInWeek();
|
||||||
|
}
|
||||||
/**
|
return $w;
|
||||||
* Returns the default first day of the week
|
}
|
||||||
* @param int year (2003)
|
|
||||||
* @param int month (9)
|
/**
|
||||||
* @param int day (4)
|
* Returns the number of weeks in the month
|
||||||
* @return int (default 1 = Monday)
|
*
|
||||||
* @access protected
|
* @param int $y year (2003)
|
||||||
*/
|
* @param int $m month (9)
|
||||||
function getFirstDayOfWeek($y=NULL, $m=NULL, $d=NULL)
|
* @param int $firstDay first day of the week (default: monday)
|
||||||
{
|
*
|
||||||
return 1;
|
* @return int weeks number
|
||||||
}
|
* @access protected
|
||||||
|
*/
|
||||||
/**
|
function getWeeksInMonth($y, $m, $firstDay=1)
|
||||||
* Returns the number of hours in a day
|
{
|
||||||
* @return int (24)
|
$FDOM = Date_Calc::firstOfMonthWeekday($m, $y);
|
||||||
* @access protected
|
if ($FDOM == 0) {
|
||||||
*/
|
$FDOM = $this->getDaysInWeek();
|
||||||
function getHoursInDay($y=null,$m=null,$d=null)
|
}
|
||||||
{
|
if ($FDOM > $firstDay) {
|
||||||
return 24;
|
$daysInTheFirstWeek = $this->getDaysInWeek() - $FDOM + $firstDay;
|
||||||
}
|
$weeks = 1;
|
||||||
|
} else {
|
||||||
/**
|
$daysInTheFirstWeek = $firstDay - $FDOM;
|
||||||
* Returns the number of minutes in an hour
|
$weeks = 0;
|
||||||
* @return int (60)
|
}
|
||||||
* @access protected
|
$daysInTheFirstWeek %= $this->getDaysInWeek();
|
||||||
*/
|
return (int)(ceil(($this->getDaysInMonth($y, $m) - $daysInTheFirstWeek) /
|
||||||
function getMinutesInHour($y=null,$m=null,$d=null,$h=null)
|
$this->getDaysInWeek()) + $weeks);
|
||||||
{
|
}
|
||||||
return 60;
|
|
||||||
}
|
/**
|
||||||
|
* Returns the number of the day of the week (0=sunday, 1=monday...)
|
||||||
/**
|
*
|
||||||
* Returns the number of seconds in a minutes
|
* @param int $y year (2003)
|
||||||
* @return int (60)
|
* @param int $m month (9)
|
||||||
* @access protected
|
* @param int $d day (4)
|
||||||
*/
|
*
|
||||||
function getSecondsInMinute($y=null,$m=null,$d=null,$h=null,$i=null)
|
* @return int weekday number
|
||||||
{
|
* @access protected
|
||||||
return 60;
|
*/
|
||||||
}
|
function getDayOfWeek($y, $m, $d)
|
||||||
}
|
{
|
||||||
|
return Date_Calc::dayOfWeek($d, $m, $y);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of integer days of the week beginning 0
|
||||||
|
*
|
||||||
|
* @param int $y year (2003)
|
||||||
|
* @param int $m month (9)
|
||||||
|
* @param int $d day (4)
|
||||||
|
*
|
||||||
|
* @return array (0, 1, 2, 3, 4, 5, 6) 1 = Monday
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
|
function getWeekDays($y=null, $m=null, $d=null)
|
||||||
|
{
|
||||||
|
return array(0, 1, 2, 3, 4, 5, 6);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the default first day of the week
|
||||||
|
*
|
||||||
|
* @param int $y year (2003)
|
||||||
|
* @param int $m month (9)
|
||||||
|
* @param int $d day (4)
|
||||||
|
*
|
||||||
|
* @return int (default 1 = Monday)
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
|
function getFirstDayOfWeek($y=null, $m=null, $d=null)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the number of hours in a day
|
||||||
|
*
|
||||||
|
* @param int $y year (2003)
|
||||||
|
* @param int $m month (9)
|
||||||
|
* @param int $d day (4)
|
||||||
|
*
|
||||||
|
* @return int (24)
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
|
function getHoursInDay($y=null,$m=null,$d=null)
|
||||||
|
{
|
||||||
|
return 24;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the number of minutes in an hour
|
||||||
|
*
|
||||||
|
* @param int $y year (2003)
|
||||||
|
* @param int $m month (9)
|
||||||
|
* @param int $d day (4)
|
||||||
|
* @param int $h hour
|
||||||
|
*
|
||||||
|
* @return int (60)
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
|
function getMinutesInHour($y=null,$m=null,$d=null,$h=null)
|
||||||
|
{
|
||||||
|
return 60;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the number of seconds in a minutes
|
||||||
|
*
|
||||||
|
* @param int $y year (2003)
|
||||||
|
* @param int $m month (9)
|
||||||
|
* @param int $d day (4)
|
||||||
|
* @param int $h hour
|
||||||
|
* @param int $i minute
|
||||||
|
*
|
||||||
|
* @return int (60)
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
|
function getSecondsInMinute($y=null,$m=null,$d=null,$h=null,$i=null)
|
||||||
|
{
|
||||||
|
return 60;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the given day is the current day
|
||||||
|
*
|
||||||
|
* @param mixed $stamp Any timestamp format recognized by Pear::Date
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
|
function isToday($stamp)
|
||||||
|
{
|
||||||
|
static $today = null;
|
||||||
|
if (is_null($today)) {
|
||||||
|
$today = new Date();
|
||||||
|
}
|
||||||
|
$date = Calendar_Engine_PearDate::stampCollection($stamp);
|
||||||
|
return ( $date->day == $today->getDay()
|
||||||
|
&& $date->month == $today->getMonth()
|
||||||
|
&& $date->year == $today->getYear()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
@@ -1,365 +1,463 @@
|
|||||||
<?php
|
<?php
|
||||||
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
||||||
//
|
|
||||||
// +----------------------------------------------------------------------+
|
/**
|
||||||
// | PHP Version 4 |
|
* Contains the Calendar_Engine_UnixTS class
|
||||||
// +----------------------------------------------------------------------+
|
*
|
||||||
// | Copyright (c) 1997-2002 The PHP Group |
|
* PHP versions 4 and 5
|
||||||
// +----------------------------------------------------------------------+
|
*
|
||||||
// | This source file is subject to version 2.02 of the PHP license, |
|
* LICENSE: Redistribution and use in source and binary forms, with or without
|
||||||
// | that is bundled with this package in the file LICENSE, and is |
|
* modification, are permitted provided that the following conditions are met:
|
||||||
// | available at through the world-wide-web at |
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
// | http://www.php.net/license/3_0.txt. |
|
* notice, this list of conditions and the following disclaimer.
|
||||||
// | If you did not receive a copy of the PHP license and are unable to |
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
// | obtain it through the world-wide-web, please send a note to |
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
// | license@php.net so we can mail you a copy immediately. |
|
* documentation and/or other materials provided with the distribution.
|
||||||
// +----------------------------------------------------------------------+
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
// | Authors: Harry Fuecks <hfuecks@phppatterns.com> |
|
* derived from this software without specific prior written permission.
|
||||||
// +----------------------------------------------------------------------+
|
*
|
||||||
//
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||||
// $Id: UnixTS.php,v 1.9 2004/08/20 20:00:55 quipo Exp $
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
//
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
/**
|
* IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
* @package Calendar
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* @version $Id: UnixTS.php,v 1.9 2004/08/20 20:00:55 quipo Exp $
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
*/
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
/**
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
* Performs calendar calculations based on the PHP date() function and
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
* Unix timestamps (using PHP's mktime() function).
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
* @package Calendar
|
*
|
||||||
* @access protected
|
* @category Date and Time
|
||||||
*/
|
* @package Calendar
|
||||||
class Calendar_Engine_UnixTS /* implements Calendar_Engine_Interface */
|
* @author Harry Fuecks <hfuecks@phppatterns.com>
|
||||||
{
|
* @copyright 2003-2007 Harry Fuecks
|
||||||
/**
|
* @license http://www.debian.org/misc/bsd.license BSD License (3 Clause)
|
||||||
* Makes sure a given timestamp is only ever parsed once
|
* @version CVS: $Id: UnixTS.php 269074 2008-11-15 21:21:42Z quipo $
|
||||||
* <pre>
|
* @link http://pear.php.net/package/Calendar
|
||||||
* array (
|
*/
|
||||||
* [0] => year (e.g 2003),
|
|
||||||
* [1] => month (e.g 9),
|
/**
|
||||||
* [2] => day (e.g 6),
|
* Performs calendar calculations based on the PHP date() function and
|
||||||
* [3] => hour (e.g 14),
|
* Unix timestamps (using PHP's mktime() function).
|
||||||
* [4] => minute (e.g 34),
|
*
|
||||||
* [5] => second (e.g 45),
|
* @category Date and Time
|
||||||
* [6] => num days in month (e.g. 31),
|
* @package Calendar
|
||||||
* [7] => week in year (e.g. 50),
|
* @author Harry Fuecks <hfuecks@phppatterns.com>
|
||||||
* [8] => day in week (e.g. 0 for Sunday)
|
* @copyright 2003-2007 Harry Fuecks
|
||||||
* )
|
* @license http://www.debian.org/misc/bsd.license BSD License (3 Clause)
|
||||||
* </pre>
|
* @link http://pear.php.net/package/Calendar
|
||||||
* Uses a static variable to prevent date() being used twice
|
* @access protected
|
||||||
* for a date which is already known
|
*/
|
||||||
* @param int Unix timestamp
|
class Calendar_Engine_UnixTS /* implements Calendar_Engine_Interface */
|
||||||
* @return array
|
{
|
||||||
* @access protected
|
/**
|
||||||
*/
|
* Makes sure a given timestamp is only ever parsed once
|
||||||
function stampCollection($stamp)
|
* <pre>
|
||||||
{
|
* array (
|
||||||
static $stamps = array();
|
* [0] => year (e.g 2003),
|
||||||
if ( !isset($stamps[$stamp]) ) {
|
* [1] => month (e.g 9),
|
||||||
$date = @date('Y n j H i s t W w',$stamp);
|
* [2] => day (e.g 6),
|
||||||
$stamps[$stamp] = sscanf($date, "%d %d %d %d %d %d %d %d %d");
|
* [3] => hour (e.g 14),
|
||||||
}
|
* [4] => minute (e.g 34),
|
||||||
return $stamps[$stamp];
|
* [5] => second (e.g 45),
|
||||||
}
|
* [6] => num days in month (e.g. 31),
|
||||||
|
* [7] => week in year (e.g. 50),
|
||||||
/**
|
* [8] => day in week (e.g. 0 for Sunday)
|
||||||
* Returns a numeric year given a timestamp
|
* )
|
||||||
* @param int Unix timestamp
|
* </pre>
|
||||||
* @return int year (e.g. 2003)
|
* Uses a static variable to prevent date() being used twice
|
||||||
* @access protected
|
* for a date which is already known
|
||||||
*/
|
*
|
||||||
function stampToYear($stamp)
|
* @param int $stamp Unix timestamp
|
||||||
{
|
*
|
||||||
$date = Calendar_Engine_UnixTS::stampCollection($stamp);
|
* @return array
|
||||||
return (int)$date[0];
|
* @access protected
|
||||||
}
|
*/
|
||||||
|
function stampCollection($stamp)
|
||||||
/**
|
{
|
||||||
* Returns a numeric month given a timestamp
|
static $stamps = array();
|
||||||
* @param int Unix timestamp
|
if ( !isset($stamps[$stamp]) ) {
|
||||||
* @return int month (e.g. 9)
|
$date = @date('Y n j H i s t W w', $stamp);
|
||||||
* @access protected
|
$stamps[$stamp] = sscanf($date, "%d %d %d %d %d %d %d %d %d");
|
||||||
*/
|
}
|
||||||
function stampToMonth($stamp)
|
return $stamps[$stamp];
|
||||||
{
|
}
|
||||||
$date = Calendar_Engine_UnixTS::stampCollection($stamp);
|
|
||||||
return (int)$date[1];
|
/**
|
||||||
}
|
* Returns a numeric year given a timestamp
|
||||||
|
*
|
||||||
/**
|
* @param int $stamp Unix timestamp
|
||||||
* Returns a numeric day given a timestamp
|
*
|
||||||
* @param int Unix timestamp
|
* @return int year (e.g. 2003)
|
||||||
* @return int day (e.g. 15)
|
* @access protected
|
||||||
* @access protected
|
*/
|
||||||
*/
|
function stampToYear($stamp)
|
||||||
function stampToDay($stamp)
|
{
|
||||||
{
|
$date = Calendar_Engine_UnixTS::stampCollection($stamp);
|
||||||
$date = Calendar_Engine_UnixTS::stampCollection($stamp);
|
return (int)$date[0];
|
||||||
return (int)$date[2];
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
/**
|
* Returns a numeric month given a timestamp
|
||||||
* Returns a numeric hour given a timestamp
|
*
|
||||||
* @param int Unix timestamp
|
* @param int $stamp Unix timestamp
|
||||||
* @return int hour (e.g. 13)
|
*
|
||||||
* @access protected
|
* @return int month (e.g. 9)
|
||||||
*/
|
* @access protected
|
||||||
function stampToHour($stamp)
|
*/
|
||||||
{
|
function stampToMonth($stamp)
|
||||||
$date = Calendar_Engine_UnixTS::stampCollection($stamp);
|
{
|
||||||
return (int)$date[3];
|
$date = Calendar_Engine_UnixTS::stampCollection($stamp);
|
||||||
}
|
return (int)$date[1];
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Returns a numeric minute given a timestamp
|
/**
|
||||||
* @param int Unix timestamp
|
* Returns a numeric day given a timestamp
|
||||||
* @return int minute (e.g. 34)
|
*
|
||||||
* @access protected
|
* @param int $stamp Unix timestamp
|
||||||
*/
|
*
|
||||||
function stampToMinute($stamp)
|
* @return int day (e.g. 15)
|
||||||
{
|
* @access protected
|
||||||
$date = Calendar_Engine_UnixTS::stampCollection($stamp);
|
*/
|
||||||
return (int)$date[4];
|
function stampToDay($stamp)
|
||||||
}
|
{
|
||||||
|
$date = Calendar_Engine_UnixTS::stampCollection($stamp);
|
||||||
/**
|
return (int)$date[2];
|
||||||
* Returns a numeric second given a timestamp
|
}
|
||||||
* @param int Unix timestamp
|
|
||||||
* @return int second (e.g. 51)
|
/**
|
||||||
* @access protected
|
* Returns a numeric hour given a timestamp
|
||||||
*/
|
*
|
||||||
function stampToSecond($stamp)
|
* @param int $stamp Unix timestamp
|
||||||
{
|
*
|
||||||
$date = Calendar_Engine_UnixTS::stampCollection($stamp);
|
* @return int hour (e.g. 13)
|
||||||
return (int)$date[5];
|
* @access protected
|
||||||
}
|
*/
|
||||||
|
function stampToHour($stamp)
|
||||||
/**
|
{
|
||||||
* Returns a timestamp
|
$date = Calendar_Engine_UnixTS::stampCollection($stamp);
|
||||||
* @param int year (2003)
|
return (int)$date[3];
|
||||||
* @param int month (9)
|
}
|
||||||
* @param int day (13)
|
|
||||||
* @param int hour (13)
|
/**
|
||||||
* @param int minute (34)
|
* Returns a numeric minute given a timestamp
|
||||||
* @param int second (53)
|
*
|
||||||
* @return int Unix timestamp
|
* @param int $stamp Unix timestamp
|
||||||
* @access protected
|
*
|
||||||
*/
|
* @return int minute (e.g. 34)
|
||||||
function dateToStamp($y, $m, $d, $h=0, $i=0, $s=0)
|
* @access protected
|
||||||
{
|
*/
|
||||||
static $dates = array();
|
function stampToMinute($stamp)
|
||||||
if ( !isset($dates[$y][$m][$d][$h][$i][$s]) ) {
|
{
|
||||||
$dates[$y][$m][$d][$h][$i][$s] = @mktime($h, $i, $s, $m, $d, $y);
|
$date = Calendar_Engine_UnixTS::stampCollection($stamp);
|
||||||
}
|
return (int)$date[4];
|
||||||
return $dates[$y][$m][$d][$h][$i][$s];
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
/**
|
* Returns a numeric second given a timestamp
|
||||||
* The upper limit on years that the Calendar Engine can work with
|
*
|
||||||
* @return int (2037)
|
* @param int $stamp Unix timestamp
|
||||||
* @access protected
|
*
|
||||||
*/
|
* @return int second (e.g. 51)
|
||||||
function getMaxYears()
|
* @access protected
|
||||||
{
|
*/
|
||||||
return 2037;
|
function stampToSecond($stamp)
|
||||||
}
|
{
|
||||||
|
$date = Calendar_Engine_UnixTS::stampCollection($stamp);
|
||||||
/**
|
return (int)$date[5];
|
||||||
* The lower limit on years that the Calendar Engine can work with
|
}
|
||||||
* @return int (1970 if it's Windows and 1902 for all other OSs)
|
|
||||||
* @access protected
|
/**
|
||||||
*/
|
* Returns a timestamp
|
||||||
function getMinYears()
|
*
|
||||||
{
|
* @param int $y year (2003)
|
||||||
return $min = strpos(PHP_OS, 'WIN') === false ? 1902 : 1970;
|
* @param int $m month (9)
|
||||||
}
|
* @param int $d day (13)
|
||||||
|
* @param int $h hour (13)
|
||||||
/**
|
* @param int $i minute (34)
|
||||||
* Returns the number of months in a year
|
* @param int $s second (53)
|
||||||
* @return int (12)
|
*
|
||||||
* @access protected
|
* @return int Unix timestamp
|
||||||
*/
|
* @access protected
|
||||||
function getMonthsInYear($y=null)
|
*/
|
||||||
{
|
function dateToStamp($y, $m, $d, $h=0, $i=0, $s=0)
|
||||||
return 12;
|
{
|
||||||
}
|
static $dates = array();
|
||||||
|
if (!isset($dates[$y][$m][$d][$h][$i][$s])) {
|
||||||
/**
|
$dates[$y][$m][$d][$h][$i][$s] = @mktime($h, $i, $s, $m, $d, $y);
|
||||||
* Returns the number of days in a month, given year and month
|
}
|
||||||
* @param int year (2003)
|
return $dates[$y][$m][$d][$h][$i][$s];
|
||||||
* @param int month (9)
|
}
|
||||||
* @return int days in month
|
|
||||||
* @access protected
|
/**
|
||||||
*/
|
* The upper limit on years that the Calendar Engine can work with
|
||||||
function getDaysInMonth($y, $m)
|
*
|
||||||
{
|
* @return int (2037)
|
||||||
$stamp = Calendar_Engine_UnixTS::dateToStamp($y,$m,1);
|
* @access protected
|
||||||
$date = Calendar_Engine_UnixTS::stampCollection($stamp);
|
*/
|
||||||
return $date[6];
|
function getMaxYears()
|
||||||
}
|
{
|
||||||
|
return 2037;
|
||||||
/**
|
}
|
||||||
* Returns numeric representation of the day of the week in a month,
|
|
||||||
* given year and month
|
/**
|
||||||
* @param int year (2003)
|
* The lower limit on years that the Calendar Engine can work with
|
||||||
* @param int month (9)
|
*
|
||||||
* @return int from 0 to 6
|
* @return int (1970 if it's Windows and 1902 for all other OSs)
|
||||||
* @access protected
|
* @access protected
|
||||||
*/
|
*/
|
||||||
function getFirstDayInMonth($y, $m)
|
function getMinYears()
|
||||||
{
|
{
|
||||||
$stamp = Calendar_Engine_UnixTS::dateToStamp($y,$m,1);
|
return $min = strpos(PHP_OS, 'WIN') === false ? 1902 : 1970;
|
||||||
$date = Calendar_Engine_UnixTS::stampCollection($stamp);
|
}
|
||||||
return $date[8];
|
|
||||||
}
|
/**
|
||||||
|
* Returns the number of months in a year
|
||||||
/**
|
*
|
||||||
* Returns the number of days in a week
|
* @param int $y year
|
||||||
* @param int year (2003)
|
*
|
||||||
* @param int month (9)
|
* @return int (12)
|
||||||
* @param int day (4)
|
* @access protected
|
||||||
* @return int (7)
|
*/
|
||||||
* @access protected
|
function getMonthsInYear($y=null)
|
||||||
*/
|
{
|
||||||
function getDaysInWeek($y=NULL, $m=NULL, $d=NULL)
|
return 12;
|
||||||
{
|
}
|
||||||
return 7;
|
|
||||||
}
|
/**
|
||||||
|
* Returns the number of days in a month, given year and month
|
||||||
/**
|
*
|
||||||
* Returns the number of the week in the year (ISO-8601), given a date
|
* @param int $y year (2003)
|
||||||
* @param int year (2003)
|
* @param int $m month (9)
|
||||||
* @param int month (9)
|
*
|
||||||
* @param int day (4)
|
* @return int days in month
|
||||||
* @return int week number
|
* @access protected
|
||||||
* @access protected
|
*/
|
||||||
*/
|
function getDaysInMonth($y, $m)
|
||||||
function getWeekNInYear($y, $m, $d)
|
{
|
||||||
{
|
$stamp = Calendar_Engine_UnixTS::dateToStamp($y, $m, 1);
|
||||||
$stamp = Calendar_Engine_UnixTS::dateToStamp($y,$m,$d);
|
$date = Calendar_Engine_UnixTS::stampCollection($stamp);
|
||||||
$date = Calendar_Engine_UnixTS::stampCollection($stamp);
|
return $date[6];
|
||||||
return $date[7];
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
/**
|
* Returns numeric representation of the day of the week in a month,
|
||||||
* Returns the number of the week in the month, given a date
|
* given year and month
|
||||||
* @param int year (2003)
|
*
|
||||||
* @param int month (9)
|
* @param int $y year (2003)
|
||||||
* @param int day (4)
|
* @param int $m month (9)
|
||||||
* @param int first day of the week (default: monday)
|
*
|
||||||
* @return int week number
|
* @return int from 0 to 6
|
||||||
* @access protected
|
* @access protected
|
||||||
*/
|
*/
|
||||||
function getWeekNInMonth($y, $m, $d, $firstDay=1)
|
function getFirstDayInMonth($y, $m)
|
||||||
{
|
{
|
||||||
$weekEnd = ($firstDay == 0) ? $this->getDaysInWeek()-1 : $firstDay-1;
|
$stamp = Calendar_Engine_UnixTS::dateToStamp($y, $m, 1);
|
||||||
$end_of_week = 1;
|
$date = Calendar_Engine_UnixTS::stampCollection($stamp);
|
||||||
while (@date('w', @mktime(0, 0, 0, $m, $end_of_week, $y)) != $weekEnd) {
|
return $date[8];
|
||||||
++$end_of_week; //find first weekend of the month
|
}
|
||||||
}
|
|
||||||
$w = 1;
|
/**
|
||||||
while ($d > $end_of_week) {
|
* Returns the number of days in a week
|
||||||
++$w;
|
*
|
||||||
$end_of_week += $this->getDaysInWeek();
|
* @param int $y year (2003)
|
||||||
}
|
* @param int $m month (9)
|
||||||
return $w;
|
* @param int $d day (4)
|
||||||
}
|
*
|
||||||
|
* @return int (7)
|
||||||
/**
|
* @access protected
|
||||||
* Returns the number of weeks in the month
|
*/
|
||||||
* @param int year (2003)
|
function getDaysInWeek($y=null, $m=null, $d=null)
|
||||||
* @param int month (9)
|
{
|
||||||
* @param int first day of the week (default: monday)
|
return 7;
|
||||||
* @return int weeks number
|
}
|
||||||
* @access protected
|
|
||||||
*/
|
/**
|
||||||
function getWeeksInMonth($y, $m, $firstDay=1)
|
* Returns the number of the week in the year (ISO-8601), given a date
|
||||||
{
|
*
|
||||||
$FDOM = $this->getFirstDayInMonth($y, $m);
|
* @param int $y year (2003)
|
||||||
if ($FDOM == 0) {
|
* @param int $m month (9)
|
||||||
$FDOM = $this->getDaysInWeek();
|
* @param int $d day (4)
|
||||||
}
|
*
|
||||||
if ($FDOM > $firstDay) {
|
* @return int week number
|
||||||
$daysInTheFirstWeek = $this->getDaysInWeek() - $FDOM + $firstDay;
|
* @access protected
|
||||||
$weeks = 1;
|
*/
|
||||||
} else {
|
function getWeekNInYear($y, $m, $d)
|
||||||
$daysInTheFirstWeek = $firstDay - $FDOM;
|
{
|
||||||
$weeks = 0;
|
$stamp = Calendar_Engine_UnixTS::dateToStamp($y, $m, $d);
|
||||||
}
|
$date = Calendar_Engine_UnixTS::stampCollection($stamp);
|
||||||
$daysInTheFirstWeek %= $this->getDaysInWeek();
|
return $date[7];
|
||||||
return (int)(ceil(($this->getDaysInMonth($y, $m) - $daysInTheFirstWeek) /
|
}
|
||||||
$this->getDaysInWeek()) + $weeks);
|
|
||||||
}
|
/**
|
||||||
|
* Returns the number of the week in the month, given a date
|
||||||
/**
|
*
|
||||||
* Returns the number of the day of the week (0=sunday, 1=monday...)
|
* @param int $y year (2003)
|
||||||
* @param int year (2003)
|
* @param int $m month (9)
|
||||||
* @param int month (9)
|
* @param int $d day (4)
|
||||||
* @param int day (4)
|
* @param int $firstDay first day of the week (default: monday)
|
||||||
* @return int weekday number
|
*
|
||||||
* @access protected
|
* @return int week number
|
||||||
*/
|
* @access protected
|
||||||
function getDayOfWeek($y, $m, $d)
|
*/
|
||||||
{
|
function getWeekNInMonth($y, $m, $d, $firstDay=1)
|
||||||
$stamp = Calendar_Engine_UnixTS::dateToStamp($y,$m,$d);
|
{
|
||||||
$date = Calendar_Engine_UnixTS::stampCollection($stamp);
|
$weekEnd = (0 == $firstDay) ? $this->getDaysInWeek()-1 : $firstDay-1;
|
||||||
return $date[8];
|
$end_of_week = 1;
|
||||||
}
|
while (@date('w', @mktime(0, 0, 0, $m, $end_of_week, $y)) != $weekEnd) {
|
||||||
|
++$end_of_week; //find first weekend of the month
|
||||||
/**
|
}
|
||||||
* Returns a list of integer days of the week beginning 0
|
$w = 1;
|
||||||
* @param int year (2003)
|
while ($d > $end_of_week) {
|
||||||
* @param int month (9)
|
++$w;
|
||||||
* @param int day (4)
|
$end_of_week += $this->getDaysInWeek();
|
||||||
* @return array (0,1,2,3,4,5,6) 1 = Monday
|
}
|
||||||
* @access protected
|
return $w;
|
||||||
*/
|
}
|
||||||
function getWeekDays($y=NULL, $m=NULL, $d=NULL)
|
|
||||||
{
|
/**
|
||||||
return array(0, 1, 2, 3, 4, 5, 6);
|
* Returns the number of weeks in the month
|
||||||
}
|
*
|
||||||
|
* @param int $y year (2003)
|
||||||
/**
|
* @param int $m month (9)
|
||||||
* Returns the default first day of the week
|
* @param int $firstDay first day of the week (default: monday)
|
||||||
* @param int year (2003)
|
*
|
||||||
* @param int month (9)
|
* @return int weeks number
|
||||||
* @param int day (4)
|
* @access protected
|
||||||
* @return int (default 1 = Monday)
|
*/
|
||||||
* @access protected
|
function getWeeksInMonth($y, $m, $firstDay = 1)
|
||||||
*/
|
{
|
||||||
function getFirstDayOfWeek($y=NULL, $m=NULL, $d=NULL)
|
$FDOM = $this->getFirstDayInMonth($y, $m);
|
||||||
{
|
if ($FDOM == 0) {
|
||||||
return 1;
|
$FDOM = $this->getDaysInWeek();
|
||||||
}
|
}
|
||||||
|
if ($FDOM > $firstDay) {
|
||||||
/**
|
$daysInTheFirstWeek = $this->getDaysInWeek() - $FDOM + $firstDay;
|
||||||
* Returns the number of hours in a day
|
$weeks = 1;
|
||||||
* @return int (24)
|
} else {
|
||||||
* @access protected
|
$daysInTheFirstWeek = $firstDay - $FDOM;
|
||||||
*/
|
$weeks = 0;
|
||||||
function getHoursInDay($y=null,$m=null,$d=null)
|
}
|
||||||
{
|
$daysInTheFirstWeek %= $this->getDaysInWeek();
|
||||||
return 24;
|
return (int)(ceil(($this->getDaysInMonth($y, $m) - $daysInTheFirstWeek) /
|
||||||
}
|
$this->getDaysInWeek()) + $weeks);
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Returns the number of minutes in an hour
|
/**
|
||||||
* @return int (60)
|
* Returns the number of the day of the week (0=sunday, 1=monday...)
|
||||||
* @access protected
|
*
|
||||||
*/
|
* @param int $y year (2003)
|
||||||
function getMinutesInHour($y=null,$m=null,$d=null,$h=null)
|
* @param int $m month (9)
|
||||||
{
|
* @param int $d day (4)
|
||||||
return 60;
|
*
|
||||||
}
|
* @return int weekday number
|
||||||
|
* @access protected
|
||||||
/**
|
*/
|
||||||
* Returns the number of seconds in a minutes
|
function getDayOfWeek($y, $m, $d)
|
||||||
* @return int (60)
|
{
|
||||||
* @access protected
|
$stamp = Calendar_Engine_UnixTS::dateToStamp($y, $m, $d);
|
||||||
*/
|
$date = Calendar_Engine_UnixTS::stampCollection($stamp);
|
||||||
function getSecondsInMinute($y=null,$m=null,$d=null,$h=null,$i=null)
|
return $date[8];
|
||||||
{
|
}
|
||||||
return 60;
|
|
||||||
}
|
/**
|
||||||
}
|
* Returns a list of integer days of the week beginning 0
|
||||||
|
*
|
||||||
|
* @param int $y year (2003)
|
||||||
|
* @param int $m month (9)
|
||||||
|
* @param int $d day (4)
|
||||||
|
*
|
||||||
|
* @return array (0,1,2,3,4,5,6) 1 = Monday
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
|
function getWeekDays($y=null, $m=null, $d=null)
|
||||||
|
{
|
||||||
|
return array(0, 1, 2, 3, 4, 5, 6);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the default first day of the week
|
||||||
|
*
|
||||||
|
* @param int $y year (2003)
|
||||||
|
* @param int $m month (9)
|
||||||
|
* @param int $d day (4)
|
||||||
|
*
|
||||||
|
* @return int (default 1 = Monday)
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
|
function getFirstDayOfWeek($y=null, $m=null, $d=null)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the number of hours in a day
|
||||||
|
*
|
||||||
|
* @param int $y year (2003)
|
||||||
|
* @param int $m month (9)
|
||||||
|
* @param int $d day (4)
|
||||||
|
*
|
||||||
|
* @return int (24)
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
|
function getHoursInDay($y=null, $m=null, $d=null)
|
||||||
|
{
|
||||||
|
return 24;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the number of minutes in an hour
|
||||||
|
*
|
||||||
|
* @param int $y year (2003)
|
||||||
|
* @param int $m month (9)
|
||||||
|
* @param int $d day (4)
|
||||||
|
* @param int $h hour
|
||||||
|
*
|
||||||
|
* @return int (60)
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
|
function getMinutesInHour($y=null, $m=null, $d=null, $h=null)
|
||||||
|
{
|
||||||
|
return 60;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the number of seconds in a minutes
|
||||||
|
*
|
||||||
|
* @param int $y year (2003)
|
||||||
|
* @param int $m month (9)
|
||||||
|
* @param int $d day (4)
|
||||||
|
* @param int $h hour
|
||||||
|
* @param int $i minute
|
||||||
|
*
|
||||||
|
* @return int (60)
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
|
function getSecondsInMinute($y=null, $m=null, $d=null, $h=null, $i=null)
|
||||||
|
{
|
||||||
|
return 60;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks if the given day is the current day
|
||||||
|
*
|
||||||
|
* @param mixed $stamp Any timestamp format recognized by Pear::Date
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
|
function isToday($stamp)
|
||||||
|
{
|
||||||
|
static $today = null;
|
||||||
|
if (is_null($today)) {
|
||||||
|
$today_date = @date('Y n j');
|
||||||
|
$today = sscanf($today_date, '%d %d %d');
|
||||||
|
}
|
||||||
|
$date = Calendar_Engine_UnixTS::stampCollection($stamp);
|
||||||
|
return ( $date[2] == $today[2]
|
||||||
|
&& $date[1] == $today[1]
|
||||||
|
&& $date[0] == $today[0]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
@@ -1,145 +1,168 @@
|
|||||||
<?php
|
<?php
|
||||||
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
||||||
//
|
|
||||||
// +----------------------------------------------------------------------+
|
/**
|
||||||
// | PHP Version 4 |
|
* Contains the Calendar_Factory class
|
||||||
// +----------------------------------------------------------------------+
|
*
|
||||||
// | Copyright (c) 1997-2002 The PHP Group |
|
* PHP versions 4 and 5
|
||||||
// +----------------------------------------------------------------------+
|
*
|
||||||
// | This source file is subject to version 2.02 of the PHP license, |
|
* LICENSE: Redistribution and use in source and binary forms, with or without
|
||||||
// | that is bundled with this package in the file LICENSE, and is |
|
* modification, are permitted provided that the following conditions are met:
|
||||||
// | available at through the world-wide-web at |
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
// | http://www.php.net/license/3_0.txt. |
|
* notice, this list of conditions and the following disclaimer.
|
||||||
// | If you did not receive a copy of the PHP license and are unable to |
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
// | obtain it through the world-wide-web, please send a note to |
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
// | license@php.net so we can mail you a copy immediately. |
|
* documentation and/or other materials provided with the distribution.
|
||||||
// +----------------------------------------------------------------------+
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
// | Authors: Harry Fuecks <hfuecks@phppatterns.com> |
|
* derived from this software without specific prior written permission.
|
||||||
// | Lorenzo Alberton <l dot alberton at quipo dot it> |
|
*
|
||||||
// +----------------------------------------------------------------------+
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||||
//
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
// $Id: Factory.php,v 1.3 2005/10/22 10:08:47 quipo Exp $
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
//
|
* IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
/**
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* @package Calendar
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
* @version $Id: Factory.php,v 1.3 2005/10/22 10:08:47 quipo Exp $
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
*/
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
/**
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
* Allows Calendar include path to be redefined
|
*
|
||||||
* @ignore
|
* @category Date and Time
|
||||||
*/
|
* @package Calendar
|
||||||
if (!defined('CALENDAR_ROOT')) {
|
* @author Harry Fuecks <hfuecks@phppatterns.com>
|
||||||
define('CALENDAR_ROOT', 'Calendar'.DIRECTORY_SEPARATOR);
|
* @author Lorenzo Alberton <l.alberton@quipo.it>
|
||||||
}
|
* @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton
|
||||||
|
* @license http://www.debian.org/misc/bsd.license BSD License (3 Clause)
|
||||||
/**
|
* @version CVS: $Id: Factory.php 246404 2007-11-18 21:46:43Z quipo $
|
||||||
* Load Calendar base class
|
* @link http://pear.php.net/package/Calendar
|
||||||
*/
|
*/
|
||||||
require_once CALENDAR_ROOT.'Calendar.php';
|
|
||||||
|
/**
|
||||||
/**
|
* Allows Calendar include path to be redefined
|
||||||
* Contains a factory method to return a Singleton instance of a class
|
* @ignore
|
||||||
* implementing the Calendar_Engine_Interface.<br>
|
*/
|
||||||
* For Month objects, to control type of month returned, use CALENDAR_MONTH_STATE
|
if (!defined('CALENDAR_ROOT')) {
|
||||||
* constact e.g.;
|
define('CALENDAR_ROOT', 'Calendar'.DIRECTORY_SEPARATOR);
|
||||||
* <code>
|
}
|
||||||
* require_once 'Calendar/Factory.php';
|
|
||||||
* define ('CALENDAR_MONTH_STATE',CALENDAR_USE_MONTH_WEEKDAYS); // Use Calendar_Month_Weekdays
|
/**
|
||||||
* // define ('CALENDAR_MONTH_STATE',CALENDAR_USE_MONTH_WEEKS); // Use Calendar_Month_Weeks
|
* Load Calendar base class
|
||||||
* // define ('CALENDAR_MONTH_STATE',CALENDAR_USE_MONTH); // Use Calendar_Month
|
*/
|
||||||
* </code>
|
require_once CALENDAR_ROOT.'Calendar.php';
|
||||||
* It defaults to building Calendar_Month objects.<br>
|
|
||||||
* Use the constract CALENDAR_FIRST_DAY_OF_WEEK to control the first day of the week
|
/**
|
||||||
* for Month or Week objects (e.g. 0 = Sunday, 6 = Saturday)
|
* Contains a factory method to return a Singleton instance of a class
|
||||||
* @package Calendar
|
* implementing the Calendar_Engine_Interface.<br>
|
||||||
* @access protected
|
* For Month objects, to control type of month returned, use CALENDAR_MONTH_STATE
|
||||||
*/
|
* constact e.g.;
|
||||||
class Calendar_Factory
|
* <code>
|
||||||
{
|
* require_once 'Calendar/Factory.php';
|
||||||
/**
|
* define ('CALENDAR_MONTH_STATE',CALENDAR_USE_MONTH_WEEKDAYS); // Use Calendar_Month_Weekdays
|
||||||
* Creates a calendar object given the type and units
|
* // define ('CALENDAR_MONTH_STATE',CALENDAR_USE_MONTH_WEEKS); // Use Calendar_Month_Weeks
|
||||||
* @param string class of calendar object to create
|
* // define ('CALENDAR_MONTH_STATE',CALENDAR_USE_MONTH); // Use Calendar_Month
|
||||||
* @param int year
|
* </code>
|
||||||
* @param int month
|
* It defaults to building Calendar_Month objects.<br>
|
||||||
* @param int day
|
* Use the constract CALENDAR_FIRST_DAY_OF_WEEK to control the first day of the week
|
||||||
* @param int hour
|
* for Month or Week objects (e.g. 0 = Sunday, 6 = Saturday)
|
||||||
* @param int minute
|
*
|
||||||
* @param int second
|
* @category Date and Time
|
||||||
* @return object subclass of Calendar
|
* @package Calendar
|
||||||
* @access public
|
* @author Harry Fuecks <hfuecks@phppatterns.com>
|
||||||
* @static
|
* @author Lorenzo Alberton <l.alberton@quipo.it>
|
||||||
*/
|
* @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton
|
||||||
function create($type, $y = 2000, $m = 1, $d = 1, $h = 0, $i = 0, $s = 0)
|
* @license http://www.debian.org/misc/bsd.license BSD License (3 Clause)
|
||||||
{
|
* @link http://pear.php.net/package/Calendar
|
||||||
$firstDay = defined('CALENDAR_FIRST_DAY_OF_WEEK') ? CALENDAR_FIRST_DAY_OF_WEEK : 1;
|
* @access protected
|
||||||
switch ($type) {
|
*/
|
||||||
case 'Day':
|
class Calendar_Factory
|
||||||
require_once CALENDAR_ROOT.'Day.php';
|
{
|
||||||
return new Calendar_Day($y,$m,$d);
|
/**
|
||||||
case 'Month':
|
* Creates a calendar object given the type and units
|
||||||
// Set default state for which month type to build
|
*
|
||||||
if (!defined('CALENDAR_MONTH_STATE')) {
|
* @param string $type class of calendar object to create
|
||||||
define('CALENDAR_MONTH_STATE', CALENDAR_USE_MONTH);
|
* @param int $y year
|
||||||
}
|
* @param int $m month
|
||||||
switch (CALENDAR_MONTH_STATE) {
|
* @param int $d day
|
||||||
case CALENDAR_USE_MONTH_WEEKDAYS:
|
* @param int $h hour
|
||||||
require_once CALENDAR_ROOT.'Month/Weekdays.php';
|
* @param int $i minute
|
||||||
$class = 'Calendar_Month_Weekdays';
|
* @param int $s second
|
||||||
break;
|
*
|
||||||
case CALENDAR_USE_MONTH_WEEKS:
|
* @return object subclass of Calendar
|
||||||
require_once CALENDAR_ROOT.'Month/Weeks.php';
|
* @access public
|
||||||
$class = 'Calendar_Month_Weeks';
|
* @static
|
||||||
break;
|
*/
|
||||||
case CALENDAR_USE_MONTH:
|
static function create($type, $y = 2000, $m = 1, $d = 1, $h = 0, $i = 0, $s = 0)
|
||||||
default:
|
{
|
||||||
require_once CALENDAR_ROOT.'Month.php';
|
$firstDay = defined('CALENDAR_FIRST_DAY_OF_WEEK') ? CALENDAR_FIRST_DAY_OF_WEEK : 1;
|
||||||
$class = 'Calendar_Month';
|
switch ($type) {
|
||||||
break;
|
case 'Day':
|
||||||
}
|
include_once CALENDAR_ROOT.'Day.php';
|
||||||
return new $class($y, $m, $firstDay);
|
return new Calendar_Day($y, $m, $d);
|
||||||
case 'Week':
|
case 'Month':
|
||||||
require_once CALENDAR_ROOT.'Week.php';
|
// Set default state for which month type to build
|
||||||
return new Calendar_Week($y, $m, $d, $firstDay);
|
if (!defined('CALENDAR_MONTH_STATE')) {
|
||||||
case 'Hour':
|
define('CALENDAR_MONTH_STATE', CALENDAR_USE_MONTH);
|
||||||
require_once CALENDAR_ROOT.'Hour.php';
|
}
|
||||||
return new Calendar_Hour($y, $m, $d, $h);
|
switch (CALENDAR_MONTH_STATE) {
|
||||||
case 'Minute':
|
case CALENDAR_USE_MONTH_WEEKDAYS:
|
||||||
require_once CALENDAR_ROOT.'Minute.php';
|
include_once CALENDAR_ROOT.'Month/Weekdays.php';
|
||||||
return new Calendar_Minute($y, $m, $d, $h, $i);
|
$class = 'Calendar_Month_Weekdays';
|
||||||
case 'Second':
|
break;
|
||||||
require_once CALENDAR_ROOT.'Second.php';
|
case CALENDAR_USE_MONTH_WEEKS:
|
||||||
return new Calendar_Second($y,$m,$d,$h,$i,$s);
|
include_once CALENDAR_ROOT.'Month/Weeks.php';
|
||||||
case 'Year':
|
$class = 'Calendar_Month_Weeks';
|
||||||
require_once CALENDAR_ROOT.'Year.php';
|
break;
|
||||||
return new Calendar_Year($y);
|
case CALENDAR_USE_MONTH:
|
||||||
default:
|
default:
|
||||||
require_once 'PEAR.php';
|
include_once CALENDAR_ROOT.'Month.php';
|
||||||
PEAR::raiseError(
|
$class = 'Calendar_Month';
|
||||||
'Calendar_Factory::create() unrecognised type: '.$type, null, PEAR_ERROR_TRIGGER,
|
break;
|
||||||
E_USER_NOTICE, 'Calendar_Factory::create()');
|
}
|
||||||
return false;
|
return new $class($y, $m, $firstDay);
|
||||||
}
|
case 'Week':
|
||||||
}
|
include_once CALENDAR_ROOT.'Week.php';
|
||||||
/**
|
return new Calendar_Week($y, $m, $d, $firstDay);
|
||||||
* Creates an instance of a calendar object, given a type and timestamp
|
case 'Hour':
|
||||||
* @param string type of object to create
|
include_once CALENDAR_ROOT.'Hour.php';
|
||||||
* @param mixed timestamp (depending on Calendar engine being used)
|
return new Calendar_Hour($y, $m, $d, $h);
|
||||||
* @return object subclass of Calendar
|
case 'Minute':
|
||||||
* @access public
|
include_once CALENDAR_ROOT.'Minute.php';
|
||||||
* @static
|
return new Calendar_Minute($y, $m, $d, $h, $i);
|
||||||
*/
|
case 'Second':
|
||||||
function & createByTimestamp($type, $stamp)
|
include_once CALENDAR_ROOT.'Second.php';
|
||||||
{
|
return new Calendar_Second($y, $m, $d, $h, $i, $s);
|
||||||
$cE = & Calendar_Engine_Factory::getEngine();
|
case 'Year':
|
||||||
$y = $cE->stampToYear($stamp);
|
include_once CALENDAR_ROOT.'Year.php';
|
||||||
$m = $cE->stampToMonth($stamp);
|
return new Calendar_Year($y);
|
||||||
$d = $cE->stampToDay($stamp);
|
default:
|
||||||
$h = $cE->stampToHour($stamp);
|
include_once 'PEAR.php';
|
||||||
$i = $cE->stampToMinute($stamp);
|
PEAR::raiseError('Calendar_Factory::create() unrecognised type: '.$type,
|
||||||
$s = $cE->stampToSecond($stamp);
|
null, PEAR_ERROR_TRIGGER, E_USER_NOTICE, 'Calendar_Factory::create()');
|
||||||
$cal = Calendar_Factory::create($type, $y, $m, $d, $h, $i, $s);
|
return false;
|
||||||
return $cal;
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
?>
|
/**
|
||||||
|
* Creates an instance of a calendar object, given a type and timestamp
|
||||||
|
*
|
||||||
|
* @param string $type type of object to create
|
||||||
|
* @param mixed $stamp timestamp (depending on Calendar engine being used)
|
||||||
|
*
|
||||||
|
* @return object subclass of Calendar
|
||||||
|
* @access public
|
||||||
|
* @static
|
||||||
|
*/
|
||||||
|
static function & createByTimestamp($type, $stamp)
|
||||||
|
{
|
||||||
|
$cE = & Calendar_Engine_Factory::getEngine();
|
||||||
|
$y = $cE->stampToYear($stamp);
|
||||||
|
$m = $cE->stampToMonth($stamp);
|
||||||
|
$d = $cE->stampToDay($stamp);
|
||||||
|
$h = $cE->stampToHour($stamp);
|
||||||
|
$i = $cE->stampToMinute($stamp);
|
||||||
|
$s = $cE->stampToSecond($stamp);
|
||||||
|
$cal = Calendar_Factory::create($type, $y, $m, $d, $h, $i, $s);
|
||||||
|
return $cal;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|||||||
@@ -1,113 +1,137 @@
|
|||||||
<?php
|
<?php
|
||||||
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
||||||
//
|
|
||||||
// +----------------------------------------------------------------------+
|
/**
|
||||||
// | PHP Version 4 |
|
* Contains the Calendar_Hour class
|
||||||
// +----------------------------------------------------------------------+
|
*
|
||||||
// | Copyright (c) 1997-2002 The PHP Group |
|
* PHP versions 4 and 5
|
||||||
// +----------------------------------------------------------------------+
|
*
|
||||||
// | This source file is subject to version 2.02 of the PHP license, |
|
* LICENSE: Redistribution and use in source and binary forms, with or without
|
||||||
// | that is bundled with this package in the file LICENSE, and is |
|
* modification, are permitted provided that the following conditions are met:
|
||||||
// | available at through the world-wide-web at |
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
// | http://www.php.net/license/3_0.txt. |
|
* notice, this list of conditions and the following disclaimer.
|
||||||
// | If you did not receive a copy of the PHP license and are unable to |
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
// | obtain it through the world-wide-web, please send a note to |
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
// | license@php.net so we can mail you a copy immediately. |
|
* documentation and/or other materials provided with the distribution.
|
||||||
// +----------------------------------------------------------------------+
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
// | Authors: Harry Fuecks <hfuecks@phppatterns.com> |
|
* derived from this software without specific prior written permission.
|
||||||
// +----------------------------------------------------------------------+
|
*
|
||||||
//
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||||
// $Id: Hour.php,v 1.1 2004/05/24 22:25:42 quipo Exp $
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
//
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
/**
|
* IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
* @package Calendar
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* @version $Id: Hour.php,v 1.1 2004/05/24 22:25:42 quipo Exp $
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
*/
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
/**
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
* Allows Calendar include path to be redefined
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
* @ignore
|
*
|
||||||
*/
|
* @category Date and Time
|
||||||
if (!defined('CALENDAR_ROOT')) {
|
* @package Calendar
|
||||||
define('CALENDAR_ROOT', 'Calendar'.DIRECTORY_SEPARATOR);
|
* @author Harry Fuecks <hfuecks@phppatterns.com>
|
||||||
}
|
* @copyright 2003-2007 Harry Fuecks
|
||||||
|
* @license http://www.debian.org/misc/bsd.license BSD License (3 Clause)
|
||||||
/**
|
* @version CVS: $Id: Hour.php 300729 2010-06-24 12:05:53Z quipo $
|
||||||
* Load Calendar base class
|
* @link http://pear.php.net/package/Calendar
|
||||||
*/
|
*/
|
||||||
require_once CALENDAR_ROOT.'Calendar.php';
|
|
||||||
|
/**
|
||||||
/**
|
* Allows Calendar include path to be redefined
|
||||||
* Represents an Hour and builds Minutes
|
* @ignore
|
||||||
* <code>
|
*/
|
||||||
* require_once 'Calendar'.DIRECTORY_SEPARATOR.'Hour.php';
|
if (!defined('CALENDAR_ROOT')) {
|
||||||
* $Hour = & new Calendar_Hour(2003, 10, 21, 15); // Oct 21st 2003, 3pm
|
define('CALENDAR_ROOT', 'Calendar'.DIRECTORY_SEPARATOR);
|
||||||
* $Hour->build(); // Build Calendar_Minute objects
|
}
|
||||||
* while ($Minute = & $Hour->fetch()) {
|
|
||||||
* echo $Minute->thisMinute().'<br />';
|
/**
|
||||||
* }
|
* Load Calendar base class
|
||||||
* </code>
|
*/
|
||||||
* @package Calendar
|
require_once CALENDAR_ROOT.'Calendar.php';
|
||||||
* @access public
|
|
||||||
*/
|
/**
|
||||||
class Calendar_Hour extends Calendar
|
* Represents an Hour and builds Minutes
|
||||||
{
|
* <code>
|
||||||
/**
|
* require_once 'Calendar'.DIRECTORY_SEPARATOR.'Hour.php';
|
||||||
* Constructs Calendar_Hour
|
* $Hour = new Calendar_Hour(2003, 10, 21, 15); // Oct 21st 2003, 3pm
|
||||||
* @param int year e.g. 2003
|
* $Hour->build(); // Build Calendar_Minute objects
|
||||||
* @param int month e.g. 5
|
* while ($Minute = & $Hour->fetch()) {
|
||||||
* @param int day e.g. 11
|
* echo $Minute->thisMinute().'<br />';
|
||||||
* @param int hour e.g. 13
|
* }
|
||||||
* @access public
|
* </code>
|
||||||
*/
|
*
|
||||||
function Calendar_Hour($y, $m, $d, $h)
|
* @category Date and Time
|
||||||
{
|
* @package Calendar
|
||||||
Calendar::Calendar($y, $m, $d, $h);
|
* @author Harry Fuecks <hfuecks@phppatterns.com>
|
||||||
}
|
* @copyright 2003-2007 Harry Fuecks
|
||||||
|
* @license http://www.debian.org/misc/bsd.license BSD License (3 Clause)
|
||||||
/**
|
* @link http://pear.php.net/package/Calendar
|
||||||
* Builds the Minutes in the Hour
|
* @access public
|
||||||
* @param array (optional) Calendar_Minute objects representing selected dates
|
*/
|
||||||
* @return boolean
|
class Calendar_Hour extends Calendar
|
||||||
* @access public
|
{
|
||||||
*/
|
/**
|
||||||
function build($sDates=array())
|
* Constructs Calendar_Hour
|
||||||
{
|
*
|
||||||
require_once CALENDAR_ROOT.'Minute.php';
|
* @param int $y year e.g. 2003
|
||||||
$mIH = $this->cE->getMinutesInHour($this->year, $this->month, $this->day,
|
* @param int $m month e.g. 5
|
||||||
$this->hour);
|
* @param int $d day e.g. 11
|
||||||
for ($i=0; $i < $mIH; $i++) {
|
* @param int $h hour e.g. 13
|
||||||
$this->children[$i]=
|
*
|
||||||
new Calendar_Minute($this->year, $this->month, $this->day,
|
* @access public
|
||||||
$this->hour, $i);
|
*/
|
||||||
}
|
function Calendar_Hour($y, $m, $d, $h)
|
||||||
if (count($sDates) > 0) {
|
{
|
||||||
$this->setSelection($sDates);
|
parent::Calendar($y, $m, $d, $h);
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
/**
|
||||||
|
* Builds the Minutes in the Hour
|
||||||
/**
|
*
|
||||||
* Called from build()
|
* @param array $sDates (optional) Calendar_Minute objects representing selected dates
|
||||||
* @param array
|
*
|
||||||
* @return void
|
* @return boolean
|
||||||
* @access private
|
* @access public
|
||||||
*/
|
*/
|
||||||
function setSelection($sDates)
|
function build($sDates = array())
|
||||||
{
|
{
|
||||||
foreach ($sDates as $sDate) {
|
include_once CALENDAR_ROOT.'Minute.php';
|
||||||
if ($this->year == $sDate->thisYear()
|
$mIH = $this->cE->getMinutesInHour($this->year, $this->month, $this->day,
|
||||||
&& $this->month == $sDate->thisMonth()
|
$this->hour);
|
||||||
&& $this->day == $sDate->thisDay()
|
for ($i=0; $i < $mIH; $i++) {
|
||||||
&& $this->hour == $sDate->thisHour())
|
$this->children[$i] =
|
||||||
{
|
new Calendar_Minute($this->year, $this->month, $this->day,
|
||||||
$key = (int)$sDate->thisMinute();
|
$this->hour, $i);
|
||||||
if (isset($this->children[$key])) {
|
}
|
||||||
$sDate->setSelected();
|
if (count($sDates) > 0) {
|
||||||
$this->children[$key] = $sDate;
|
$this->setSelection($sDates);
|
||||||
}
|
}
|
||||||
}
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
/**
|
||||||
|
* Called from build()
|
||||||
|
*
|
||||||
|
* @param array $sDates Calendar_Minute objects representing selected dates
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
function setSelection($sDates)
|
||||||
|
{
|
||||||
|
foreach ($sDates as $sDate) {
|
||||||
|
if ($this->year == $sDate->thisYear()
|
||||||
|
&& $this->month == $sDate->thisMonth()
|
||||||
|
&& $this->day == $sDate->thisDay()
|
||||||
|
&& $this->hour == $sDate->thisHour())
|
||||||
|
{
|
||||||
|
$key = (int)$sDate->thisMinute();
|
||||||
|
if (isset($this->children[$key])) {
|
||||||
|
$sDate->setSelected();
|
||||||
|
$this->children[$key] = $sDate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
@@ -1,114 +1,138 @@
|
|||||||
<?php
|
<?php
|
||||||
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
||||||
//
|
|
||||||
// +----------------------------------------------------------------------+
|
/**
|
||||||
// | PHP Version 4 |
|
* Contains the Calendar_Minute class
|
||||||
// +----------------------------------------------------------------------+
|
*
|
||||||
// | Copyright (c) 1997-2002 The PHP Group |
|
* PHP versions 4 and 5
|
||||||
// +----------------------------------------------------------------------+
|
*
|
||||||
// | This source file is subject to version 2.02 of the PHP license, |
|
* LICENSE: Redistribution and use in source and binary forms, with or without
|
||||||
// | that is bundled with this package in the file LICENSE, and is |
|
* modification, are permitted provided that the following conditions are met:
|
||||||
// | available at through the world-wide-web at |
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
// | http://www.php.net/license/3_0.txt. |
|
* notice, this list of conditions and the following disclaimer.
|
||||||
// | If you did not receive a copy of the PHP license and are unable to |
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
// | obtain it through the world-wide-web, please send a note to |
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
// | license@php.net so we can mail you a copy immediately. |
|
* documentation and/or other materials provided with the distribution.
|
||||||
// +----------------------------------------------------------------------+
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
// | Authors: Harry Fuecks <hfuecks@phppatterns.com> |
|
* derived from this software without specific prior written permission.
|
||||||
// +----------------------------------------------------------------------+
|
*
|
||||||
//
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||||
// $Id: Minute.php,v 1.1 2004/05/24 22:25:42 quipo Exp $
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
//
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
/**
|
* IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
* @package Calendar
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* @version $Id: Minute.php,v 1.1 2004/05/24 22:25:42 quipo Exp $
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
*/
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
/**
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
* Allows Calendar include path to be redefined
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
* @ignore
|
*
|
||||||
*/
|
* @category Date and Time
|
||||||
if (!defined('CALENDAR_ROOT')) {
|
* @package Calendar
|
||||||
define('CALENDAR_ROOT', 'Calendar'.DIRECTORY_SEPARATOR);
|
* @author Harry Fuecks <hfuecks@phppatterns.com>
|
||||||
}
|
* @copyright 2003-2007 Harry Fuecks
|
||||||
|
* @license http://www.debian.org/misc/bsd.license BSD License (3 Clause)
|
||||||
/**
|
* @version CVS: $Id: Minute.php 300729 2010-06-24 12:05:53Z quipo $
|
||||||
* Load Calendar base class
|
* @link http://pear.php.net/package/Calendar
|
||||||
*/
|
*/
|
||||||
require_once CALENDAR_ROOT.'Calendar.php';
|
|
||||||
|
/**
|
||||||
/**
|
* Allows Calendar include path to be redefined
|
||||||
* Represents a Minute and builds Seconds
|
* @ignore
|
||||||
* <code>
|
*/
|
||||||
* require_once 'Calendar'.DIRECTORY_SEPARATOR.'Minute.php';
|
if (!defined('CALENDAR_ROOT')) {
|
||||||
* $Minute = & new Calendar_Minute(2003, 10, 21, 15, 31); // Oct 21st 2003, 3:31pm
|
define('CALENDAR_ROOT', 'Calendar'.DIRECTORY_SEPARATOR);
|
||||||
* $Minute->build(); // Build Calendar_Second objects
|
}
|
||||||
* while ($Second = & $Minute->fetch()) {
|
|
||||||
* echo $Second->thisSecond().'<br />';
|
/**
|
||||||
* }
|
* Load Calendar base class
|
||||||
* </code>
|
*/
|
||||||
* @package Calendar
|
require_once CALENDAR_ROOT.'Calendar.php';
|
||||||
* @access public
|
|
||||||
*/
|
/**
|
||||||
class Calendar_Minute extends Calendar
|
* Represents a Minute and builds Seconds
|
||||||
{
|
* <code>
|
||||||
/**
|
* require_once 'Calendar'.DIRECTORY_SEPARATOR.'Minute.php';
|
||||||
* Constructs Minute
|
* $Minute = new Calendar_Minute(2003, 10, 21, 15, 31); // Oct 21st 2003, 3:31pm
|
||||||
* @param int year e.g. 2003
|
* $Minute->build(); // Build Calendar_Second objects
|
||||||
* @param int month e.g. 5
|
* while ($Second = & $Minute->fetch()) {
|
||||||
* @param int day e.g. 11
|
* echo $Second->thisSecond().'<br />';
|
||||||
* @param int hour e.g. 13
|
* }
|
||||||
* @param int minute e.g. 31
|
* </code>
|
||||||
* @access public
|
*
|
||||||
*/
|
* @category Date and Time
|
||||||
function Calendar_Minute($y, $m, $d, $h, $i)
|
* @package Calendar
|
||||||
{
|
* @author Harry Fuecks <hfuecks@phppatterns.com>
|
||||||
Calendar::Calendar($y, $m, $d, $h, $i);
|
* @copyright 2003-2007 Harry Fuecks
|
||||||
}
|
* @license http://www.debian.org/misc/bsd.license BSD License (3 Clause)
|
||||||
|
* @link http://pear.php.net/package/Calendar
|
||||||
/**
|
* @access public
|
||||||
* Builds the Calendar_Second objects
|
*/
|
||||||
* @param array (optional) Calendar_Second objects representing selected dates
|
class Calendar_Minute extends Calendar
|
||||||
* @return boolean
|
{
|
||||||
* @access public
|
/**
|
||||||
*/
|
* Constructs Minute
|
||||||
function build($sDates=array())
|
*
|
||||||
{
|
* @param int $y year e.g. 2003
|
||||||
require_once CALENDAR_ROOT.'Second.php';
|
* @param int $m month e.g. 5
|
||||||
$sIM = $this->cE->getSecondsInMinute($this->year, $this->month,
|
* @param int $d day e.g. 11
|
||||||
$this->day, $this->hour, $this->minute);
|
* @param int $h hour e.g. 13
|
||||||
for ($i=0; $i < $sIM; $i++) {
|
* @param int $i minute e.g. 31
|
||||||
$this->children[$i] = new Calendar_Second($this->year, $this->month,
|
*
|
||||||
$this->day, $this->hour, $this->minute, $i);
|
* @access public
|
||||||
}
|
*/
|
||||||
if (count($sDates) > 0) {
|
function Calendar_Minute($y, $m, $d, $h, $i)
|
||||||
$this->setSelection($sDates);
|
{
|
||||||
}
|
parent::Calendar($y, $m, $d, $h, $i);
|
||||||
return true;
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
/**
|
* Builds the Calendar_Second objects
|
||||||
* Called from build()
|
*
|
||||||
* @param array
|
* @param array $sDates (optional) Calendar_Second objects representing selected dates
|
||||||
* @return void
|
*
|
||||||
* @access private
|
* @return boolean
|
||||||
*/
|
* @access public
|
||||||
function setSelection($sDates)
|
*/
|
||||||
{
|
function build($sDates = array())
|
||||||
foreach ($sDates as $sDate) {
|
{
|
||||||
if ($this->year == $sDate->thisYear()
|
include_once CALENDAR_ROOT.'Second.php';
|
||||||
&& $this->month == $sDate->thisMonth()
|
$sIM = $this->cE->getSecondsInMinute($this->year, $this->month,
|
||||||
&& $this->day == $sDate->thisDay()
|
$this->day, $this->hour, $this->minute);
|
||||||
&& $this->hour == $sDate->thisHour()
|
for ($i=0; $i < $sIM; $i++) {
|
||||||
&& $this->minute == $sDate->thisMinute())
|
$this->children[$i] = new Calendar_Second($this->year, $this->month,
|
||||||
{
|
$this->day, $this->hour, $this->minute, $i);
|
||||||
$key = (int)$sDate->thisSecond();
|
}
|
||||||
if (isset($this->children[$key])) {
|
if (count($sDates) > 0) {
|
||||||
$sDate->setSelected();
|
$this->setSelection($sDates);
|
||||||
$this->children[$key] = $sDate;
|
}
|
||||||
}
|
return true;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
/**
|
||||||
}
|
* Called from build()
|
||||||
|
*
|
||||||
|
* @param array $sDates Calendar_Second objects representing selected dates
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
function setSelection($sDates)
|
||||||
|
{
|
||||||
|
foreach ($sDates as $sDate) {
|
||||||
|
if ($this->year == $sDate->thisYear()
|
||||||
|
&& $this->month == $sDate->thisMonth()
|
||||||
|
&& $this->day == $sDate->thisDay()
|
||||||
|
&& $this->hour == $sDate->thisHour()
|
||||||
|
&& $this->minute == $sDate->thisMinute())
|
||||||
|
{
|
||||||
|
$key = (int)$sDate->thisSecond();
|
||||||
|
if (isset($this->children[$key])) {
|
||||||
|
$sDate->setSelected();
|
||||||
|
$this->children[$key] = $sDate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
@@ -1,114 +1,138 @@
|
|||||||
<?php
|
<?php
|
||||||
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
||||||
//
|
|
||||||
// +----------------------------------------------------------------------+
|
/**
|
||||||
// | PHP Version 4 |
|
* Contains the Calendar_Month class
|
||||||
// +----------------------------------------------------------------------+
|
*
|
||||||
// | Copyright (c) 1997-2002 The PHP Group |
|
* PHP versions 4 and 5
|
||||||
// +----------------------------------------------------------------------+
|
*
|
||||||
// | This source file is subject to version 2.02 of the PHP license, |
|
* LICENSE: Redistribution and use in source and binary forms, with or without
|
||||||
// | that is bundled with this package in the file LICENSE, and is |
|
* modification, are permitted provided that the following conditions are met:
|
||||||
// | available at through the world-wide-web at |
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
// | http://www.php.net/license/3_0.txt. |
|
* notice, this list of conditions and the following disclaimer.
|
||||||
// | If you did not receive a copy of the PHP license and are unable to |
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
// | obtain it through the world-wide-web, please send a note to |
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
// | license@php.net so we can mail you a copy immediately. |
|
* documentation and/or other materials provided with the distribution.
|
||||||
// +----------------------------------------------------------------------+
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
// | Authors: Harry Fuecks <hfuecks@phppatterns.com> |
|
* derived from this software without specific prior written permission.
|
||||||
// +----------------------------------------------------------------------+
|
*
|
||||||
//
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||||
// $Id: Month.php,v 1.3 2005/10/22 10:10:26 quipo Exp $
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
//
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
/**
|
* IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
* @package Calendar
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* @version $Id: Month.php,v 1.3 2005/10/22 10:10:26 quipo Exp $
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
*/
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
/**
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
* Allows Calendar include path to be redefined
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
* @ignore
|
*
|
||||||
*/
|
* @category Date and Time
|
||||||
if (!defined('CALENDAR_ROOT')) {
|
* @package Calendar
|
||||||
define('CALENDAR_ROOT', 'Calendar'.DIRECTORY_SEPARATOR);
|
* @author Harry Fuecks <hfuecks@phppatterns.com>
|
||||||
}
|
* @copyright 2003-2007 Harry Fuecks
|
||||||
|
* @license http://www.debian.org/misc/bsd.license BSD License (3 Clause)
|
||||||
/**
|
* @version CVS: $Id: Month.php 300729 2010-06-24 12:05:53Z quipo $
|
||||||
* Load Calendar base class
|
* @link http://pear.php.net/package/Calendar
|
||||||
*/
|
*/
|
||||||
require_once CALENDAR_ROOT.'Calendar.php';
|
|
||||||
|
/**
|
||||||
/**
|
* Allows Calendar include path to be redefined
|
||||||
* Represents a Month and builds Days
|
* @ignore
|
||||||
* <code>
|
*/
|
||||||
* require_once 'Calendar/Month.php';
|
if (!defined('CALENDAR_ROOT')) {
|
||||||
* $Month = & new Calendar_Month(2003, 10); // Oct 2003
|
define('CALENDAR_ROOT', 'Calendar'.DIRECTORY_SEPARATOR);
|
||||||
* $Month->build(); // Build Calendar_Day objects
|
}
|
||||||
* while ($Day = & $Month->fetch()) {
|
|
||||||
* echo $Day->thisDay().'<br />';
|
/**
|
||||||
* }
|
* Load Calendar base class
|
||||||
* </code>
|
*/
|
||||||
* @package Calendar
|
require_once CALENDAR_ROOT.'Calendar.php';
|
||||||
* @access public
|
|
||||||
*/
|
/**
|
||||||
class Calendar_Month extends Calendar
|
* Represents a Month and builds Days
|
||||||
{
|
* <code>
|
||||||
/**
|
* require_once 'Calendar/Month.php';
|
||||||
* Constructs Calendar_Month
|
* $Month = new Calendar_Month(2003, 10); // Oct 2003
|
||||||
* @param int $y year e.g. 2003
|
* $Month->build(); // Build Calendar_Day objects
|
||||||
* @param int $m month e.g. 5
|
* while ($Day = & $Month->fetch()) {
|
||||||
* @param int $firstDay first day of the week [optional]
|
* echo $Day->thisDay().'<br />';
|
||||||
* @access public
|
* }
|
||||||
*/
|
* </code>
|
||||||
function Calendar_Month($y, $m, $firstDay=null)
|
*
|
||||||
{
|
* @category Date and Time
|
||||||
Calendar::Calendar($y, $m);
|
* @package Calendar
|
||||||
$this->firstDay = $this->defineFirstDayOfWeek($firstDay);
|
* @author Harry Fuecks <hfuecks@phppatterns.com>
|
||||||
}
|
* @copyright 2003-2007 Harry Fuecks
|
||||||
|
* @license http://www.debian.org/misc/bsd.license BSD License (3 Clause)
|
||||||
/**
|
* @link http://pear.php.net/package/Calendar
|
||||||
* Builds Day objects for this Month. Creates as many Calendar_Day objects
|
* @access public
|
||||||
* as there are days in the month
|
*/
|
||||||
* @param array (optional) Calendar_Day objects representing selected dates
|
class Calendar_Month extends Calendar
|
||||||
* @return boolean
|
{
|
||||||
* @access public
|
/**
|
||||||
*/
|
* Constructs Calendar_Month
|
||||||
function build($sDates=array())
|
*
|
||||||
{
|
* @param int $y year e.g. 2003
|
||||||
require_once CALENDAR_ROOT.'Day.php';
|
* @param int $m month e.g. 5
|
||||||
$daysInMonth = $this->cE->getDaysInMonth($this->year, $this->month);
|
* @param int $firstDay first day of the week [optional]
|
||||||
for ($i=1; $i<=$daysInMonth; $i++) {
|
*
|
||||||
$this->children[$i] = new Calendar_Day($this->year, $this->month, $i);
|
* @access public
|
||||||
}
|
*/
|
||||||
if (count($sDates) > 0) {
|
function Calendar_Month($y, $m, $firstDay=null)
|
||||||
$this->setSelection($sDates);
|
{
|
||||||
}
|
parent::Calendar($y, $m);
|
||||||
return true;
|
$this->firstDay = $this->defineFirstDayOfWeek($firstDay);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called from build()
|
* Builds Day objects for this Month. Creates as many Calendar_Day objects
|
||||||
* @param array
|
* as there are days in the month
|
||||||
* @return void
|
*
|
||||||
* @access private
|
* @param array $sDates (optional) Calendar_Day objects representing selected dates
|
||||||
*/
|
*
|
||||||
function setSelection($sDates)
|
* @return boolean
|
||||||
{
|
* @access public
|
||||||
foreach ($sDates as $sDate) {
|
*/
|
||||||
if ($this->year == $sDate->thisYear()
|
function build($sDates = array())
|
||||||
&& $this->month == $sDate->thisMonth()
|
{
|
||||||
) {
|
include_once CALENDAR_ROOT.'Day.php';
|
||||||
$key = $sDate->thisDay();
|
$daysInMonth = $this->cE->getDaysInMonth($this->year, $this->month);
|
||||||
if (isset($this->children[$key])) {
|
for ($i=1; $i<=$daysInMonth; $i++) {
|
||||||
$sDate->setSelected();
|
$this->children[$i] = new Calendar_Day($this->year, $this->month, $i);
|
||||||
$class = strtolower(get_class($sDate));
|
}
|
||||||
if ($class == 'calendar_day' || $class == 'calendar_decorator') {
|
if (count($sDates) > 0) {
|
||||||
$sDate->setFirst($this->children[$key]->isFirst());
|
$this->setSelection($sDates);
|
||||||
$sDate->setLast($this->children[$key]->isLast());
|
}
|
||||||
}
|
return true;
|
||||||
$this->children[$key] = $sDate;
|
}
|
||||||
}
|
|
||||||
}
|
/**
|
||||||
}
|
* Called from build()
|
||||||
}
|
*
|
||||||
}
|
* @param array $sDates Calendar_Day objects representing selected dates
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
function setSelection($sDates)
|
||||||
|
{
|
||||||
|
foreach ($sDates as $sDate) {
|
||||||
|
if ($this->year == $sDate->thisYear()
|
||||||
|
&& $this->month == $sDate->thisMonth()
|
||||||
|
) {
|
||||||
|
$key = $sDate->thisDay();
|
||||||
|
if (isset($this->children[$key])) {
|
||||||
|
$sDate->setSelected();
|
||||||
|
$class = strtolower(get_class($sDate));
|
||||||
|
if ($class == 'calendar_day' || $class == 'calendar_decorator') {
|
||||||
|
$sDate->setFirst($this->children[$key]->isFirst());
|
||||||
|
$sDate->setLast($this->children[$key]->isLast());
|
||||||
|
}
|
||||||
|
$this->children[$key] = $sDate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
@@ -1,189 +1,215 @@
|
|||||||
<?php
|
<?php
|
||||||
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
||||||
//
|
|
||||||
// +----------------------------------------------------------------------+
|
/**
|
||||||
// | PHP Version 4 |
|
* Contains the Calendar_Month_Weekdays class
|
||||||
// +----------------------------------------------------------------------+
|
*
|
||||||
// | Copyright (c) 1997-2002 The PHP Group |
|
* PHP versions 4 and 5
|
||||||
// +----------------------------------------------------------------------+
|
*
|
||||||
// | This source file is subject to version 2.02 of the PHP license, |
|
* LICENSE: Redistribution and use in source and binary forms, with or without
|
||||||
// | that is bundled with this package in the file LICENSE, and is |
|
* modification, are permitted provided that the following conditions are met:
|
||||||
// | available at through the world-wide-web at |
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
// | http://www.php.net/license/3_0.txt. |
|
* notice, this list of conditions and the following disclaimer.
|
||||||
// | If you did not receive a copy of the PHP license and are unable to |
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
// | obtain it through the world-wide-web, please send a note to |
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
// | license@php.net so we can mail you a copy immediately. |
|
* documentation and/or other materials provided with the distribution.
|
||||||
// +----------------------------------------------------------------------+
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
// | Authors: Harry Fuecks <hfuecks@phppatterns.com> |
|
* derived from this software without specific prior written permission.
|
||||||
// +----------------------------------------------------------------------+
|
*
|
||||||
//
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||||
// $Id: Weekdays.php,v 1.4 2005/10/22 10:28:49 quipo Exp $
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
//
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
/**
|
* IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
* @package Calendar
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* @version $Id: Weekdays.php,v 1.4 2005/10/22 10:28:49 quipo Exp $
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
*/
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
/**
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
* Allows Calendar include path to be redefined
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
* @ignore
|
*
|
||||||
*/
|
* @category Date and Time
|
||||||
if (!defined('CALENDAR_ROOT')) {
|
* @package Calendar
|
||||||
define('CALENDAR_ROOT', 'Calendar'.DIRECTORY_SEPARATOR);
|
* @author Harry Fuecks <hfuecks@phppatterns.com>
|
||||||
}
|
* @copyright 2003-2007 Harry Fuecks
|
||||||
|
* @license http://www.debian.org/misc/bsd.license BSD License (3 Clause)
|
||||||
/**
|
* @version CVS: $Id: Weekdays.php 300729 2010-06-24 12:05:53Z quipo $
|
||||||
* Load Calendar base class
|
* @link http://pear.php.net/package/Calendar
|
||||||
*/
|
*/
|
||||||
require_once CALENDAR_ROOT.'Calendar.php';
|
|
||||||
|
/**
|
||||||
/**
|
* Allows Calendar include path to be redefined
|
||||||
* Load base month
|
* @ignore
|
||||||
*/
|
*/
|
||||||
require_once CALENDAR_ROOT.'Month.php';
|
if (!defined('CALENDAR_ROOT')) {
|
||||||
|
define('CALENDAR_ROOT', 'Calendar'.DIRECTORY_SEPARATOR);
|
||||||
/**
|
}
|
||||||
* Represents a Month and builds Days in tabular form<br>
|
|
||||||
* <code>
|
/**
|
||||||
* require_once 'Calendar/Month/Weekdays.php';
|
* Load Calendar base class
|
||||||
* $Month = & new Calendar_Month_Weekdays(2003, 10); // Oct 2003
|
*/
|
||||||
* $Month->build(); // Build Calendar_Day objects
|
require_once CALENDAR_ROOT.'Calendar.php';
|
||||||
* while ($Day = & $Month->fetch()) {
|
|
||||||
* if ($Day->isFirst()) {
|
/**
|
||||||
* echo '<tr>';
|
* Load base month
|
||||||
* }
|
*/
|
||||||
* if ($Day->isEmpty()) {
|
require_once CALENDAR_ROOT.'Month.php';
|
||||||
* echo '<td> </td>';
|
|
||||||
* } else {
|
/**
|
||||||
* echo '<td>'.$Day->thisDay().'</td>';
|
* Represents a Month and builds Days in tabular form<br>
|
||||||
* }
|
* <code>
|
||||||
* if ($Day->isLast()) {
|
* require_once 'Calendar/Month/Weekdays.php';
|
||||||
* echo '</tr>';
|
* $Month = new Calendar_Month_Weekdays(2003, 10); // Oct 2003
|
||||||
* }
|
* $Month->build(); // Build Calendar_Day objects
|
||||||
* }
|
* while ($Day = & $Month->fetch()) {
|
||||||
* </code>
|
* if ($Day->isFirst()) {
|
||||||
* @package Calendar
|
* echo '<tr>';
|
||||||
* @access public
|
* }
|
||||||
*/
|
* if ($Day->isEmpty()) {
|
||||||
class Calendar_Month_Weekdays extends Calendar_Month
|
* echo '<td> </td>';
|
||||||
{
|
* } else {
|
||||||
/**
|
* echo '<td>'.$Day->thisDay().'</td>';
|
||||||
* Instance of Calendar_Table_Helper
|
* }
|
||||||
* @var Calendar_Table_Helper
|
* if ($Day->isLast()) {
|
||||||
* @access private
|
* echo '</tr>';
|
||||||
*/
|
* }
|
||||||
var $tableHelper;
|
* }
|
||||||
|
* </code>
|
||||||
/**
|
*
|
||||||
* First day of the week
|
* @category Date and Time
|
||||||
* @access private
|
* @package Calendar
|
||||||
* @var string
|
* @author Harry Fuecks <hfuecks@phppatterns.com>
|
||||||
*/
|
* @copyright 2003-2007 Harry Fuecks
|
||||||
var $firstDay;
|
* @license http://www.debian.org/misc/bsd.license BSD License (3 Clause)
|
||||||
|
* @link http://pear.php.net/package/Calendar
|
||||||
/**
|
* @access public
|
||||||
* Constructs Calendar_Month_Weekdays
|
*/
|
||||||
* @param int year e.g. 2003
|
class Calendar_Month_Weekdays extends Calendar_Month
|
||||||
* @param int month e.g. 5
|
{
|
||||||
* @param int (optional) first day of week (e.g. 0 for Sunday, 2 for Tuesday etc.)
|
/**
|
||||||
* @access public
|
* Instance of Calendar_Table_Helper
|
||||||
*/
|
* @var Calendar_Table_Helper
|
||||||
function Calendar_Month_Weekdays($y, $m, $firstDay=null)
|
* @access private
|
||||||
{
|
*/
|
||||||
Calendar_Month::Calendar_Month($y, $m, $firstDay);
|
var $tableHelper;
|
||||||
}
|
|
||||||
|
/**
|
||||||
/**
|
* First day of the week
|
||||||
* Builds Day objects in tabular form, to allow display of calendar month
|
* @access private
|
||||||
* with empty cells if the first day of the week does not fall on the first
|
* @var string
|
||||||
* day of the month.
|
*/
|
||||||
* @see Calendar_Day::isEmpty()
|
var $firstDay;
|
||||||
* @see Calendar_Day_Base::isFirst()
|
|
||||||
* @see Calendar_Day_Base::isLast()
|
/**
|
||||||
* @param array (optional) Calendar_Day objects representing selected dates
|
* Constructs Calendar_Month_Weekdays
|
||||||
* @return boolean
|
*
|
||||||
* @access public
|
* @param int $y year e.g. 2003
|
||||||
*/
|
* @param int $m month e.g. 5
|
||||||
function build($sDates=array())
|
* @param int $firstDay (optional) first day of week (e.g. 0 for Sunday, 2 for Tuesday etc.)
|
||||||
{
|
*
|
||||||
require_once CALENDAR_ROOT.'Table/Helper.php';
|
* @access public
|
||||||
$this->tableHelper = & new Calendar_Table_Helper($this, $this->firstDay);
|
*/
|
||||||
Calendar_Month::build($sDates);
|
function Calendar_Month_Weekdays($y, $m, $firstDay=null)
|
||||||
$this->buildEmptyDaysBefore();
|
{
|
||||||
$this->shiftDays();
|
parent::Calendar_Month($y, $m, $firstDay);
|
||||||
$this->buildEmptyDaysAfter();
|
}
|
||||||
$this->setWeekMarkers();
|
|
||||||
return true;
|
/**
|
||||||
}
|
* Builds Day objects in tabular form, to allow display of calendar month
|
||||||
|
* with empty cells if the first day of the week does not fall on the first
|
||||||
/**
|
* day of the month.
|
||||||
* Prepends empty days before the real days in the month
|
*
|
||||||
* @return void
|
* @param array $sDates (optional) Calendar_Day objects representing selected dates
|
||||||
* @access private
|
*
|
||||||
*/
|
* @return boolean
|
||||||
function buildEmptyDaysBefore()
|
* @access public
|
||||||
{
|
* @see Calendar_Day::isEmpty()
|
||||||
$eBefore = $this->tableHelper->getEmptyDaysBefore();
|
* @see Calendar_Day_Base::isFirst()
|
||||||
for ($i=0; $i < $eBefore; $i++) {
|
* @see Calendar_Day_Base::isLast()
|
||||||
$stamp = $this->cE->dateToStamp($this->year, $this->month, -$i);
|
*/
|
||||||
$Day = new Calendar_Day(
|
function build($sDates = array())
|
||||||
$this->cE->stampToYear($stamp),
|
{
|
||||||
$this->cE->stampToMonth($stamp),
|
include_once CALENDAR_ROOT.'Table/Helper.php';
|
||||||
$this->cE->stampToDay($stamp));
|
$this->tableHelper = new Calendar_Table_Helper($this, $this->firstDay);
|
||||||
$Day->setEmpty();
|
Calendar_Month::build($sDates);
|
||||||
$Day->adjust();
|
$this->buildEmptyDaysBefore();
|
||||||
array_unshift($this->children, $Day);
|
$this->shiftDays();
|
||||||
}
|
$this->buildEmptyDaysAfter();
|
||||||
}
|
$this->setWeekMarkers();
|
||||||
|
return true;
|
||||||
/**
|
}
|
||||||
* Shifts the array of children forward, if necessary
|
|
||||||
* @return void
|
/**
|
||||||
* @access private
|
* Prepends empty days before the real days in the month
|
||||||
*/
|
*
|
||||||
function shiftDays()
|
* @return void
|
||||||
{
|
* @access private
|
||||||
if (isset ($this->children[0])) {
|
*/
|
||||||
array_unshift($this->children, null);
|
function buildEmptyDaysBefore()
|
||||||
unset($this->children[0]);
|
{
|
||||||
}
|
$eBefore = $this->tableHelper->getEmptyDaysBefore();
|
||||||
}
|
for ($i=0; $i < $eBefore; $i++) {
|
||||||
|
$stamp = $this->cE->dateToStamp($this->year, $this->month, -$i);
|
||||||
/**
|
$Day = new Calendar_Day(
|
||||||
* Appends empty days after the real days in the month
|
$this->cE->stampToYear($stamp),
|
||||||
* @return void
|
$this->cE->stampToMonth($stamp),
|
||||||
* @access private
|
$this->cE->stampToDay($stamp));
|
||||||
*/
|
$Day->setEmpty();
|
||||||
function buildEmptyDaysAfter()
|
$Day->adjust();
|
||||||
{
|
array_unshift($this->children, $Day);
|
||||||
$eAfter = $this->tableHelper->getEmptyDaysAfter();
|
}
|
||||||
$sDOM = $this->tableHelper->getNumTableDaysInMonth();
|
}
|
||||||
for ($i = 1; $i <= $sDOM-$eAfter; $i++) {
|
|
||||||
$Day = new Calendar_Day($this->year, $this->month+1, $i);
|
/**
|
||||||
$Day->setEmpty();
|
* Shifts the array of children forward, if necessary
|
||||||
$Day->adjust();
|
*
|
||||||
array_push($this->children, $Day);
|
* @return void
|
||||||
}
|
* @access private
|
||||||
}
|
*/
|
||||||
|
function shiftDays()
|
||||||
/**
|
{
|
||||||
* Sets the "markers" for the beginning and of a of week, in the
|
if (isset($this->children[0])) {
|
||||||
* built Calendar_Day children
|
array_unshift($this->children, null);
|
||||||
* @return void
|
unset($this->children[0]);
|
||||||
* @access private
|
}
|
||||||
*/
|
}
|
||||||
function setWeekMarkers()
|
|
||||||
{
|
/**
|
||||||
$dIW = $this->cE->getDaysInWeek(
|
* Appends empty days after the real days in the month
|
||||||
$this->thisYear(),
|
*
|
||||||
$this->thisMonth(),
|
* @return void
|
||||||
$this->thisDay()
|
* @access private
|
||||||
);
|
*/
|
||||||
$sDOM = $this->tableHelper->getNumTableDaysInMonth();
|
function buildEmptyDaysAfter()
|
||||||
for ($i=1; $i <= $sDOM; $i+= $dIW) {
|
{
|
||||||
$this->children[$i]->setFirst();
|
$eAfter = $this->tableHelper->getEmptyDaysAfter();
|
||||||
$this->children[$i+($dIW-1)]->setLast();
|
$sDOM = $this->tableHelper->getNumTableDaysInMonth();
|
||||||
}
|
for ($i=1; $i <= $sDOM-$eAfter; $i++) {
|
||||||
}
|
$Day = new Calendar_Day($this->year, $this->month+1, $i);
|
||||||
}
|
$Day->setEmpty();
|
||||||
|
$Day->adjust();
|
||||||
|
array_push($this->children, $Day);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the "markers" for the beginning and of a of week, in the
|
||||||
|
* built Calendar_Day children
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
function setWeekMarkers()
|
||||||
|
{
|
||||||
|
$dIW = $this->cE->getDaysInWeek(
|
||||||
|
$this->thisYear(),
|
||||||
|
$this->thisMonth(),
|
||||||
|
$this->thisDay()
|
||||||
|
);
|
||||||
|
$sDOM = $this->tableHelper->getNumTableDaysInMonth();
|
||||||
|
for ($i=1; $i <= $sDOM; $i+= $dIW) {
|
||||||
|
$this->children[$i]->setFirst();
|
||||||
|
$this->children[$i+($dIW-1)]->setLast();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
@@ -1,139 +1,166 @@
|
|||||||
<?php
|
<?php
|
||||||
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
||||||
//
|
|
||||||
// +----------------------------------------------------------------------+
|
/**
|
||||||
// | PHP Version 4 |
|
* Contains the Calendar_Month_Weeks class
|
||||||
// +----------------------------------------------------------------------+
|
*
|
||||||
// | Copyright (c) 1997-2002 The PHP Group |
|
* PHP versions 4 and 5
|
||||||
// +----------------------------------------------------------------------+
|
*
|
||||||
// | This source file is subject to version 2.02 of the PHP license, |
|
* LICENSE: Redistribution and use in source and binary forms, with or without
|
||||||
// | that is bundled with this package in the file LICENSE, and is |
|
* modification, are permitted provided that the following conditions are met:
|
||||||
// | available at through the world-wide-web at |
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
// | http://www.php.net/license/3_0.txt. |
|
* notice, this list of conditions and the following disclaimer.
|
||||||
// | If you did not receive a copy of the PHP license and are unable to |
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
// | obtain it through the world-wide-web, please send a note to |
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
// | license@php.net so we can mail you a copy immediately. |
|
* documentation and/or other materials provided with the distribution.
|
||||||
// +----------------------------------------------------------------------+
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
// | Authors: Harry Fuecks <hfuecks@phppatterns.com> |
|
* derived from this software without specific prior written permission.
|
||||||
// | Lorenzo Alberton <l dot alberton at quipo dot it> |
|
*
|
||||||
// +----------------------------------------------------------------------+
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||||
//
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
// $Id: Weeks.php,v 1.3 2005/10/22 10:28:49 quipo Exp $
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
//
|
* IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
/**
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* @package Calendar
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
* @version $Id: Weeks.php,v 1.3 2005/10/22 10:28:49 quipo Exp $
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
*/
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
/**
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
* Allows Calendar include path to be redefined
|
*
|
||||||
* @ignore
|
* @category Date and Time
|
||||||
*/
|
* @package Calendar
|
||||||
if (!defined('CALENDAR_ROOT')) {
|
* @author Harry Fuecks <hfuecks@phppatterns.com>
|
||||||
define('CALENDAR_ROOT', 'Calendar'.DIRECTORY_SEPARATOR);
|
* @author Lorenzo Alberton <l.alberton@quipo.it>
|
||||||
}
|
* @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton
|
||||||
|
* @license http://www.debian.org/misc/bsd.license BSD License (3 Clause)
|
||||||
/**
|
* @version CVS: $Id: Weeks.php 300729 2010-06-24 12:05:53Z quipo $
|
||||||
* Load Calendar base class
|
* @link http://pear.php.net/package/Calendar
|
||||||
*/
|
*/
|
||||||
require_once CALENDAR_ROOT.'Calendar.php';
|
|
||||||
|
/**
|
||||||
/**
|
* Allows Calendar include path to be redefined
|
||||||
* Load base month
|
* @ignore
|
||||||
*/
|
*/
|
||||||
require_once CALENDAR_ROOT.'Month.php';
|
if (!defined('CALENDAR_ROOT')) {
|
||||||
|
define('CALENDAR_ROOT', 'Calendar'.DIRECTORY_SEPARATOR);
|
||||||
/**
|
}
|
||||||
* Represents a Month and builds Weeks
|
|
||||||
* <code>
|
/**
|
||||||
* require_once 'Calendar'.DIRECTORY_SEPARATOR.'Month'.DIRECTORY_SEPARATOR.'Weeks.php';
|
* Load Calendar base class
|
||||||
* $Month = & new Calendar_Month_Weeks(2003, 10); // Oct 2003
|
*/
|
||||||
* $Month->build(); // Build Calendar_Day objects
|
require_once CALENDAR_ROOT.'Calendar.php';
|
||||||
* while ($Week = & $Month->fetch()) {
|
|
||||||
* echo $Week->thisWeek().'<br />';
|
/**
|
||||||
* }
|
* Load base month
|
||||||
* </code>
|
*/
|
||||||
* @package Calendar
|
require_once CALENDAR_ROOT.'Month.php';
|
||||||
* @access public
|
|
||||||
*/
|
/**
|
||||||
class Calendar_Month_Weeks extends Calendar_Month
|
* Represents a Month and builds Weeks
|
||||||
{
|
* <code>
|
||||||
/**
|
* require_once 'Calendar'.DIRECTORY_SEPARATOR.'Month'.DIRECTORY_SEPARATOR.'Weeks.php';
|
||||||
* Instance of Calendar_Table_Helper
|
* $Month = new Calendar_Month_Weeks(2003, 10); // Oct 2003
|
||||||
* @var Calendar_Table_Helper
|
* $Month->build(); // Build Calendar_Day objects
|
||||||
* @access private
|
* while ($Week = & $Month->fetch()) {
|
||||||
*/
|
* echo $Week->thisWeek().'<br />';
|
||||||
var $tableHelper;
|
* }
|
||||||
|
* </code>
|
||||||
/**
|
*
|
||||||
* First day of the week
|
* @category Date and Time
|
||||||
* @access private
|
* @package Calendar
|
||||||
* @var string
|
* @author Harry Fuecks <hfuecks@phppatterns.com>
|
||||||
*/
|
* @author Lorenzo Alberton <l.alberton@quipo.it>
|
||||||
var $firstDay;
|
* @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton
|
||||||
|
* @license http://www.debian.org/misc/bsd.license BSD License (3 Clause)
|
||||||
/**
|
* @link http://pear.php.net/package/Calendar
|
||||||
* Constructs Calendar_Month_Weeks
|
* @access public
|
||||||
* @param int year e.g. 2003
|
*/
|
||||||
* @param int month e.g. 5
|
class Calendar_Month_Weeks extends Calendar_Month
|
||||||
* @param int (optional) first day of week (e.g. 0 for Sunday, 2 for Tuesday etc.)
|
{
|
||||||
* @access public
|
/**
|
||||||
*/
|
* Instance of Calendar_Table_Helper
|
||||||
function Calendar_Month_Weeks($y, $m, $firstDay=null)
|
* @var Calendar_Table_Helper
|
||||||
{
|
* @access private
|
||||||
Calendar_Month::Calendar_Month($y, $m, $firstDay);
|
*/
|
||||||
}
|
var $tableHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Builds Calendar_Week objects for the Month. Note that Calendar_Week
|
* First day of the week
|
||||||
* builds Calendar_Day object in tabular form (with Calendar_Day->empty)
|
* @access private
|
||||||
* @param array (optional) Calendar_Week objects representing selected dates
|
* @var string
|
||||||
* @return boolean
|
*/
|
||||||
* @access public
|
var $firstDay;
|
||||||
*/
|
|
||||||
function build($sDates=array())
|
/**
|
||||||
{
|
* Constructs Calendar_Month_Weeks
|
||||||
require_once CALENDAR_ROOT.'Table/Helper.php';
|
*
|
||||||
$this->tableHelper = & new Calendar_Table_Helper($this, $this->firstDay);
|
* @param int $y year e.g. 2003
|
||||||
require_once CALENDAR_ROOT.'Week.php';
|
* @param int $m month e.g. 5
|
||||||
$numWeeks = $this->tableHelper->getNumWeeks();
|
* @param int $firstDay (optional) first day of week (e.g. 0 for Sunday, 2 for Tuesday etc.)
|
||||||
for ($i=1, $d=1; $i<=$numWeeks; $i++,
|
*
|
||||||
$d+=$this->cE->getDaysInWeek(
|
* @access public
|
||||||
$this->thisYear(),
|
*/
|
||||||
$this->thisMonth(),
|
function Calendar_Month_Weeks($y, $m, $firstDay=null)
|
||||||
$this->thisDay()) ) {
|
{
|
||||||
$this->children[$i] = new Calendar_Week(
|
parent::Calendar_Month($y, $m, $firstDay);
|
||||||
$this->year, $this->month, $d, $this->tableHelper->getFirstDay());
|
}
|
||||||
}
|
|
||||||
//used to set empty days
|
/**
|
||||||
$this->children[1]->setFirst(true);
|
* Builds Calendar_Week objects for the Month. Note that Calendar_Week
|
||||||
$this->children[$numWeeks]->setLast(true);
|
* builds Calendar_Day object in tabular form (with Calendar_Day->empty)
|
||||||
|
*
|
||||||
// Handle selected weeks here
|
* @param array $sDates (optional) Calendar_Week objects representing selected dates
|
||||||
if (count($sDates) > 0) {
|
*
|
||||||
$this->setSelection($sDates);
|
* @return boolean
|
||||||
}
|
* @access public
|
||||||
return true;
|
*/
|
||||||
}
|
function build($sDates = array())
|
||||||
|
{
|
||||||
/**
|
include_once CALENDAR_ROOT.'Table/Helper.php';
|
||||||
* Called from build()
|
$this->tableHelper = new Calendar_Table_Helper($this, $this->firstDay);
|
||||||
* @param array
|
include_once CALENDAR_ROOT.'Week.php';
|
||||||
* @return void
|
$numWeeks = $this->tableHelper->getNumWeeks();
|
||||||
* @access private
|
for ($i=1, $d=1; $i<=$numWeeks; $i++,
|
||||||
*/
|
$d+=$this->cE->getDaysInWeek(
|
||||||
function setSelection($sDates)
|
$this->thisYear(),
|
||||||
{
|
$this->thisMonth(),
|
||||||
foreach ($sDates as $sDate) {
|
$this->thisDay()
|
||||||
if ($this->year == $sDate->thisYear()
|
)
|
||||||
&& $this->month == $sDate->thisMonth())
|
) {
|
||||||
{
|
$this->children[$i] = new Calendar_Week(
|
||||||
$key = $sDate->thisWeek('n_in_month');
|
$this->year, $this->month, $d, $this->tableHelper->getFirstDay());
|
||||||
if (isset($this->children[$key])) {
|
}
|
||||||
$this->children[$key]->setSelected();
|
//used to set empty days
|
||||||
}
|
$this->children[1]->setFirst(true);
|
||||||
}
|
$this->children[$numWeeks]->setLast(true);
|
||||||
}
|
|
||||||
}
|
// Handle selected weeks here
|
||||||
}
|
if (count($sDates) > 0) {
|
||||||
|
$this->setSelection($sDates);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called from build()
|
||||||
|
*
|
||||||
|
* @param array $sDates Calendar_Week objects representing selected dates
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
function setSelection($sDates)
|
||||||
|
{
|
||||||
|
foreach ($sDates as $sDate) {
|
||||||
|
if ($this->year == $sDate->thisYear()
|
||||||
|
&& $this->month == $sDate->thisMonth())
|
||||||
|
{
|
||||||
|
$key = $sDate->thisWeek('n_in_month');
|
||||||
|
if (isset($this->children[$key])) {
|
||||||
|
$this->children[$key]->setSelected();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
@@ -1,98 +1,122 @@
|
|||||||
<?php
|
<?php
|
||||||
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
||||||
//
|
|
||||||
// +----------------------------------------------------------------------+
|
/**
|
||||||
// | PHP Version 4 |
|
* Contains the Calendar_Second class
|
||||||
// +----------------------------------------------------------------------+
|
*
|
||||||
// | Copyright (c) 1997-2002 The PHP Group |
|
* PHP versions 4 and 5
|
||||||
// +----------------------------------------------------------------------+
|
*
|
||||||
// | This source file is subject to version 2.02 of the PHP license, |
|
* LICENSE: Redistribution and use in source and binary forms, with or without
|
||||||
// | that is bundled with this package in the file LICENSE, and is |
|
* modification, are permitted provided that the following conditions are met:
|
||||||
// | available at through the world-wide-web at |
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
// | http://www.php.net/license/3_0.txt. |
|
* notice, this list of conditions and the following disclaimer.
|
||||||
// | If you did not receive a copy of the PHP license and are unable to |
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
// | obtain it through the world-wide-web, please send a note to |
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
// | license@php.net so we can mail you a copy immediately. |
|
* documentation and/or other materials provided with the distribution.
|
||||||
// +----------------------------------------------------------------------+
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
// | Authors: Harry Fuecks <hfuecks@phppatterns.com> |
|
* derived from this software without specific prior written permission.
|
||||||
// +----------------------------------------------------------------------+
|
*
|
||||||
//
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||||
// $Id: Second.php,v 1.1 2004/05/24 22:25:42 quipo Exp $
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
//
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
/**
|
* IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
* @package Calendar
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* @version $Id: Second.php,v 1.1 2004/05/24 22:25:42 quipo Exp $
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
*/
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
/**
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
* Allows Calendar include path to be redefined
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
* @ignore
|
*
|
||||||
*/
|
* @category Date and Time
|
||||||
if (!defined('CALENDAR_ROOT')) {
|
* @package Calendar
|
||||||
define('CALENDAR_ROOT', 'Calendar'.DIRECTORY_SEPARATOR);
|
* @author Harry Fuecks <hfuecks@phppatterns.com>
|
||||||
}
|
* @copyright 2003-2007 Harry Fuecks
|
||||||
|
* @license http://www.debian.org/misc/bsd.license BSD License (3 Clause)
|
||||||
/**
|
* @version CVS: $Id: Second.php 300728 2010-06-24 11:43:56Z quipo $
|
||||||
* Load Calendar base class
|
* @link http://pear.php.net/package/Calendar
|
||||||
*/
|
*/
|
||||||
require_once CALENDAR_ROOT.'Calendar.php';
|
|
||||||
|
/**
|
||||||
/**
|
* Allows Calendar include path to be redefined
|
||||||
* Represents a Second<br />
|
* @ignore
|
||||||
* <b>Note:</b> Seconds do not build other objects
|
*/
|
||||||
* so related methods are overridden to return NULL
|
if (!defined('CALENDAR_ROOT')) {
|
||||||
* @package Calendar
|
define('CALENDAR_ROOT', 'Calendar'.DIRECTORY_SEPARATOR);
|
||||||
*/
|
}
|
||||||
class Calendar_Second extends Calendar
|
|
||||||
{
|
/**
|
||||||
/**
|
* Load Calendar base class
|
||||||
* Constructs Second
|
*/
|
||||||
* @param int year e.g. 2003
|
require_once CALENDAR_ROOT.'Calendar.php';
|
||||||
* @param int month e.g. 5
|
|
||||||
* @param int day e.g. 11
|
/**
|
||||||
* @param int hour e.g. 13
|
* Represents a Second<br />
|
||||||
* @param int minute e.g. 31
|
* <b>Note:</b> Seconds do not build other objects
|
||||||
* @param int second e.g. 45
|
* so related methods are overridden to return NULL
|
||||||
*/
|
*
|
||||||
function Calendar_Second($y, $m, $d, $h, $i, $s)
|
* @category Date and Time
|
||||||
{
|
* @package Calendar
|
||||||
Calendar::Calendar($y, $m, $d, $h, $i, $s);
|
* @author Harry Fuecks <hfuecks@phppatterns.com>
|
||||||
}
|
* @copyright 2003-2007 Harry Fuecks
|
||||||
|
* @license http://www.debian.org/misc/bsd.license BSD License (3 Clause)
|
||||||
/**
|
* @link http://pear.php.net/package/Calendar
|
||||||
* Overwrite build
|
* @access public
|
||||||
* @return NULL
|
*/
|
||||||
*/
|
class Calendar_Second extends Calendar
|
||||||
function build()
|
{
|
||||||
{
|
/**
|
||||||
return null;
|
* Constructs Second
|
||||||
}
|
*
|
||||||
|
* @param int $y year e.g. 2003
|
||||||
/**
|
* @param int $m month e.g. 5
|
||||||
* Overwrite fetch
|
* @param int $d day e.g. 11
|
||||||
* @return NULL
|
* @param int $h hour e.g. 13
|
||||||
*/
|
* @param int $i minute e.g. 31
|
||||||
function fetch()
|
* @param int $s second e.g. 45
|
||||||
{
|
*/
|
||||||
return null;
|
function Calendar_Second($y, $m, $d, $h, $i, $s)
|
||||||
}
|
{
|
||||||
|
parent::Calendar($y, $m, $d, $h, $i, $s);
|
||||||
/**
|
}
|
||||||
* Overwrite fetchAll
|
|
||||||
* @return NULL
|
/**
|
||||||
*/
|
* Overwrite build
|
||||||
function fetchAll()
|
*
|
||||||
{
|
* @return NULL
|
||||||
return null;
|
*/
|
||||||
}
|
function build()
|
||||||
|
{
|
||||||
/**
|
return null;
|
||||||
* Overwrite size
|
}
|
||||||
* @return NULL
|
|
||||||
*/
|
/**
|
||||||
function size()
|
* Overwrite fetch
|
||||||
{
|
*
|
||||||
return null;
|
* @return NULL
|
||||||
}
|
*/
|
||||||
}
|
function fetch()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Overwrite fetchAll
|
||||||
|
*
|
||||||
|
* @return NULL
|
||||||
|
*/
|
||||||
|
function fetchAll()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Overwrite size
|
||||||
|
*
|
||||||
|
* @return NULL
|
||||||
|
*/
|
||||||
|
function size()
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
@@ -1,280 +1,316 @@
|
|||||||
<?php
|
<?php
|
||||||
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
||||||
//
|
|
||||||
// +----------------------------------------------------------------------+
|
/**
|
||||||
// | PHP Version 4 |
|
* Contains the Calendar_Decorator_Wrapper class
|
||||||
// +----------------------------------------------------------------------+
|
*
|
||||||
// | Copyright (c) 1997-2002 The PHP Group |
|
* PHP versions 4 and 5
|
||||||
// +----------------------------------------------------------------------+
|
*
|
||||||
// | This source file is subject to version 2.02 of the PHP license, |
|
* LICENSE: Redistribution and use in source and binary forms, with or without
|
||||||
// | that is bundled with this package in the file LICENSE, and is |
|
* modification, are permitted provided that the following conditions are met:
|
||||||
// | available at through the world-wide-web at |
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
// | http://www.php.net/license/3_0.txt. |
|
* notice, this list of conditions and the following disclaimer.
|
||||||
// | If you did not receive a copy of the PHP license and are unable to |
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
// | obtain it through the world-wide-web, please send a note to |
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
// | license@php.net so we can mail you a copy immediately. |
|
* documentation and/or other materials provided with the distribution.
|
||||||
// +----------------------------------------------------------------------+
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
// | Authors: Harry Fuecks <hfuecks@phppatterns.com> |
|
* derived from this software without specific prior written permission.
|
||||||
// +----------------------------------------------------------------------+
|
*
|
||||||
//
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||||
// $Id: Helper.php,v 1.5 2005/10/22 09:51:53 quipo Exp $
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
//
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
/**
|
* IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
* @package Calendar
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* @version $Id: Helper.php,v 1.5 2005/10/22 09:51:53 quipo Exp $
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
*/
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
/**
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
* Used by Calendar_Month_Weekdays, Calendar_Month_Weeks and Calendar_Week to
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
* help with building the calendar in tabular form
|
*
|
||||||
* @package Calendar
|
* @category Date and Time
|
||||||
* @access protected
|
* @package Calendar
|
||||||
*/
|
* @author Harry Fuecks <hfuecks@phppatterns.com>
|
||||||
class Calendar_Table_Helper
|
* @copyright 2003-2007 Harry Fuecks
|
||||||
{
|
* @license http://www.debian.org/misc/bsd.license BSD License (3 Clause)
|
||||||
/**
|
* @version CVS: $Id: Helper.php 246317 2007-11-16 20:05:32Z quipo $
|
||||||
* Instance of the Calendar object being helped.
|
* @link http://pear.php.net/package/Calendar
|
||||||
* @var object
|
*/
|
||||||
* @access private
|
|
||||||
*/
|
/**
|
||||||
var $calendar;
|
* Used by Calendar_Month_Weekdays, Calendar_Month_Weeks and Calendar_Week to
|
||||||
|
* help with building the calendar in tabular form
|
||||||
/**
|
*
|
||||||
* Instance of the Calendar_Engine
|
* @category Date and Time
|
||||||
* @var object
|
* @package Calendar
|
||||||
* @access private
|
* @author Harry Fuecks <hfuecks@phppatterns.com>
|
||||||
*/
|
* @copyright 2003-2007 Harry Fuecks
|
||||||
var $cE;
|
* @license http://www.debian.org/misc/bsd.license BSD License (3 Clause)
|
||||||
|
* @link http://pear.php.net/package/Calendar
|
||||||
/**
|
* @access public
|
||||||
* First day of the week
|
*/
|
||||||
* @access private
|
class Calendar_Table_Helper
|
||||||
* @var string
|
{
|
||||||
*/
|
/**
|
||||||
var $firstDay;
|
* Instance of the Calendar object being helped.
|
||||||
|
* @var object
|
||||||
/**
|
* @access private
|
||||||
* The seven days of the week named
|
*/
|
||||||
* @access private
|
var $calendar;
|
||||||
* @var array
|
|
||||||
*/
|
/**
|
||||||
var $weekDays;
|
* Instance of the Calendar_Engine
|
||||||
|
* @var object
|
||||||
/**
|
* @access private
|
||||||
* Days of the week ordered with $firstDay at the beginning
|
*/
|
||||||
* @access private
|
var $cE;
|
||||||
* @var array
|
|
||||||
*/
|
/**
|
||||||
var $daysOfWeek = array();
|
* First day of the week
|
||||||
|
* @access private
|
||||||
/**
|
* @var string
|
||||||
* Days of the month built from days of the week
|
*/
|
||||||
* @access private
|
var $firstDay;
|
||||||
* @var array
|
|
||||||
*/
|
/**
|
||||||
var $daysOfMonth = array();
|
* The seven days of the week named
|
||||||
|
* @access private
|
||||||
/**
|
* @var array
|
||||||
* Number of weeks in month
|
*/
|
||||||
* @var int
|
var $weekDays;
|
||||||
* @access private
|
|
||||||
*/
|
/**
|
||||||
var $numWeeks = null;
|
* Days of the week ordered with $firstDay at the beginning
|
||||||
|
* @access private
|
||||||
/**
|
* @var array
|
||||||
* Number of emtpy days before real days begin in month
|
*/
|
||||||
* @var int
|
var $daysOfWeek = array();
|
||||||
* @access private
|
|
||||||
*/
|
/**
|
||||||
var $emptyBefore = 0;
|
* Days of the month built from days of the week
|
||||||
|
* @access private
|
||||||
/**
|
* @var array
|
||||||
* Constructs Calendar_Table_Helper
|
*/
|
||||||
* @param object Calendar_Month_Weekdays, Calendar_Month_Weeks, Calendar_Week
|
var $daysOfMonth = array();
|
||||||
* @param int (optional) first day of the week e.g. 1 for Monday
|
|
||||||
* @access protected
|
/**
|
||||||
*/
|
* Number of weeks in month
|
||||||
function Calendar_Table_Helper(& $calendar, $firstDay=null)
|
* @var int
|
||||||
{
|
* @access private
|
||||||
$this->calendar = & $calendar;
|
*/
|
||||||
$this->cE = & $calendar->getEngine();
|
var $numWeeks = null;
|
||||||
if (is_null($firstDay)) {
|
|
||||||
$firstDay = $this->cE->getFirstDayOfWeek(
|
/**
|
||||||
$this->calendar->thisYear(),
|
* Number of emtpy days before real days begin in month
|
||||||
$this->calendar->thisMonth(),
|
* @var int
|
||||||
$this->calendar->thisDay()
|
* @access private
|
||||||
);
|
*/
|
||||||
}
|
var $emptyBefore = 0;
|
||||||
$this->firstDay = $firstDay;
|
|
||||||
$this->setFirstDay();
|
/**
|
||||||
$this->setDaysOfMonth();
|
* Constructs Calendar_Table_Helper
|
||||||
}
|
*
|
||||||
|
* @param object &$calendar Calendar_Month_Weekdays, Calendar_Month_Weeks, Calendar_Week
|
||||||
/**
|
* @param int $firstDay (optional) first day of the week e.g. 1 for Monday
|
||||||
* Constructs $this->daysOfWeek based on $this->firstDay
|
*
|
||||||
* @return void
|
* @access protected
|
||||||
* @access private
|
*/
|
||||||
*/
|
function Calendar_Table_Helper(& $calendar, $firstDay=null)
|
||||||
function setFirstDay()
|
{
|
||||||
{
|
$this->calendar = & $calendar;
|
||||||
$weekDays = $this->cE->getWeekDays(
|
$this->cE = & $calendar->getEngine();
|
||||||
$this->calendar->thisYear(),
|
if (is_null($firstDay)) {
|
||||||
$this->calendar->thisMonth(),
|
$firstDay = $this->cE->getFirstDayOfWeek(
|
||||||
$this->calendar->thisDay()
|
$this->calendar->thisYear(),
|
||||||
);
|
$this->calendar->thisMonth(),
|
||||||
$endDays = array();
|
$this->calendar->thisDay()
|
||||||
$tmpDays = array();
|
);
|
||||||
$begin = false;
|
}
|
||||||
foreach ($weekDays as $day) {
|
$this->firstDay = $firstDay;
|
||||||
if ($begin) {
|
$this->setFirstDay();
|
||||||
$endDays[] = $day;
|
$this->setDaysOfMonth();
|
||||||
} else if ($day === $this->firstDay) {
|
}
|
||||||
$begin = true;
|
|
||||||
$endDays[] = $day;
|
/**
|
||||||
} else {
|
* Constructs $this->daysOfWeek based on $this->firstDay
|
||||||
$tmpDays[] = $day;
|
*
|
||||||
}
|
* @return void
|
||||||
}
|
* @access private
|
||||||
$this->daysOfWeek = array_merge($endDays, $tmpDays);
|
*/
|
||||||
}
|
function setFirstDay()
|
||||||
|
{
|
||||||
/**
|
$weekDays = $this->cE->getWeekDays(
|
||||||
* Constructs $this->daysOfMonth
|
$this->calendar->thisYear(),
|
||||||
* @return void
|
$this->calendar->thisMonth(),
|
||||||
* @access private
|
$this->calendar->thisDay()
|
||||||
*/
|
);
|
||||||
function setDaysOfMonth()
|
$endDays = array();
|
||||||
{
|
$tmpDays = array();
|
||||||
$this->daysOfMonth = $this->daysOfWeek;
|
$begin = false;
|
||||||
$daysInMonth = $this->cE->getDaysInMonth(
|
foreach ($weekDays as $day) {
|
||||||
$this->calendar->thisYear(), $this->calendar->thisMonth());
|
if ($begin) {
|
||||||
$firstDayInMonth = $this->cE->getFirstDayInMonth(
|
$endDays[] = $day;
|
||||||
$this->calendar->thisYear(), $this->calendar->thisMonth());
|
} else if ($day === $this->firstDay) {
|
||||||
$this->emptyBefore=0;
|
$begin = true;
|
||||||
foreach ($this->daysOfMonth as $dayOfWeek) {
|
$endDays[] = $day;
|
||||||
if ($firstDayInMonth == $dayOfWeek) {
|
} else {
|
||||||
break;
|
$tmpDays[] = $day;
|
||||||
}
|
}
|
||||||
$this->emptyBefore++;
|
}
|
||||||
}
|
$this->daysOfWeek = array_merge($endDays, $tmpDays);
|
||||||
$this->numWeeks = ceil(
|
}
|
||||||
($daysInMonth + $this->emptyBefore)
|
|
||||||
/
|
/**
|
||||||
$this->cE->getDaysInWeek(
|
* Constructs $this->daysOfMonth
|
||||||
$this->calendar->thisYear(),
|
*
|
||||||
$this->calendar->thisMonth(),
|
* @return void
|
||||||
$this->calendar->thisDay()
|
* @access private
|
||||||
)
|
*/
|
||||||
);
|
function setDaysOfMonth()
|
||||||
for ($i=1; $i < $this->numWeeks; $i++) {
|
{
|
||||||
$this->daysOfMonth =
|
$this->daysOfMonth = $this->daysOfWeek;
|
||||||
array_merge($this->daysOfMonth, $this->daysOfWeek);
|
$daysInMonth = $this->cE->getDaysInMonth(
|
||||||
}
|
$this->calendar->thisYear(), $this->calendar->thisMonth());
|
||||||
}
|
$firstDayInMonth = $this->cE->getFirstDayInMonth(
|
||||||
|
$this->calendar->thisYear(), $this->calendar->thisMonth());
|
||||||
/**
|
$this->emptyBefore=0;
|
||||||
* Returns the first day of the month
|
foreach ($this->daysOfMonth as $dayOfWeek) {
|
||||||
* @see Calendar_Engine_Interface::getFirstDayOfWeek()
|
if ($firstDayInMonth == $dayOfWeek) {
|
||||||
* @return int
|
break;
|
||||||
* @access protected
|
}
|
||||||
*/
|
$this->emptyBefore++;
|
||||||
function getFirstDay()
|
}
|
||||||
{
|
$this->numWeeks = ceil(
|
||||||
return $this->firstDay;
|
($daysInMonth + $this->emptyBefore)
|
||||||
}
|
/
|
||||||
|
$this->cE->getDaysInWeek(
|
||||||
/**
|
$this->calendar->thisYear(),
|
||||||
* Returns the order array of days in a week
|
$this->calendar->thisMonth(),
|
||||||
* @return int
|
$this->calendar->thisDay()
|
||||||
* @access protected
|
)
|
||||||
*/
|
);
|
||||||
function getDaysOfWeek()
|
for ($i=1; $i < $this->numWeeks; $i++) {
|
||||||
{
|
$this->daysOfMonth =
|
||||||
return $this->daysOfWeek;
|
array_merge($this->daysOfMonth, $this->daysOfWeek);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Returns the number of tabular weeks in a month
|
/**
|
||||||
* @return int
|
* Returns the first day of the month
|
||||||
* @access protected
|
*
|
||||||
*/
|
* @return int
|
||||||
function getNumWeeks()
|
* @access protected
|
||||||
{
|
* @see Calendar_Engine_Interface::getFirstDayOfWeek()
|
||||||
return $this->numWeeks;
|
*/
|
||||||
}
|
function getFirstDay()
|
||||||
|
{
|
||||||
/**
|
return $this->firstDay;
|
||||||
* Returns the number of real days + empty days
|
}
|
||||||
* @return int
|
|
||||||
* @access protected
|
/**
|
||||||
*/
|
* Returns the order array of days in a week
|
||||||
function getNumTableDaysInMonth()
|
*
|
||||||
{
|
* @return int
|
||||||
return count($this->daysOfMonth);
|
* @access protected
|
||||||
}
|
*/
|
||||||
|
function getDaysOfWeek()
|
||||||
/**
|
{
|
||||||
* Returns the number of empty days before the real days begin
|
return $this->daysOfWeek;
|
||||||
* @return int
|
}
|
||||||
* @access protected
|
|
||||||
*/
|
/**
|
||||||
function getEmptyDaysBefore()
|
* Returns the number of tabular weeks in a month
|
||||||
{
|
*
|
||||||
return $this->emptyBefore;
|
* @return int
|
||||||
}
|
* @access protected
|
||||||
|
*/
|
||||||
/**
|
function getNumWeeks()
|
||||||
* Returns the index of the last real day in the month
|
{
|
||||||
* @todo Potential performance optimization with static
|
return $this->numWeeks;
|
||||||
* @return int
|
}
|
||||||
* @access protected
|
|
||||||
*/
|
/**
|
||||||
function getEmptyDaysAfter()
|
* Returns the number of real days + empty days
|
||||||
{
|
*
|
||||||
// Causes bug when displaying more than one month
|
* @return int
|
||||||
// static $index;
|
* @access protected
|
||||||
// if (!isset($index)) {
|
*/
|
||||||
$index = $this->getEmptyDaysBefore() + $this->cE->getDaysInMonth(
|
function getNumTableDaysInMonth()
|
||||||
$this->calendar->thisYear(), $this->calendar->thisMonth());
|
{
|
||||||
// }
|
return count($this->daysOfMonth);
|
||||||
return $index;
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
/**
|
* Returns the number of empty days before the real days begin
|
||||||
* Returns the index of the last real day in the month, relative to the
|
*
|
||||||
* beginning of the tabular week it is part of
|
* @return int
|
||||||
* @return int
|
* @access protected
|
||||||
* @access protected
|
*/
|
||||||
*/
|
function getEmptyDaysBefore()
|
||||||
function getEmptyDaysAfterOffset()
|
{
|
||||||
{
|
return $this->emptyBefore;
|
||||||
$eAfter = $this->getEmptyDaysAfter();
|
}
|
||||||
return $eAfter - (
|
|
||||||
$this->cE->getDaysInWeek(
|
/**
|
||||||
$this->calendar->thisYear(),
|
* Returns the index of the last real day in the month
|
||||||
$this->calendar->thisMonth(),
|
*
|
||||||
$this->calendar->thisDay()
|
* @todo Potential performance optimization with static
|
||||||
) * ($this->numWeeks-1) );
|
* @return int
|
||||||
}
|
* @access protected
|
||||||
|
*/
|
||||||
/**
|
function getEmptyDaysAfter()
|
||||||
* Returns the timestamp of the first day of the current week
|
{
|
||||||
*/
|
// Causes bug when displaying more than one month
|
||||||
function getWeekStart($y, $m, $d, $firstDay=1)
|
//static $index;
|
||||||
{
|
//if (!isset($index)) {
|
||||||
$dow = $this->cE->getDayOfWeek($y, $m, $d);
|
$index = $this->getEmptyDaysBefore() + $this->cE->getDaysInMonth(
|
||||||
if ($dow > $firstDay) {
|
$this->calendar->thisYear(), $this->calendar->thisMonth());
|
||||||
$d -= ($dow - $firstDay);
|
//}
|
||||||
}
|
return $index;
|
||||||
if ($dow < $firstDay) {
|
}
|
||||||
$d -= (
|
|
||||||
$this->cE->getDaysInWeek(
|
/**
|
||||||
$this->calendar->thisYear(),
|
* Returns the index of the last real day in the month, relative to the
|
||||||
$this->calendar->thisMonth(),
|
* beginning of the tabular week it is part of
|
||||||
$this->calendar->thisDay()
|
*
|
||||||
) - $firstDay + $dow);
|
* @return int
|
||||||
}
|
* @access protected
|
||||||
return $this->cE->dateToStamp($y, $m, $d);
|
*/
|
||||||
}
|
function getEmptyDaysAfterOffset()
|
||||||
}
|
{
|
||||||
|
$eAfter = $this->getEmptyDaysAfter();
|
||||||
|
return $eAfter - (
|
||||||
|
$this->cE->getDaysInWeek(
|
||||||
|
$this->calendar->thisYear(),
|
||||||
|
$this->calendar->thisMonth(),
|
||||||
|
$this->calendar->thisDay()
|
||||||
|
) * ($this->numWeeks-1));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the timestamp of the first day of the current week
|
||||||
|
*
|
||||||
|
* @param int $y year
|
||||||
|
* @param int $m month
|
||||||
|
* @param int $d day
|
||||||
|
* @param int $firstDay first day of the week (default 1 = Monday)
|
||||||
|
*
|
||||||
|
* @return int timestamp
|
||||||
|
*/
|
||||||
|
function getWeekStart($y, $m, $d, $firstDay=1)
|
||||||
|
{
|
||||||
|
$dow = $this->cE->getDayOfWeek($y, $m, $d);
|
||||||
|
if ($dow > $firstDay) {
|
||||||
|
$d -= ($dow - $firstDay);
|
||||||
|
}
|
||||||
|
if ($dow < $firstDay) {
|
||||||
|
$d -= (
|
||||||
|
$this->cE->getDaysInWeek(
|
||||||
|
$this->calendar->thisYear(),
|
||||||
|
$this->calendar->thisMonth(),
|
||||||
|
$this->calendar->thisDay()
|
||||||
|
) - $firstDay + $dow);
|
||||||
|
}
|
||||||
|
return $this->cE->dateToStamp($y, $m, $d);
|
||||||
|
}
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
@@ -1,239 +1,304 @@
|
|||||||
<?php
|
<?php
|
||||||
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
||||||
//
|
|
||||||
// +----------------------------------------------------------------------+
|
/**
|
||||||
// | PHP Version 4 |
|
* Contains the Calendar_Util_Textual class
|
||||||
// +----------------------------------------------------------------------+
|
*
|
||||||
// | Copyright (c) 1997-2002 The PHP Group |
|
* PHP versions 4 and 5
|
||||||
// +----------------------------------------------------------------------+
|
*
|
||||||
// | This source file is subject to version 2.02 of the PHP license, |
|
* LICENSE: Redistribution and use in source and binary forms, with or without
|
||||||
// | that is bundled with this package in the file LICENSE, and is |
|
* modification, are permitted provided that the following conditions are met:
|
||||||
// | available at through the world-wide-web at |
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
// | http://www.php.net/license/3_0.txt. |
|
* notice, this list of conditions and the following disclaimer.
|
||||||
// | If you did not receive a copy of the PHP license and are unable to |
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
// | obtain it through the world-wide-web, please send a note to |
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
// | license@php.net so we can mail you a copy immediately. |
|
* documentation and/or other materials provided with the distribution.
|
||||||
// +----------------------------------------------------------------------+
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
// | Authors: Harry Fuecks <hfuecks@phppatterns.com> |
|
* derived from this software without specific prior written permission.
|
||||||
// | Lorenzo Alberton <l dot alberton at quipo dot it> |
|
*
|
||||||
// +----------------------------------------------------------------------+
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||||
//
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
// $Id: Textual.php,v 1.2 2004/08/16 13:13:09 hfuecks Exp $
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
//
|
* IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
/**
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* @package Calendar
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
* @version $Id: Textual.php,v 1.2 2004/08/16 13:13:09 hfuecks Exp $
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
*/
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
/**
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
* Allows Calendar include path to be redefined
|
*
|
||||||
* @ignore
|
* @category Date and Time
|
||||||
*/
|
* @package Calendar
|
||||||
if (!defined('CALENDAR_ROOT')) {
|
* @author Harry Fuecks <hfuecks@phppatterns.com>
|
||||||
define('CALENDAR_ROOT', 'Calendar'.DIRECTORY_SEPARATOR);
|
* @author Lorenzo Alberton <l.alberton@quipo.it>
|
||||||
}
|
* @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton
|
||||||
|
* @license http://www.debian.org/misc/bsd.license BSD License (3 Clause)
|
||||||
/**
|
* @version CVS: $Id: Textual.php 247250 2007-11-28 19:42:01Z quipo $
|
||||||
* Load Calendar decorator base class
|
* @link http://pear.php.net/package/Calendar
|
||||||
*/
|
*/
|
||||||
require_once CALENDAR_ROOT.'Decorator.php';
|
|
||||||
|
/**
|
||||||
/**
|
* @package Calendar
|
||||||
* Static utlities to help with fetching textual representations of months and
|
* @version $Id: Textual.php 247250 2007-11-28 19:42:01Z quipo $
|
||||||
* days of the week.
|
*/
|
||||||
* @package Calendar
|
|
||||||
* @access public
|
/**
|
||||||
*/
|
* Allows Calendar include path to be redefined
|
||||||
class Calendar_Util_Textual
|
* @ignore
|
||||||
{
|
*/
|
||||||
|
if (!defined('CALENDAR_ROOT')) {
|
||||||
/**
|
define('CALENDAR_ROOT', 'Calendar'.DIRECTORY_SEPARATOR);
|
||||||
* Returns an array of 12 month names (first index = 1)
|
}
|
||||||
* @param string (optional) format of returned months (one,two,short or long)
|
|
||||||
* @return array
|
/**
|
||||||
* @access public
|
* Load Calendar decorator base class
|
||||||
* @static
|
*/
|
||||||
*/
|
require_once CALENDAR_ROOT.'Decorator.php';
|
||||||
function monthNames($format='long')
|
|
||||||
{
|
/**
|
||||||
$formats = array('one'=>'%b', 'two'=>'%b', 'short'=>'%b', 'long'=>'%B');
|
* Static utlities to help with fetching textual representations of months and
|
||||||
if (!array_key_exists($format,$formats)) {
|
* days of the week.
|
||||||
$format = 'long';
|
*
|
||||||
}
|
* @category Date and Time
|
||||||
$months = array();
|
* @package Calendar
|
||||||
for ($i=1; $i<=12; $i++) {
|
* @author Harry Fuecks <hfuecks@phppatterns.com>
|
||||||
$stamp = mktime(0, 0, 0, $i, 1, 2003);
|
* @author Lorenzo Alberton <l.alberton@quipo.it>
|
||||||
$month = strftime($formats[$format], $stamp);
|
* @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton
|
||||||
switch($format) {
|
* @license http://www.debian.org/misc/bsd.license BSD License (3 Clause)
|
||||||
case 'one':
|
* @link http://pear.php.net/package/Calendar
|
||||||
$month = substr($month, 0, 1);
|
* @access public
|
||||||
break;
|
*/
|
||||||
case 'two':
|
class Calendar_Util_Textual
|
||||||
$month = substr($month, 0, 2);
|
{
|
||||||
break;
|
|
||||||
}
|
/**
|
||||||
$months[$i] = $month;
|
* Returns an array of 12 month names (first index = 1)
|
||||||
}
|
*
|
||||||
return $months;
|
* @param string $format (optional) format of returned months (one|two|short|long)
|
||||||
}
|
*
|
||||||
|
* @return array
|
||||||
/**
|
* @access public
|
||||||
* Returns an array of 7 week day names (first index = 0)
|
* @static
|
||||||
* @param string (optional) format of returned days (one,two,short or long)
|
*/
|
||||||
* @return array
|
function monthNames($format = 'long')
|
||||||
* @access public
|
{
|
||||||
* @static
|
$formats = array(
|
||||||
*/
|
'one' => '%b',
|
||||||
function weekdayNames($format='long')
|
'two' => '%b',
|
||||||
{
|
'short' => '%b',
|
||||||
$formats = array('one'=>'%a', 'two'=>'%a', 'short'=>'%a', 'long'=>'%A');
|
'long' => '%B',
|
||||||
if (!array_key_exists($format,$formats)) {
|
);
|
||||||
$format = 'long';
|
if (!array_key_exists($format, $formats)) {
|
||||||
}
|
$format = 'long';
|
||||||
$days = array();
|
}
|
||||||
for ($i=0; $i<=6; $i++) {
|
$months = array();
|
||||||
$stamp = mktime(0, 0, 0, 11, $i+2, 2003);
|
for ($i=1; $i<=12; $i++) {
|
||||||
$day = strftime($formats[$format], $stamp);
|
$stamp = mktime(0, 0, 0, $i, 1, 2003);
|
||||||
switch($format) {
|
$month = strftime($formats[$format], $stamp);
|
||||||
case 'one':
|
switch($format) {
|
||||||
$day = substr($day, 0, 1);
|
case 'one':
|
||||||
break;
|
$month = substr($month, 0, 1);
|
||||||
case 'two':
|
break;
|
||||||
$day = substr($day, 0, 2);
|
case 'two':
|
||||||
break;
|
$month = substr($month, 0, 2);
|
||||||
}
|
break;
|
||||||
$days[$i] = $day;
|
}
|
||||||
}
|
$months[$i] = $month;
|
||||||
return $days;
|
}
|
||||||
}
|
return $months;
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Returns textual representation of the previous month of the decorated calendar object
|
/**
|
||||||
* @param object subclass of Calendar e.g. Calendar_Month
|
* Returns an array of 7 week day names (first index = 0)
|
||||||
* @param string (optional) format of returned months (one,two,short or long)
|
*
|
||||||
* @return string
|
* @param string $format (optional) format of returned days (one,two,short or long)
|
||||||
* @access public
|
*
|
||||||
* @static
|
* @return array
|
||||||
*/
|
* @access public
|
||||||
function prevMonthName($Calendar, $format='long')
|
* @static
|
||||||
{
|
*/
|
||||||
$months = Calendar_Util_Textual::monthNames($format);
|
function weekdayNames($format = 'long')
|
||||||
return $months[$Calendar->prevMonth()];
|
{
|
||||||
}
|
$formats = array(
|
||||||
|
'one' => '%a',
|
||||||
/**
|
'two' => '%a',
|
||||||
* Returns textual representation of the month of the decorated calendar object
|
'short' => '%a',
|
||||||
* @param object subclass of Calendar e.g. Calendar_Month
|
'long' => '%A',
|
||||||
* @param string (optional) format of returned months (one,two,short or long)
|
);
|
||||||
* @return string
|
if (!array_key_exists($format, $formats)) {
|
||||||
* @access public
|
$format = 'long';
|
||||||
* @static
|
}
|
||||||
*/
|
$days = array();
|
||||||
function thisMonthName($Calendar, $format='long')
|
for ($i=0; $i<=6; $i++) {
|
||||||
{
|
$stamp = mktime(0, 0, 0, 11, $i+2, 2003);
|
||||||
$months = Calendar_Util_Textual::monthNames($format);
|
$day = strftime($formats[$format], $stamp);
|
||||||
return $months[$Calendar->thisMonth()];
|
switch($format) {
|
||||||
}
|
case 'one':
|
||||||
|
$day = substr($day, 0, 1);
|
||||||
/**
|
break;
|
||||||
* Returns textual representation of the next month of the decorated calendar object
|
case 'two':
|
||||||
* @param object subclass of Calendar e.g. Calendar_Month
|
$day = substr($day, 0, 2);
|
||||||
* @param string (optional) format of returned months (one,two,short or long)
|
break;
|
||||||
* @return string
|
}
|
||||||
* @access public
|
$days[$i] = $day;
|
||||||
* @static
|
}
|
||||||
*/
|
return $days;
|
||||||
function nextMonthName($Calendar, $format='long')
|
}
|
||||||
{
|
|
||||||
$months = Calendar_Util_Textual::monthNames($format);
|
/**
|
||||||
return $months[$Calendar->nextMonth()];
|
* Returns textual representation of the previous month of the decorated calendar object
|
||||||
}
|
*
|
||||||
|
* @param object $Calendar subclass of Calendar e.g. Calendar_Month
|
||||||
/**
|
* @param string $format (optional) format of returned months (one,two,short or long)
|
||||||
* Returns textual representation of the previous day of week of the decorated calendar object
|
*
|
||||||
* <b>Note:</b> Requires PEAR::Date
|
* @return string
|
||||||
* @param object subclass of Calendar e.g. Calendar_Month
|
* @access public
|
||||||
* @param string (optional) format of returned months (one,two,short or long)
|
* @static
|
||||||
* @return string
|
*/
|
||||||
* @access public
|
function prevMonthName($Calendar, $format = 'long')
|
||||||
* @static
|
{
|
||||||
*/
|
$months = Calendar_Util_Textual::monthNames($format);
|
||||||
function prevDayName($Calendar, $format='long')
|
return $months[$Calendar->prevMonth()];
|
||||||
{
|
}
|
||||||
$days = Calendar_Util_Textual::weekdayNames($format);
|
|
||||||
$stamp = $Calendar->prevDay('timestamp');
|
/**
|
||||||
$cE = $Calendar->getEngine();
|
* Returns textual representation of the month of the decorated calendar object
|
||||||
require_once 'Date/Calc.php';
|
*
|
||||||
$day = Date_Calc::dayOfWeek($cE->stampToDay($stamp),
|
* @param object $Calendar subclass of Calendar e.g. Calendar_Month
|
||||||
$cE->stampToMonth($stamp), $cE->stampToYear($stamp));
|
* @param string $format (optional) format of returned months (one,two,short or long)
|
||||||
return $days[$day];
|
*
|
||||||
}
|
* @return string
|
||||||
|
* @access public
|
||||||
/**
|
* @static
|
||||||
* Returns textual representation of the day of week of the decorated calendar object
|
*/
|
||||||
* <b>Note:</b> Requires PEAR::Date
|
function thisMonthName($Calendar, $format = 'long')
|
||||||
* @param object subclass of Calendar e.g. Calendar_Month
|
{
|
||||||
* @param string (optional) format of returned months (one,two,short or long)
|
$months = Calendar_Util_Textual::monthNames($format);
|
||||||
* @return string
|
return $months[$Calendar->thisMonth()];
|
||||||
* @access public
|
}
|
||||||
* @static
|
|
||||||
*/
|
/**
|
||||||
function thisDayName($Calendar, $format='long')
|
* Returns textual representation of the next month of the decorated calendar object
|
||||||
{
|
*
|
||||||
$days = Calendar_Util_Textual::weekdayNames($format);
|
* @param object $Calendar subclass of Calendar e.g. Calendar_Month
|
||||||
require_once 'Date/Calc.php';
|
* @param string $format (optional) format of returned months (one,two,short or long)
|
||||||
$day = Date_Calc::dayOfWeek($Calendar->thisDay(), $Calendar->thisMonth(), $Calendar->thisYear());
|
*
|
||||||
return $days[$day];
|
* @return string
|
||||||
}
|
* @access public
|
||||||
|
* @static
|
||||||
/**
|
*/
|
||||||
* Returns textual representation of the next day of week of the decorated calendar object
|
function nextMonthName($Calendar, $format = 'long')
|
||||||
* @param object subclass of Calendar e.g. Calendar_Month
|
{
|
||||||
* @param string (optional) format of returned months (one,two,short or long)
|
$months = Calendar_Util_Textual::monthNames($format);
|
||||||
* @return string
|
return $months[$Calendar->nextMonth()];
|
||||||
* @access public
|
}
|
||||||
* @static
|
|
||||||
*/
|
/**
|
||||||
function nextDayName($Calendar, $format='long')
|
* Returns textual representation of the previous day of week of the decorated calendar object
|
||||||
{
|
* <b>Note:</b> Requires PEAR::Date
|
||||||
$days = Calendar_Util_Textual::weekdayNames($format);
|
*
|
||||||
$stamp = $Calendar->nextDay('timestamp');
|
* @param object $Calendar subclass of Calendar e.g. Calendar_Month
|
||||||
$cE = $Calendar->getEngine();
|
* @param string $format (optional) format of returned months (one,two,short or long)
|
||||||
require_once 'Date/Calc.php';
|
*
|
||||||
$day = Date_Calc::dayOfWeek($cE->stampToDay($stamp),
|
* @return string
|
||||||
$cE->stampToMonth($stamp), $cE->stampToYear($stamp));
|
* @access public
|
||||||
return $days[$day];
|
* @static
|
||||||
}
|
*/
|
||||||
|
function prevDayName($Calendar, $format = 'long')
|
||||||
/**
|
{
|
||||||
* Returns the days of the week using the order defined in the decorated
|
$days = Calendar_Util_Textual::weekdayNames($format);
|
||||||
* calendar object. Only useful for Calendar_Month_Weekdays, Calendar_Month_Weeks
|
$stamp = $Calendar->prevDay('timestamp');
|
||||||
* and Calendar_Week. Otherwise the returned array will begin on Sunday
|
$cE = $Calendar->getEngine();
|
||||||
* @param object subclass of Calendar e.g. Calendar_Month
|
include_once 'Date/Calc.php';
|
||||||
* @param string (optional) format of returned months (one,two,short or long)
|
$day = Date_Calc::dayOfWeek($cE->stampToDay($stamp),
|
||||||
* @return array ordered array of week day names
|
$cE->stampToMonth($stamp), $cE->stampToYear($stamp));
|
||||||
* @access public
|
return $days[$day];
|
||||||
* @static
|
}
|
||||||
*/
|
|
||||||
function orderedWeekdays($Calendar, $format='long')
|
/**
|
||||||
{
|
* Returns textual representation of the day of week of the decorated calendar object
|
||||||
$days = Calendar_Util_Textual::weekdayNames($format);
|
* <b>Note:</b> Requires PEAR::Date
|
||||||
|
*
|
||||||
// Not so good - need methods to access this information perhaps...
|
* @param object $Calendar subclass of Calendar e.g. Calendar_Month
|
||||||
if (isset($Calendar->tableHelper)) {
|
* @param string $format (optional) format of returned months (one,two,short or long)
|
||||||
$ordereddays = $Calendar->tableHelper->daysOfWeek;
|
*
|
||||||
} else {
|
* @return string
|
||||||
$ordereddays = array(0, 1, 2, 3, 4, 5, 6);
|
* @access public
|
||||||
}
|
* @static
|
||||||
|
*/
|
||||||
$ordereddays = array_flip($ordereddays);
|
function thisDayName($Calendar, $format='long')
|
||||||
$i = 0;
|
{
|
||||||
$returndays = array();
|
$days = Calendar_Util_Textual::weekdayNames($format);
|
||||||
foreach ($ordereddays as $key => $value) {
|
include_once 'Date/Calc.php';
|
||||||
$returndays[$i] = $days[$key];
|
$day = Date_Calc::dayOfWeek($Calendar->thisDay(), $Calendar->thisMonth(), $Calendar->thisYear());
|
||||||
$i++;
|
return $days[$day];
|
||||||
}
|
}
|
||||||
return $returndays;
|
|
||||||
}
|
/**
|
||||||
}
|
* Returns textual representation of the next day of week of the decorated calendar object
|
||||||
|
*
|
||||||
|
* @param object $Calendar subclass of Calendar e.g. Calendar_Month
|
||||||
|
* @param string $format (optional) format of returned months (one,two,short or long)
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* @access public
|
||||||
|
* @static
|
||||||
|
*/
|
||||||
|
function nextDayName($Calendar, $format='long')
|
||||||
|
{
|
||||||
|
$days = Calendar_Util_Textual::weekdayNames($format);
|
||||||
|
$stamp = $Calendar->nextDay('timestamp');
|
||||||
|
$cE = $Calendar->getEngine();
|
||||||
|
include_once 'Date/Calc.php';
|
||||||
|
$day = Date_Calc::dayOfWeek($cE->stampToDay($stamp),
|
||||||
|
$cE->stampToMonth($stamp), $cE->stampToYear($stamp));
|
||||||
|
return $days[$day];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the days of the week using the order defined in the decorated
|
||||||
|
* calendar object. Only useful for Calendar_Month_Weekdays, Calendar_Month_Weeks
|
||||||
|
* and Calendar_Week. Otherwise the returned array will begin on Sunday
|
||||||
|
*
|
||||||
|
* @param object $Calendar subclass of Calendar e.g. Calendar_Month
|
||||||
|
* @param string $format (optional) format of returned months (one,two,short or long)
|
||||||
|
*
|
||||||
|
* @return array ordered array of week day names
|
||||||
|
* @access public
|
||||||
|
* @static
|
||||||
|
*/
|
||||||
|
function orderedWeekdays($Calendar, $format = 'long')
|
||||||
|
{
|
||||||
|
$days = Calendar_Util_Textual::weekdayNames($format);
|
||||||
|
|
||||||
|
if (isset($Calendar->tableHelper)) {
|
||||||
|
$ordereddays = $Calendar->tableHelper->getDaysOfWeek();
|
||||||
|
} else {
|
||||||
|
//default: start from Sunday
|
||||||
|
$firstDay = 0;
|
||||||
|
//check if defined / set
|
||||||
|
if (defined('CALENDAR_FIRST_DAY_OF_WEEK')) {
|
||||||
|
$firstDay = CALENDAR_FIRST_DAY_OF_WEEK;
|
||||||
|
} elseif(isset($Calendar->firstDay)) {
|
||||||
|
$firstDay = $Calendar->firstDay;
|
||||||
|
}
|
||||||
|
$ordereddays = array();
|
||||||
|
for ($i = $firstDay; $i < 7; $i++) {
|
||||||
|
$ordereddays[] = $i;
|
||||||
|
}
|
||||||
|
for ($i = 0; $i < $firstDay; $i++) {
|
||||||
|
$ordereddays[] = $i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$ordereddays = array_flip($ordereddays);
|
||||||
|
$i = 0;
|
||||||
|
$returndays = array();
|
||||||
|
foreach ($ordereddays as $key => $value) {
|
||||||
|
$returndays[$i] = $days[$key];
|
||||||
|
$i++;
|
||||||
|
}
|
||||||
|
return $returndays;
|
||||||
|
}
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
@@ -1,169 +1,204 @@
|
|||||||
<?php
|
<?php
|
||||||
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
||||||
//
|
|
||||||
// +----------------------------------------------------------------------+
|
/**
|
||||||
// | PHP |
|
* Contains the Calendar_Util_Uri class
|
||||||
// +----------------------------------------------------------------------+
|
*
|
||||||
// | Copyright (c) 1997-2002 The PHP Group |
|
* PHP versions 4 and 5
|
||||||
// +----------------------------------------------------------------------+
|
*
|
||||||
// | This source file is subject to version 2.02 of the PHP license, |
|
* LICENSE: Redistribution and use in source and binary forms, with or without
|
||||||
// | that is bundled with this package in the file LICENSE, and is |
|
* modification, are permitted provided that the following conditions are met:
|
||||||
// | available at through the world-wide-web at |
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
// | http://www.php.net/license/3_0.txt. |
|
* notice, this list of conditions and the following disclaimer.
|
||||||
// | If you did not receive a copy of the PHP license and are unable to |
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
// | obtain it through the world-wide-web, please send a note to |
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
// | license@php.net so we can mail you a copy immediately. |
|
* documentation and/or other materials provided with the distribution.
|
||||||
// +----------------------------------------------------------------------+
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
// | Authors: Harry Fuecks <hfuecks@phppatterns.com> |
|
* derived from this software without specific prior written permission.
|
||||||
// | Lorenzo Alberton <l dot alberton at quipo dot it> |
|
*
|
||||||
// +----------------------------------------------------------------------+
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||||
//
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
// $Id: Uri.php,v 1.1 2004/08/16 09:03:55 hfuecks Exp $
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
//
|
* IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
/**
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* @package Calendar
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
* @version $Id: Uri.php,v 1.1 2004/08/16 09:03:55 hfuecks Exp $
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
*/
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
/**
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
* Utility to help building HTML links for navigating the calendar<br />
|
*
|
||||||
* <code>
|
* @category Date and Time
|
||||||
* $Day = new Calendar_Day(2003, 10, 23);
|
* @package Calendar
|
||||||
* $Uri = & new Calendar_Util_Uri('year', 'month', 'day');
|
* @author Harry Fuecks <hfuecks@phppatterns.com>
|
||||||
* echo $Uri->prev($Day,'month'); // Displays year=2003&month=10
|
* @author Lorenzo Alberton <l.alberton@quipo.it>
|
||||||
* echo $Uri->prev($Day,'day'); // Displays year=2003&month=10&day=22
|
* @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton
|
||||||
* $Uri->seperator = '/';
|
* @license http://www.debian.org/misc/bsd.license BSD License (3 Clause)
|
||||||
* $Uri->scalar = true;
|
* @version CVS: $Id: Uri.php 300729 2010-06-24 12:05:53Z quipo $
|
||||||
* echo $Uri->prev($Day,'month'); // Displays 2003/10
|
* @link http://pear.php.net/package/Calendar
|
||||||
* echo $Uri->prev($Day,'day'); // Displays 2003/10/22
|
*/
|
||||||
* </code>
|
|
||||||
* @package Calendar
|
/**
|
||||||
* @access public
|
* Utility to help building HTML links for navigating the calendar<br />
|
||||||
*/
|
* <code>
|
||||||
class Calendar_Util_Uri
|
* $Day = new Calendar_Day(2003, 10, 23);
|
||||||
{
|
* $Uri = new Calendar_Util_Uri('year', 'month', 'day');
|
||||||
/**
|
* echo $Uri->prev($Day,'month'); // Displays year=2003&month=10
|
||||||
* Uri fragments for year, month, day etc.
|
* echo $Uri->prev($Day,'day'); // Displays year=2003&month=10&day=22
|
||||||
* @var array
|
* $Uri->seperator = '/';
|
||||||
* @access private
|
* $Uri->scalar = true;
|
||||||
*/
|
* echo $Uri->prev($Day,'month'); // Displays 2003/10
|
||||||
var $uris = array();
|
* echo $Uri->prev($Day,'day'); // Displays 2003/10/22
|
||||||
|
* </code>
|
||||||
/**
|
*
|
||||||
* String to separate fragments with.
|
* @category Date and Time
|
||||||
* Set to just & for HTML.
|
* @package Calendar
|
||||||
* For a scalar URL you might use / as the seperator
|
* @author Harry Fuecks <hfuecks@phppatterns.com>
|
||||||
* @var string (default XHTML &)
|
* @author Lorenzo Alberton <l.alberton@quipo.it>
|
||||||
* @access public
|
* @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton
|
||||||
*/
|
* @license http://www.debian.org/misc/bsd.license BSD License (3 Clause)
|
||||||
var $separator = '&';
|
* @link http://pear.php.net/package/Calendar
|
||||||
|
* @access public
|
||||||
/**
|
*/
|
||||||
* To output a "scalar" string - variable names omitted.
|
class Calendar_Util_Uri
|
||||||
* Used for urls like index.php/2004/8/12
|
{
|
||||||
* @var boolean (default false)
|
/**
|
||||||
* @access public
|
* Uri fragments for year, month, day etc.
|
||||||
*/
|
* @var array
|
||||||
var $scalar = false;
|
* @access private
|
||||||
|
*/
|
||||||
/**
|
var $uris = array();
|
||||||
* Constructs Calendar_Decorator_Uri
|
|
||||||
* The term "fragment" means <i>name</i> of a calendar GET variables in the URL
|
/**
|
||||||
* @param string URI fragment for year
|
* String to separate fragments with.
|
||||||
* @param string (optional) URI fragment for month
|
* Set to just & for HTML.
|
||||||
* @param string (optional) URI fragment for day
|
* For a scalar URL you might use / as the seperator
|
||||||
* @param string (optional) URI fragment for hour
|
* @var string (default XHTML &)
|
||||||
* @param string (optional) URI fragment for minute
|
* @access public
|
||||||
* @param string (optional) URI fragment for second
|
*/
|
||||||
* @access public
|
var $separator = '&';
|
||||||
*/
|
|
||||||
function Calendar_Util_Uri($y, $m=null, $d=null, $h=null, $i=null, $s=null)
|
/**
|
||||||
{
|
* To output a "scalar" string - variable names omitted.
|
||||||
$this->setFragments($y, $m, $d, $h, $i, $s);
|
* Used for urls like index.php/2004/8/12
|
||||||
}
|
* @var boolean (default false)
|
||||||
|
* @access public
|
||||||
/**
|
*/
|
||||||
* Sets the URI fragment names
|
var $scalar = false;
|
||||||
* @param string URI fragment for year
|
|
||||||
* @param string (optional) URI fragment for month
|
/**
|
||||||
* @param string (optional) URI fragment for day
|
* Constructs Calendar_Decorator_Uri
|
||||||
* @param string (optional) URI fragment for hour
|
* The term "fragment" means <i>name</i> of a calendar GET variables in the URL
|
||||||
* @param string (optional) URI fragment for minute
|
*
|
||||||
* @param string (optional) URI fragment for second
|
* @param string $y URI fragment for year
|
||||||
* @return void
|
* @param string $m (optional) URI fragment for month
|
||||||
* @access public
|
* @param string $d (optional) URI fragment for day
|
||||||
*/
|
* @param string $h (optional) URI fragment for hour
|
||||||
function setFragments($y, $m=null, $d=null, $h=null, $i=null, $s=null) {
|
* @param string $i (optional) URI fragment for minute
|
||||||
if (!is_null($y)) $this->uris['Year'] = $y;
|
* @param string $s (optional) URI fragment for second
|
||||||
if (!is_null($m)) $this->uris['Month'] = $m;
|
*
|
||||||
if (!is_null($d)) $this->uris['Day'] = $d;
|
* @access public
|
||||||
if (!is_null($h)) $this->uris['Hour'] = $h;
|
*/
|
||||||
if (!is_null($i)) $this->uris['Minute'] = $i;
|
function Calendar_Util_Uri($y, $m=null, $d=null, $h=null, $i=null, $s=null)
|
||||||
if (!is_null($s)) $this->uris['Second'] = $s;
|
{
|
||||||
}
|
$this->setFragments($y, $m, $d, $h, $i, $s);
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Gets the URI string for the previous calendar unit
|
/**
|
||||||
* @param object subclassed from Calendar e.g. Calendar_Month
|
* Sets the URI fragment names
|
||||||
* @param string calendar unit ( must be year, month, week, day, hour, minute or second)
|
*
|
||||||
* @return string
|
* @param string $y URI fragment for year
|
||||||
* @access public
|
* @param string $m (optional) URI fragment for month
|
||||||
*/
|
* @param string $d (optional) URI fragment for day
|
||||||
function prev($Calendar, $unit)
|
* @param string $h (optional) URI fragment for hour
|
||||||
{
|
* @param string $i (optional) URI fragment for minute
|
||||||
$method = 'prev'.$unit;
|
* @param string $s (optional) URI fragment for second
|
||||||
$stamp = $Calendar->{$method}('timestamp');
|
*
|
||||||
return $this->buildUriString($Calendar, $method, $stamp);
|
* @return void
|
||||||
}
|
* @access public
|
||||||
|
*/
|
||||||
/**
|
function setFragments($y, $m=null, $d=null, $h=null, $i=null, $s=null)
|
||||||
* Gets the URI string for the current calendar unit
|
{
|
||||||
* @param object subclassed from Calendar e.g. Calendar_Month
|
if (!is_null($y)) $this->uris['Year'] = $y;
|
||||||
* @param string calendar unit ( must be year, month, week, day, hour, minute or second)
|
if (!is_null($m)) $this->uris['Month'] = $m;
|
||||||
* @return string
|
if (!is_null($d)) $this->uris['Day'] = $d;
|
||||||
* @access public
|
if (!is_null($h)) $this->uris['Hour'] = $h;
|
||||||
*/
|
if (!is_null($i)) $this->uris['Minute'] = $i;
|
||||||
function this($Calendar, $unit)
|
if (!is_null($s)) $this->uris['Second'] = $s;
|
||||||
{
|
}
|
||||||
$method = 'this'.$unit;
|
|
||||||
$stamp = $Calendar->{$method}('timestamp');
|
/**
|
||||||
return $this->buildUriString($Calendar, $method, $stamp);
|
* Gets the URI string for the previous calendar unit
|
||||||
}
|
*
|
||||||
|
* @param object $Calendar subclassed from Calendar e.g. Calendar_Month
|
||||||
/**
|
* @param string $unit calendar unit (year|month|week|day|hour|minute|second)
|
||||||
* Gets the URI string for the next calendar unit
|
*
|
||||||
* @param object subclassed from Calendar e.g. Calendar_Month
|
* @return string
|
||||||
* @param string calendar unit ( must be year, month, week, day, hour, minute or second)
|
* @access public
|
||||||
* @return string
|
*/
|
||||||
* @access public
|
function prev($Calendar, $unit)
|
||||||
*/
|
{
|
||||||
function next($Calendar, $unit)
|
$method = 'prev'.$unit;
|
||||||
{
|
$stamp = $Calendar->{$method}('timestamp');
|
||||||
$method = 'next'.$unit;
|
return $this->buildUriString($Calendar, $method, $stamp);
|
||||||
$stamp = $Calendar->{$method}('timestamp');
|
}
|
||||||
return $this->buildUriString($Calendar, $method, $stamp);
|
|
||||||
}
|
/**
|
||||||
|
* Gets the URI string for the current calendar unit
|
||||||
/**
|
*
|
||||||
* Build the URI string
|
* @param object $Calendar subclassed from Calendar e.g. Calendar_Month
|
||||||
* @param string method substring
|
* @param string $unit calendar unit (year|month|week|day|hour|minute|second)
|
||||||
* @param int timestamp
|
*
|
||||||
* @return string build uri string
|
* @return string
|
||||||
* @access private
|
* @access public
|
||||||
*/
|
*/
|
||||||
function buildUriString($Calendar, $method, $stamp)
|
function this($Calendar, $unit)
|
||||||
{
|
{
|
||||||
$uriString = '';
|
$method = 'this'.$unit;
|
||||||
$cE = & $Calendar->getEngine();
|
$stamp = $Calendar->{$method}('timestamp');
|
||||||
$separator = '';
|
return $this->buildUriString($Calendar, $method, $stamp);
|
||||||
foreach ($this->uris as $unit => $uri) {
|
}
|
||||||
$call = 'stampTo'.$unit;
|
|
||||||
$uriString .= $separator;
|
/**
|
||||||
if (!$this->scalar) $uriString .= $uri.'=';
|
* Gets the URI string for the next calendar unit
|
||||||
$uriString .= $cE->{$call}($stamp);
|
*
|
||||||
$separator = $this->separator;
|
* @param object $Calendar subclassed from Calendar e.g. Calendar_Month
|
||||||
}
|
* @param string $unit calendar unit (year|month|week|day|hour|minute|second)
|
||||||
return $uriString;
|
*
|
||||||
}
|
* @return string
|
||||||
}
|
* @access public
|
||||||
|
*/
|
||||||
|
function next($Calendar, $unit)
|
||||||
|
{
|
||||||
|
$method = 'next'.$unit;
|
||||||
|
$stamp = $Calendar->{$method}('timestamp');
|
||||||
|
return $this->buildUriString($Calendar, $method, $stamp);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build the URI string
|
||||||
|
*
|
||||||
|
* @param object $Calendar subclassed from Calendar e.g. Calendar_Month
|
||||||
|
* @param string $method method substring
|
||||||
|
* @param int $stamp timestamp
|
||||||
|
*
|
||||||
|
* @return string build uri string
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
function buildUriString($Calendar, $method, $stamp)
|
||||||
|
{
|
||||||
|
$uriString = '';
|
||||||
|
$cE = & $Calendar->getEngine();
|
||||||
|
$separator = '';
|
||||||
|
foreach ($this->uris as $unit => $uri) {
|
||||||
|
$call = 'stampTo'.$unit;
|
||||||
|
$uriString .= $separator;
|
||||||
|
if (!$this->scalar) {
|
||||||
|
$uriString .= $uri.'=';
|
||||||
|
}
|
||||||
|
$uriString .= $cE->{$call}($stamp);
|
||||||
|
$separator = $this->separator;
|
||||||
|
}
|
||||||
|
return $uriString;
|
||||||
|
}
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
@@ -1,335 +1,377 @@
|
|||||||
<?php
|
<?php
|
||||||
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
||||||
//
|
|
||||||
// +----------------------------------------------------------------------+
|
/**
|
||||||
// | PHP Version 4 |
|
* Contains the Calendar_Validator class
|
||||||
// +----------------------------------------------------------------------+
|
*
|
||||||
// | Copyright (c) 1997-2002 The PHP Group |
|
* PHP versions 4 and 5
|
||||||
// +----------------------------------------------------------------------+
|
*
|
||||||
// | This source file is subject to version 2.02 of the PHP license, |
|
* LICENSE: Redistribution and use in source and binary forms, with or without
|
||||||
// | that is bundled with this package in the file LICENSE, and is |
|
* modification, are permitted provided that the following conditions are met:
|
||||||
// | available at through the world-wide-web at |
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
// | http://www.php.net/license/3_0.txt. |
|
* notice, this list of conditions and the following disclaimer.
|
||||||
// | If you did not receive a copy of the PHP license and are unable to |
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
// | obtain it through the world-wide-web, please send a note to |
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
// | license@php.net so we can mail you a copy immediately. |
|
* documentation and/or other materials provided with the distribution.
|
||||||
// +----------------------------------------------------------------------+
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
// | Authors: Harry Fuecks <hfuecks@phppatterns.com> |
|
* derived from this software without specific prior written permission.
|
||||||
// +----------------------------------------------------------------------+
|
*
|
||||||
//
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||||
// $Id: Validator.php,v 1.1 2004/05/24 22:25:42 quipo Exp $
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
//
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
/**
|
* IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
* @package Calendar
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* @version $Id: Validator.php,v 1.1 2004/05/24 22:25:42 quipo Exp $
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
*/
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
/**
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
* Validation Error Messages
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*
|
||||||
if (!defined('CALENDAR_VALUE_TOOSMALL')) {
|
* @category Date and Time
|
||||||
define('CALENDAR_VALUE_TOOSMALL', 'Too small: min = ');
|
* @package Calendar
|
||||||
}
|
* @author Harry Fuecks <hfuecks@phppatterns.com>
|
||||||
if (!defined('CALENDAR_VALUE_TOOLARGE')) {
|
* @copyright 2003-2007 Harry Fuecks
|
||||||
define('CALENDAR_VALUE_TOOLARGE', 'Too large: max = ');
|
* @license http://www.debian.org/misc/bsd.license BSD License (3 Clause)
|
||||||
}
|
* @version CVS: $Id: Validator.php 247251 2007-11-28 19:42:33Z quipo $
|
||||||
|
* @link http://pear.php.net/package/Calendar
|
||||||
/**
|
*/
|
||||||
* Used to validate any given Calendar date object. Instances of this class
|
|
||||||
* can be obtained from any data object using the getValidator method
|
/**
|
||||||
* @see Calendar::getValidator()
|
* Validation Error Messages
|
||||||
* @package Calendar
|
*/
|
||||||
* @access public
|
if (!defined('CALENDAR_VALUE_TOOSMALL')) {
|
||||||
*/
|
define('CALENDAR_VALUE_TOOSMALL', 'Too small: min = ');
|
||||||
class Calendar_Validator
|
}
|
||||||
{
|
if (!defined('CALENDAR_VALUE_TOOLARGE')) {
|
||||||
/**
|
define('CALENDAR_VALUE_TOOLARGE', 'Too large: max = ');
|
||||||
* Instance of the Calendar date object to validate
|
}
|
||||||
* @var object
|
|
||||||
* @access private
|
/**
|
||||||
*/
|
* Used to validate any given Calendar date object. Instances of this class
|
||||||
var $calendar;
|
* can be obtained from any data object using the getValidator method
|
||||||
|
*
|
||||||
/**
|
* @category Date and Time
|
||||||
* Instance of the Calendar_Engine
|
* @package Calendar
|
||||||
* @var object
|
* @author Harry Fuecks <hfuecks@phppatterns.com>
|
||||||
* @access private
|
* @copyright 2003-2007 Harry Fuecks
|
||||||
*/
|
* @license http://www.debian.org/misc/bsd.license BSD License (3 Clause)
|
||||||
var $cE;
|
* @link http://pear.php.net/package/Calendar
|
||||||
|
* @see Calendar::getValidator()
|
||||||
/**
|
* @access public
|
||||||
* Array of errors for validation failures
|
*/
|
||||||
* @var array
|
class Calendar_Validator
|
||||||
* @access private
|
{
|
||||||
*/
|
/**
|
||||||
var $errors = array();
|
* Instance of the Calendar date object to validate
|
||||||
|
* @var object
|
||||||
/**
|
* @access private
|
||||||
* Constructs Calendar_Validator
|
*/
|
||||||
* @param object subclass of Calendar
|
var $calendar;
|
||||||
* @access public
|
|
||||||
*/
|
/**
|
||||||
function Calendar_Validator(& $calendar)
|
* Instance of the Calendar_Engine
|
||||||
{
|
* @var object
|
||||||
$this->calendar = & $calendar;
|
* @access private
|
||||||
$this->cE = & $calendar->getEngine();
|
*/
|
||||||
}
|
var $cE;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calls all the other isValidXXX() methods in the validator
|
* Array of errors for validation failures
|
||||||
* @return boolean
|
* @var array
|
||||||
* @access public
|
* @access private
|
||||||
*/
|
*/
|
||||||
function isValid()
|
var $errors = array();
|
||||||
{
|
|
||||||
$checks = array('isValidYear', 'isValidMonth', 'isValidDay',
|
/**
|
||||||
'isValidHour', 'isValidMinute', 'isValidSecond');
|
* Constructs Calendar_Validator
|
||||||
$valid = true;
|
*
|
||||||
foreach ($checks as $check) {
|
* @param object &$calendar subclass of Calendar
|
||||||
if (!$this->{$check}()) {
|
*
|
||||||
$valid = false;
|
* @access public
|
||||||
}
|
*/
|
||||||
}
|
function Calendar_Validator(&$calendar)
|
||||||
return $valid;
|
{
|
||||||
}
|
$this->calendar = & $calendar;
|
||||||
|
$this->cE = & $calendar->getEngine();
|
||||||
/**
|
}
|
||||||
* Check whether this is a valid year
|
|
||||||
* @return boolean
|
/**
|
||||||
* @access public
|
* Calls all the other isValidXXX() methods in the validator
|
||||||
*/
|
*
|
||||||
function isValidYear()
|
* @return boolean
|
||||||
{
|
* @access public
|
||||||
$y = $this->calendar->thisYear();
|
*/
|
||||||
$min = $this->cE->getMinYears();
|
function isValid()
|
||||||
if ($min > $y) {
|
{
|
||||||
$this->errors[] = new Calendar_Validation_Error(
|
$checks = array('isValidYear', 'isValidMonth', 'isValidDay',
|
||||||
'Year', $y, CALENDAR_VALUE_TOOSMALL.$min);
|
'isValidHour', 'isValidMinute', 'isValidSecond');
|
||||||
return false;
|
$valid = true;
|
||||||
}
|
foreach ($checks as $check) {
|
||||||
$max = $this->cE->getMaxYears();
|
if (!$this->{$check}()) {
|
||||||
if ($y > $max) {
|
$valid = false;
|
||||||
$this->errors[] = new Calendar_Validation_Error(
|
}
|
||||||
'Year', $y, CALENDAR_VALUE_TOOLARGE.$max);
|
}
|
||||||
return false;
|
return $valid;
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
/**
|
||||||
|
* Check whether this is a valid year
|
||||||
/**
|
*
|
||||||
* Check whether this is a valid month
|
* @return boolean
|
||||||
* @return boolean
|
* @access public
|
||||||
* @access public
|
*/
|
||||||
*/
|
function isValidYear()
|
||||||
function isValidMonth()
|
{
|
||||||
{
|
$y = $this->calendar->thisYear();
|
||||||
$m = $this->calendar->thisMonth();
|
$min = $this->cE->getMinYears();
|
||||||
$min = 1;
|
if ($min > $y) {
|
||||||
if ($min > $m) {
|
$this->errors[] = new Calendar_Validation_Error(
|
||||||
$this->errors[] = new Calendar_Validation_Error(
|
'Year', $y, CALENDAR_VALUE_TOOSMALL.$min);
|
||||||
'Month', $m, CALENDAR_VALUE_TOOSMALL.$min);
|
return false;
|
||||||
return false;
|
}
|
||||||
}
|
$max = $this->cE->getMaxYears();
|
||||||
$max = $this->cE->getMonthsInYear($this->calendar->thisYear());
|
if ($y > $max) {
|
||||||
if ($m > $max) {
|
$this->errors[] = new Calendar_Validation_Error(
|
||||||
$this->errors[] = new Calendar_Validation_Error(
|
'Year', $y, CALENDAR_VALUE_TOOLARGE.$max);
|
||||||
'Month', $m, CALENDAR_VALUE_TOOLARGE.$max);
|
return false;
|
||||||
return false;
|
}
|
||||||
}
|
return true;
|
||||||
return true;
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
/**
|
* Check whether this is a valid month
|
||||||
* Check whether this is a valid day
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function isValidDay()
|
function isValidMonth()
|
||||||
{
|
{
|
||||||
$d = $this->calendar->thisDay();
|
$m = $this->calendar->thisMonth();
|
||||||
$min = 1;
|
$min = 1;
|
||||||
if ($min > $d) {
|
if ($min > $m) {
|
||||||
$this->errors[] = new Calendar_Validation_Error(
|
$this->errors[] = new Calendar_Validation_Error(
|
||||||
'Day', $d, CALENDAR_VALUE_TOOSMALL.$min);
|
'Month', $m, CALENDAR_VALUE_TOOSMALL.$min);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$max = $this->cE->getDaysInMonth(
|
$max = $this->cE->getMonthsInYear($this->calendar->thisYear());
|
||||||
$this->calendar->thisYear(), $this->calendar->thisMonth());
|
if ($m > $max) {
|
||||||
if ($d > $max) {
|
$this->errors[] = new Calendar_Validation_Error(
|
||||||
$this->errors[] = new Calendar_Validation_Error(
|
'Month', $m, CALENDAR_VALUE_TOOLARGE.$max);
|
||||||
'Day', $d, CALENDAR_VALUE_TOOLARGE.$max);
|
return false;
|
||||||
return false;
|
}
|
||||||
}
|
return true;
|
||||||
return true;
|
}
|
||||||
}
|
|
||||||
|
/**
|
||||||
/**
|
* Check whether this is a valid day
|
||||||
* Check whether this is a valid hour
|
*
|
||||||
* @return boolean
|
* @return boolean
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function isValidHour()
|
function isValidDay()
|
||||||
{
|
{
|
||||||
$h = $this->calendar->thisHour();
|
$d = $this->calendar->thisDay();
|
||||||
$min = 0;
|
$min = 1;
|
||||||
if ($min > $h) {
|
if ($min > $d) {
|
||||||
$this->errors[] = new Calendar_Validation_Error(
|
$this->errors[] = new Calendar_Validation_Error(
|
||||||
'Hour', $h, CALENDAR_VALUE_TOOSMALL.$min);
|
'Day', $d, CALENDAR_VALUE_TOOSMALL.$min);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$max = ($this->cE->getHoursInDay($this->calendar->thisDay())-1);
|
$max = $this->cE->getDaysInMonth(
|
||||||
if ($h > $max) {
|
$this->calendar->thisYear(),
|
||||||
$this->errors[] = new Calendar_Validation_Error(
|
$this->calendar->thisMonth()
|
||||||
'Hour', $h, CALENDAR_VALUE_TOOLARGE.$max);
|
);
|
||||||
return false;
|
if ($d > $max) {
|
||||||
}
|
$this->errors[] = new Calendar_Validation_Error(
|
||||||
return true;
|
'Day', $d, CALENDAR_VALUE_TOOLARGE.$max);
|
||||||
}
|
return false;
|
||||||
|
}
|
||||||
/**
|
return true;
|
||||||
* Check whether this is a valid minute
|
}
|
||||||
* @return boolean
|
|
||||||
* @access public
|
/**
|
||||||
*/
|
* Check whether this is a valid hour
|
||||||
function isValidMinute()
|
*
|
||||||
{
|
* @return boolean
|
||||||
$i = $this->calendar->thisMinute();
|
* @access public
|
||||||
$min = 0;
|
*/
|
||||||
if ($min > $i) {
|
function isValidHour()
|
||||||
$this->errors[] = new Calendar_Validation_Error(
|
{
|
||||||
'Minute', $i, CALENDAR_VALUE_TOOSMALL.$min);
|
$h = $this->calendar->thisHour();
|
||||||
return false;
|
$min = 0;
|
||||||
}
|
if ($min > $h) {
|
||||||
$max = ($this->cE->getMinutesInHour($this->calendar->thisHour())-1);
|
$this->errors[] = new Calendar_Validation_Error(
|
||||||
if ($i > $max) {
|
'Hour', $h, CALENDAR_VALUE_TOOSMALL.$min);
|
||||||
$this->errors[] = new Calendar_Validation_Error(
|
return false;
|
||||||
'Minute', $i, CALENDAR_VALUE_TOOLARGE.$max);
|
}
|
||||||
return false;
|
$max = ($this->cE->getHoursInDay($this->calendar->thisDay())-1);
|
||||||
}
|
if ($h > $max) {
|
||||||
return true;
|
$this->errors[] = new Calendar_Validation_Error(
|
||||||
}
|
'Hour', $h, CALENDAR_VALUE_TOOLARGE.$max);
|
||||||
|
return false;
|
||||||
/**
|
}
|
||||||
* Check whether this is a valid second
|
return true;
|
||||||
* @return boolean
|
}
|
||||||
* @access public
|
|
||||||
*/
|
/**
|
||||||
function isValidSecond()
|
* Check whether this is a valid minute
|
||||||
{
|
*
|
||||||
$s = $this->calendar->thisSecond();
|
* @return boolean
|
||||||
$min = 0;
|
* @access public
|
||||||
if ($min > $s) {
|
*/
|
||||||
$this->errors[] = new Calendar_Validation_Error(
|
function isValidMinute()
|
||||||
'Second', $s, CALENDAR_VALUE_TOOSMALL.$min);
|
{
|
||||||
return false;
|
$i = $this->calendar->thisMinute();
|
||||||
}
|
$min = 0;
|
||||||
$max = ($this->cE->getSecondsInMinute($this->calendar->thisMinute())-1);
|
if ($min > $i) {
|
||||||
if ($s > $max) {
|
$this->errors[] = new Calendar_Validation_Error(
|
||||||
$this->errors[] = new Calendar_Validation_Error(
|
'Minute', $i, CALENDAR_VALUE_TOOSMALL.$min);
|
||||||
'Second', $s, CALENDAR_VALUE_TOOLARGE.$max);
|
return false;
|
||||||
return false;
|
}
|
||||||
}
|
$max = ($this->cE->getMinutesInHour($this->calendar->thisHour())-1);
|
||||||
return true;
|
if ($i > $max) {
|
||||||
}
|
$this->errors[] = new Calendar_Validation_Error(
|
||||||
|
'Minute', $i, CALENDAR_VALUE_TOOLARGE.$max);
|
||||||
/**
|
return false;
|
||||||
* Iterates over any validation errors
|
}
|
||||||
* @return mixed either Calendar_Validation_Error or false
|
return true;
|
||||||
* @access public
|
}
|
||||||
*/
|
|
||||||
function fetch()
|
/**
|
||||||
{
|
* Check whether this is a valid second
|
||||||
$error = each ($this->errors);
|
*
|
||||||
if ($error) {
|
* @return boolean
|
||||||
return $error['value'];
|
* @access public
|
||||||
} else {
|
*/
|
||||||
reset($this->errors);
|
function isValidSecond()
|
||||||
return false;
|
{
|
||||||
}
|
$s = $this->calendar->thisSecond();
|
||||||
}
|
$min = 0;
|
||||||
}
|
if ($min > $s) {
|
||||||
|
$this->errors[] = new Calendar_Validation_Error(
|
||||||
/**
|
'Second', $s, CALENDAR_VALUE_TOOSMALL.$min);
|
||||||
* For Validation Error messages
|
return false;
|
||||||
* @see Calendar::fetch()
|
}
|
||||||
* @package Calendar
|
$max = ($this->cE->getSecondsInMinute($this->calendar->thisMinute())-1);
|
||||||
* @access public
|
if ($s > $max) {
|
||||||
*/
|
$this->errors[] = new Calendar_Validation_Error(
|
||||||
class Calendar_Validation_Error
|
'Second', $s, CALENDAR_VALUE_TOOLARGE.$max);
|
||||||
{
|
return false;
|
||||||
/**
|
}
|
||||||
* Date unit (e.g. month,hour,second) which failed test
|
return true;
|
||||||
* @var string
|
}
|
||||||
* @access private
|
|
||||||
*/
|
/**
|
||||||
var $unit;
|
* Iterates over any validation errors
|
||||||
|
*
|
||||||
/**
|
* @return mixed either Calendar_Validation_Error or false
|
||||||
* Value of unit which failed test
|
* @access public
|
||||||
* @var int
|
*/
|
||||||
* @access private
|
function fetch()
|
||||||
*/
|
{
|
||||||
var $value;
|
$error = each($this->errors);
|
||||||
|
if ($error) {
|
||||||
/**
|
return $error['value'];
|
||||||
* Validation error message
|
} else {
|
||||||
* @var string
|
reset($this->errors);
|
||||||
* @access private
|
return false;
|
||||||
*/
|
}
|
||||||
var $message;
|
}
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Constructs Calendar_Validation_Error
|
/**
|
||||||
* @param string Date unit (e.g. month,hour,second)
|
* For Validation Error messages
|
||||||
* @param int Value of unit which failed test
|
*
|
||||||
* @param string Validation error message
|
* @category Date and Time
|
||||||
* @access protected
|
* @package Calendar
|
||||||
*/
|
* @author Harry Fuecks <hfuecks@phppatterns.com>
|
||||||
function Calendar_Validation_Error($unit,$value,$message)
|
* @copyright 2003-2007 Harry Fuecks
|
||||||
{
|
* @license http://www.debian.org/misc/bsd.license BSD License (3 Clause)
|
||||||
$this->unit = $unit;
|
* @link http://pear.php.net/package/Calendar
|
||||||
$this->value = $value;
|
* @see Calendar::fetch()
|
||||||
$this->message = $message;
|
* @access public
|
||||||
}
|
*/
|
||||||
|
class Calendar_Validation_Error
|
||||||
/**
|
{
|
||||||
* Returns the Date unit
|
/**
|
||||||
* @return string
|
* Date unit (e.g. month,hour,second) which failed test
|
||||||
* @access public
|
* @var string
|
||||||
*/
|
* @access private
|
||||||
function getUnit()
|
*/
|
||||||
{
|
var $unit;
|
||||||
return $this->unit;
|
|
||||||
}
|
/**
|
||||||
|
* Value of unit which failed test
|
||||||
/**
|
* @var int
|
||||||
* Returns the value of the unit
|
* @access private
|
||||||
* @return int
|
*/
|
||||||
* @access public
|
var $value;
|
||||||
*/
|
|
||||||
function getValue()
|
/**
|
||||||
{
|
* Validation error message
|
||||||
return $this->value;
|
* @var string
|
||||||
}
|
* @access private
|
||||||
|
*/
|
||||||
/**
|
var $message;
|
||||||
* Returns the validation error message
|
|
||||||
* @return string
|
/**
|
||||||
* @access public
|
* Constructs Calendar_Validation_Error
|
||||||
*/
|
*
|
||||||
function getMessage()
|
* @param string $unit Date unit (e.g. month,hour,second)
|
||||||
{
|
* @param int $value Value of unit which failed test
|
||||||
return $this->message;
|
* @param string $message Validation error message
|
||||||
}
|
*
|
||||||
|
* @access protected
|
||||||
/**
|
*/
|
||||||
* Returns a string containing the unit, value and error message
|
function Calendar_Validation_Error($unit, $value, $message)
|
||||||
* @return string
|
{
|
||||||
* @access public
|
$this->unit = $unit;
|
||||||
*/
|
$this->value = $value;
|
||||||
function toString ()
|
$this->message = $message;
|
||||||
{
|
}
|
||||||
return $this->unit.' = '.$this->value.' ['.$this->message.']';
|
|
||||||
}
|
/**
|
||||||
}
|
* Returns the Date unit
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function getUnit()
|
||||||
|
{
|
||||||
|
return $this->unit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the value of the unit
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function getValue()
|
||||||
|
{
|
||||||
|
return $this->value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the validation error message
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function getMessage()
|
||||||
|
{
|
||||||
|
return $this->message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a string containing the unit, value and error message
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function toString ()
|
||||||
|
{
|
||||||
|
return $this->unit.' = '.$this->value.' ['.$this->message.']';
|
||||||
|
}
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
@@ -1,394 +1,470 @@
|
|||||||
<?php
|
<?php
|
||||||
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||||
//
|
|
||||||
// +----------------------------------------------------------------------+
|
/**
|
||||||
// | PHP Version 4 |
|
* Contains the Calendar_Week class
|
||||||
// +----------------------------------------------------------------------+
|
*
|
||||||
// | Copyright (c) 1997-2002 The PHP Group |
|
* PHP versions 4 and 5
|
||||||
// +----------------------------------------------------------------------+
|
*
|
||||||
// | This source file is subject to version 2.02 of the PHP license, |
|
* LICENSE: Redistribution and use in source and binary forms, with or without
|
||||||
// | that is bundled with this package in the file LICENSE, and is |
|
* modification, are permitted provided that the following conditions are met:
|
||||||
// | available at through the world-wide-web at |
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
// | http://www.php.net/license/3_0.txt. |
|
* notice, this list of conditions and the following disclaimer.
|
||||||
// | If you did not receive a copy of the PHP license and are unable to |
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
// | obtain it through the world-wide-web, please send a note to |
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
// | license@php.net so we can mail you a copy immediately. |
|
* documentation and/or other materials provided with the distribution.
|
||||||
// +----------------------------------------------------------------------+
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
// | Authors: Harry Fuecks <hfuecks@phppatterns.com> |
|
* derived from this software without specific prior written permission.
|
||||||
// | Lorenzo Alberton <l dot alberton at quipo dot it> |
|
*
|
||||||
// +----------------------------------------------------------------------+
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||||
//
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
// $Id: Week.php,v 1.7 2005/10/22 10:26:49 quipo Exp $
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
//
|
* IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
/**
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* @package Calendar
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
* @version $Id: Week.php,v 1.7 2005/10/22 10:26:49 quipo Exp $
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
*/
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
/**
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
* Allows Calendar include path to be redefined
|
*
|
||||||
* @ignore
|
* @category Date and Time
|
||||||
*/
|
* @package Calendar
|
||||||
if (!defined('CALENDAR_ROOT')) {
|
* @author Harry Fuecks <hfuecks@phppatterns.com>
|
||||||
define('CALENDAR_ROOT', 'Calendar'.DIRECTORY_SEPARATOR);
|
* @author Lorenzo Alberton <l.alberton@quipo.it>
|
||||||
}
|
* @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton
|
||||||
|
* @license http://www.debian.org/misc/bsd.license BSD License (3 Clause)
|
||||||
/**
|
* @version CVS: $Id: Week.php 300729 2010-06-24 12:05:53Z quipo $
|
||||||
* Load Calendar base class
|
* @link http://pear.php.net/package/Calendar
|
||||||
*/
|
*/
|
||||||
require_once CALENDAR_ROOT.'Calendar.php';
|
|
||||||
|
/**
|
||||||
/**
|
* Allows Calendar include path to be redefined
|
||||||
* Represents a Week and builds Days in tabular format<br>
|
* @ignore
|
||||||
* <code>
|
*/
|
||||||
* require_once 'Calendar'.DIRECTORY_SEPARATOR.'Week.php';
|
if (!defined('CALENDAR_ROOT')) {
|
||||||
* $Week = & new Calendar_Week(2003, 10, 1); Oct 2003, 1st tabular week
|
define('CALENDAR_ROOT', 'Calendar'.DIRECTORY_SEPARATOR);
|
||||||
* echo '<tr>';
|
}
|
||||||
* while ($Day = & $Week->fetch()) {
|
|
||||||
* if ($Day->isEmpty()) {
|
/**
|
||||||
* echo '<td> </td>';
|
* Load Calendar base class
|
||||||
* } else {
|
*/
|
||||||
* echo '<td>'.$Day->thisDay().'</td>';
|
require_once CALENDAR_ROOT.'Calendar.php';
|
||||||
* }
|
|
||||||
* }
|
/**
|
||||||
* echo '</tr>';
|
* Represents a Week and builds Days in tabular format<br>
|
||||||
* </code>
|
* <code>
|
||||||
* @package Calendar
|
* require_once 'Calendar/Week.php';
|
||||||
* @access public
|
* $Week = new Calendar_Week(2003, 10, 1); Oct 2003, 1st tabular week
|
||||||
*/
|
* echo '<tr>';
|
||||||
class Calendar_Week extends Calendar
|
* while ($Day = & $Week->fetch()) {
|
||||||
{
|
* if ($Day->isEmpty()) {
|
||||||
/**
|
* echo '<td> </td>';
|
||||||
* Instance of Calendar_Table_Helper
|
* } else {
|
||||||
* @var Calendar_Table_Helper
|
* echo '<td>'.$Day->thisDay().'</td>';
|
||||||
* @access private
|
* }
|
||||||
*/
|
* }
|
||||||
var $tableHelper;
|
* echo '</tr>';
|
||||||
|
* </code>
|
||||||
/**
|
*
|
||||||
* Stores the timestamp of the first day of this week
|
* @category Date and Time
|
||||||
* @access private
|
* @package Calendar
|
||||||
* @var object
|
* @author Harry Fuecks <hfuecks@phppatterns.com>
|
||||||
*/
|
* @author Lorenzo Alberton <l.alberton@quipo.it>
|
||||||
var $thisWeek;
|
* @copyright 2003-2007 Harry Fuecks, Lorenzo Alberton
|
||||||
|
* @license http://www.debian.org/misc/bsd.license BSD License (3 Clause)
|
||||||
/**
|
* @link http://pear.php.net/package/Calendar
|
||||||
* Stores the timestamp of first day of previous week
|
*/
|
||||||
* @access private
|
class Calendar_Week extends Calendar
|
||||||
* @var object
|
{
|
||||||
*/
|
/**
|
||||||
var $prevWeek;
|
* Instance of Calendar_Table_Helper
|
||||||
|
* @var Calendar_Table_Helper
|
||||||
/**
|
* @access private
|
||||||
* Stores the timestamp of first day of next week
|
*/
|
||||||
* @access private
|
var $tableHelper;
|
||||||
* @var object
|
|
||||||
*/
|
/**
|
||||||
var $nextWeek;
|
* Stores the timestamp of the first day of this week
|
||||||
|
* @access private
|
||||||
/**
|
* @var object
|
||||||
* Used by build() to set empty days
|
*/
|
||||||
* @access private
|
var $thisWeek;
|
||||||
* @var boolean
|
|
||||||
*/
|
/**
|
||||||
var $firstWeek = false;
|
* Stores the timestamp of first day of previous week
|
||||||
|
* @access private
|
||||||
/**
|
* @var object
|
||||||
* Used by build() to set empty days
|
*/
|
||||||
* @access private
|
var $prevWeek;
|
||||||
* @var boolean
|
|
||||||
*/
|
/**
|
||||||
var $lastWeek = false;
|
* Stores the timestamp of first day of next week
|
||||||
|
* @access private
|
||||||
/**
|
* @var object
|
||||||
* First day of the week (0=sunday, 1=monday...)
|
*/
|
||||||
* @access private
|
var $nextWeek;
|
||||||
* @var boolean
|
|
||||||
*/
|
/**
|
||||||
var $firstDay = 1;
|
* Used by build() to set empty days
|
||||||
|
* @access private
|
||||||
/**
|
* @var boolean
|
||||||
* Constructs Week
|
*/
|
||||||
* @param int year e.g. 2003
|
var $firstWeek = false;
|
||||||
* @param int month e.g. 5
|
|
||||||
* @param int a day of the desired week
|
/**
|
||||||
* @param int (optional) first day of week (e.g. 0 for Sunday, 2 for Tuesday etc.)
|
* Used by build() to set empty days
|
||||||
* @access public
|
* @access private
|
||||||
*/
|
* @var boolean
|
||||||
function Calendar_Week($y, $m, $d, $firstDay=null)
|
*/
|
||||||
{
|
var $lastWeek = false;
|
||||||
require_once CALENDAR_ROOT.'Table/Helper.php';
|
|
||||||
Calendar::Calendar($y, $m, $d);
|
/**
|
||||||
$this->firstDay = $this->defineFirstDayOfWeek($firstDay);
|
* First day of the week (0=sunday, 1=monday...)
|
||||||
$this->tableHelper = & new Calendar_Table_Helper($this, $this->firstDay);
|
* @access private
|
||||||
$this->thisWeek = $this->tableHelper->getWeekStart($y, $m, $d, $this->firstDay);
|
* @var boolean
|
||||||
$this->prevWeek = $this->tableHelper->getWeekStart($y, $m, $d - $this->cE->getDaysInWeek(
|
*/
|
||||||
$this->thisYear(),
|
var $firstDay = 1;
|
||||||
$this->thisMonth(),
|
|
||||||
$this->thisDay()), $this->firstDay);
|
/**
|
||||||
$this->nextWeek = $this->tableHelper->getWeekStart($y, $m, $d + $this->cE->getDaysInWeek(
|
* Constructs Week
|
||||||
$this->thisYear(),
|
*
|
||||||
$this->thisMonth(),
|
* @param int $y year e.g. 2003
|
||||||
$this->thisDay()), $this->firstDay);
|
* @param int $m month e.g. 5
|
||||||
}
|
* @param int $d a day of the desired week
|
||||||
|
* @param int $firstDay (optional) first day of week (e.g. 0 for Sunday, 2 for Tuesday etc.)
|
||||||
/**
|
*
|
||||||
* Defines the calendar by a timestamp (Unix or ISO-8601), replacing values
|
* @access public
|
||||||
* passed to the constructor
|
*/
|
||||||
* @param int|string Unix or ISO-8601 timestamp
|
function Calendar_Week($y, $m, $d, $firstDay = null)
|
||||||
* @return void
|
{
|
||||||
* @access public
|
include_once CALENDAR_ROOT.'Table/Helper.php';
|
||||||
*/
|
parent::Calendar($y, $m, $d);
|
||||||
function setTimestamp($ts)
|
$this->firstDay = $this->defineFirstDayOfWeek($firstDay);
|
||||||
{
|
$this->tableHelper = new Calendar_Table_Helper($this, $this->firstDay);
|
||||||
parent::setTimestamp($ts);
|
$this->thisWeek = $this->tableHelper->getWeekStart($y, $m, $d, $this->firstDay);
|
||||||
$this->thisWeek = $this->tableHelper->getWeekStart(
|
$this->prevWeek = $this->tableHelper->getWeekStart(
|
||||||
$this->year, $this->month, $this->day, $this->firstDay
|
$y,
|
||||||
);
|
$m,
|
||||||
$this->prevWeek = $this->tableHelper->getWeekStart(
|
$d - $this->cE->getDaysInWeek(
|
||||||
$this->year, $this->month, $this->day - $this->cE->getDaysInWeek(
|
$this->thisYear(),
|
||||||
$this->thisYear(),
|
$this->thisMonth(),
|
||||||
$this->thisMonth(),
|
$this->thisDay()
|
||||||
$this->thisDay()), $this->firstDay
|
),
|
||||||
);
|
$this->firstDay
|
||||||
$this->nextWeek = $this->tableHelper->getWeekStart(
|
);
|
||||||
$this->year, $this->month, $this->day + $this->cE->getDaysInWeek(
|
$this->nextWeek = $this->tableHelper->getWeekStart(
|
||||||
$this->thisYear(),
|
$y,
|
||||||
$this->thisMonth(),
|
$m,
|
||||||
$this->thisDay()), $this->firstDay
|
$d + $this->cE->getDaysInWeek(
|
||||||
);
|
$this->thisYear(),
|
||||||
}
|
$this->thisMonth(),
|
||||||
|
$this->thisDay()
|
||||||
/**
|
),
|
||||||
* Builds Calendar_Day objects for this Week
|
$this->firstDay
|
||||||
* @param array (optional) Calendar_Day objects representing selected dates
|
);
|
||||||
* @return boolean
|
}
|
||||||
* @access public
|
|
||||||
*/
|
/**
|
||||||
function build($sDates = array())
|
* Defines the calendar by a timestamp (Unix or ISO-8601), replacing values
|
||||||
{
|
* passed to the constructor
|
||||||
require_once CALENDAR_ROOT.'Day.php';
|
*
|
||||||
$year = $this->cE->stampToYear($this->thisWeek);
|
* @param int|string $ts Unix or ISO-8601 timestamp
|
||||||
$month = $this->cE->stampToMonth($this->thisWeek);
|
*
|
||||||
$day = $this->cE->stampToDay($this->thisWeek);
|
* @return void
|
||||||
$end = $this->cE->getDaysInWeek(
|
* @access public
|
||||||
$this->thisYear(),
|
*/
|
||||||
$this->thisMonth(),
|
function setTimestamp($ts)
|
||||||
$this->thisDay()
|
{
|
||||||
);
|
parent::setTimestamp($ts);
|
||||||
|
$this->thisWeek = $this->tableHelper->getWeekStart(
|
||||||
for ($i=1; $i <= $end; $i++) {
|
$this->year, $this->month, $this->day, $this->firstDay
|
||||||
$stamp = $this->cE->dateToStamp($year, $month, $day++);
|
);
|
||||||
$this->children[$i] = new Calendar_Day(
|
$this->prevWeek = $this->tableHelper->getWeekStart(
|
||||||
$this->cE->stampToYear($stamp),
|
$this->year,
|
||||||
$this->cE->stampToMonth($stamp),
|
$this->month,
|
||||||
$this->cE->stampToDay($stamp));
|
$this->day - $this->cE->getDaysInWeek(
|
||||||
}
|
$this->thisYear(),
|
||||||
|
$this->thisMonth(),
|
||||||
//set empty days (@see Calendar_Month_Weeks::build())
|
$this->thisDay()
|
||||||
if ($this->firstWeek) {
|
),
|
||||||
$eBefore = $this->tableHelper->getEmptyDaysBefore();
|
$this->firstDay
|
||||||
for ($i=1; $i <= $eBefore; $i++) {
|
);
|
||||||
$this->children[$i]->setEmpty();
|
$this->nextWeek = $this->tableHelper->getWeekStart(
|
||||||
}
|
$this->year,
|
||||||
}
|
$this->month,
|
||||||
if ($this->lastWeek) {
|
$this->day + $this->cE->getDaysInWeek(
|
||||||
$eAfter = $this->tableHelper->getEmptyDaysAfterOffset();
|
$this->thisYear(),
|
||||||
for ($i = $eAfter+1; $i <= $end; $i++) {
|
$this->thisMonth(),
|
||||||
$this->children[$i]->setEmpty();
|
$this->thisDay()
|
||||||
}
|
),
|
||||||
}
|
$this->firstDay
|
||||||
|
);
|
||||||
if (count($sDates) > 0) {
|
}
|
||||||
$this->setSelection($sDates);
|
|
||||||
}
|
/**
|
||||||
return true;
|
* Builds Calendar_Day objects for this Week
|
||||||
}
|
*
|
||||||
|
* @param array $sDates (optional) Calendar_Day objects representing selected dates
|
||||||
/**
|
*
|
||||||
* @param boolean
|
* @return boolean
|
||||||
* @return void
|
* @access public
|
||||||
* @access private
|
*/
|
||||||
*/
|
function build($sDates = array())
|
||||||
function setFirst($state=true)
|
{
|
||||||
{
|
include_once CALENDAR_ROOT.'Day.php';
|
||||||
$this->firstWeek = $state;
|
$year = $this->cE->stampToYear($this->thisWeek);
|
||||||
}
|
$month = $this->cE->stampToMonth($this->thisWeek);
|
||||||
|
$day = $this->cE->stampToDay($this->thisWeek);
|
||||||
/**
|
$end = $this->cE->getDaysInWeek(
|
||||||
* @param boolean
|
$this->thisYear(),
|
||||||
* @return void
|
$this->thisMonth(),
|
||||||
* @access private
|
$this->thisDay()
|
||||||
*/
|
);
|
||||||
function setLast($state=true)
|
|
||||||
{
|
for ($i=1; $i <= $end; $i++) {
|
||||||
$this->lastWeek = $state;
|
$stamp = $this->cE->dateToStamp($year, $month, $day++);
|
||||||
}
|
$this->children[$i] = new Calendar_Day(
|
||||||
|
$this->cE->stampToYear($stamp),
|
||||||
/**
|
$this->cE->stampToMonth($stamp),
|
||||||
* Called from build()
|
$this->cE->stampToDay($stamp)
|
||||||
* @param array
|
);
|
||||||
* @return void
|
}
|
||||||
* @access private
|
|
||||||
*/
|
//set empty days (@see Calendar_Month_Weeks::build())
|
||||||
function setSelection($sDates)
|
if ($this->firstWeek) {
|
||||||
{
|
$eBefore = $this->tableHelper->getEmptyDaysBefore();
|
||||||
foreach ($sDates as $sDate) {
|
for ($i=1; $i <= $eBefore; $i++) {
|
||||||
foreach ($this->children as $key => $child) {
|
$this->children[$i]->setEmpty();
|
||||||
if ($child->thisDay() == $sDate->thisDay() &&
|
}
|
||||||
$child->thisMonth() == $sDate->thisMonth() &&
|
}
|
||||||
$child->thisYear() == $sDate->thisYear()
|
if ($this->lastWeek) {
|
||||||
) {
|
$eAfter = $this->tableHelper->getEmptyDaysAfterOffset();
|
||||||
$this->children[$key] = $sDate;
|
for ($i = $eAfter+1; $i <= $end; $i++) {
|
||||||
$this->children[$key]->setSelected();
|
$this->children[$i]->setEmpty();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
reset($this->children);
|
if (count($sDates) > 0) {
|
||||||
}
|
$this->setSelection($sDates);
|
||||||
|
}
|
||||||
/**
|
return true;
|
||||||
* Gets the value of the previous week, according to the requested format
|
}
|
||||||
*
|
|
||||||
* @param string $format ['timestamp' | 'n_in_month' | 'n_in_year' | 'array']
|
/**
|
||||||
* @return mixed
|
* Set as first week of the month
|
||||||
* @access public
|
*
|
||||||
*/
|
* @param boolean $state whether it's first or not
|
||||||
function prevWeek($format = 'n_in_month')
|
*
|
||||||
{
|
* @return void
|
||||||
switch (strtolower($format)) {
|
* @access private
|
||||||
case 'int':
|
*/
|
||||||
case 'n_in_month':
|
function setFirst($state = true)
|
||||||
return ($this->firstWeek) ? null : $this->thisWeek('n_in_month') -1;
|
{
|
||||||
break;
|
$this->firstWeek = $state;
|
||||||
case 'n_in_year':
|
}
|
||||||
return $this->cE->getWeekNInYear(
|
|
||||||
$this->cE->stampToYear($this->prevWeek),
|
/**
|
||||||
$this->cE->stampToMonth($this->prevWeek),
|
* Set as last week of the month
|
||||||
$this->cE->stampToDay($this->prevWeek));
|
*
|
||||||
break;
|
* @param boolean $state whether it's lasst or not
|
||||||
case 'array':
|
*
|
||||||
return $this->toArray($this->prevWeek);
|
* @return void
|
||||||
break;
|
* @access private
|
||||||
case 'object':
|
*/
|
||||||
require_once CALENDAR_ROOT.'Factory.php';
|
function setLast($state = true)
|
||||||
return Calendar_Factory::createByTimestamp('Week', $this->prevWeek);
|
{
|
||||||
break;
|
$this->lastWeek = $state;
|
||||||
case 'timestamp':
|
}
|
||||||
default:
|
|
||||||
return $this->prevWeek;
|
/**
|
||||||
break;
|
* Called from build()
|
||||||
}
|
*
|
||||||
}
|
* @param array $sDates Calendar_Day objects representing selected dates
|
||||||
|
*
|
||||||
/**
|
* @return void
|
||||||
* Gets the value of the current week, according to the requested format
|
* @access private
|
||||||
*
|
*/
|
||||||
* @param string $format ['timestamp' | 'n_in_month' | 'n_in_year' | 'array']
|
function setSelection($sDates)
|
||||||
* @return mixed
|
{
|
||||||
* @access public
|
foreach ($sDates as $sDate) {
|
||||||
*/
|
foreach ($this->children as $key => $child) {
|
||||||
function thisWeek($format = 'n_in_month')
|
if ($child->thisDay() == $sDate->thisDay() &&
|
||||||
{
|
$child->thisMonth() == $sDate->thisMonth() &&
|
||||||
switch (strtolower($format)) {
|
$child->thisYear() == $sDate->thisYear()
|
||||||
case 'int':
|
) {
|
||||||
case 'n_in_month':
|
$this->children[$key] = $sDate;
|
||||||
if ($this->firstWeek) {
|
$this->children[$key]->setSelected();
|
||||||
return 1;
|
}
|
||||||
}
|
}
|
||||||
if ($this->lastWeek) {
|
}
|
||||||
return $this->cE->getWeeksInMonth(
|
reset($this->children);
|
||||||
$this->thisYear(),
|
}
|
||||||
$this->thisMonth(),
|
|
||||||
$this->firstDay);
|
/**
|
||||||
}
|
* Returns the value for this year
|
||||||
return $this->cE->getWeekNInMonth(
|
*
|
||||||
$this->thisYear(),
|
* When a on the first/last week of the year, the year of the week is
|
||||||
$this->thisMonth(),
|
* calculated according to ISO-8601
|
||||||
$this->thisDay(),
|
*
|
||||||
$this->firstDay);
|
* @param string $format return value format ['int' | 'timestamp' | 'object' | 'array']
|
||||||
break;
|
*
|
||||||
case 'n_in_year':
|
* @return int e.g. 2003 or timestamp
|
||||||
return $this->cE->getWeekNInYear(
|
* @access public
|
||||||
$this->cE->stampToYear($this->thisWeek),
|
*/
|
||||||
$this->cE->stampToMonth($this->thisWeek),
|
function thisYear($format = 'int')
|
||||||
$this->cE->stampToDay($this->thisWeek));
|
{
|
||||||
break;
|
if (null !== $this->thisWeek) {
|
||||||
case 'array':
|
$tmp_cal = new Calendar();
|
||||||
return $this->toArray($this->thisWeek);
|
$tmp_cal->setTimestamp($this->thisWeek);
|
||||||
break;
|
$first_dow = $tmp_cal->thisDay('array');
|
||||||
case 'object':
|
$days_in_week = $tmp_cal->cE->getDaysInWeek($tmp_cal->year, $tmp_cal->month, $tmp_cal->day);
|
||||||
require_once CALENDAR_ROOT.'Factory.php';
|
$tmp_cal->day += $days_in_week;
|
||||||
return Calendar_Factory::createByTimestamp('Week', $this->thisWeek);
|
$last_dow = $tmp_cal->thisDay('array');
|
||||||
break;
|
|
||||||
case 'timestamp':
|
if ($first_dow['year'] == $last_dow['year']) {
|
||||||
default:
|
return $first_dow['year'];
|
||||||
return $this->thisWeek;
|
}
|
||||||
break;
|
|
||||||
}
|
if ($last_dow['day'] > floor($days_in_week / 2)) {
|
||||||
}
|
return $last_dow['year'];
|
||||||
|
}
|
||||||
/**
|
return $first_dow['year'];
|
||||||
* Gets the value of the following week, according to the requested format
|
}
|
||||||
*
|
return parent::thisYear();
|
||||||
* @param string $format ['timestamp' | 'n_in_month' | 'n_in_year' | 'array']
|
}
|
||||||
* @return mixed
|
|
||||||
* @access public
|
/**
|
||||||
*/
|
* Gets the value of the previous week, according to the requested format
|
||||||
function nextWeek($format = 'n_in_month')
|
*
|
||||||
{
|
* @param string $format ['timestamp' | 'n_in_month' | 'n_in_year' | 'array']
|
||||||
switch (strtolower($format)) {
|
*
|
||||||
case 'int':
|
* @return mixed
|
||||||
case 'n_in_month':
|
* @access public
|
||||||
return ($this->lastWeek) ? null : $this->thisWeek('n_in_month') +1;
|
*/
|
||||||
break;
|
function prevWeek($format = 'n_in_month')
|
||||||
case 'n_in_year':
|
{
|
||||||
return $this->cE->getWeekNInYear(
|
switch (strtolower($format)) {
|
||||||
$this->cE->stampToYear($this->nextWeek),
|
case 'int':
|
||||||
$this->cE->stampToMonth($this->nextWeek),
|
case 'n_in_month':
|
||||||
$this->cE->stampToDay($this->nextWeek));
|
return ($this->firstWeek) ? null : $this->thisWeek('n_in_month') -1;
|
||||||
break;
|
case 'n_in_year':
|
||||||
case 'array':
|
return $this->cE->getWeekNInYear(
|
||||||
return $this->toArray($this->nextWeek);
|
$this->cE->stampToYear($this->prevWeek),
|
||||||
break;
|
$this->cE->stampToMonth($this->prevWeek),
|
||||||
case 'object':
|
$this->cE->stampToDay($this->prevWeek));
|
||||||
require_once CALENDAR_ROOT.'Factory.php';
|
case 'array':
|
||||||
return Calendar_Factory::createByTimestamp('Week', $this->nextWeek);
|
return $this->toArray($this->prevWeek);
|
||||||
break;
|
case 'object':
|
||||||
case 'timestamp':
|
include_once CALENDAR_ROOT.'Factory.php';
|
||||||
default:
|
return Calendar_Factory::createByTimestamp('Week', $this->prevWeek);
|
||||||
return $this->nextWeek;
|
case 'timestamp':
|
||||||
break;
|
default:
|
||||||
}
|
return $this->prevWeek;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
/**
|
|
||||||
* Returns the instance of Calendar_Table_Helper.
|
/**
|
||||||
* Called from Calendar_Validator::isValidWeek
|
* Gets the value of the current week, according to the requested format
|
||||||
* @return Calendar_Table_Helper
|
*
|
||||||
* @access protected
|
* @param string $format ['timestamp' | 'n_in_month' | 'n_in_year' | 'array']
|
||||||
*/
|
*
|
||||||
function & getHelper()
|
* @return mixed
|
||||||
{
|
* @access public
|
||||||
return $this->tableHelper;
|
*/
|
||||||
}
|
function thisWeek($format = 'n_in_month')
|
||||||
|
{
|
||||||
/**
|
switch (strtolower($format)) {
|
||||||
* Makes sure theres a value for $this->day
|
case 'int':
|
||||||
* @return void
|
case 'n_in_month':
|
||||||
* @access private
|
if ($this->firstWeek) {
|
||||||
*/
|
return 1;
|
||||||
function findFirstDay()
|
}
|
||||||
{
|
if ($this->lastWeek) {
|
||||||
if (!count($this->children) > 0) {
|
return $this->cE->getWeeksInMonth(
|
||||||
$this->build();
|
$this->thisYear(),
|
||||||
foreach ($this->children as $Day) {
|
$this->thisMonth(),
|
||||||
if (!$Day->isEmpty()) {
|
$this->firstDay);
|
||||||
$this->day = $Day->thisDay();
|
}
|
||||||
break;
|
return $this->cE->getWeekNInMonth(
|
||||||
}
|
$this->thisYear(),
|
||||||
}
|
$this->thisMonth(),
|
||||||
}
|
$this->thisDay(),
|
||||||
}
|
$this->firstDay);
|
||||||
}
|
case 'n_in_year':
|
||||||
|
return $this->cE->getWeekNInYear(
|
||||||
|
$this->cE->stampToYear($this->thisWeek),
|
||||||
|
$this->cE->stampToMonth($this->thisWeek),
|
||||||
|
$this->cE->stampToDay($this->thisWeek));
|
||||||
|
case 'array':
|
||||||
|
return $this->toArray($this->thisWeek);
|
||||||
|
case 'object':
|
||||||
|
include_once CALENDAR_ROOT.'Factory.php';
|
||||||
|
return Calendar_Factory::createByTimestamp('Week', $this->thisWeek);
|
||||||
|
case 'timestamp':
|
||||||
|
default:
|
||||||
|
return $this->thisWeek;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the value of the following week, according to the requested format
|
||||||
|
*
|
||||||
|
* @param string $format ['timestamp' | 'n_in_month' | 'n_in_year' | 'array']
|
||||||
|
*
|
||||||
|
* @return mixed
|
||||||
|
* @access public
|
||||||
|
*/
|
||||||
|
function nextWeek($format = 'n_in_month')
|
||||||
|
{
|
||||||
|
switch (strtolower($format)) {
|
||||||
|
case 'int':
|
||||||
|
case 'n_in_month':
|
||||||
|
return ($this->lastWeek) ? null : $this->thisWeek('n_in_month') +1;
|
||||||
|
case 'n_in_year':
|
||||||
|
return $this->cE->getWeekNInYear(
|
||||||
|
$this->cE->stampToYear($this->nextWeek),
|
||||||
|
$this->cE->stampToMonth($this->nextWeek),
|
||||||
|
$this->cE->stampToDay($this->nextWeek));
|
||||||
|
case 'array':
|
||||||
|
return $this->toArray($this->nextWeek);
|
||||||
|
case 'object':
|
||||||
|
include_once CALENDAR_ROOT.'Factory.php';
|
||||||
|
return Calendar_Factory::createByTimestamp('Week', $this->nextWeek);
|
||||||
|
case 'timestamp':
|
||||||
|
default:
|
||||||
|
return $this->nextWeek;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the instance of Calendar_Table_Helper.
|
||||||
|
* Called from Calendar_Validator::isValidWeek
|
||||||
|
*
|
||||||
|
* @return Calendar_Table_Helper
|
||||||
|
* @access protected
|
||||||
|
*/
|
||||||
|
function & getHelper()
|
||||||
|
{
|
||||||
|
return $this->tableHelper;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Makes sure theres a value for $this->day
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
function findFirstDay()
|
||||||
|
{
|
||||||
|
if (!count($this->children) > 0) {
|
||||||
|
$this->build();
|
||||||
|
foreach ($this->children as $Day) {
|
||||||
|
if (!$Day->isEmpty()) {
|
||||||
|
$this->day = $Day->thisDay();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
@@ -1,113 +1,140 @@
|
|||||||
<?php
|
<?php
|
||||||
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
||||||
//
|
|
||||||
// +----------------------------------------------------------------------+
|
/**
|
||||||
// | PHP Version 4 |
|
* Contains the Calendar_Minute class
|
||||||
// +----------------------------------------------------------------------+
|
*
|
||||||
// | Copyright (c) 1997-2002 The PHP Group |
|
* PHP versions 4 and 5
|
||||||
// +----------------------------------------------------------------------+
|
*
|
||||||
// | This source file is subject to version 2.02 of the PHP license, |
|
* LICENSE: Redistribution and use in source and binary forms, with or without
|
||||||
// | that is bundled with this package in the file LICENSE, and is |
|
* modification, are permitted provided that the following conditions are met:
|
||||||
// | available at through the world-wide-web at |
|
* 1. Redistributions of source code must retain the above copyright
|
||||||
// | http://www.php.net/license/3_0.txt. |
|
* notice, this list of conditions and the following disclaimer.
|
||||||
// | If you did not receive a copy of the PHP license and are unable to |
|
* 2. Redistributions in binary form must reproduce the above copyright
|
||||||
// | obtain it through the world-wide-web, please send a note to |
|
* notice, this list of conditions and the following disclaimer in the
|
||||||
// | license@php.net so we can mail you a copy immediately. |
|
* documentation and/or other materials provided with the distribution.
|
||||||
// +----------------------------------------------------------------------+
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
// | Authors: Harry Fuecks <hfuecks@phppatterns.com> |
|
* derived from this software without specific prior written permission.
|
||||||
// +----------------------------------------------------------------------+
|
*
|
||||||
//
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
|
||||||
// $Id: Year.php,v 1.4 2005/10/22 10:25:39 quipo Exp $
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
//
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
||||||
/**
|
* IN NO EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY
|
||||||
* @package Calendar
|
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
* @version $Id: Year.php,v 1.4 2005/10/22 10:25:39 quipo Exp $
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
*/
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
/**
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||||
* Allows Calendar include path to be redefined
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
* @ignore
|
*
|
||||||
*/
|
* @category Date and Time
|
||||||
if (!defined('CALENDAR_ROOT')) {
|
* @package Calendar
|
||||||
define('CALENDAR_ROOT', 'Calendar'.DIRECTORY_SEPARATOR);
|
* @author Harry Fuecks <hfuecks@phppatterns.com>
|
||||||
}
|
* @copyright 2003-2007 Harry Fuecks
|
||||||
|
* @license http://www.debian.org/misc/bsd.license BSD License (3 Clause)
|
||||||
/**
|
* @version CVS: $Id: Year.php 300728 2010-06-24 11:43:56Z quipo $
|
||||||
* Load Calendar base class
|
* @link http://pear.php.net/package/Calendar
|
||||||
*/
|
*/
|
||||||
require_once CALENDAR_ROOT.'Calendar.php';
|
|
||||||
|
/**
|
||||||
/**
|
* Allows Calendar include path to be redefined
|
||||||
* Represents a Year and builds Months<br>
|
* @ignore
|
||||||
* <code>
|
*/
|
||||||
* require_once 'Calendar'.DIRECTORY_SEPARATOR.'Year.php';
|
if (!defined('CALENDAR_ROOT')) {
|
||||||
* $Year = & new Calendar_Year(2003, 10, 21); // 21st Oct 2003
|
define('CALENDAR_ROOT', 'Calendar'.DIRECTORY_SEPARATOR);
|
||||||
* $Year->build(); // Build Calendar_Month objects
|
}
|
||||||
* while ($Month = & $Year->fetch()) {
|
|
||||||
* echo $Month->thisMonth().'<br />';
|
/**
|
||||||
* }
|
* Load Calendar base class
|
||||||
* </code>
|
*/
|
||||||
* @package Calendar
|
require_once CALENDAR_ROOT.'Calendar.php';
|
||||||
* @access public
|
|
||||||
*/
|
/**
|
||||||
class Calendar_Year extends Calendar
|
* Represents a Year and builds Months<br>
|
||||||
{
|
* <code>
|
||||||
/**
|
* require_once 'Calendar'.DIRECTORY_SEPARATOR.'Year.php';
|
||||||
* Constructs Calendar_Year
|
* $Year = & new Calendar_Year(2003, 10, 21); // 21st Oct 2003
|
||||||
* @param int year e.g. 2003
|
* $Year->build(); // Build Calendar_Month objects
|
||||||
* @access public
|
* while ($Month = & $Year->fetch()) {
|
||||||
*/
|
* echo $Month->thisMonth().'<br />';
|
||||||
function Calendar_Year($y)
|
* }
|
||||||
{
|
* </code>
|
||||||
Calendar::Calendar($y);
|
*
|
||||||
}
|
* @category Date and Time
|
||||||
|
* @package Calendar
|
||||||
/**
|
* @author Harry Fuecks <hfuecks@phppatterns.com>
|
||||||
* Builds the Months of the Year.<br>
|
* @copyright 2003-2007 Harry Fuecks
|
||||||
* <b>Note:</b> by defining the constant CALENDAR_MONTH_STATE you can
|
* @license http://www.debian.org/misc/bsd.license BSD License (3 Clause)
|
||||||
* control what class of Calendar_Month is built e.g.;
|
* @link http://pear.php.net/package/Calendar
|
||||||
* <code>
|
* @access public
|
||||||
* require_once 'Calendar/Calendar_Year.php';
|
*/
|
||||||
* define ('CALENDAR_MONTH_STATE',CALENDAR_USE_MONTH_WEEKDAYS); // Use Calendar_Month_Weekdays
|
class Calendar_Year extends Calendar
|
||||||
* // define ('CALENDAR_MONTH_STATE',CALENDAR_USE_MONTH_WEEKS); // Use Calendar_Month_Weeks
|
{
|
||||||
* // define ('CALENDAR_MONTH_STATE',CALENDAR_USE_MONTH); // Use Calendar_Month
|
/**
|
||||||
* </code>
|
* Constructs Calendar_Year
|
||||||
* It defaults to building Calendar_Month objects.
|
*
|
||||||
* @param array (optional) array of Calendar_Month objects representing selected dates
|
* @param int $y year e.g. 2003
|
||||||
* @param int (optional) first day of week (e.g. 0 for Sunday, 2 for Tuesday etc.)
|
*
|
||||||
* @return boolean
|
* @access public
|
||||||
* @access public
|
*/
|
||||||
*/
|
function Calendar_Year($y)
|
||||||
function build($sDates = array(), $firstDay = null)
|
{
|
||||||
{
|
parent::Calendar($y);
|
||||||
require_once CALENDAR_ROOT.'Factory.php';
|
}
|
||||||
$this->firstDay = $this->defineFirstDayOfWeek($firstDay);
|
|
||||||
$monthsInYear = $this->cE->getMonthsInYear($this->thisYear());
|
/**
|
||||||
for ($i=1; $i <= $monthsInYear; $i++) {
|
* Builds the Months of the Year.<br>
|
||||||
$this->children[$i] = Calendar_Factory::create('Month', $this->year, $i);
|
* <b>Note:</b> by defining the constant CALENDAR_MONTH_STATE you can
|
||||||
}
|
* control what class of Calendar_Month is built e.g.;
|
||||||
if (count($sDates) > 0) {
|
* <code>
|
||||||
$this->setSelection($sDates);
|
* require_once 'Calendar/Calendar_Year.php';
|
||||||
}
|
* define ('CALENDAR_MONTH_STATE',CALENDAR_USE_MONTH_WEEKDAYS); // Use Calendar_Month_Weekdays
|
||||||
return true;
|
* // define ('CALENDAR_MONTH_STATE',CALENDAR_USE_MONTH_WEEKS); // Use Calendar_Month_Weeks
|
||||||
}
|
* // define ('CALENDAR_MONTH_STATE',CALENDAR_USE_MONTH); // Use Calendar_Month
|
||||||
|
* </code>
|
||||||
/**
|
* It defaults to building Calendar_Month objects.
|
||||||
* Called from build()
|
*
|
||||||
* @param array
|
* @param array $sDates (optional) array of Calendar_Month objects
|
||||||
* @return void
|
* representing selected dates
|
||||||
* @access private
|
* @param int $firstDay (optional) first day of week
|
||||||
*/
|
* (e.g. 0 for Sunday, 2 for Tuesday etc.)
|
||||||
function setSelection($sDates) {
|
*
|
||||||
foreach ($sDates as $sDate) {
|
* @return boolean
|
||||||
if ($this->year == $sDate->thisYear()) {
|
* @access public
|
||||||
$key = $sDate->thisMonth();
|
*/
|
||||||
if (isset($this->children[$key])) {
|
function build($sDates = array(), $firstDay = null)
|
||||||
$sDate->setSelected();
|
{
|
||||||
$this->children[$key] = $sDate;
|
include_once CALENDAR_ROOT.'Factory.php';
|
||||||
}
|
$this->firstDay = $this->defineFirstDayOfWeek($firstDay);
|
||||||
}
|
$monthsInYear = $this->cE->getMonthsInYear($this->thisYear());
|
||||||
}
|
for ($i=1; $i <= $monthsInYear; $i++) {
|
||||||
}
|
$this->children[$i] = Calendar_Factory::create('Month', $this->year, $i);
|
||||||
}
|
}
|
||||||
|
if (count($sDates) > 0) {
|
||||||
|
$this->setSelection($sDates);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called from build()
|
||||||
|
*
|
||||||
|
* @param array $sDates array of Calendar_Month objects representing selected dates
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @access private
|
||||||
|
*/
|
||||||
|
function setSelection($sDates)
|
||||||
|
{
|
||||||
|
foreach ($sDates as $sDate) {
|
||||||
|
if ($this->year == $sDate->thisYear()) {
|
||||||
|
$key = $sDate->thisMonth();
|
||||||
|
if (isset($this->children[$key])) {
|
||||||
|
$sDate->setSelected();
|
||||||
|
$this->children[$key] = $sDate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
Reference in New Issue
Block a user