Subversion Repositories Applications.gtt

Compare Revisions

Ignore whitespace Rev 61 → Rev 192

/branches/v1.3-critias/bibliotheque/pear/Calendar/Decorator/Weekday.php
New file
0,0 → 1,148
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
//
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2002 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.02 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Harry Fuecks <hfuecks@phppatterns.com> |
// | Lorenzo Alberton <l dot alberton at quipo dot it> |
// +----------------------------------------------------------------------+
//
// $Id: Weekday.php,v 1.3 2004/08/16 12:25:15 hfuecks Exp $
//
/**
* @package Calendar
* @version $Id: Weekday.php,v 1.3 2004/08/16 12:25:15 hfuecks Exp $
*/
 
/**
* Allows Calendar include path to be redefined
* @ignore
*/
if (!defined('CALENDAR_ROOT')) {
define('CALENDAR_ROOT', 'Calendar'.DIRECTORY_SEPARATOR);
}
 
/**
* Load Calendar decorator base class
*/
require_once CALENDAR_ROOT.'Decorator.php';
 
/**
* Load a Calendar_Day
*/
require_once CALENDAR_ROOT.'Day.php';
/**
* Decorator for fetching the day of the week
* <code>
* $Day = new Calendar_Day(2003, 10, 23);
* $Weekday = & new Calendar_Decorator_Weekday($Day);
* $Weekday->setFirstDay(0); // Set first day of week to Sunday (default Mon)
* echo $Weekday->thisWeekDay(); // Displays 5 - fifth day of week relative to Sun
* </code>
* @package Calendar
* @access public
*/
class Calendar_Decorator_Weekday extends Calendar_Decorator
{
/**
* First day of week
* @var int (default = 1 for Monday)
* @access private
*/
var $firstDay = 1;
 
/**
* Constructs Calendar_Decorator_Weekday
* @param object subclass of Calendar
* @access public
*/
function Calendar_Decorator_Weekday(& $Calendar)
{
parent::Calendar_Decorator($Calendar);
}
 
/**
* Sets the first day of the week (0 = Sunday, 1 = Monday (default) etc)
* @param int first day of week
* @return void
* @access public
*/
function setFirstDay($firstDay) {
$this->firstDay = (int)$firstDay;
}
 
/**
* Returns the previous weekday
* @param string (default = 'int') return value format
* @return int numeric day of week or timestamp
* @access public
*/
function prevWeekDay($format = 'int')
{
$ts = $this->calendar->prevDay('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);
}
 
/**
* Returns the current weekday
* @param string (default = 'int') return value format
* @return int numeric day of week or timestamp
* @access public
*/
function thisWeekDay($format = 'int')
{
$ts = $this->calendar->thisDay('timestamp');
$day = $this->calendar->cE->getDayOfWeek($this->calendar->year,$this->calendar->month,$this->calendar->day);
$day = $this->adjustWeekScale($day);
return $this->returnValue('Day', $format, $ts, $day);
}
 
/**
* Returns the next weekday
* @param string (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 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;
}
}
}
?>
/branches/v1.3-critias/bibliotheque/pear/Calendar/Decorator/Uri.php
New file
0,0 → 1,151
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
//
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2002 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.02 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Harry Fuecks <hfuecks@phppatterns.com> |
// | Lorenzo Alberton <l dot alberton at quipo dot it> |
// +----------------------------------------------------------------------+
//
// $Id: Uri.php,v 1.3 2004/08/16 09:04:20 hfuecks Exp $
//
/**
* @package Calendar
* @version $Id: Uri.php,v 1.3 2004/08/16 09:04:20 hfuecks Exp $
*/
 
/**
* Allows Calendar include path to be redefined
* @ignore
*/
if (!defined('CALENDAR_ROOT')) {
define('CALENDAR_ROOT', 'Calendar'.DIRECTORY_SEPARATOR);
}
 
/**
* Load Calendar decorator base class
*/
require_once CALENDAR_ROOT.'Decorator.php';
 
/**
* Load the Uri utility
*/
require_once CALENDAR_ROOT.'Util'.DIRECTORY_SEPARATOR.'Uri.php';
 
/**
* 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
* <code>
* $Day = new Calendar_Day(2003, 10, 23);
* $Uri = & new Calendar_Decorator_Uri($Day);
* $Uri->setFragments('year', 'month', 'day');
* echo $Uri->getPrev(); // Displays year=2003&month=10&day=22
* </code>
* @see Calendar_Util_Uri
* @package Calendar
* @access public
*/
class Calendar_Decorator_Uri extends Calendar_Decorator
{
 
/**
* @var Calendar_Util_Uri
* @access private
*/
var $Uri;
 
/**
* Constructs Calendar_Decorator_Uri
* @param object subclass of Calendar
* @access public
*/
function Calendar_Decorator_Uri(&$Calendar)
{
parent::Calendar_Decorator($Calendar);
}
 
/**
* 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
* @param string (optional) URI fragment for hour
* @param string (optional) URI fragment for minute
* @param string (optional) URI fragment for second
* @return void
* @access public
*/
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);
}
 
/**
* Sets the separator string between fragments
* @param string separator e.g. /
* @return void
* @access public
*/
function setSeparator($separator)
{
$this->Uri->separator = $separator;
}
 
/**
* Puts Uri decorator into "scalar mode" - URI variable names are not
* returned
* @param boolean (optional)
* @return void
* @access public
*/
function setScalar($state=true)
{
$this->Uri->scalar = $state;
}
 
/**
* Gets the URI string for the previous calendar unit
* @param string 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 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 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);
}
 
}
?>
/branches/v1.3-critias/bibliotheque/pear/Calendar/Decorator/Wrapper.php
New file
0,0 → 1,90
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
//
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2002 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.02 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Harry Fuecks <hfuecks@phppatterns.com> |
// | Lorenzo Alberton <l dot alberton at quipo dot it> |
// +----------------------------------------------------------------------+
//
// $Id: Wrapper.php,v 1.2 2005/11/03 20:35:03 quipo Exp $
//
/**
* @package Calendar
* @version $Id: Wrapper.php,v 1.2 2005/11/03 20:35:03 quipo Exp $
*/
 
/**
* Allows Calendar include path to be redefined
* @ignore
*/
if (!defined('CALENDAR_ROOT')) {
define('CALENDAR_ROOT', 'Calendar'.DIRECTORY_SEPARATOR);
}
 
/**
* Load Calendar decorator base class
*/
require_once CALENDAR_ROOT.'Decorator.php';
 
/**
* Decorator to help with wrapping built children in another decorator
* @package Calendar
* @access public
*/
class Calendar_Decorator_Wrapper extends Calendar_Decorator
{
/**
* Constructs Calendar_Decorator_Wrapper
* @param object subclass of Calendar
* @access public
*/
function Calendar_Decorator_Wrapper(&$Calendar)
{
parent::Calendar_Decorator($Calendar);
}
 
/**
* Wraps objects returned from fetch in the named Decorator class
* @param string name of Decorator class to wrap with
* @return object instance of named decorator
* @access public
*/
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 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;
}
}
?>
/branches/v1.3-critias/bibliotheque/pear/Calendar/Decorator/Textual.php
New file
0,0 → 1,169
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
//
// +----------------------------------------------------------------------+
// | PHP Version 4 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2002 The PHP Group |
// +----------------------------------------------------------------------+
// | This source file is subject to version 2.02 of the PHP license, |
// | that is bundled with this package in the file LICENSE, and is |
// | available at through the world-wide-web at |
// | http://www.php.net/license/3_0.txt. |
// | If you did not receive a copy of the PHP license and are unable to |
// | obtain it through the world-wide-web, please send a note to |
// | license@php.net so we can mail you a copy immediately. |
// +----------------------------------------------------------------------+
// | Authors: Harry Fuecks <hfuecks@phppatterns.com> |
// | Lorenzo Alberton <l dot alberton at quipo dot it> |
// +----------------------------------------------------------------------+
//
// $Id: Textual.php,v 1.3 2004/08/16 13:02:44 hfuecks Exp $
//
/**
* @package Calendar
* @version $Id: Textual.php,v 1.3 2004/08/16 13:02:44 hfuecks Exp $
*/
 
/**
* Allows Calendar include path to be redefined
* @ignore
*/
if (!defined('CALENDAR_ROOT')) {
define('CALENDAR_ROOT', 'Calendar'.DIRECTORY_SEPARATOR);
}
 
/**
* Load Calendar decorator base class
*/
require_once CALENDAR_ROOT.'Decorator.php';
 
/**
* Load the Uri utility
*/
require_once CALENDAR_ROOT.'Util'.DIRECTORY_SEPARATOR.'Textual.php';
 
/**
* 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
* have a specific need to use a decorator
* @package Calendar
* @access public
*/
class Calendar_Decorator_Textual extends Calendar_Decorator
{
/**
* Constructs Calendar_Decorator_Textual
* @param object subclass of Calendar
* @access public
*/
function Calendar_Decorator_Textual(&$Calendar)
{
parent::Calendar_Decorator($Calendar);
}
 
/**
* 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
* @static
*/
function monthNames($format='long')
{
return Calendar_Util_Textual::monthNames($format);
}
 
/**
* Returns an array of 7 week day names (first index = 0)
* @param string (optional) format of returned days (one,two,short or long)
* @return array
* @access public
* @static
*/
function weekdayNames($format='long')
{
return Calendar_Util_Textual::weekdayNames($format);
}
 
/**
* 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 string
* @access public
*/
function prevMonthName($format='long')
{
return Calendar_Util_Textual::prevMonthName($this->calendar,$format);
}
 
/**
* Returns textual representation of the month of the decorated calendar object
* @param string (optional) format of returned months (one,two,short or long)
* @return string
* @access public
*/
function thisMonthName($format='long')
{
return Calendar_Util_Textual::thisMonthName($this->calendar,$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
*/
function nextMonthName($format='long')
{
return Calendar_Util_Textual::nextMonthName($this->calendar,$format);
}
 
/**
* 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 string
* @access public
*/
function prevDayName($format='long')
{
return Calendar_Util_Textual::prevDayName($this->calendar,$format);
}
 
/**
* 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)
* @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 (optional) format of returned months (one,two,short or 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 (optional) format of returned months (one,two,short or long)
* @return array ordered array of week day names
* @access public
*/
function orderedWeekdays($format='long')
{
return Calendar_Util_Textual::orderedWeekdays($this->calendar,$format);
}
}
?>