Route relative is now relative to the base of the website instead of the current directory
git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@5626 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
@@ -23,7 +23,7 @@ class test_route extends PHPUnit_Framework_TestCase
|
|||||||
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
||||||
$route = new route ();
|
$route = new route ();
|
||||||
echo $route->baseURL ();
|
echo $route->baseURL ();
|
||||||
$this->expectOutputString("./");
|
$this->expectOutputString("/");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Port 443 and HTTPS without module */
|
/** Port 443 and HTTPS without module */
|
||||||
@@ -36,7 +36,7 @@ class test_route extends PHPUnit_Framework_TestCase
|
|||||||
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
||||||
$route = new route ();
|
$route = new route ();
|
||||||
echo $route->baseURL ();
|
echo $route->baseURL ();
|
||||||
$this->expectOutputString("./");
|
$this->expectOutputString("/");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Port 888 and HTTP without module */
|
/** Port 888 and HTTP without module */
|
||||||
@@ -48,7 +48,7 @@ class test_route extends PHPUnit_Framework_TestCase
|
|||||||
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
||||||
$route = new route ();
|
$route = new route ();
|
||||||
echo $route->baseURL ();
|
echo $route->baseURL ();
|
||||||
$this->expectOutputString("./");
|
$this->expectOutputString("/");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Port 888 and HTTPS without module */
|
/** Port 888 and HTTPS without module */
|
||||||
@@ -60,7 +60,7 @@ class test_route extends PHPUnit_Framework_TestCase
|
|||||||
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
$_SERVER["SCRIPT_NAME"] = "/index.php";
|
||||||
$route = new route ();
|
$route = new route ();
|
||||||
echo $route->baseURL ();
|
echo $route->baseURL ();
|
||||||
$this->expectOutputString("./");
|
$this->expectOutputString("/");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Port 80 and HTTP with module */
|
/** Port 80 and HTTP with module */
|
||||||
@@ -72,7 +72,7 @@ class test_route extends PHPUnit_Framework_TestCase
|
|||||||
$_SERVER["SCRIPT_NAME"] = "/module/index.php";
|
$_SERVER["SCRIPT_NAME"] = "/module/index.php";
|
||||||
$route = new route ();
|
$route = new route ();
|
||||||
echo $route->baseURL ("module");
|
echo $route->baseURL ("module");
|
||||||
$this->expectOutputString("./");
|
$this->expectOutputString("/");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Port 443 and HTTPS with module */
|
/** Port 443 and HTTPS with module */
|
||||||
@@ -84,7 +84,7 @@ class test_route extends PHPUnit_Framework_TestCase
|
|||||||
$_SERVER["SCRIPT_NAME"] = "/module/index.php";
|
$_SERVER["SCRIPT_NAME"] = "/module/index.php";
|
||||||
$route = new route ();
|
$route = new route ();
|
||||||
echo $route->baseURL ("module");
|
echo $route->baseURL ("module");
|
||||||
$this->expectOutputString("./");
|
$this->expectOutputString("/");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Port 888 and HTTP with module */
|
/** Port 888 and HTTP with module */
|
||||||
@@ -96,7 +96,7 @@ class test_route extends PHPUnit_Framework_TestCase
|
|||||||
$_SERVER["SCRIPT_NAME"] = "/module/index.php";
|
$_SERVER["SCRIPT_NAME"] = "/module/index.php";
|
||||||
$route = new route ();
|
$route = new route ();
|
||||||
echo $route->baseURL ("module");
|
echo $route->baseURL ("module");
|
||||||
$this->expectOutputString("./");
|
$this->expectOutputString("/");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Port 888 and HTTPS with module */
|
/** Port 888 and HTTPS with module */
|
||||||
@@ -108,7 +108,7 @@ class test_route extends PHPUnit_Framework_TestCase
|
|||||||
$_SERVER["SCRIPT_NAME"] = "/module/index.php";
|
$_SERVER["SCRIPT_NAME"] = "/module/index.php";
|
||||||
$route = new route ();
|
$route = new route ();
|
||||||
echo $route->baseURL ("module");
|
echo $route->baseURL ("module");
|
||||||
$this->expectOutputString("./");
|
$this->expectOutputString("/");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// ABSOLUTE ///
|
/// ABSOLUTE ///
|
||||||
|
|||||||
@@ -127,7 +127,10 @@ class route
|
|||||||
{
|
{
|
||||||
// Calculate the root in relative
|
// Calculate the root in relative
|
||||||
$request = $this->requestURL ();
|
$request = $this->requestURL ();
|
||||||
if (substr ($_SERVER["REQUEST_URI"], -1 * strlen ($request)) === $request)
|
if (! isset ($_SERVER["REQUEST_URI"]))
|
||||||
|
$this->baseURL = "/";
|
||||||
|
elseif (substr ($_SERVER["REQUEST_URI"], -1 * strlen ($request)) ===
|
||||||
|
$request)
|
||||||
{
|
{
|
||||||
$this->baseURL = substr ($_SERVER["REQUEST_URI"], 0,
|
$this->baseURL = substr ($_SERVER["REQUEST_URI"], 0,
|
||||||
strlen ($_SERVER["REQUEST_URI"]) - strlen ($request));
|
strlen ($_SERVER["REQUEST_URI"]) - strlen ($request));
|
||||||
@@ -156,7 +159,8 @@ class route
|
|||||||
if ($this->module != FALSE)
|
if ($this->module != FALSE)
|
||||||
{
|
{
|
||||||
$this->baseURLmodule = $this->baseURL;
|
$this->baseURLmodule = $this->baseURL;
|
||||||
$this->baseURL = dirname ($this->baseURL)."/";
|
if (dirname ($this->baseURL) !== "/")
|
||||||
|
$this->baseURL = dirname ($this->baseURL)."/";
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->baseURL;
|
return $this->baseURL;
|
||||||
|
|||||||
Reference in New Issue
Block a user