198 lines
No EOL
4.8 KiB
PHP
198 lines
No EOL
4.8 KiB
PHP
<?php
|
|
/**
|
|
* Bootstrap this shit
|
|
*/
|
|
class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
|
|
{
|
|
/**
|
|
* Setup navigaion
|
|
*
|
|
* @return Zend_Navigation $navigation
|
|
*/
|
|
protected function _initNav()
|
|
{
|
|
$this->bootstrap('translate');
|
|
$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()->setTranslator($this->getResource('translate'));
|
|
$view->navigation($navigation);
|
|
|
|
|
|
return $navigation;
|
|
}
|
|
|
|
/**
|
|
* Setup layout
|
|
*
|
|
* @return Zend_Layout $layout
|
|
*/
|
|
protected function _initLayout()
|
|
{
|
|
$layout = Zend_Layout::startMvc();
|
|
$layout->setLayoutPath(APPLICATION_PATH . '/modules/default/views/layout');
|
|
$layout->setLayout('default');
|
|
|
|
return $layout;
|
|
}
|
|
|
|
|
|
/**
|
|
* View and Layout configuration
|
|
*
|
|
* @return Zend_View $view
|
|
*/
|
|
protected function _initView()
|
|
{
|
|
$this->bootstrap('layout');
|
|
|
|
$view = $this->getResource('layout')->getView();
|
|
$view->setEncoding('UTF-8');
|
|
|
|
// Set site title from application.ini
|
|
$config = $this->getApplication()->getOptions();
|
|
$view->headTitle($config['app']['name']);
|
|
$view->headMeta()->appendHttpEquiv('Content-Type','text/html;charset=utf-8');
|
|
|
|
// Set helper path
|
|
$view->addHelperPath('Fiktiv/View/Helper/', 'Fiktiv_View_Helper');
|
|
|
|
|
|
return $view;
|
|
}
|
|
|
|
/**
|
|
* Configure the front controller
|
|
*
|
|
* @return Zend_Controller_Front $frontController
|
|
*/
|
|
protected function _initFront()
|
|
{
|
|
$this->bootstrap('autoloader');
|
|
|
|
// Get front controller
|
|
$frontController = Zend_Controller_Front::getInstance();
|
|
|
|
// Set modules directory
|
|
$frontController->addModuleDirectory(APPLICATION_PATH . '/modules');
|
|
|
|
// Add plugins
|
|
$frontController->registerPlugin(new Fiktiv_Controller_Plugin_Language());
|
|
$frontController->registerPlugin(new Fiktiv_Controller_Plugin_Navigation());
|
|
|
|
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;
|
|
}
|
|
|
|
/**
|
|
* Configure global and local(modules) models
|
|
*/
|
|
protected function _initModels()
|
|
{
|
|
$this->bootstrap('autoloader');
|
|
|
|
// Include global model directory
|
|
set_include_path(implode(PATH_SEPARATOR, array(
|
|
APPLICATION_PATH . '/models',
|
|
get_include_path()
|
|
)));
|
|
|
|
// Let our model autoloader plugin handle local models
|
|
$front = $this->getResource('front');
|
|
$front->registerPlugin(new Fiktiv_Controller_Plugin_ModelAutoloader());
|
|
|
|
}
|
|
|
|
/**
|
|
* Configure autoloader
|
|
*
|
|
* @return Zend_Loader_Autoloader $autoloader
|
|
*/
|
|
protected function _initAutoloader()
|
|
{
|
|
$autoloader = Zend_Loader_Autoloader::getInstance();
|
|
$autoloader->registerNamespace('Fiktiv_');
|
|
$autoloader->setFallbackAutoloader(true);
|
|
|
|
return $autoloader;
|
|
}
|
|
|
|
/**
|
|
* Configure multilanguage (translator)
|
|
*
|
|
* @return Zend_Translate $translate
|
|
*/
|
|
protected function _initTranslate()
|
|
{
|
|
$this->bootstrap('autoloader');
|
|
|
|
$translate = new Fiktiv_Translate(array(
|
|
'adapter' => 'Fiktiv_Translate_Adapter_Ini',
|
|
'locale' => 'sv',
|
|
'content' => APPLICATION_PATH . '/languages/se.ini'
|
|
));
|
|
|
|
$translate->addTranslation(APPLICATION_PATH . '/languages/en.ini', 'en');
|
|
|
|
Zend_Form::setDefaultTranslator($translate);
|
|
|
|
Zend_Registry::set('Zend_Translate', $translate);
|
|
|
|
return $translate;
|
|
}
|
|
|
|
/**
|
|
* Setup a sweet and simple database
|
|
* connection.
|
|
*
|
|
* @return
|
|
*/
|
|
protected function _initDatabase()
|
|
{
|
|
// Oh, my!
|
|
}
|
|
|
|
/**
|
|
* Setup session
|
|
*
|
|
* @return Zend_Session $session
|
|
*/
|
|
protected function _initSession()
|
|
{
|
|
Zend_Session::start();
|
|
|
|
// TODO: Better name for global session namespace (default namespace)
|
|
$defaultNamespace = new Zend_Session_Namespace('global');
|
|
|
|
return $defaultNamespace;
|
|
}
|
|
} |