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.2 2005/11/03 20:35:03 quipo Exp $ |
---|
22 | // |
---|
23 | /** |
---|
24 | * @package Calendar |
---|
25 | * @version $Id: Wrapper.php,v 1.2 2005/11/03 20:35:03 quipo 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 | $ret =& new $decorator($Calendar); |
---|
69 | } else { |
---|
70 | $ret = false; |
---|
71 | } |
---|
72 | return $ret; |
---|
73 | } |
---|
74 | |
---|
75 | /** |
---|
76 | * Wraps the returned calendar objects from fetchAll in the named decorator |
---|
77 | * @param string name of Decorator class to wrap with |
---|
78 | * @return array |
---|
79 | * @access public |
---|
80 | */ |
---|
81 | function fetchAll($decorator) |
---|
82 | { |
---|
83 | $children = parent::fetchAll(); |
---|
84 | foreach ($children as $key => $Calendar) { |
---|
85 | $children[$key] = & new $decorator($Calendar); |
---|
86 | } |
---|
87 | return $children; |
---|
88 | } |
---|
89 | } |
---|
90 | ?> |
---|