Guest User

Untitled

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