Guest User

Untitled

a guest
Jun 18th, 2018
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.50 KB | None | 0 0
  1. <?php
  2.  
  3. // Define path to application directory
  4. defined('APPLICATION_PATH')
  5. || define('APPLICATION_PATH',
  6. realpath(dirname(__FILE__) . '/../application'));
  7.  
  8. // Define application environment
  9. defined('APPLICATION_ENV')
  10. || define('APPLICATION_ENV',
  11. (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV')
  12. : 'production'));
  13.  
  14.  
  15. /** Zend_Application */
  16. require_once 'Zend/Application.php';
  17.  
  18. // Create application, bootstrap, and run
  19. $application = new Zend_Application(
  20. APPLICATION_ENV,
  21. APPLICATION_PATH . '/config/application.ini'
  22. );
  23. $application->bootstrap()
  24. ->run();
  25.  
  26.  
  27.  
  28. ==========================================
  29.  
  30. <?php
  31.  
  32. class Bootstrap extends Zend_Application_Bootstrap_Bootstrap
  33. {
  34.  
  35. }
  36.  
  37.  
  38. ==========================================
  39.  
  40. [production]
  41. ;error reporting
  42. phpSettings.display_startup_errors = 0
  43. phpSettings.display_errors = 0
  44. phpsettings.date.timezone = "America/Chicago"
  45.  
  46. ;include path
  47. includePaths.library = APPLICATION_PATH "/../library"
  48.  
  49. ;bootstrap
  50. bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
  51. bootstrap.class = "Bootstrap"
  52. autoloadernamespaces.0 = "Zend_"
  53. autoloadernamespaces.1 = "ZendX_"
  54. autoloadernamespaces.2 = "App_"
  55.  
  56.  
  57. ;resources
  58. resources.frontController.moduleDirectory = APPLICATION_PATH "/modules"
  59. resources.frontController.defaultControllerName = "index"
  60. resources.frontController.plugins.switchmodulelayout = "App_Controller_Plugin_SwitchModuleLayout"
  61. resources.frontController.baseUrl = APPLICATION_PATH "/public"
  62. resources.frontController.env = APPLICATION_ENV
  63. resources.frontcontroller.throwerrors = false
  64. resources.frontcontroller.params.prefixDefaultModule = true
  65.  
  66. ;resources.database
  67. resources.db.params.adapter = PDO_MYSQL
  68. resources.db.isdefaulttableadapter = true
  69. resources.db.params.host = localhost
  70. resources.db.params.username =
  71. resources.db.params.password =
  72. resources.db.params.dbname =
  73.  
  74. [staging : production]
  75.  
  76. [testing : production]
  77. ;error reporting
  78. phpSettings.display_startup_errors = 1
  79. phpSettings.display_errors = 1
  80.  
  81. ;resources
  82. resources.frontcontroller.throwerrors = true
  83.  
  84. [development : production]
  85. ;error reporting
  86. phpSettings.display_startup_errors = 1
  87. phpSettings.display_errors = 1
  88.  
  89. ;resources
  90. resources.frontcontroller.throwerrors = true
  91.  
  92.  
  93.  
  94. ===========================================
  95.  
  96. <?php
  97.  
  98. class App_Controller_Plugin_SwitchModuleLayout extends Zend_Controller_Plugin_Abstract
  99. {
  100. protected $_baseIncludePath;
  101. protected $_view = null;
  102.  
  103. public function __construct()
  104. {
  105. $this->_baseIncludePath = get_include_path();
  106. }
  107.  
  108. public function routeShutdown(Zend_Controller_Request_Abstract $request)
  109. {
  110. // Changes the Layout based on the module name
  111. $moduleName = $request->getModuleName();
  112.  
  113. $frontController = Zend_Controller_Front::getInstance();
  114. $controllerDirectory = $frontController->getControllerDirectory($moduleName);
  115.  
  116. $moduleDirectory = dirname($controllerDirectory);
  117. $modelsDirectory = $moduleDirectory . '/models/';
  118. $formsDirectory = $moduleDirectory . '/forms/';
  119.  
  120. $layout = Zend_Layout::getMvcInstance();
  121. $layout->setLayoutPath('../application/modules/' . $moduleName . '/layouts')->setLayout($moduleName);
  122.  
  123. $view = new Zend_View();
  124. $viewRenderer = Zend_Controller_Action_HelperBroker::getStaticHelper('viewRenderer');
  125. $viewRenderer->init();
  126.  
  127.  
  128. $this->_view = $viewRenderer->view;
  129. $this->_view->doctype(Zend_View_Helper_Doctype::XHTML1_STRICT);
  130. $this->_view->headMeta()->setHttpEquiv('content-type', 'text/html; charset=utf-8');
  131. $this->_view->addHelperPath($moduleDirectory . '/views/helpers/');
  132. $this->_view->setHelperPath($moduleDirectory . '/views/helpers');
  133. $this->_view->headTitle('')->setSeparator(' - ');
  134.  
  135. set_include_path($modelsDirectory . PATH_SEPARATOR . $formsDirectory . PATH_SEPARATOR . $this->_baseIncludePath);
  136.  
  137.  
  138. return $request;
  139. }
  140.  
  141. public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request)
  142. {
  143.  
  144. }
  145.  
  146. public function postDispatch(Zend_Controller_Request_Abstract $request)
  147. {
  148. if (!$request->isDispatched())
  149. {
  150. return;
  151. }
  152.  
  153. $this->_view->headTitle($this->_view->title);
  154. }
  155. }
Add Comment
Please, Sign In to add comment