<?php
/**
* SVF_Controller_Plugin_Initialize
*
* LICENSE
*
* This source file is subject to the BSD license that is bundled
* with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://svf.webutilities.ch/license/bsd
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to hide@address.com so we can send you a copy immediately.
*
* @package SVF
* @category Controller
* @subpackage Controller
* @uses Zend_Controller_Plugin_Abstract
* @uses Zend_Controller_Request_Abstract
* @uses Zend_Controller_Front
* @uses Zend_View
* @uses Zend_Layout
* @uses SVF_Log
* @copyright Copyright (c) 2002-2008 Webutilities CH Inc. (http://www.webutilities.ch)
* @license BSD {@link http://svf.webutilities.ch/license/bsd}
* @author Silvan von Felten
* @version $Id$
*/
require_once 'Zend/Controller/Plugin/Abstract.php';
require_once 'Zend/Controller/Request/Abstract.php';
class SVF_Controller_Plugin_Initialize extends Zend_Controller_Plugin_Abstract
{
/**
* Instance
*
* @var Zend_Controller_Request_Abstract
*/
protected $_request;
/**
* Instance
*
* @var Zend_Controller_Front
*/
protected $_front;
/**
* Route Startup handler
*
* @param Zend_Controller_Request_Abstract $request
* @return void
*/
public function routeStartup(Zend_Controller_Request_Abstract $request)
{
require_once 'Zend/Controller/Front.php';
$this->_request = $request;
$this->_front = Zend_Controller_Front::getInstance();
$this->initControllers()
->initView()
->initLog();
}
/**
* Initialize controller directories
*
* @return SVF_Controller_Plugin_Initialize
*/
public function initControllers()
{
$this->_front->setControllerDirectory(APPLICATION_PATH .
'/controllers', 'default');
return $this;
}
/**
* Initialize view
*
* @return SVF_Controller_Plugin_Initialize
*/
public function initView()
{
require_once 'Zend/View.php';
require_once 'Zend/Layout.php';
$view = new Zend_View;
$view->baseUrl = rtrim($this->getRequest()->getBaseUrl(), '/');
$view->doctype('XHTML1_STRICT');
$view->headMeta()->appendHttpEquiv('Content-Type',
'text/html; charset=utf-8');
Zend_Registry::set('view', $view);
$viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('ViewRenderer');
$viewRenderer->setView($view);
Zend_Layout::startMvc
(
array
(
'layoutPath' => APPLICATION_PATH.
'/layouts/'.APPLICATION_LAYOUT.'/scripts'
)
);
return $this;
}
/**
* Initialize logger
*
* @return SVF_Controller_Plugin_Initialize
*/
public function initLog()
{
require_once 'SVF/Log.php';
$log = new SVF_Log;
/**
* Set here your logger or just add one of the plugins
* file, firebug, hard, php in the bootstrap file.
*/
// Set the logger to the registry
Zend_Registry::set('log', $log);
return $this;
}
}