1
|
<?php
|
2
|
|
3
|
/**
|
4
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
|
5
|
*
|
6
|
* This program is free software: you can redistribute it and/or modify
|
7
|
* it under the terms of the GNU General Public License as published by
|
8
|
* the Free Software Foundation, either version 3 of the License, or
|
9
|
* (at your option) any later version.
|
10
|
*
|
11
|
* This program is distributed in the hope that it will be useful,
|
12
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
* GNU General Public License for more details.
|
15
|
*
|
16
|
* You should have received a copy of the GNU General Public License
|
17
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
18
|
*/
|
19
|
|
20
|
/**
|
21
|
* WbAdaptor.php
|
22
|
*
|
23
|
* @category Core
|
24
|
* @package Core_package
|
25
|
* @author Werner v.d.Decken <wkl@isteam.de>
|
26
|
* @copyright Werner v.d.Decken <wkl@isteam.de>
|
27
|
* @license http://www.gnu.org/licenses/gpl.html GPL License
|
28
|
* @version 0.0.1
|
29
|
* @revision $Revision: 2070 $
|
30
|
* @lastmodified $Date: 2014-01-03 02:21:42 +0100 (Fri, 03 Jan 2014) $
|
31
|
* @since File available since 18.01.2013
|
32
|
* @deprecated This class will be removed if Registry comes activated
|
33
|
* @description This adaptor is a temporary replacement for the future registry class
|
34
|
*/
|
35
|
class WbAdaptor {
|
36
|
|
37
|
/** active instance */
|
38
|
protected static $_oInstance = null;
|
39
|
/** array hold settings */
|
40
|
protected $_aSys = array();
|
41
|
/** constructor */
|
42
|
protected function __construct()
|
43
|
{
|
44
|
$this->_aSys = array('System' => array(), 'Request' => array());
|
45
|
}
|
46
|
/**
|
47
|
* Get active instance
|
48
|
* @return WbAdaptor
|
49
|
*/
|
50
|
public static function getInstance()
|
51
|
{
|
52
|
if(self::$_oInstance == null) {
|
53
|
$c = __CLASS__;
|
54
|
self::$_oInstance = new $c();
|
55
|
|
56
|
}
|
57
|
return self::$_oInstance;
|
58
|
}
|
59
|
/**
|
60
|
* handle unknown properties
|
61
|
* @param string name of the property
|
62
|
* @param mixed value to set
|
63
|
* @throws InvalidArgumentException
|
64
|
*/
|
65
|
public function __set($name, $value)
|
66
|
{
|
67
|
throw new InvalidArgumentException('tried to set readonly or nonexisting property [ '.$name.' }!! ');
|
68
|
}
|
69
|
/**
|
70
|
* Get value of a variable
|
71
|
* @param string name of the variable
|
72
|
* @return mixed
|
73
|
*/
|
74
|
public function __get($sVarname)
|
75
|
{
|
76
|
if( isset($this->_aSys['Request'][$sVarname])) {
|
77
|
return $this->_aSys['Request'][$sVarname];
|
78
|
}elseif( isset($this->_aSys['System'][$sVarname])) {
|
79
|
return $this->_aSys['System'][$sVarname];
|
80
|
}elseif( isset($this->_aSys[$sVarname])) {
|
81
|
return $this->_aSys[$sVarname];
|
82
|
}else {
|
83
|
return null;
|
84
|
}
|
85
|
}
|
86
|
/**
|
87
|
* Check if var is set
|
88
|
* @param string name of the variable
|
89
|
* @return bool
|
90
|
*/
|
91
|
public function __isset($sVarname)
|
92
|
{
|
93
|
$bRetval = (isset($this->_aSys['Request'][$sVarname]) ||
|
94
|
isset($this->_aSys['System'][$sVarname]) ||
|
95
|
isset($this->_aSys[$sVarname]));
|
96
|
return $bRetval;
|
97
|
}
|
98
|
/**
|
99
|
* Import WB-Constants
|
100
|
*/
|
101
|
public function getWbConstants()
|
102
|
{
|
103
|
$this->_aSys = array('System' => array(), 'Request' => array());
|
104
|
$aConsts = get_defined_constants(true);
|
105
|
foreach($aConsts['user'] as $sKey=>$sVal)
|
106
|
{
|
107
|
// skip possible existing database constants
|
108
|
if (preg_match('/^db_|^TABLE_PREFIX$/i', $sKey)) { continue; }
|
109
|
// change all path items to trailing slash scheme
|
110
|
switch($sKey):
|
111
|
case 'WB_URL':
|
112
|
$sVal = rtrim(str_replace('\\', '/', $sVal), '/').'/';
|
113
|
$sKey = 'AppUrl';
|
114
|
$this->_aSys['System'][$sKey] = $sVal;
|
115
|
break;
|
116
|
case 'WB_REL':
|
117
|
$sVal = rtrim(str_replace('\\', '/', $sVal), '/').'/';
|
118
|
$sKey = 'AppRel';
|
119
|
$this->_aSys['System'][$sKey] = $sVal;
|
120
|
break;
|
121
|
case 'WB_PATH':
|
122
|
$sVal = rtrim(str_replace('\\', '/', $sVal), '/').'/';
|
123
|
$sKey = 'AppPath';
|
124
|
$this->_aSys['System'][$sKey] = $sVal;
|
125
|
break;
|
126
|
case 'ADMIN_URL':
|
127
|
$sVal = rtrim(str_replace('\\', '/', $sVal), '/').'/';
|
128
|
$sKey = 'AcpUrl';
|
129
|
$this->_aSys['System'][$sKey] = $sVal;
|
130
|
break;
|
131
|
case 'ADMIN_REL':
|
132
|
$sVal = rtrim(str_replace('\\', '/', $sVal), '/').'/';
|
133
|
$sKey = 'AcpRel';
|
134
|
$this->_aSys['System'][$sKey] = $sVal;
|
135
|
break;
|
136
|
case 'ADMIN_PATH':
|
137
|
$sVal = rtrim(str_replace('\\', '/', $sVal), '/').'/';
|
138
|
$sKey = 'AcpPath';
|
139
|
$this->_aSys['System'][$sKey] = $sVal;
|
140
|
break;
|
141
|
case 'THEME_URL':
|
142
|
$sVal = rtrim(str_replace('\\', '/', $sVal), '/').'/';
|
143
|
$sKey = 'ThemeUrl';
|
144
|
$this->_aSys['Request'][$sKey] = $sVal;
|
145
|
break;
|
146
|
case 'THEME_REL':
|
147
|
$sVal = rtrim(str_replace('\\', '/', $sVal), '/').'/';
|
148
|
$sKey = 'ThemeRel';
|
149
|
$this->_aSys['Request'][$sKey] = $sVal;
|
150
|
break;
|
151
|
case 'THEME_PATH':
|
152
|
$sVal = rtrim(str_replace('\\', '/', $sVal), '/').'/';
|
153
|
$sKey = 'ThemePath';
|
154
|
$this->_aSys['Request'][$sKey] = $sVal;
|
155
|
break;
|
156
|
case 'TMP_PATH':
|
157
|
$sVal = rtrim(str_replace('\\', '/', $sVal), '/').'/';
|
158
|
$sKey = 'TempPath';
|
159
|
$this->_aSys['System'][$sKey] = $sVal;
|
160
|
break;
|
161
|
case 'ADMIN_DIRECTORY':
|
162
|
$sVal = trim(str_replace('\\', '/', $sVal), '/').'/';
|
163
|
$sKey = 'AcpDir';
|
164
|
$this->_aSys['System'][$sKey] = $sVal;
|
165
|
break;
|
166
|
case 'DOCUMENT_ROOT':
|
167
|
$sVal = rtrim(str_replace('\\', '/', $sVal), '/').'/';
|
168
|
$sKey = 'DocumentRoot';
|
169
|
$this->_aSys['System'][$sKey] = $sVal;
|
170
|
break;
|
171
|
case 'PAGES_DIRECTORY':
|
172
|
$sVal = trim(str_replace('\\', '/', $sVal), '/').'/';
|
173
|
$sVal = $sVal=='/' ? '' : $sVal;
|
174
|
$sKey = 'PagesDir';
|
175
|
$this->_aSys['System'][$sKey] = $sVal;
|
176
|
break;
|
177
|
case 'MEDIA_DIRECTORY':
|
178
|
$sVal = trim(str_replace('\\', '/', $sVal), '/').'/';
|
179
|
$sKey = 'MediaDir';
|
180
|
$this->_aSys['System'][$sKey] = $sVal;
|
181
|
break;
|
182
|
case 'DEFAULT_TEMPLATE':
|
183
|
$sVal = trim(str_replace('\\', '/', $sVal), '/').'/';
|
184
|
$sKey = 'DefaultTemplate';
|
185
|
$this->_aSys['Request'][$sKey] = $sVal;
|
186
|
break;
|
187
|
case 'DEFAULT_THEME':
|
188
|
$sVal = trim(str_replace('\\', '/', $sVal), '/').'/';
|
189
|
$sKey = 'DefaultTheme';
|
190
|
$this->_aSys['Request'][$sKey] = $sVal;
|
191
|
break;
|
192
|
case 'OCTAL_FILE_MODE':
|
193
|
$sVal = ((intval($sVal) & ~0111)|0600); // o-x/g-x/u-x/o+rw
|
194
|
$sKey = 'OctalFileMode';
|
195
|
$this->_aSys['Request'][$sKey] = $sVal;
|
196
|
break;
|
197
|
case 'OCTAL_DIR_MODE':
|
198
|
$sVal = (intval($sVal) |0711); // o+rwx/g+x/u+x
|
199
|
$sKey = 'OctalDirMode';
|
200
|
$this->_aSys['Request'][$sKey] = $sVal;
|
201
|
break;
|
202
|
case 'WB_VERSION':
|
203
|
$sKey = 'AppVersion';
|
204
|
$this->_aSys['System'][$sKey] = $sVal;
|
205
|
break;
|
206
|
case 'WB_REVISION':
|
207
|
$sKey = 'AppRevision';
|
208
|
$this->_aSys['System'][$sKey] = $sVal;
|
209
|
break;
|
210
|
case 'WB_SP':
|
211
|
$sKey = 'AppServicePack';
|
212
|
$this->_aSys['System'][$sKey] = $sVal;
|
213
|
break;
|
214
|
default:
|
215
|
$sVal = ($sVal == 'true' ? true : ($sVal == 'false' ? false : $sVal));
|
216
|
$sKey = str_replace(' ', '', ucwords(str_replace('_', ' ', strtolower($sKey))));
|
217
|
$this->_aSys['Request'][$sKey] = $sVal;
|
218
|
break;
|
219
|
endswitch;
|
220
|
$this->_aSys[$sKey] = $sVal;
|
221
|
}
|
222
|
$this->_aSys['AppName'] = 'WebsiteBaker';
|
223
|
$this->_aSys['System']['AppName'] = 'WebsiteBaker';
|
224
|
$this->_aSys['Request']['AppName'] = 'WebsiteBaker';
|
225
|
}
|
226
|
|
227
|
} // end of class WbAdaptor
|
228
|
|