cvs: pear /Calendar Factory.php
| From: | Lorenzo Alberton | Date: | Sat, 22 Oct 2005 10:08:51 +0000 |
| Subject: | cvs: pear /Calendar Factory.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-35778@lists.php.net to get a copy of this message | ||
quipo Sat Oct 22 06:08:51 2005 EDT
Modified files:
/pear/Calendar Factory.php
Log:
- don't define CALENDAR_FIRST_DAY_OF_WEEK by default
- removed useless break statements
- CS
http://cvs.php.net/diff.php/pear/Calendar/Factory.php?r1=1.2&r2=1.3&ty=u
Index: pear/Calendar/Factory.php
diff -u pear/Calendar/Factory.php:1.2 pear/Calendar/Factory.php:1.3
--- pear/Calendar/Factory.php:1.2 Thu Oct 20 04:08:45 2005
+++ pear/Calendar/Factory.php Sat Oct 22 06:08:47 2005
@@ -18,11 +18,11 @@
// | Lorenzo Alberton <l dot alberton at quipo dot it> |
// +----------------------------------------------------------------------+
//
-// $Id: Factory.php,v 1.2 2005/10/20 08:08:45 quipo Exp $
+// $Id: Factory.php,v 1.3 2005/10/22 10:08:47 quipo Exp $
//
/**
* @package Calendar
- * @version $Id: Factory.php,v 1.2 2005/10/20 08:08:45 quipo Exp $
+ * @version $Id: Factory.php,v 1.3 2005/10/22 10:08:47 quipo Exp $
*/
/**
@@ -39,13 +39,6 @@
require_once CALENDAR_ROOT.'Calendar.php';
/**
- * Constant for the first day of the week (integer e.g. 0-6)
- */
-if ( !defined ('CALENDAR_FIRST_DAY_OF_WEEK') ) {
- define ('CALENDAR_FIRST_DAY_OF_WEEK',1);
-}
-
-/**
* Contains a factory method to return a Singleton instance of a class
* implementing the Calendar_Engine_Interface.<br>
* For Month objects, to control type of month returned, use CALENDAR_MONTH_STATE
@@ -79,11 +72,11 @@
*/
function create($type, $y = 2000, $m = 1, $d = 1, $h = 0, $i = 0, $s = 0)
{
- switch ( $type ) {
+ $firstDay = defined('CALENDAR_FIRST_DAY_OF_WEEK') ? CALENDAR_FIRST_DAY_OF_WEEK :
1;
+ switch ($type) {
case 'Day':
require_once CALENDAR_ROOT.'Day.php';
return new Calendar_Day($y,$m,$d);
- break;
case 'Month':
// Set default state for which month type to build
if (!defined('CALENDAR_MONTH_STATE')) {
@@ -91,11 +84,11 @@
}
switch (CALENDAR_MONTH_STATE) {
case CALENDAR_USE_MONTH_WEEKDAYS:
- require_once
CALENDAR_ROOT.'Month'.DIRECTORY_SEPARATOR.'Weekdays.php';
+ require_once CALENDAR_ROOT.'Month/Weekdays.php';
$class = 'Calendar_Month_Weekdays';
break;
case CALENDAR_USE_MONTH_WEEKS:
- require_once
CALENDAR_ROOT.'Month'.DIRECTORY_SEPARATOR.'Weeks.php';
+ require_once CALENDAR_ROOT.'Month/Weeks.php';
$class = 'Calendar_Month_Weeks';
break;
case CALENDAR_USE_MONTH:
@@ -104,35 +97,28 @@
$class = 'Calendar_Month';
break;
}
- return new $class($y,$m,CALENDAR_FIRST_DAY_OF_WEEK);
- break;
+ return new $class($y, $m, $firstDay);
case 'Week':
require_once CALENDAR_ROOT.'Week.php';
- return new Calendar_Week($y,$m,$d,CALENDAR_FIRST_DAY_OF_WEEK);
- break;
+ return new Calendar_Week($y, $m, $d, $firstDay);
case 'Hour':
require_once CALENDAR_ROOT.'Hour.php';
- return new Calendar_Hour($y,$m,$d,$h);
- break;
+ return new Calendar_Hour($y, $m, $d, $h);
case 'Minute':
require_once CALENDAR_ROOT.'Minute.php';
- return new Calendar_Minute($y,$m,$d,$h,$i);
- break;
+ return new Calendar_Minute($y, $m, $d, $h, $i);
case 'Second':
require_once CALENDAR_ROOT.'Second.php';
return new Calendar_Second($y,$m,$d,$h,$i,$s);
- break;
case 'Year':
require_once CALENDAR_ROOT.'Year.php';
return new Calendar_Year($y);
- break;
default:
require_once 'PEAR.php';
PEAR::raiseError(
'Calendar_Factory::create() unrecognised type: '.$type, null,
PEAR_ERROR_TRIGGER,
E_USER_NOTICE, 'Calendar_Factory::create()');
return false;
- break;
}
}
/**