Subversion Repositories PHPX

Compare Revisions

Last modification

Regard whitespace Rev 30 → Rev 31

/trunk/Application.php
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;
}
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)
{
/* 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(
'Neither $_SERVER["SCRIPT_URL"] nor $_SERVER["URL"] is available, cannot continue.');
'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('/^[^?]+/',