public function routeShutdown(Zend_Controller_Request_Abstract $request) { if (!Pimcore_Tool::useFrontendOutputFilters($request)) { return $this->disable(); } if ($request->getParam("document") instanceof Document_Page) { $this->document = $request->getParam("document"); } }
public static function run() { self::setSystemRequirements(); // detect frontend (website) $frontend = Pimcore_Tool::isFrontend(); // enable the output-buffer, why? see in self::outputBufferStart() if ($frontend) { self::outputBufferStart(); } self::initAutoloader(); self::initConfiguration(); self::setupFramework(); // config is loaded now init the real logger self::initLogger(); self::initModules(); self::initPlugins(); // init front controller $front = Zend_Controller_Front::getInstance(); $conf = Pimcore_Config::getSystemConfig(); if (!$conf) { // redirect to installer if configuration isn't present if (!preg_match("/^\\/install.*/", $_SERVER["REQUEST_URI"])) { header("Location: /install/"); exit; } } // set timezone if ($conf instanceof Zend_Config) { if ($conf->general->timezone) { date_default_timezone_set($conf->general->timezone); } } $front->registerPlugin(new Pimcore_Controller_Plugin_Maintenance(), 2); // register general pimcore plugins for frontend if ($frontend) { $front->registerPlugin(new Pimcore_Controller_Plugin_ErrorHandler(), 1); $front->registerPlugin(new Pimcore_Controller_Plugin_Less(), 799); } if (Pimcore_Tool::useFrontendOutputFilters(new Zend_Controller_Request_Http())) { $front->registerPlugin(new Pimcore_Controller_Plugin_WysiwygAttributes(), 796); $front->registerPlugin(new Pimcore_Controller_Plugin_Webmastertools(), 797); $front->registerPlugin(new Pimcore_Controller_Plugin_Analytics(), 798); $front->registerPlugin(new Pimcore_Controller_Plugin_CssMinify(), 800); $front->registerPlugin(new Pimcore_Controller_Plugin_JavascriptMinify(), 801); $front->registerPlugin(new Pimcore_Controller_Plugin_HtmlMinify(), 802); $front->registerPlugin(new Pimcore_Controller_Plugin_ImageDataUri(), 803); $front->registerPlugin(new Pimcore_Controller_Plugin_CDN(), 804); $front->registerPlugin(new Pimcore_Controller_Plugin_Cache(), 901); // for caching } self::initControllerFront($front); // set router $router = $front->getRouter(); $routeAdmin = new Zend_Controller_Router_Route('admin/:controller/:action/*', array('module' => 'admin', "controller" => "index", "action" => "index")); $routeInstall = new Zend_Controller_Router_Route('install/:controller/:action/*', array('module' => 'install', "controller" => "index", "action" => "index")); $routeUpdate = new Zend_Controller_Router_Route('admin/update/:controller/:action/*', array('module' => 'update', "controller" => "index", "action" => "index")); $routePlugins = new Zend_Controller_Router_Route('admin/plugin/:controller/:action/*', array('module' => 'pluginadmin', "controller" => "index", "action" => "index")); $routeExtensions = new Zend_Controller_Router_Route('admin/extensionmanager/:controller/:action/*', array('module' => 'extensionmanager', "controller" => "index", "action" => "index")); $routeReports = new Zend_Controller_Router_Route('admin/reports/:controller/:action/*', array('module' => 'reports', "controller" => "index", "action" => "index")); $routePlugin = new Zend_Controller_Router_Route('plugin/:module/:controller/:action/*', array("controller" => "index", "action" => "index")); $routeWebservice = new Zend_Controller_Router_Route('webservice/:controller/:action/*', array("module" => "webservice", "controller" => "index", "action" => "index")); $routeSearchAdmin = new Zend_Controller_Router_Route('admin/search/:controller/:action/*', array("module" => "searchadmin", "controller" => "index", "action" => "index")); // website route => custom router which check for a suitable document $routeFrontend = new Pimcore_Controller_Router_Route_Frontend(); $router->addRoute('default', $routeFrontend); // only do this if not frontend => performance issue if (!$frontend) { $router->addRoute("install", $routeInstall); $router->addRoute('plugin', $routePlugin); $router->addRoute('admin', $routeAdmin); $router->addRoute('update', $routeUpdate); $router->addRoute('plugins', $routePlugins); $router->addRoute('extensionmanager', $routeExtensions); $router->addRoute('reports', $routeReports); $router->addRoute('searchadmin', $routeSearchAdmin); if ($conf instanceof Zend_Config and $conf->webservice and $conf->webservice->enabled) { $router->addRoute('webservice', $routeWebservice); } } // check if webdav is configured and add router if ($conf instanceof Zend_Config) { if ($conf->assets->webdav->hostname) { $routeWebdav = new Zend_Controller_Router_Route_Hostname($conf->assets->webdav->hostname, array("module" => "admin", 'controller' => 'asset', 'action' => 'webdav')); $router->addRoute('webdav', $routeWebdav); } } $front->setRouter($router); Pimcore_API_Plugin_Broker::getInstance()->preDispatch(); // run dispatcher if ($frontend && !PIMCORE_DEBUG) { @ini_set("display_errors", "Off"); @ini_set("display_startup_errors", "Off"); $front->dispatch(); } else { @ini_set("display_errors", "On"); @ini_set("display_startup_errors", "On"); $front->throwExceptions(true); try { $front->dispatch(); } catch (Zend_Controller_Router_Exception $e) { header("HTTP/1.0 404 Not Found"); throw new Zend_Controller_Router_Exception("No route, document, custom route or redirect is matching the request: " . $_SERVER["REQUEST_URI"]); } catch (Exception $e) { header("HTTP/1.0 500 Internal Server Error"); throw $e; } } }
/** * @static * @throws Exception|Zend_Controller_Router_Exception */ public static function run() { self::setSystemRequirements(); // register shutdown function Pimcore_Event::register("pimcore.shutdown", array("Pimcore", "shutdown"), array(), 999); // detect frontend (website) $frontend = Pimcore_Tool::isFrontend(); // enable the output-buffer, why? see in self::outputBufferStart() //if($frontend) { self::outputBufferStart(); //} self::initAutoloader(); self::initConfiguration(); self::setupFramework(); // config is loaded now init the real logger self::initLogger(); // set locale data cache, this must be after self::initLogger() since Pimcore_Model_Cache requires the logger // to log if there's something wrong with the cache configuration in cache.xml Zend_Locale_Data::setCache(Pimcore_Model_Cache::getInstance()); // load plugins and modules (=core plugins) self::initModules(); self::initPlugins(); // init front controller $front = Zend_Controller_Front::getInstance(); $conf = Pimcore_Config::getSystemConfig(); if (!$conf) { // redirect to installer if configuration isn't present if (!preg_match("/^\\/install.*/", $_SERVER["REQUEST_URI"])) { header("Location: /install/"); exit; } } $front->registerPlugin(new Pimcore_Controller_Plugin_ErrorHandler(), 1); $front->registerPlugin(new Pimcore_Controller_Plugin_Maintenance(), 2); // register general pimcore plugins for frontend if ($frontend) { $front->registerPlugin(new Pimcore_Controller_Plugin_Less(), 799); } if (Pimcore_Tool::useFrontendOutputFilters(new Zend_Controller_Request_Http())) { $front->registerPlugin(new Pimcore_Controller_Plugin_Robotstxt(), 795); $front->registerPlugin(new Pimcore_Controller_Plugin_WysiwygAttributes(), 796); $front->registerPlugin(new Pimcore_Controller_Plugin_Webmastertools(), 797); $front->registerPlugin(new Pimcore_Controller_Plugin_Analytics(), 798); $front->registerPlugin(new Pimcore_Controller_Plugin_CssMinify(), 800); $front->registerPlugin(new Pimcore_Controller_Plugin_JavascriptMinify(), 801); $front->registerPlugin(new Pimcore_Controller_Plugin_ImageDataUri(), 803); $front->registerPlugin(new Pimcore_Controller_Plugin_TagManagement(), 804); $front->registerPlugin(new Pimcore_Controller_Plugin_HttpErrorLog(), 850); $front->registerPlugin(new Pimcore_Controller_Plugin_Cache(), 901); // for caching } self::initControllerFront($front); // set router $router = $front->getRouter(); $routeAdmin = new Zend_Controller_Router_Route('admin/:controller/:action/*', array('module' => 'admin', "controller" => "index", "action" => "index")); $routeInstall = new Zend_Controller_Router_Route('install/:controller/:action/*', array('module' => 'install', "controller" => "index", "action" => "index")); $routeUpdate = new Zend_Controller_Router_Route('admin/update/:controller/:action/*', array('module' => 'update', "controller" => "index", "action" => "index")); $routePlugins = new Zend_Controller_Router_Route('admin/plugin/:controller/:action/*', array('module' => 'pluginadmin', "controller" => "index", "action" => "index")); $routeExtensions = new Zend_Controller_Router_Route('admin/extensionmanager/:controller/:action/*', array('module' => 'extensionmanager', "controller" => "index", "action" => "index")); $routeReports = new Zend_Controller_Router_Route('admin/reports/:controller/:action/*', array('module' => 'reports', "controller" => "index", "action" => "index")); $routePlugin = new Zend_Controller_Router_Route('plugin/:module/:controller/:action/*', array("controller" => "index", "action" => "index")); $routeWebservice = new Zend_Controller_Router_Route('webservice/:controller/:action/*', array("module" => "webservice", "controller" => "index", "action" => "index")); $routeSearchAdmin = new Zend_Controller_Router_Route('admin/search/:controller/:action/*', array("module" => "searchadmin", "controller" => "index", "action" => "index")); // website route => custom router which check for a suitable document $routeFrontend = new Pimcore_Controller_Router_Route_Frontend(); $router->addRoute('default', $routeFrontend); // only do this if not frontend => performance issue if (!$frontend) { $router->addRoute("install", $routeInstall); $router->addRoute('plugin', $routePlugin); $router->addRoute('admin', $routeAdmin); $router->addRoute('update', $routeUpdate); $router->addRoute('plugins', $routePlugins); $router->addRoute('extensionmanager', $routeExtensions); $router->addRoute('reports', $routeReports); $router->addRoute('searchadmin', $routeSearchAdmin); if ($conf instanceof Zend_Config and $conf->webservice and $conf->webservice->enabled) { $router->addRoute('webservice', $routeWebservice); } } // check if webdav is configured and add router if ($conf instanceof Zend_Config) { if ($conf->assets->webdav->hostname) { $routeWebdav = new Zend_Controller_Router_Route_Hostname($conf->assets->webdav->hostname, array("module" => "admin", 'controller' => 'asset', 'action' => 'webdav')); $router->addRoute('webdav', $routeWebdav); } } $front->setRouter($router); Pimcore_API_Plugin_Broker::getInstance()->preDispatch(); // throw exceptions also when in preview or in editmode (documents) to see it immediately when there's a problem with this page $throwExceptions = false; if (array_key_exists("pimcore_editmode", $_REQUEST) || array_key_exists("pimcore_preview", $_REQUEST) || array_key_exists("pimcore_admin", $_REQUEST)) { $user = Pimcore_Tool_Authentication::authenticateSession(); if ($user instanceof User) { $throwExceptions = true; } } // run dispatcher if (!PIMCORE_DEBUG && !$throwExceptions && !PIMCORE_DEVMODE) { @ini_set("display_errors", "Off"); @ini_set("display_startup_errors", "Off"); $front->dispatch(); } else { @ini_set("display_errors", "On"); @ini_set("display_startup_errors", "On"); $front->throwExceptions(true); try { $front->dispatch(); } catch (Zend_Controller_Router_Exception $e) { header("HTTP/1.0 404 Not Found"); throw new Zend_Controller_Router_Exception("No route, document, custom route or redirect is matching the request: " . $_SERVER["REQUEST_URI"]); } catch (Exception $e) { header("HTTP/1.0 500 Internal Server Error"); throw $e; } } }