/** * Method to run the application routines. * * @return void * * @since 1.0 */ public function doExecute() { // Register the template to the config $template = $this->getTemplate(true); $this->set('theme', $template->template); $this->set('themeFile', $this->input->get('tmpl', 'index') . '.php'); // Set metadata $this->document->setTitle('Cobalt'); // Start the output buffer ob_start(); // Install check if (!file_exists(JPATH_CONFIGURATION . '/configuration.php') || filesize(JPATH_CONFIGURATION . '/configuration.php') < 10) { // Redirect to the installer if we aren't there if (strpos($this->get('uri.route'), 'install') === false && $this->input->getString('task') != 'install') { ob_end_flush(); $this->redirect(RouteHelper::_('index.php?view=install')); } // Build a session object to push into the DI container $session = new Session(new MockFileSessionStorage()); $this->getContainer()->set('session', $session); // Fetch the controller $controllerObj = $this->getRouter()->getController($this->get('uri.route')); // Perform the Request task $controllerObj->execute(); } elseif (file_exists(JPATH_CONFIGURATION . '/configuration.php') && filesize(JPATH_CONFIGURATION . '/configuration.php') > 10 && strpos($this->get('uri.route'), 'install') !== false) { $this->redirect(RouteHelper::_('index.php')); } else { // Finish bootstrapping the application now $this->getContainer()->registerServiceProvider(new Provider\ConfigServiceProvider())->registerServiceProvider(new Provider\DatabaseServiceProvider())->registerServiceProvider(new Provider\SessionServiceProvider()); $this->loadConfiguration(); // Load Language UsersHelper::loadLanguage(); // Set site timezone $tz = DateHelper::getSiteTimezone(); // Get user object $user = $this->getUser(); // Fetch the controller $controllerObj = $this->getRouter()->getController($this->get('uri.route')); // Require specific controller if requested $controller = $this->input->get('controller', 'default'); // Load user toolbar $format = $this->input->get('format'); $overrides = array('ajax', 'mail', 'login'); $loggedIn = $user->isAuthenticated(); if ($loggedIn && $format !== 'raw' && !in_array($controller, $overrides)) { ActivityHelper::saveUserLoginHistory(); // Set a default view if none exists $this->input->def('view', 'dashboard'); // Grab document instance $document = $this->getDocument(); // Start component div wrapper if (!in_array($this->input->get('view'), array('print'))) { TemplateHelper::loadToolbar(); } TemplateHelper::startCompWrap(); // Load javascript language TemplateHelper::loadJavascriptLanguage(); TemplateHelper::showMessages(); } if (!$loggedIn && !$controllerObj instanceof \Cobalt\Controller\Login) { $this->redirect(RouteHelper::_('index.php?view=login')); } // Fullscreen detection if (UsersHelper::isFullscreen()) { $this->input->set('tmpl', 'component'); } // Perform the Request task $controllerObj->execute(); // End componenet wrapper if ($user !== false && $format !== 'raw') { TemplateHelper::endCompWrap(); } } $contents = ob_get_clean(); if ($this->input->get('format', 'html') === 'raw') { $this->setBody($contents); } else { $this->document->setBuffer($contents, 'cobalt'); $this->setBody($this->document->render(false, (array) $template)); } }