Better server path handling when Standalone; Corrected references to 'Controler' for 'Controller'
This commit is contained in:
parent
d2b2cb31ff
commit
b178c9a884
22 changed files with 109 additions and 105 deletions
|
@ -1,14 +1,14 @@
|
|||
<?php
|
||||
|
||||
namespace BaikalAdmin\Controler;
|
||||
namespace BaikalAdmin\Controller;
|
||||
|
||||
class Dashboard extends \Flake\Core\Controler {
|
||||
class Dashboard extends \Flake\Core\Controller {
|
||||
|
||||
function execute() {
|
||||
}
|
||||
|
||||
function render() {
|
||||
$sLinkUsers = \BaikalAdmin\Controler\Users::link();
|
||||
$sLinkUsers = \BaikalAdmin\Controller\Users::link();
|
||||
|
||||
$sMessage =<<<MESSAGE
|
||||
Ici, infos sur:<br />
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace BaikalAdmin\Controler;
|
||||
namespace BaikalAdmin\Controller;
|
||||
|
||||
class Details extends \Flake\Core\Controler {
|
||||
class Details extends \Flake\Core\Controller {
|
||||
|
||||
function execute() {
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ class Details extends \Flake\Core\Controler {
|
|||
function render() {
|
||||
$aParams = $GLOBALS["ROUTER"]::getURLParams();
|
||||
if(($iUser = intval($aParams[0])) === 0) {
|
||||
throw new \Exception("BaikalAdmin\Controler\Details::render(): User get-parameter not found.");
|
||||
throw new \Exception("BaikalAdmin\Controller\Details::render(): User get-parameter not found.");
|
||||
}
|
||||
|
||||
$oUser = new \Baikal\Model\User($iUser);
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace BaikalAdmin\Controler;
|
||||
namespace BaikalAdmin\Controller;
|
||||
|
||||
class Install extends \Flake\Core\Controler {
|
||||
class Install extends \Flake\Core\Controller {
|
||||
|
||||
function execute() {
|
||||
}
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace BaikalAdmin\Controler;
|
||||
namespace BaikalAdmin\Controller;
|
||||
|
||||
class Users extends \Flake\Core\Controler {
|
||||
class Users extends \Flake\Core\Controller {
|
||||
|
||||
const BASEPATH = "/admin/";
|
||||
protected $aMessages = array();
|
||||
|
@ -23,7 +23,6 @@ class Users extends \Flake\Core\Controler {
|
|||
}
|
||||
|
||||
function execute() {
|
||||
|
||||
if(($iUser = self::editRequested()) !== FALSE) {
|
||||
if($this->oForm->submitted()) {
|
||||
$this->oForm->execute();
|
||||
|
@ -157,7 +156,7 @@ class Users extends \Flake\Core\Controler {
|
|||
}
|
||||
|
||||
public static function link() {
|
||||
return BAIKAL_URI . BAIKALADMIN_URIPATH . $GLOBALS["ROUTER"]::buildRouteForControler("\BaikalAdmin\Controler\Users");
|
||||
return BAIKAL_URI . BAIKALADMIN_URIPATH . $GLOBALS["ROUTER"]::buildRouteForController("\BaikalAdmin\Controller\Users");
|
||||
}
|
||||
|
||||
public static function linkNew() {
|
|
@ -1,61 +1,52 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>{pagetitle}</title>
|
||||
<base href="{baseurl}" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<meta name="description" content="" />
|
||||
<meta name="author" content="" />
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>{pagetitle}</title>
|
||||
<base href="{baseurl}" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
|
||||
<!-- Le styles -->
|
||||
<link href="res/core/TwitterBootstrap/css/bootstrap.css" rel="stylesheet" />
|
||||
<link href="res/core/BaikalAdmin/Templates/Page/style.css" rel="stylesheet" />
|
||||
<style>
|
||||
body {
|
||||
padding-top: 60px; /* 60px to make the container go all the way to the bottom of the topbar */
|
||||
}
|
||||
</style>
|
||||
<link href="res/core/TwitterBootstrap/css/bootstrap-responsive.css" rel="stylesheet" />
|
||||
<!-- Le styles -->
|
||||
<link href="res/core/TwitterBootstrap/css/bootstrap.css" rel="stylesheet" />
|
||||
<link href="res/core/BaikalAdmin/Templates/Page/style.css" rel="stylesheet" />
|
||||
<link href="res/core/TwitterBootstrap/css/bootstrap-responsive.css" rel="stylesheet" />
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
{head}
|
||||
</head>
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
{head}
|
||||
</head>
|
||||
<body>
|
||||
<div class="navbar navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container">
|
||||
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</a>
|
||||
<a class="brand" href="{adminurl}">Baïkal Admin</a>
|
||||
<div class="nav-collapse">
|
||||
<ul class="nav">
|
||||
<li class="active"><a href="{baseurl}">Home</a></li>
|
||||
<li><a href="#about">Users</a></li>
|
||||
<li><a href="#contact">Settings</a></li>
|
||||
</ul>
|
||||
</div><!--/.nav-collapse -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<body>
|
||||
|
||||
<div class="navbar navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container">
|
||||
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</a>
|
||||
<a class="brand" href="#">Baïkal Admin</a>
|
||||
<div class="nav-collapse">
|
||||
<ul class="nav">
|
||||
<li class="active"><a href="#">Home</a></li>
|
||||
<li><a href="#about">About</a></li>
|
||||
<li><a href="#contact">Contact</a></li>
|
||||
</ul>
|
||||
</div><!--/.nav-collapse -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="container">
|
||||
{Payload}
|
||||
</div> <!-- /container -->
|
||||
|
||||
<div class="container">
|
||||
{Payload}
|
||||
</div> <!-- /container -->
|
||||
|
||||
<!-- Le javascript
|
||||
================================================== -->
|
||||
<!-- Placed at the end of the document so the pages load faster -->
|
||||
<script src="res/core/TwitterBootstrap/js/jquery-1.7.1.min.js"></script>
|
||||
<script src="res/core/TwitterBootstrap/js/bootstrap.min.js"></script>
|
||||
{javascript}
|
||||
</body>
|
||||
<!-- Le javascript
|
||||
================================================== -->
|
||||
<!-- Placed at the end of the document so the pages load faster -->
|
||||
<script src="res/core/TwitterBootstrap/js/jquery-1.7.1.min.js"></script>
|
||||
<script src="res/core/TwitterBootstrap/js/bootstrap.min.js"></script>
|
||||
{javascript}
|
||||
</body>
|
||||
</html>
|
|
@ -1,3 +1,7 @@
|
|||
body {
|
||||
padding-top: 60px; /* 60px to make the container go all the way to the bottom of the topbar */
|
||||
}
|
||||
|
||||
/* Jumbotrons
|
||||
-------------------------------------------------- */
|
||||
.jumbotron {
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
<header class="jumbotron subhead" id="overview">
|
||||
<h1>Users</h1>
|
||||
<p class="lead pull-left">Browse, create, update and delete Baïkal user accounts.</p>
|
||||
<p class="pull-right"><a class="btn" href="<?= \BaikalAdmin\Controler\Users::linkNew() ?>"><i class="<?= \Baikal\Model\User::getIcon() ?>"></i> + Add user</a></p>
|
||||
<p class="pull-right"><a class="btn" href="<?= \BaikalAdmin\Controller\Users::linkNew() ?>"><i class="<?= \Baikal\Model\User::getIcon() ?>"></i> + Add user</a></p>
|
||||
</header>
|
||||
|
||||
<table class="table table-bordered table-striped">
|
||||
|
@ -17,9 +17,9 @@
|
|||
<th class="col-actions no-border-left"></th>
|
||||
</tr-->
|
||||
<? foreach($users as $user) {
|
||||
$linkdetails = \BaikalAdmin\Controler\Users::linkDetails($user);
|
||||
$linkedit = \BaikalAdmin\Controler\Users::linkEdit($user);
|
||||
$linkdelete = \BaikalAdmin\Controler\Users::linkDelete($user);
|
||||
$linkdetails = \BaikalAdmin\Controller\Users::linkDetails($user);
|
||||
$linkedit = \BaikalAdmin\Controller\Users::linkEdit($user);
|
||||
$linkdelete = \BaikalAdmin\Controller\Users::linkDelete($user);
|
||||
$mailtouri = $user->getMailtoURI();
|
||||
?>
|
||||
<tr>
|
||||
|
|
|
@ -5,6 +5,6 @@ namespace BaikalAdmin\Route;
|
|||
class Dashboard {
|
||||
|
||||
public static function execute(\Flake\Core\Render\Container &$oRenderContainer) {
|
||||
$oRenderContainer->zone("Payload")->addBlock(new \BaikalAdmin\Controler\Dashboard());
|
||||
$oRenderContainer->zone("Payload")->addBlock(new \BaikalAdmin\Controller\Dashboard());
|
||||
}
|
||||
}
|
|
@ -5,6 +5,6 @@ namespace BaikalAdmin\Route;
|
|||
class Details {
|
||||
|
||||
public static function execute(\Flake\Core\Render\Container &$oRenderContainer) {
|
||||
$oRenderContainer->zone("Payload")->addBlock(new \BaikalAdmin\Controler\Details());
|
||||
$oRenderContainer->zone("Payload")->addBlock(new \BaikalAdmin\Controller\Details());
|
||||
}
|
||||
}
|
|
@ -5,6 +5,6 @@ namespace BaikalAdmin\Route;
|
|||
class Install {
|
||||
|
||||
public static function execute(\Flake\Core\Render\Container &$oRenderContainer) {
|
||||
$oRenderContainer->zone("Payload")->addBlock(new \BaikalAdmin\Controler\Install());
|
||||
$oRenderContainer->zone("Payload")->addBlock(new \BaikalAdmin\Controller\Install());
|
||||
}
|
||||
}
|
|
@ -5,6 +5,6 @@ namespace BaikalAdmin\Route;
|
|||
class Users {
|
||||
|
||||
public static function execute(\Flake\Core\Render\Container &$oRenderContainer) {
|
||||
$oRenderContainer->zone("Payload")->addBlock(new \BaikalAdmin\Controler\Users());
|
||||
$oRenderContainer->zone("Payload")->addBlock(new \BaikalAdmin\Controller\Users());
|
||||
}
|
||||
}
|
|
@ -9,8 +9,8 @@ class Form extends \Flake\Core\View {
|
|||
|
||||
return $oTemplate->parse(array(
|
||||
"user" => $oUser,
|
||||
"linkcancel" => \BaikalAdmin\Controler\Users::link(),
|
||||
"action" => \BaikalAdmin\Controler\Users::linkEdit($oUser),
|
||||
"linkcancel" => \BaikalAdmin\Controller\Users::link(),
|
||||
"action" => \BaikalAdmin\Controller\Users::linkEdit($oUser),
|
||||
"messages" => $this->get("messages"),
|
||||
));
|
||||
}
|
||||
|
|
|
@ -38,11 +38,16 @@ require_once(dirname(__FILE__) . "/Core/Bootstrap.php");
|
|||
\BaikalAdmin\Core\Auth::assertAuthentified();
|
||||
|
||||
# Create and setup a page object
|
||||
$oPage = new \Flake\Controler\Page(BAIKALADMIN_PATH_TEMPLATES . "Page/index.html");
|
||||
$oPage = new \Flake\Controller\Page(BAIKALADMIN_PATH_TEMPLATES . "Page/index.html");
|
||||
$oPage->injectHTTPHeaders();
|
||||
$oPage->setTitle("Baïkal Web Admin");
|
||||
$oPage->setBaseUrl(BAIKAL_URI);
|
||||
|
||||
$sControllerForDefaultRoute = $GLOBALS["ROUTER"]::getControllerForRoute("default");
|
||||
$oPage->zone("adminurl")->addBlock(new \Flake\Controller\HtmlBlock(
|
||||
$sControllerForDefaultRoute::link()
|
||||
));
|
||||
|
||||
# Route the request
|
||||
$GLOBALS["ROUTER"]::route($oPage);
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Flake\Controler;
|
||||
namespace Flake\Controller;
|
||||
|
||||
class Cli extends \Flake\Core\Render\Container {
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace Flake\Controler;
|
||||
namespace Flake\Controller;
|
||||
|
||||
class HtmlBlock extends \Flake\Core\Controler {
|
||||
class HtmlBlock extends \Flake\Core\Controller {
|
||||
|
||||
function __construct($sHtml) {
|
||||
$this->sHtml = $sHtml;
|
|
@ -1,8 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace Flake\Controler;
|
||||
namespace Flake\Controller;
|
||||
|
||||
class HtmlBlockTemplated extends \Flake\Core\Controler {
|
||||
class HtmlBlockTemplated extends \Flake\Core\Controller {
|
||||
|
||||
function __construct($sTemplatePath, $aMarkers = array()) {
|
||||
$this->sTemplatePath = $sTemplatePath;
|
|
@ -1,12 +1,10 @@
|
|||
<?php
|
||||
|
||||
namespace Flake\Controler;
|
||||
namespace Flake\Controller;
|
||||
|
||||
class Kickstart extends \Flake\Core\Controler {
|
||||
class Kickstart extends \Flake\Core\Controller {
|
||||
|
||||
public function execute() {
|
||||
# "--helloworld"
|
||||
|
||||
if(array_key_exists("helloworld", self::cli()->aArgs)) {
|
||||
$this->action_helloworld();
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
<?php
|
||||
|
||||
namespace Flake\Controler;
|
||||
namespace Flake\Controller;
|
||||
|
||||
class Page extends \Flake\Core\Render\Container {
|
||||
|
||||
|
@ -114,6 +114,6 @@ class Page extends \Flake\Core\Render\Container {
|
|||
$sCssUrl = \Flake\Util\Tools::serverToRelativeWebPath($sCompiledFilePath);
|
||||
|
||||
$sHtml = "<link rel=\"stylesheet\" type=\"text/css\" href=\"" . $sCssUrl . "\" media=\"all\"/>";
|
||||
$this->zone("head")->addBlock(new \Flake\Controler\HtmlBlock($sHtml));
|
||||
$this->zone("head")->addBlock(new \Flake\Controller\HtmlBlock($sHtml));
|
||||
}
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Flake\Core;
|
||||
|
||||
abstract class Controler extends \Flake\Core\FLObject {
|
||||
abstract class Controller extends \Flake\Core\FLObject {
|
||||
|
||||
protected $aParams = array();
|
||||
|
||||
|
@ -12,11 +12,14 @@ abstract class Controler extends \Flake\Core\FLObject {
|
|||
|
||||
abstract function execute();
|
||||
abstract function render();
|
||||
static function link(/*[$sParam, $sParam2, ...]*/) {
|
||||
|
||||
}
|
||||
|
||||
public static function buildRoute(/*[$sParam, $sParam2, ...]*/) {
|
||||
$aParams = func_get_args();
|
||||
$sControler = "\\" . get_called_class();
|
||||
array_unshift($aParams, $sControler); # Injecting current controler as first param
|
||||
return call_user_func_array($GLOBALS["ROUTER"] . "::buildRouteForControler", $aParams);
|
||||
$sController = "\\" . get_called_class();
|
||||
array_unshift($aParams, $sController); # Injecting current controller as first param
|
||||
return call_user_func_array($GLOBALS["ROUTER"] . "::buildRouteForController", $aParams);
|
||||
}
|
||||
}
|
|
@ -5,6 +5,6 @@ namespace Flake\Route\Kickstart;
|
|||
class Main {
|
||||
|
||||
public function execute(\Flake\Core\Render\Container &$oRenderContainer) {
|
||||
$oRenderContainer->zone("Payload")->addBlock(new \Flake\Controler\Kickstart());
|
||||
$oRenderContainer->zone("Payload")->addBlock(new \Flake\Controller\Kickstart());
|
||||
}
|
||||
}
|
|
@ -15,22 +15,26 @@ abstract class Router extends \Flake\Core\FLObject {
|
|||
return $GLOBALS["ROUTES"];
|
||||
}
|
||||
|
||||
public static function getControlerForRoute($sRoute) {
|
||||
public static function getControllerForRoute($sRoute) {
|
||||
return str_replace("\\Route", "\\Controller", self::getRouteClassForRoute($sRoute));
|
||||
}
|
||||
|
||||
public static function getRouteClassForRoute($sRoute) {
|
||||
$aRoutes = $GLOBALS["ROUTER"]::getRoutes();
|
||||
return $aRoutes[$sRoute];
|
||||
}
|
||||
|
||||
public static function getRouteForControler($sControler) {
|
||||
public static function getRouteForController($sController) {
|
||||
|
||||
if($sControler{0} !== "\\") {
|
||||
$sControler = "\\" . $sControler;
|
||||
if($sController{0} !== "\\") {
|
||||
$sController = "\\" . $sController;
|
||||
}
|
||||
|
||||
$aRoutes = $GLOBALS["ROUTER"]::getRoutes();
|
||||
|
||||
reset($aRoutes);
|
||||
while(list($sRoute,) = each($aRoutes)) {
|
||||
if(str_replace("\\Route", "\\Controler", $aRoutes[$sRoute]) === $sControler) {
|
||||
if(str_replace("\\Route", "\\Controller", $aRoutes[$sRoute]) === $sController) {
|
||||
return $sRoute;
|
||||
}
|
||||
}
|
||||
|
@ -39,20 +43,20 @@ abstract class Router extends \Flake\Core\FLObject {
|
|||
}
|
||||
|
||||
public static function route(\Flake\Core\Render\Container &$oRenderContainer) {
|
||||
$sControler = $GLOBALS["ROUTER"]::getControlerForRoute(
|
||||
$sRouteClass = $GLOBALS["ROUTER"]::getRouteClassForRoute(
|
||||
$GLOBALS["ROUTER"]::getCurrentRoute()
|
||||
);
|
||||
|
||||
$sControler::execute($oRenderContainer);
|
||||
$sRouteClass::execute($oRenderContainer);
|
||||
}
|
||||
|
||||
public static function buildRouteForControler($sControler /* [, $sParam, $sParam2, ...] */) {
|
||||
public static function buildRouteForController($sController /* [, $sParam, $sParam2, ...] */) {
|
||||
|
||||
$aParams = func_get_args();
|
||||
array_shift($aParams); # stripping $sControler
|
||||
$sRouteForControler = $GLOBALS["ROUTER"]::getRouteForControler($sControler);
|
||||
array_shift($aParams); # stripping $sController
|
||||
$sRouteForController = $GLOBALS["ROUTER"]::getRouteForController($sController);
|
||||
|
||||
array_unshift($aParams, $sRouteForControler); # Injecting route as first param
|
||||
array_unshift($aParams, $sRouteForController); # Injecting route as first param
|
||||
return call_user_func_array($GLOBALS["ROUTER"] . "::buildRoute", $aParams);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ class QuestionMarkRewrite extends \Flake\Util\Router {
|
|||
|
||||
$aRoutes = self::getRoutes();
|
||||
reset($aRoutes);
|
||||
foreach($aRoutes as $sDefinedRoute => $sDefinedControler) {
|
||||
foreach($aRoutes as $sDefinedRoute => $sDefinedController) {
|
||||
if(strpos($sRoutePart, $sDefinedRoute) !== FALSE) {
|
||||
|
||||
# found a match
|
||||
|
|
Loading…
Reference in a new issue