Subversion-Projekte lars-tiefland.cakephp

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
/* SVN FILE: $Id: overloadable_php4.php 7945 2008-12-19 02:16:01Z gwoo $ */
3
/**
4
 * Overload abstraction interface.  Merges differences between PHP4 and 5.
5
 *
6
 * PHP versions 4 and 5
7
 *
8
 * CakePHP(tm) :  Rapid Development Framework (http://www.cakephp.org)
9
 * Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
10
 *
11
 * Licensed under The MIT License
12
 * Redistributions of files must retain the above copyright notice.
13
 *
14
 * @filesource
15
 * @copyright     Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
16
 * @link          http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
17
 * @package       cake
18
 * @subpackage    cake.cake.libs
19
 * @since         CakePHP(tm) v 1.2
20
 * @version       $Revision: 7945 $
21
 * @modifiedby    $LastChangedBy: gwoo $
22
 * @lastmodified  $Date: 2008-12-18 18:16:01 -0800 (Thu, 18 Dec 2008) $
23
 * @license       http://www.opensource.org/licenses/mit-license.php The MIT License
24
 */
25
/**
26
 * Overloadable class selector
27
 *
28
 * Load the interface class based on the version of PHP.
29
 *
30
 * @package       cake
31
 * @subpackage    cake.cake.libs
32
 */
33
class Overloadable extends Object {
34
/**
35
 * Constructor.
36
 *
37
 * @access private
38
 */
39
	function __construct() {
40
		$this->overload();
41
		parent::__construct();
42
	}
43
/**
44
 * Overload implementation.
45
 *
46
 * @access public
47
 */
48
	function overload() {
49
		if (function_exists('overload')) {
50
			if (func_num_args() > 0) {
51
				foreach (func_get_args() as $class) {
52
					if (is_object($class)) {
53
						overload(get_class($class));
54
					} elseif (is_string($class)) {
55
						overload($class);
56
					}
57
				}
58
			} else {
59
				overload(get_class($this));
60
			}
61
		}
62
	}
63
 
64
/**
65
 * Magic method handler.
66
 *
67
 * @param string $method Method name
68
 * @param array $params Parameters to send to method
69
 * @param mixed $return Where to store return value from method
70
 * @return boolean Success
71
 * @access private
72
 */
73
	function __call($method, $params, &$return) {
74
		if (!method_exists($this, 'call__')) {
75
			trigger_error(sprintf(__('Magic method handler call__ not defined in %s', true), get_class($this)), E_USER_ERROR);
76
		}
77
		$return = $this->call__($method, $params);
78
		return true;
79
	}
80
}
81
Overloadable::overload('Overloadable');
82
 
83
/**
84
 * Overloadable2 class selector
85
 *
86
 * Load the interface class based on the version of PHP.
87
 *
88
 * @package       cake
89
 * @subpackage    cake.cake.libs
90
 */
91
class Overloadable2 extends Object {
92
/**
93
 * Constructor
94
 *
95
 * @access private
96
 */
97
	function __construct() {
98
		$this->overload();
99
		parent::__construct();
100
	}
101
/**
102
 * Overload implementation.
103
 *
104
 * @access public
105
 */
106
	function overload() {
107
		if (function_exists('overload')) {
108
			if (func_num_args() > 0) {
109
				foreach (func_get_args() as $class) {
110
					if (is_object($class)) {
111
						overload(get_class($class));
112
					} elseif (is_string($class)) {
113
						overload($class);
114
					}
115
				}
116
			} else {
117
				overload(get_class($this));
118
			}
119
		}
120
	}
121
/**
122
 * Magic method handler.
123
 *
124
 * @param string $method Method name
125
 * @param array $params Parameters to send to method
126
 * @param mixed $return Where to store return value from method
127
 * @return boolean Success
128
 * @access private
129
 */
130
	function __call($method, $params, &$return) {
131
		if (!method_exists($this, 'call__')) {
132
			trigger_error(sprintf(__('Magic method handler call__ not defined in %s', true), get_class($this)), E_USER_ERROR);
133
		}
134
		$return = $this->call__($method, $params);
135
		return true;
136
	}
137
/**
138
 * Getter.
139
 *
140
 * @param mixed $name What to get
141
 * @param mixed $value Where to store returned value
142
 * @return boolean Success
143
 * @access private
144
 */
145
	function __get($name, &$value) {
146
		$value = $this->get__($name);
147
		return true;
148
	}
149
/**
150
 * Setter.
151
 *
152
 * @param mixed $name What to set
153
 * @param mixed $value Value to set
154
 * @return boolean Success
155
 * @access private
156
 */
157
	function __set($name, $value) {
158
		$this->set__($name, $value);
159
		return true;
160
	}
161
}
162
Overloadable::overload('Overloadable2');
163
 
164
?>