Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Define path to application directory
- defined('APPLICATION_PATH')
- || define('APPLICATION_PATH',
- realpath(dirname(__FILE__) . '/../application'));
- // Define application environment
- defined('APPLICATION_ENV')
- || define('APPLICATION_ENV',
- (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV')
- : 'production'));
- /** Zend_Application */
- require_once 'Zend/Application.php';
- // Create application, bootstrap, and run
- $application = new Zend_Application(
- APPLICATION_ENV,
- APPLICATION_PATH . '/config/application.ini'
- );
- $application->bootstrap()
- ->run();
- ==========================================
- <?php
- class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
- {
- }
- ==========================================
- [production]
- ;error reporting
- phpSettings.display_startup_errors = 0
- phpSettings.display_errors = 0
- phpsettings.date.timezone = "America/Chicago"
- ;include path
- includePaths.library = APPLICATION_PATH "/../library"
- ;bootstrap
- bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
- bootstrap.class = "Bootstrap"
- autoloadernamespaces.0 = "Zend_"
- autoloadernamespaces.1 = "ZendX_"
- autoloadernamespaces.2 = "App_"
- ;resources
- resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
- resources.frontController.defaultControllerName = "index"
- resources.frontController.plugins.switchmodulelayout = "App_Controller_Plugin_SwitchModuleLayout"
- resources.frontController.baseUrl = APPLICATION_PATH "/public"
- resources.frontController.env = APPLICATION_ENV
- resources.frontcontroller.throwerrors = false
- resources.frontcontroller.params.prefixDefaultModule = true
- ;resources.database
- resources.db.params.adapter = PDO_MYSQL
- resources.db.isdefaulttableadapter = true
- resources.db.params.host = localhost
- resources.db.params.username =
- resources.db.params.password =
- resources.db.params.dbname =
- [staging : production]
- [testing : production]
- ;error reporting
- phpSettings.display_startup_errors = 1
- phpSettings.display_errors = 1
- ;resources
- resources.frontcontroller.throwerrors = true
- [development : production]
- ;error reporting
- phpSettings.display_startup_errors = 1
- phpSettings.display_errors = 1
- ;resources
- resources.frontcontroller.throwerrors = true
- ===========================================
- <?php
- class App_Controller_Plugin_SwitchModuleLayout extends Zend_Controller_Plugin_Abstract
- {
- protected $_baseIncludePath;
- protected $_view = null;
- public function __construct()
- {
- $this->_baseIncludePath = get_include_path();
- }
- public function routeShutdown(Zend_Controller_Request_Abstract $request)
- {
- // Changes the Layout based on the module name
- $moduleName = $request->getModuleName();
- $frontController = Zend_Controller_Front::getInstance();
- $controllerDirectory = $frontController->getControllerDirectory($moduleName);
- $moduleDirectory = dirname($controllerDirectory);
- $modelsDirectory = $moduleDirectory . '/models/';
- $formsDirectory = $moduleDirectory . '/forms/';
- $layout = Zend_Layout::getMvcInstance();
- $layout->setLayoutPath('../application/modules/' . $moduleName . '/layouts')->setLayout($moduleName);
- $view = new Zend_View();
- $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
- $viewRenderer->init();
- $this->_view = $viewRenderer->view;
- $this->_view->doctype(Zend_View_Helper_Doctype::XHTML1_STRICT);
- $this->_view->headMeta()->setHttpEquiv('content-type', 'text/html; charset=utf-8');
- $this->_view->addHelperPath($moduleDirectory . '/views/helpers/');
- $this->_view->setHelperPath($moduleDirectory . '/views/helpers');
- $this->_view->headTitle('')->setSeparator(' - ');
- set_include_path($modelsDirectory . PATH_SEPARATOR . $formsDirectory . PATH_SEPARATOR . $this->_baseIncludePath);
- return $request;
- }
- public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request)
- {
- }
- public function postDispatch(Zend_Controller_Request_Abstract $request)
- {
- if (!$request->isDispatched())
- {
- return;
- }
- $this->_view->headTitle($this->_view->title);
- }
- }
Add Comment
Please, Sign In to add comment