| 34 |
34 |
*/
|
| 35 |
35 |
class WbAdaptor {
|
| 36 |
36 |
|
| 37 |
|
/** active instance */
|
|
37 |
/** active instance */
|
| 38 |
38 |
protected static $oInstance = null;
|
| 39 |
|
/** array hold settings */
|
|
39 |
/** array hold settings */
|
| 40 |
40 |
protected $aProperties = array();
|
| 41 |
41 |
/** */
|
| 42 |
42 |
protected $aObjects = array('Db' => null, 'Trans' => null, 'App' => null);
|
| 43 |
43 |
/** vars which */
|
| 44 |
44 |
protected $aReservedVars = array('Db', 'Trans', 'App');
|
| 45 |
45 |
/** constructor */
|
| 46 |
|
protected function __construct()
|
|
46 |
protected function __construct()
|
| 47 |
47 |
{
|
| 48 |
48 |
$this->aProperties = array('System' => array(), 'Request' => array());
|
| 49 |
49 |
}
|
| 50 |
50 |
/**
|
| 51 |
|
* Get active instance
|
|
51 |
* Get active instance
|
| 52 |
52 |
* @return WbAdaptor
|
| 53 |
53 |
*/
|
| 54 |
54 |
public static function getInstance()
|
| ... | ... | |
| 56 |
56 |
if(self::$oInstance == null) {
|
| 57 |
57 |
$c = __CLASS__;
|
| 58 |
58 |
self::$oInstance = new $c();
|
| 59 |
|
|
|
59 |
|
| 60 |
60 |
}
|
| 61 |
61 |
return self::$oInstance;
|
| 62 |
62 |
}
|
| ... | ... | |
| 91 |
91 |
* @param string name of the property
|
| 92 |
92 |
* @param mixed value to set
|
| 93 |
93 |
* @throws InvalidArgumentException
|
| 94 |
|
*/
|
| 95 |
|
public function __set($name, $value)
|
|
94 |
*/
|
|
95 |
public function __set($name, $value)
|
| 96 |
96 |
{
|
| 97 |
97 |
if (array_key_exists($name, $this->aProperties['System'])) {
|
| 98 |
98 |
throw new InvalidArgumentException('tried to set readonly or nonexisting property [ '.$name.' }!! ');
|
| ... | ... | |
| 104 |
104 |
* Get value of a variable
|
| 105 |
105 |
* @param string name of the variable
|
| 106 |
106 |
* @return mixed
|
| 107 |
|
*/
|
|
107 |
*/
|
| 108 |
108 |
public function __get($sVarname)
|
| 109 |
109 |
{
|
| 110 |
110 |
if (isset($this->aObjects[$sVarname]) && !is_null($this->aObjects[$sVarname])) {
|
| ... | ... | |
| 122 |
122 |
* Check if var is set
|
| 123 |
123 |
* @param string name of the variable
|
| 124 |
124 |
* @return bool
|
| 125 |
|
*/
|
|
125 |
*/
|
| 126 |
126 |
public function __isset($sVarname)
|
| 127 |
127 |
{
|
| 128 |
128 |
if (isset($this->aObjects[$sVarname]) && !is_null($this->aObjects[$sVarname])) {
|
| ... | ... | |
| 134 |
134 |
}
|
| 135 |
135 |
/**
|
| 136 |
136 |
* Import WB-Constants
|
| 137 |
|
*/
|
|
137 |
*/
|
| 138 |
138 |
public function getWbConstants()
|
| 139 |
139 |
{
|
| 140 |
140 |
// first reinitialize arrays
|
| ... | ... | |
| 155 |
155 |
$this->aProperties['System']['Debug'] = intval($sVal);
|
| 156 |
156 |
$this->aProperties['System']['DebugLevel'] = intval($sVal);
|
| 157 |
157 |
break;
|
| 158 |
|
case 'WB_URL':
|
|
158 |
case 'WB_URL':
|
| 159 |
159 |
$sVal = rtrim(str_replace('\\', '/', $sVal), '/').'/';
|
| 160 |
160 |
$sKey = 'AppUrl';
|
| 161 |
161 |
$this->aProperties['System'][$sKey] = $sVal;
|
| ... | ... | |
| 304 |
304 |
/* correct PageIconDir if necessary */
|
| 305 |
305 |
$this->aProperties['Request']['PageIconDir'] = str_replace('/*/', '/'.$this->Template, $this->PageIconDir);
|
| 306 |
306 |
|
|
307 |
$this->aProperties['System']['VarPath'] = $this->aProperties['System']['AppPath'].'var/';
|
|
308 |
$this->aProperties['System']['VarUrl'] = $this->aProperties['System']['AppUrl'].'var/';
|
|
309 |
$this->aProperties['System']['VarRel'] = $this->aProperties['System']['AppRel'].'var/';
|
| 307 |
310 |
/* cleanup arrays */
|
| 308 |
311 |
$this->aProperties['Request'] = array_diff_key(
|
| 309 |
312 |
$this->aProperties['Request'],
|
! class WbAdaptor: added values VarUrl/VarPath/VarRel for new var/ folder