57,7 → 57,7 |
*/ |
public static function getInstance(Application $instance = null) |
{ |
if (is_null(self::$_instance)) |
if (self::$_instance === null) |
{ |
self::$_instance = ($instance === null) ? new self() : $instance; |
} |
65,64 → 65,64 |
return self::$_instance; |
} |
|
/** |
* Getter for properties |
* |
* @param string $name |
* @throws ModelPropertyException |
* @return mixed |
*/ |
public function __get($name) |
{ |
/* Support for Object-Relational Mappers */ |
if (strpos($name, 'persistent') === 0) |
{ |
$class = get_class($this); |
return $class::${ |
$name}; |
} |
|
$method = 'get' . ucfirst($name); |
|
if (method_exists($this, $method)) |
{ |
return $this->$method(); |
} |
|
if (property_exists($this, "_$name")) |
{ |
return $this->{"_$name"}; |
} |
|
return $this->$name; |
} |
|
/** |
* Setter for properties |
* |
* @param string $name |
* @param mixed $value The new property value before assignment |
* @throws ModelPropertyException |
*/ |
public function __set($name, $value) |
{ |
$method = 'set' . ucfirst($name); |
|
if (method_exists($this, $method)) |
{ |
return $this->$method($value); |
} |
|
if (property_exists($this, "_$name")) |
{ |
$this->{"_$name"} = $value; |
return $this->{"_$name"}; |
} |
|
/* NOTE: Attempts to set other properties are _silently_ _ignored_ */ |
} |
/** |
* Getter for properties |
* |
* @param string $name |
* @throws ModelPropertyException |
* @return mixed |
*/ |
public function __get($name) |
{ |
/* Support for Object-Relational Mappers */ |
if (strpos($name, 'persistent') === 0) |
{ |
$class = get_class($this); |
return $class::${ |
$name}; |
} |
|
$method = 'get' . ucfirst($name); |
|
if (method_exists($this, $method)) |
{ |
return $this->$method(); |
} |
|
if (property_exists($this, "_$name")) |
{ |
return $this->{"_$name"}; |
} |
|
return $this->$name; |
} |
|
/** |
* Setter for properties |
* |
* @param string $name |
* @param mixed $value The new property value before assignment |
* @throws ModelPropertyException |
*/ |
public function __set($name, $value) |
{ |
$method = 'set' . ucfirst($name); |
|
if (method_exists($this, $method)) |
{ |
return $this->$method($value); |
} |
|
if (property_exists($this, "_$name")) |
{ |
$this->{"_$name"} = $value; |
return $this->{"_$name"}; |
} |
|
/* NOTE: Attempts to set other properties are _silently_ _ignored_ */ |
} |
|
/** |
* Runs the application, setting up session management and |
* constructing the controller indicated by the URI |
*/ |
164,7 → 164,7 |
*/ |
public static function getParam($key, array $array = null) |
{ |
if (is_null($array)) |
if ($array === null) |
{ |
$array = $_GET; |
} |
242,14 → 242,30 |
$url = self::getParam('URL', $_SERVER); |
if ($url === null) |
{ |
throw new Exception( |
'Neither $_SERVER["SCRIPT_URL"] nor $_SERVER["URL"] is available, cannot continue.'); |
/* Server/PHP too old, compute URI */ |
$url = self::getParam('REQUEST_URI', $_SERVER); |
if (preg_match('/^[^?]+/', $url, $matches) > 0) |
{ |
$url = $matches[0]; |
} |
else |
{ |
/* Has .php in it, but at least it works */ |
$url = self::getParam('SCRIPT_NAME', $_SERVER); |
if ($url === null) |
{ |
throw new Exception( |
'None of $_SERVER["SCRIPT_URL"], $_SERVER["URL"],' |
. ' $_SERVER["REQUEST_URI"], or $_SERVER["SCRIPT_NAME"]' |
. ' is available, cannot continue.'); |
} |
} |
} |
} |
|
$query = (!is_null($controller) ? 'controller=' . $controller : '') |
. (!is_null($action) ? '&action=' . $action : '') |
. (!is_null($id) ? '&id=' . $id : ''); |
$query = (($controller !== null) ? 'controller=' . $controller : '') |
. (($action !== null) ? '&action=' . $action : '') |
. (($id !== null) ? '&id=' . $id : ''); |
|
return $url . ($query ? '?' . $query : ''); |
} |
260,7 → 276,7 |
public static function redirect($query = '') |
{ |
$script_uri = self::getParam('SCRIPT_URI', $_SERVER); |
if (is_null($script_uri)) |
if ($script_uri === null) |
{ |
/* Server/PHP too old, compute URI */ |
if (preg_match('/^[^?]+/', |