493 |
ddelon |
1 |
<?php
|
|
|
2 |
/* vim: set expandtab tabstop=4 shiftwidth=4: */
|
|
|
3 |
//
|
|
|
4 |
// +----------------------------------------------------------------------+
|
|
|
5 |
// | PHP Version 4 |
|
|
|
6 |
// +----------------------------------------------------------------------+
|
|
|
7 |
// | Copyright (c) 1997-2002 The PHP Group |
|
|
|
8 |
// +----------------------------------------------------------------------+
|
|
|
9 |
// | This source file is subject to version 2.02 of the PHP license, |
|
|
|
10 |
// | that is bundled with this package in the file LICENSE, and is |
|
|
|
11 |
// | available at through the world-wide-web at |
|
|
|
12 |
// | http://www.php.net/license/3_0.txt. |
|
|
|
13 |
// | If you did not receive a copy of the PHP license and are unable to |
|
|
|
14 |
// | obtain it through the world-wide-web, please send a note to |
|
|
|
15 |
// | license@php.net so we can mail you a copy immediately. |
|
|
|
16 |
// +----------------------------------------------------------------------+
|
|
|
17 |
// | Authors: Harry Fuecks <hfuecks@phppatterns.com> |
|
|
|
18 |
// | Lorenzo Alberton <l dot alberton at quipo dot it> |
|
|
|
19 |
// +----------------------------------------------------------------------+
|
|
|
20 |
//
|
|
|
21 |
// $Id: Wrapper.php,v 1.1 2005-09-30 14:58:00 ddelon Exp $
|
|
|
22 |
//
|
|
|
23 |
/**
|
|
|
24 |
* @package Calendar
|
|
|
25 |
* @version $Id: Wrapper.php,v 1.1 2005-09-30 14:58:00 ddelon Exp $
|
|
|
26 |
*/
|
|
|
27 |
|
|
|
28 |
/**
|
|
|
29 |
* Allows Calendar include path to be redefined
|
|
|
30 |
* @ignore
|
|
|
31 |
*/
|
|
|
32 |
if (!defined('CALENDAR_ROOT')) {
|
|
|
33 |
define('CALENDAR_ROOT', 'Calendar'.DIRECTORY_SEPARATOR);
|
|
|
34 |
}
|
|
|
35 |
|
|
|
36 |
/**
|
|
|
37 |
* Load Calendar decorator base class
|
|
|
38 |
*/
|
|
|
39 |
require_once CALENDAR_ROOT.'Decorator.php';
|
|
|
40 |
|
|
|
41 |
/**
|
|
|
42 |
* Decorator to help with wrapping built children in another decorator
|
|
|
43 |
* @package Calendar
|
|
|
44 |
* @access public
|
|
|
45 |
*/
|
|
|
46 |
class Calendar_Decorator_Wrapper extends Calendar_Decorator
|
|
|
47 |
{
|
|
|
48 |
/**
|
|
|
49 |
* Constructs Calendar_Decorator_Wrapper
|
|
|
50 |
* @param object subclass of Calendar
|
|
|
51 |
* @access public
|
|
|
52 |
*/
|
|
|
53 |
function Calendar_Decorator_Wrapper(&$Calendar)
|
|
|
54 |
{
|
|
|
55 |
parent::Calendar_Decorator($Calendar);
|
|
|
56 |
}
|
|
|
57 |
|
|
|
58 |
/**
|
|
|
59 |
* Wraps objects returned from fetch in the named Decorator class
|
|
|
60 |
* @param string name of Decorator class to wrap with
|
|
|
61 |
* @return object instance of named decorator
|
|
|
62 |
* @access public
|
|
|
63 |
*/
|
|
|
64 |
function & fetch($decorator)
|
|
|
65 |
{
|
|
|
66 |
$Calendar = parent::fetch();
|
|
|
67 |
if ($Calendar) {
|
|
|
68 |
return new $decorator($Calendar);
|
|
|
69 |
} else {
|
|
|
70 |
return false;
|
|
|
71 |
}
|
|
|
72 |
}
|
|
|
73 |
|
|
|
74 |
/**
|
|
|
75 |
* Wraps the returned calendar objects from fetchAll in the named decorator
|
|
|
76 |
* @param string name of Decorator class to wrap with
|
|
|
77 |
* @return array
|
|
|
78 |
* @access public
|
|
|
79 |
*/
|
|
|
80 |
function fetchAll($decorator)
|
|
|
81 |
{
|
|
|
82 |
$children = parent::fetchAll();
|
|
|
83 |
foreach ($children as $key => $Calendar) {
|
|
|
84 |
$children[$key] = & new $decorator($Calendar);
|
|
|
85 |
}
|
|
|
86 |
return $children;
|
|
|
87 |
}
|
|
|
88 |
}
|
|
|
89 |
?>
|