当前位置: 首页>>代码示例>>PHP>>正文


PHP Tool::useFrontendOutputFilters方法代码示例

本文整理汇总了PHP中Pimcore\Tool::useFrontendOutputFilters方法的典型用法代码示例。如果您正苦于以下问题:PHP Tool::useFrontendOutputFilters方法的具体用法?PHP Tool::useFrontendOutputFilters怎么用?PHP Tool::useFrontendOutputFilters使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Pimcore\Tool的用法示例。


在下文中一共展示了Tool::useFrontendOutputFilters方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: dispatchLoopShutdown

 public function dispatchLoopShutdown()
 {
     if (!Tool::isHtmlResponse($this->getResponse())) {
         return;
     }
     if (!Tool::useFrontendOutputFilters($this->getRequest()) && !$this->getRequest()->getParam("pimcore_preview")) {
         return;
     }
     if (\Pimcore::inDebugMode()) {
         return;
     }
     if ($this->enabled) {
         include_once "simple_html_dom.php";
         $body = $this->getResponse()->getBody();
         $html = str_get_html($body);
         if ($html) {
             $html = $this->searchForScriptSrcAndReplace($html);
             $html = $this->searchForInlineScriptAndReplace($html);
             $body = $html->save();
             $html->clear();
             unset($html);
         }
         $this->getResponse()->setBody($body);
     }
 }
开发者ID:Cruiser13,项目名称:pimcore-minify,代码行数:25,代码来源:MinifyJs.php

示例2: dispatchLoopShutdown

 /**
  *
  */
 public function dispatchLoopShutdown()
 {
     if (!Tool::isHtmlResponse($this->getResponse())) {
         return;
     }
     if (!Tool::useFrontendOutputFilters($this->getRequest()) && !$this->getRequest()->getParam("pimcore_preview")) {
         return;
     }
     if (isset($_COOKIE["pimcore_admin_sid"])) {
         try {
             // we should not start a session here as this can break the functionality of the site if
             // the website itself uses sessions, so we include the code, and check asynchronously if the user is logged in
             // this is done by the embedded script
             $body = $this->getResponse()->getBody();
             $document = $this->getRequest()->getParam("document");
             if ($document instanceof Model\Document && !Model\Staticroute::getCurrentRoute()) {
                 $documentId = $document->getId();
             }
             if (!isset($documentId) || !$documentId) {
                 $documentId = "null";
             }
             $code = '<script type="text/javascript" src="/admin/admin-button/script?documentId=' . $documentId . '"></script>';
             // search for the end <head> tag, and insert the google analytics code before
             // this method is much faster than using simple_html_dom and uses less memory
             $bodyEndPosition = stripos($body, "</body>");
             if ($bodyEndPosition !== false) {
                 $body = substr_replace($body, $code . "\n\n</body>\n", $bodyEndPosition, 7);
             }
             $this->getResponse()->setBody($body);
         } catch (\Exception $e) {
             \Logger::error($e);
         }
     }
 }
开发者ID:Gerhard13,项目名称:pimcore,代码行数:37,代码来源:AdminButton.php

示例3: dispatchLoopShutdown

 public function dispatchLoopShutdown()
 {
     if (!Tool::isHtmlResponse($this->getResponse())) {
         return;
     }
     if (\Pimcore::inDebugMode()) {
         return;
     }
     if (!Tool::useFrontendOutputFilters($this->getRequest()) && !$this->getRequest()->getParam("pimcore_preview")) {
         return;
     }
     if ($this->enabled) {
         include_once "simple_html_dom.php";
         $body = $this->getResponse()->getBody();
         $html = str_get_html($body);
         if ($html) {
             $styles = $html->find("link[rel=stylesheet], style[type=text/css]");
             $stylesheetContent = "";
             foreach ($styles as $style) {
                 if ($style->tag == "style") {
                     $stylesheetContent .= $style->innertext;
                 } else {
                     $source = $style->href;
                     $path = "";
                     if (is_file(PIMCORE_ASSET_DIRECTORY . $source)) {
                         $path = PIMCORE_ASSET_DIRECTORY . $source;
                     } else {
                         if (is_file(PIMCORE_DOCUMENT_ROOT . $source)) {
                             $path = PIMCORE_DOCUMENT_ROOT . $source;
                         }
                     }
                     if (!empty($path) && is_file("file://" . $path)) {
                         $content = file_get_contents($path);
                         $content = $this->correctReferences($source, $content);
                         if ($style->media && $style->media != "all") {
                             $content = "@media " . $style->media . " {" . $content . "}";
                         }
                         $stylesheetContent .= $content;
                         $style->outertext = "";
                     }
                 }
             }
             if (strlen($stylesheetContent) > 1) {
                 $stylesheetPath = PIMCORE_TEMPORARY_DIRECTORY . "/minified_css_" . md5($stylesheetContent) . ".css";
                 if (!is_file($stylesheetPath)) {
                     $stylesheetContent = \Minify_CSS::minify($stylesheetContent);
                     // put minified contents into one single file
                     file_put_contents($stylesheetPath, $stylesheetContent);
                     chmod($stylesheetPath, 0766);
                 }
                 $head = $html->find("head", 0);
                 $head->innertext = $head->innertext . "\n" . '<link rel="stylesheet" type="text/css" href="' . str_replace(PIMCORE_DOCUMENT_ROOT, "", $stylesheetPath) . '" />' . "\n";
             }
             $body = $html->save();
             $html->clear();
             unset($html);
             $this->getResponse()->setBody($body);
         }
     }
 }
开发者ID:Cruiser13,项目名称:pimcore-minify,代码行数:60,代码来源:MinifyCss.php

示例4: dispatchLoopShutdown

    /**
     *
     */
    public function dispatchLoopShutdown()
    {
        $config = \Pimcore\Config::getSystemConfig();
        if (!$config->general->show_cookie_notice || !Tool::useFrontendOutputFilters($this->getRequest()) || !Tool::isHtmlResponse($this->getResponse())) {
            return;
        }
        $template = file_get_contents(__DIR__ . "/EuCookieLawNotice/template.html");
        # cleanup code
        $template = preg_replace('/[\\r\\n\\t]+/', ' ', $template);
        #remove new lines, spaces, tabs
        $template = preg_replace('/>[\\s]+</', '><', $template);
        #remove new lines, spaces, tabs
        $template = preg_replace('/[\\s]+/', ' ', $template);
        #remove new lines, spaces, tabs
        $translations = $this->getTranslations();
        foreach ($translations as $key => &$value) {
            $value = htmlentities($value, ENT_COMPAT, "UTF-8");
            $template = str_replace("%" . $key . "%", $value, $template);
        }
        $linkContent = "";
        if (array_key_exists("linkTarget", $translations)) {
            $linkContent = '<a href="' . $translations["linkTarget"] . '" data-content="' . $translations["linkText"] . '"></a>';
        }
        $template = str_replace("%link%", $linkContent, $template);
        $templateCode = \Zend_Json::encode($template);
        $code = '
            <script>
                (function () {
                    var ls = window["localStorage"];
                    if(ls && !ls.getItem("pc-cookie-accepted")) {

                        var code = ' . $templateCode . ';
                        var ci = window.setInterval(function () {
                            if(document.body) {
                                clearInterval(ci);
                                document.body.insertAdjacentHTML("beforeend", code);

                                document.getElementById("pc-button").onclick = function () {
                                    document.getElementById("pc-cookie-notice").style.display = "none";
                                    ls.setItem("pc-cookie-accepted", "true");
                                };
                            }
                        }, 100);
                    }
                })();
            </script>
        ';
        $body = $this->getResponse()->getBody();
        // search for the end <head> tag, and insert the google analytics code before
        // this method is much faster than using simple_html_dom and uses less memory
        $headEndPosition = stripos($body, "</head>");
        if ($headEndPosition !== false) {
            $body = substr_replace($body, $code . "</head>", $headEndPosition, 7);
        }
        $this->getResponse()->setBody($body);
    }
开发者ID:sfie,项目名称:pimcore,代码行数:59,代码来源:EuCookieLawNotice.php

示例5: routeShutdown

 /**
  * @param \Zend_Controller_Request_Abstract $request
  * @return bool|void
  */
 public function routeShutdown(\Zend_Controller_Request_Abstract $request)
 {
     if (!Tool::useFrontendOutputFilters($request)) {
         return $this->disable();
     }
     $db = \Pimcore\Db::get();
     $enabled = $db->fetchOne("SELECT id FROM targeting_personas UNION SELECT id FROM targeting_rules LIMIT 1");
     if (!$enabled) {
         return $this->disable();
     }
     if ($request->getParam("document") instanceof Document\Page) {
         $this->document = $request->getParam("document");
     }
 }
开发者ID:quorak,项目名称:pimcore,代码行数:18,代码来源:Targeting.php

示例6: routeShutdown

 /**
  * @param \Zend_Controller_Request_Abstract $request
  * @return bool|void
  */
 public function routeShutdown(\Zend_Controller_Request_Abstract $request)
 {
     if (!Tool::useFrontendOutputFilters($request)) {
         return $this->disable();
     }
 }
开发者ID:ChristophWurst,项目名称:pimcore,代码行数:10,代码来源:Analytics.php

示例7: run

 /**
  * @static
  * @throws Exception|\Zend_Controller_Router_Exception
  */
 public static function run()
 {
     self::setSystemRequirements();
     // detect frontend (website)
     $frontend = 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();
     // initialize cache
     Cache::init();
     // load plugins and modules (=core plugins)
     self::initModules();
     self::initPlugins();
     // init front controller
     $front = \Zend_Controller_Front::getInstance();
     $conf = Config::getSystemConfig();
     if (!$conf) {
         // redirect to installer if configuration isn't present
         if (!preg_match("/^\\/install.*/", $_SERVER["REQUEST_URI"])) {
             header("Location: /install/");
             exit;
         }
     }
     if (self::inDebugMode() && $frontend && !$conf->general->disable_whoops && !defined("HHVM_VERSION")) {
         $whoops = new \Whoops\Run();
         $whoops->pushHandler(new \Whoops\Handler\PrettyPageHandler());
         $jsonErrorHandler = new \Whoops\Handler\JsonResponseHandler();
         $jsonErrorHandler->onlyForAjaxRequests(true);
         $whoops->pushHandler($jsonErrorHandler);
         $whoops->register();
         // add event handler before Pimcore::shutdown() to ensure fatal errors are handled by Whoops
         self::getEventManager()->attach("system.shutdown", array($whoops, "handleShutdown"), 10000);
     }
     $front->registerPlugin(new Controller\Plugin\ErrorHandler(), 1);
     $front->registerPlugin(new Controller\Plugin\Maintenance(), 2);
     // register general pimcore plugins for frontend
     if ($frontend) {
         $front->registerPlugin(new Controller\Plugin\Thumbnail(), 795);
         $front->registerPlugin(new Controller\Plugin\Less(), 799);
         $front->registerPlugin(new Controller\Plugin\AdminButton(), 806);
     }
     if (Tool::useFrontendOutputFilters(new \Zend_Controller_Request_Http())) {
         $front->registerPlugin(new Controller\Plugin\HybridAuth(), 792);
         $front->registerPlugin(new Controller\Plugin\QrCode(), 793);
         $front->registerPlugin(new Controller\Plugin\CommonFilesFilter(), 794);
         $front->registerPlugin(new Controller\Plugin\WysiwygAttributes(), 796);
         $front->registerPlugin(new Controller\Plugin\Webmastertools(), 797);
         $front->registerPlugin(new Controller\Plugin\Analytics(), 798);
         $front->registerPlugin(new Controller\Plugin\TagManagement(), 804);
         $front->registerPlugin(new Controller\Plugin\Targeting(), 805);
         $front->registerPlugin(new Controller\Plugin\EuCookieLawNotice(), 807);
         $front->registerPlugin(new Controller\Plugin\HttpErrorLog(), 850);
         $front->registerPlugin(new 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 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 this request routes into a plugin, if so check if the plugin is enabled
         if (preg_match("@^/plugin/([^/]+)/.*@", $_SERVER["REQUEST_URI"], $matches)) {
             $pluginName = $matches[1];
             if (!Pimcore\ExtensionManager::isEnabled("plugin", $pluginName)) {
                 \Pimcore\Tool::exitWithError("Plugin is disabled. To use this plugin please enable it in the extension manager!");
             }
         }
//.........这里部分代码省略.........
开发者ID:pdaniel-frk,项目名称:pimcore,代码行数:101,代码来源:Pimcore.php


注:本文中的Pimcore\Tool::useFrontendOutputFilters方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。