Archived
1
0
Fork 0

Bootstrap: Navigation,Router,View/Layout,Config

This commit is contained in:
Fredric N 2010-08-21 19:51:35 +02:00
parent 14375db575
commit fe10b02c33
4 changed files with 103 additions and 16 deletions

View file

@ -5,22 +5,56 @@
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
{
/**
* Setup view object
* Setup navigaion
*
* return Zend_View $view
* @return Zend_Navigation $navigation
*/
protected function _initNav()
{
// Make sure we have our layout setup first.
$this->bootstrap('view');
$navConfig = new Zend_Config_Xml(APPLICATION_PATH . '/configs/navigation.xml', 'navigation');
$navigation = new Zend_Navigation($navConfig);
$view = $this->getResource('view');
$view->navigation($navigation);
return $navigation;
}
protected function _initConfig()
{
return new Zend_Config_Ini(APPLICATION_PATH . '/configs/application.ini', APPLICATION_ENV);
}
/**
* View and Layout configuration
*
* @return Zend_View $view
*/
protected function _initView()
{
// We really should add something here ?
$this->bootstrap('config');
$view = new Zend_View();
$view->setEncoding('UTF-8');
// Set site title
$view->headTitle($this->getResource('config')->app->name);
$layout = Zend_Layout::startMvc();
$layout->setLayoutPath(APPLICATION_PATH . '/modules/default/views/layout');
$layout->setLayout('default');
$layout->setView($view);
return $view;
}
/**
* Configure the front controller
*
* @return Zend_Controller_Front $frontController
*/
protected function _initFront()
{
@ -30,11 +64,41 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
// Set modules directory
$frontController->addModuleDirectory(APPLICATION_PATH . '/modules');
return $frontController;
}
/**
* Configure routes for our application
*
* @return Zend_Controller_Router_Rewrite $router
*/
protected function _initRouter()
{
// Make sure the front controller is ready
$this->bootstrap('front');
$router = $this->getResource('front')->getRouter();
$route = new Zend_Controller_Router_Route(
':lang/:module/:controller/:action/*',
array(
'lang' => 'sv',
'module' => 'default',
'controller' => 'index',
'action' => 'index'
)
);
$router->addRoute('default', $route);
return $router;
}
/**
* Setup a sweet and simple database
* connection
* connection.
*
* @return
*/
protected function _initDatabase()
{

View file

@ -7,6 +7,12 @@ phpSettings.display_errors = 0
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
// Application
app.name = "Fiktivkod"
app.version = "1.0"
app.url = "fiktivkod.org"
[development : production]
// Error settings
phpSettings.display_startup_errors = 1

View file

@ -0,0 +1,19 @@
<?xml version="1.0"?>
<config>
<navigation>
<start>
<label>Start</label>
<controller>index</controller>
<action>index</action>
<module>default</module>
<pages>
<blog>
<label>Blog</label>
<controller>index</controller>
<action>index</action>
<module>blog</module>
</blog>
</pages>
</start>
</navigation>
</config>

View file

@ -2,24 +2,22 @@
"http://www.w3.org/TR/2002/REC-xhtml1-20020801/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Elements.htm</title>
<meta link="description"></meta>
<link rel="stylesheet" type="text/css" href="css/default.css" media="screen" />
<?=$this->headTitle()."\n" /* Newline for pretty source :) */ ?>
<meta content="description"></meta>
<link rel="stylesheet" type="text/css" href="<?=$this->baseUrl()?>/css/default.css" media="screen" />
</head>
<body>
<div id="header"></div>
<div id="header">
</div>
<div id="nav">
<ul>
<li><a href="#" id="current">Start</a></li>
<li><a href="#">Länk</a></li>
<li><a href="#">Länk</a></li>
</ul>
<?=$this->navigation() ?>
<span class="float-right">
</span>
</div>
@ -49,7 +47,7 @@
</table>
<?=$this->content()?>
<?=$this->layout()->content ?>
</body>
</html>