/** * init application * @return void */ protected function _initApplication() { Zend_Session::setOptions(array('name' => $this->settings->page->session->name, 'save_path' => realpath(APPLICATION_PATH . DIRECTORY_SEPARATOR . 'data' . DIRECTORY_SEPARATOR . 'sessions'))); Zend_Session::start(); // sollte wenn name feststeht ge�ndert werden # get an instance of the frontend controller $this->bootstrap('FrontController'); $this->frontController = Zend_Controller_Front::getInstance(); # now add our own dispatcher $this->frontController->setDispatcher(new FansubCMS_Controller_Dispatcher_Standard()); # prefix default module as well $this->frontController->setParam('prefixDefaultModule', true); # set default and module controller directrories // $this->frontController->setControllerDirectory($this->settings->controllers->toArray()); $this->frontController->addModuleDirectory(APPLICATION_PATH . "/modules"); $this->frontController->removeControllerDirectory('default'); # set default module $this->frontController->setDefaultModule("news"); # Init application-wide Session $applicationSessionNamespace = new Zend_Session_Namespace('application'); $applicationSessionNamespace->tstamp = !isset($applicationSessionNamespace->tstamp) ? time() : $applicationSessionNamespace->tstamp; # add it to the registry Zend_Registry::set('applicationSessionNamespace', $applicationSessionNamespace); # Init authentication Session $authSessionNamespace = new Zend_Session_Namespace('Zend_Auth'); # add it to the registry Zend_Registry::set('AuthSessionNamespace', $authSessionNamespace); # set timezone date_default_timezone_set(empty($this->settings->page->timezone) ? 'Europe/Berlin' : $this->settings->page->timezone); # hook to settings $this->settings->applicationStatus = $this->applicationStatus; # hook needed objects/values to the zend registry Zend_Registry::set('settings', $this->settings); Zend_Registry::set('applicationStatus', $this->applicationStatus); Zend_Registry::set('environmentSettings', $this->environmentsettings); Zend_Registry::set('emailSettings', $this->mailsettings); }
/** * Initialises the application * */ public function init() { $__start = getmicrotime(); if (isset($this->config['log_file'])) { $writer = new Zend_Log_Writer_Stream($this->config['log_file']); $this->logger = new Zend_Log($writer); if (isset($this->config['log_format'])) { $formatter = new Zend_Log_Formatter_Simple($this->config['log_format']); $writer->setFormatter($formatter); } // If not in debug mode, hide debug log messages if (!ifset($this->config, 'debug', false)) { $this->logger->addFilter(Zend_Log::NOTICE); } } $this->recordStat('za::initlog', getmicrotime() - $__start); $__start = getmicrotime(); $mailServer = $this->getConfig('smtp_server'); if (mb_strlen($mailServer)) { ini_set('SMTP', $mailServer); } // Create a new view object. $view = new CompositeView(); Zend_Registry::set(self::$ZEND_VIEW, $view); /* @var Zend_Controller_Front $controller */ $this->frontController = Zend_Controller_Front::getInstance(); $this->frontController->setDispatcher(new InjectingDispatcher()); $this->frontController->addControllerDirectory($this->getConfig('controller_dir', 'controllers'), 'default'); $modules = ifset($this->config, 'modules', array()); foreach ($modules as $module) { if (is_dir(APP_DIR . '/modules/' . $module)) { $this->frontController->addControllerDirectory('modules/' . $module, $module); } } $this->recordStat('za::initmodules', getmicrotime() - $__start); $__start = getmicrotime(); $this->frontController->throwExceptions(ifset($this->config, 'debug', false) ? true : false); if (isset($this->config['route_config']) && php_sapi_name() != 'cli') { $router = $this->frontController->getRouter(); /* @var $router Zend_Controller_Router_Rewrite */ $config = new Zend_Config_Ini($this->config['route_config'], 'routes'); $router->addConfig($config, 'routes'); } Zend_Controller_Action_HelperBroker::removeHelper('viewRenderer'); $this->frontController->setParam('noViewRenderer', true); /** * Set the session */ $session_name = str_replace(' ', '_', $this->config['name']); Zend_Session::start(array('name' => $session_name)); $this->injector->addAutoProperty('log', $this->logger); $__start = getmicrotime(); // $services = $this->loadDefaultServices(); $this->injector->addServiceDirectory(NOVEMBER_APP_DIR . '/services'); // $this->injector->loadServices($this->config['services']); $this->recordStat('za::initdefaultservices', getmicrotime() - $__start); $__start = getmicrotime(); // // foreach ($services as $defaultService) { // $this->injector->inject($defaultService); // } // $this->recordStat('za::initinjectdefaultservices', getmicrotime() - $__start); $__start = getmicrotime(); // Load extensions $this->loadExtensions(); $this->injector->addServiceDirectory(ifset($this->config, 'services_dir', APP_DIR . '/services')); $this->recordStat('za::initloadext', getmicrotime() - $__start); $__start = getmicrotime(); $this->injector->loadServices($this->config['services']); $this->recordStat('za::initloadservices', getmicrotime() - $__start); $__start = getmicrotime(); // We know that there's definitely going to be an AuthService, // so we can now go and load the user if there was one in // the session. $auth = $this->injector->getService('AuthService'); if (isset($this->getSession()->CURRENT_USER_TICKET) && mb_strlen($this->getSession()->CURRENT_USER_TICKET)) { $auth->validateTicket($this->getSession()->CURRENT_USER_NAME, $this->getSession()->CURRENT_USER_TICKET); } $this->recordStat('za::initvalidateauth', getmicrotime() - $__start); }