Various updates.
- Clearer error messages when no routes match. - Favicon link fixed. - “<base href="…">” tag removed from the layout.
This commit is contained in:
parent
b00064ca9b
commit
c96a7ca308
@ -32,7 +32,7 @@ final class ServiceLocator extends Base
|
|||||||
parent::__construct();
|
parent::__construct();
|
||||||
}
|
}
|
||||||
|
|
||||||
function get($id)
|
function get($id, $default = 'throws an exception')
|
||||||
{
|
{
|
||||||
if (isset($this->_entries[$id])
|
if (isset($this->_entries[$id])
|
||||||
|| array_key_exists($id, $this->_entries))
|
|| array_key_exists($id, $this->_entries))
|
||||||
@ -60,7 +60,13 @@ final class ServiceLocator extends Base
|
|||||||
return new $id;
|
return new $id;
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new Exception('no such entry: '.$id);
|
// Nothing found.
|
||||||
|
if (func_num_args() < 2)
|
||||||
|
{
|
||||||
|
throw new Exception('no such entry ('.$path.')');
|
||||||
|
}
|
||||||
|
|
||||||
|
return $default;
|
||||||
}
|
}
|
||||||
|
|
||||||
function set($id, $value)
|
function set($id, $value)
|
||||||
@ -186,7 +192,7 @@ final class ServiceLocator extends Base
|
|||||||
'url' => array($tu, 'url'),
|
'url' => array($tu, 'url'),
|
||||||
);
|
);
|
||||||
$tm->defaultVariables += array(
|
$tm->defaultVariables += array(
|
||||||
'base_path' => $this->get('config')['base_path'].'/',
|
'base_path' => $this->get('config')['base_path'],
|
||||||
);
|
);
|
||||||
|
|
||||||
return $tm;
|
return $tm;
|
||||||
|
Before Width: | Height: | Size: 1.5 KiB After Width: | Height: | Size: 1.5 KiB |
@ -75,10 +75,11 @@ $routes = $locator->get('routes');
|
|||||||
$parameters = $routes->match($context);
|
$parameters = $routes->match($context);
|
||||||
|
|
||||||
// Basic error message if no route found.
|
// Basic error message if no route found.
|
||||||
if (!$parameters)
|
if (!$parameters
|
||||||
|
|| !($controller = $locator->get('controller.'.$parameters['controller'], false)))
|
||||||
{
|
{
|
||||||
trigger_error(
|
trigger_error(
|
||||||
'no route found',
|
'no route found for: '.$context['path'],
|
||||||
E_USER_ERROR
|
E_USER_ERROR
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -86,8 +87,5 @@ if (!$parameters)
|
|||||||
// @todo Not sure it is the right place to put the current route.
|
// @todo Not sure it is the right place to put the current route.
|
||||||
$locator->set('current_controller', $parameters['controller']);
|
$locator->set('current_controller', $parameters['controller']);
|
||||||
|
|
||||||
// Gets the current controller.
|
|
||||||
$controller = $locator->get('controller.'.$parameters['controller']);
|
|
||||||
|
|
||||||
// Dispatches the current action.
|
// Dispatches the current action.
|
||||||
$controller->dispatch($parameters['action']);
|
$controller->dispatch($parameters['action']);
|
||||||
|
@ -33,19 +33,17 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="en" dir="ltr">
|
<html lang="en" dir="ltr">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8" />
|
||||||
|
|
||||||
<base href="{$base_path}" />
|
|
||||||
|
|
||||||
<title>{block title}Xen Orchestra{/block}</title>
|
<title>{block title}Xen Orchestra{/block}</title>
|
||||||
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
<meta name="description" content="Web Interface for XCP">
|
<meta name="description" content="Web Interface for XCP" />
|
||||||
<meta name="author" content="Olivier Lambert and Julien Fontanet">
|
<meta name="author" content="Olivier Lambert and Julien Fontanet" />
|
||||||
|
|
||||||
{* We use Bootstrap CSS. *}
|
{* We use Bootstrap CSS. *}
|
||||||
<link href="css/bootstrap.css" rel="stylesheet">
|
<link href="{$base_path}/css/bootstrap.css" rel="stylesheet" />
|
||||||
<link href="css/bootstrap-responsive.css" rel="stylesheet">
|
<link href="{$base_path}/css/bootstrap-responsive.css" rel="stylesheet" />
|
||||||
|
|
||||||
{* IE support. *}
|
{* IE support. *}
|
||||||
{* HTML5 shim, for IE6-8 support of HTML5 elements *}
|
{* HTML5 shim, for IE6-8 support of HTML5 elements *}
|
||||||
@ -53,11 +51,11 @@
|
|||||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
{* This font is used for icons. *}
|
{* This font is used for icons. *}
|
||||||
<link rel="stylesheet" href="css/font-awesome.css">
|
<link rel="stylesheet" href="{$base_path}/css/font-awesome.css" />
|
||||||
|
|
||||||
{* Our stylesheet and scripts. *}
|
{* Our stylesheet and scripts. *}
|
||||||
<link rel="stylesheet" href="css/style.css">
|
<link rel="stylesheet" href="{$base_path}/css/style.css" />
|
||||||
<link rel="icon" href="img/favicon.ico" />
|
<link rel="icon" type="image/png" href="{$base_path}/img/favicon.png" />
|
||||||
|
|
||||||
|
|
||||||
{* Children templates may used this block to add extra headers. *}
|
{* Children templates may used this block to add extra headers. *}
|
||||||
@ -68,7 +66,7 @@
|
|||||||
<div class="navbar navbar-fixed-top">
|
<div class="navbar navbar-fixed-top">
|
||||||
<div class="navbar-inner">
|
<div class="navbar-inner">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<a class="brand" href="./"><img src="img/bannerb.png"></a>
|
<a class="brand" href="./"><img src="{$base_path}/img/bannerb.png"></a>
|
||||||
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
|
<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>
|
<span class="icon-bar"></span>
|
||||||
@ -155,8 +153,8 @@
|
|||||||
{block body}{/block}
|
{block body}{/block}
|
||||||
|
|
||||||
{* JS Placed at the end of the document so the pages load faster *}
|
{* JS Placed at the end of the document so the pages load faster *}
|
||||||
<script src="js/jquery.js"></script>
|
<script src="{$base_path}/js/jquery.js"></script>
|
||||||
<script src="js/bootstrap.js"></script>
|
<script src="{$base_path}/js/bootstrap.js"></script>
|
||||||
<script type="text/javascript" src="js/xo.js"></script>
|
<script type="text/javascript" src="{$base_path}/js/xo.js"></script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
Reference in New Issue
Block a user