/** * Init the front for test it */ public function __construct() { parent::__construct(); $this->request = new Zend_Controller_Request_Http(); $this->response = new Zend_Controller_Response_Http(); $this->config = Phprojekt::getInstance()->getConfig(); $this->config->language = "en"; $this->request->setModuleName('Default'); $this->request->setActionName('index'); // Languages Set Zend_Loader::loadClass('Phprojekt_Language', PHPR_LIBRARY_PATH); $cache = Phprojekt::getInstance()->getCache(); if (!($translate = $cache->load('Phprojekt_getTranslate_en'))) { $translate = new Phprojekt_Language(array('locale' => 'en')); $cache->save($translate, 'Phprojekt_getTranslate_en', array('Language')); } Zend_Registry::set('translate', $translate); $view = new Zend_View(); $view->addScriptPath(PHPR_CORE_PATH . '/Default/Views/dojo/'); $viewRenderer = new Zend_Controller_Action_Helper_ViewRenderer($view); $viewRenderer->setViewBasePathSpec(':moduleDir/Views'); $viewRenderer->setViewScriptPathSpec(':action.:suffix'); Zend_Controller_Action_HelperBroker::addHelper($viewRenderer); /* Front controller stuff */ $this->front = Zend_Controller_Front::getInstance(); $this->front->setDispatcher(new Phprojekt_Dispatcher()); $this->front->registerPlugin(new Zend_Controller_Plugin_ErrorHandler()); $this->front->setDefaultModule('Default'); $moduleDirectories = array(); // System modules foreach (scandir(PHPR_CORE_PATH) as $module) { $dir = PHPR_CORE_PATH . DIRECTORY_SEPARATOR . $module; if (is_dir(!$dir)) { continue; } $helperPath = $dir . DIRECTORY_SEPARATOR . 'Helpers'; if (is_dir($helperPath)) { $view->addHelperPath($helperPath, $module . '_' . 'Helpers'); Zend_Controller_Action_HelperBroker::addPath($helperPath); } $dir = PHPR_CORE_PATH . DIRECTORY_SEPARATOR . $module . DIRECTORY_SEPARATOR . 'SubModules'; if (is_dir($dir)) { if ($module != 'Core') { $moduleDirectories[] = $dir; } else { $coreModules = scandir($dir); foreach ($coreModules as $coreModule) { $coreDir = $dir . DIRECTORY_SEPARATOR . $coreModule; if ($coreModule != '.' && $coreModule != '..' && is_dir($coreDir)) { $moduleDirectories[] = $coreDir; } } } } } // User modules foreach (scandir(PHPR_USER_CORE_PATH) as $module) { $dir = PHPR_USER_CORE_PATH . $module; if (is_dir(!$dir)) { continue; } $helperPath = $dir . DIRECTORY_SEPARATOR . 'Helpers'; if (is_dir($helperPath)) { $view->addHelperPath($helperPath, $module . '_' . 'Helpers'); Zend_Controller_Action_HelperBroker::addPath($helperPath); } $dir = PHPR_USER_CORE_PATH . $module . DIRECTORY_SEPARATOR . 'SubModules'; if (is_dir($dir)) { $moduleDirectories[] = $dir; } } Zend_Registry::set('view', $view); $this->front->setModuleControllerDirectoryName('Controllers'); $this->front->addModuleDirectory(PHPR_CORE_PATH); $this->front->addModuleDirectory(PHPR_USER_CORE_PATH); foreach ($moduleDirectories as $moduleDirectory) { $this->front->addModuleDirectory($moduleDirectory); } $this->front->setParam('useDefaultControllerAlways', true); $this->front->throwExceptions(true); }