2,9 → 2,21 |
|
namespace PointedEars\PHPX; |
|
require_once __DIR__ . '/AbstractModel.php'; |
require_once __DIR__ . '/Registry.php'; |
function autoload ($class) |
{ |
if (\strpos($class, '..')) |
{ |
throw new \InvalidArgumentException( |
'Refusing to load unsafe class ' . $class); |
} |
|
require_once \preg_replace('#\\\#', '/', |
\preg_replace('#^' . \preg_quote(__NAMESPACE__) .'#', __DIR__, $class) |
) . '.php'; |
} |
|
\spl_autoload_register(__NAMESPACE__ . '\\autoload'); |
|
/** |
* Basic application class |
* |
77,20 → 89,20 |
public function __get($name) |
{ |
/* Support for Object-Relational Mappers */ |
if (strpos($name, 'persistent') === 0) |
if (\strpos($name, 'persistent') === 0) |
{ |
$class = get_class($this); |
$class = \get_class($this); |
return $class::${$name}; |
} |
|
$method = 'get' . ucfirst($name); |
$method = 'get' . \ucfirst($name); |
|
if (method_exists($this, $method)) |
if (\method_exists($this, $method)) |
{ |
return $this->$method(); |
} |
|
if (property_exists($this, "_$name")) |
if (\property_exists($this, "_$name")) |
{ |
return $this->{"_$name"}; |
} |
107,14 → 119,14 |
*/ |
public function __set($name, $value) |
{ |
$method = 'set' . ucfirst($name); |
$method = 'set' . \ucfirst($name); |
|
if (method_exists($this, $method)) |
if (\method_exists($this, $method)) |
{ |
return $this->$method($value); |
} |
|
if (property_exists($this, "_$name")) |
if (\property_exists($this, "_$name")) |
{ |
$this->{"_$name"} = $value; |
return $this->{"_$name"}; |
137,7 → 149,7 |
$controller = $this->_defaultController; |
} |
|
$controller = ucfirst($controller); |
$controller = \ucfirst($controller); |
|
$controller = $controller . 'Controller'; |
require_once "{$this->_controllerPath}/{$controller}.php"; |
148,7 → 160,7 |
|
protected function startSession() |
{ |
session_start(); |
\session_start(); |
} |
|
/** |
248,7 → 260,7 |
{ |
/* Server/PHP too old, compute URI */ |
$url = self::getParam('REQUEST_URI', $_SERVER); |
if (preg_match('/^[^?]+/', $url, $matches) > 0) |
if (\preg_match('/^[^?]+/', $url, $matches) > 0) |
{ |
$url = $matches[0]; |
} |
258,7 → 270,7 |
$url = self::getParam('SCRIPT_NAME', $_SERVER); |
if ($url === null) |
{ |
throw new Exception( |
throw new \Exception( |
'None of $_SERVER["SCRIPT_URL"], $_SERVER["URL"],' |
. ' $_SERVER["REQUEST_URI"], or $_SERVER["SCRIPT_NAME"]' |
. ' is available, cannot continue.'); |
283,7 → 295,7 |
if ($script_uri === null) |
{ |
/* Server/PHP too old, compute URI */ |
if (preg_match('/^[^?]+/', |
if (\preg_match('/^[^?]+/', |
self::getParam('REQUEST_URI', $_SERVER), $matches) > 0) |
{ |
$query_prefix = $matches[0]; |
302,7 → 314,7 |
. $query_prefix; |
} |
|
header('Location: ' . $script_uri |
\header('Location: ' . $script_uri |
. ($query ? (substr($query, 0, 1) === '?' ? '' : '?') . $query : '')); |
} |
} |
} |