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


PHP Pimcore_Tool::isHtmlResponse方法代码示例

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


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

示例1: dispatchLoopShutdown

 public function dispatchLoopShutdown()
 {
     if (!Pimcore_Tool::isHtmlResponse($this->getResponse())) {
         return;
     }
     // removes the non-valid html attributes which are used by the wysiwyg editor for ID based linking
     $body = $this->getResponse()->getBody();
     $body = preg_replace("/ pimcore_(id|type)=\\\"([0-9a-z]+)\\\"/", "", $body);
     $this->getResponse()->setBody($body);
 }
开发者ID:ngocanh,项目名称:pimcore,代码行数:10,代码来源:WysiwygAttributes.php

示例2: dispatchLoopShutdown

 public function dispatchLoopShutdown()
 {
     if (!Pimcore_Tool::isHtmlResponse($this->getResponse())) {
         return;
     }
     if ($this->enabled) {
         $body = $this->getResponse()->getBody();
         $body = Minify_HTML::minify($body);
         $this->getResponse()->setBody($body);
     }
 }
开发者ID:shanky0110,项目名称:pimcore-custom,代码行数:11,代码来源:HtmlMinify.php

示例3: dispatchLoopShutdown

 public function dispatchLoopShutdown()
 {
     if (!Pimcore_Tool::isHtmlResponse($this->getResponse())) {
         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 {
                     if ($style->media == "screen" || !$style->media) {
                         $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);
                             $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" media="screen" type="text/css" href="' . str_replace(PIMCORE_DOCUMENT_ROOT, "", $stylesheetPath) . '" />' . "\n";
             }
             $body = $html->save();
             $this->getResponse()->setBody($body);
         }
     }
 }
开发者ID:shanky0110,项目名称:pimcore-custom,代码行数:51,代码来源:CssMinify.php

示例4: dispatchLoopShutdown

 public function dispatchLoopShutdown()
 {
     if (!Pimcore_Tool::isHtmlResponse($this->getResponse())) {
         return;
     }
     if ($this->enabled) {
         include_once "simple_html_dom.php";
         if ($this->getRequest()->getParam("pimcore_editmode")) {
             $this->editmode();
         } else {
             $this->frontend();
         }
     }
 }
开发者ID:shanky0110,项目名称:pimcore-custom,代码行数:14,代码来源:Less.php

示例5: dispatchLoopShutdown

 public function dispatchLoopShutdown()
 {
     if (!Pimcore_Tool::isHtmlResponse($this->getResponse())) {
         return;
     }
     if ($this->enabled) {
         include_once "simple_html_dom.php";
         $body = $this->getResponse()->getBody();
         $html = str_get_html($body);
         if ($html) {
             $scripts = $html->find("script[src]");
             $scriptContent = "";
             foreach ($scripts as $script) {
                 $source = $script->src;
                 $path = "";
                 if (is_file("file://" . PIMCORE_ASSET_DIRECTORY . $source)) {
                     $path = "file://" . PIMCORE_ASSET_DIRECTORY . $source;
                 } else {
                     if (is_file("file://" . PIMCORE_DOCUMENT_ROOT . $source)) {
                         $path = "file://" . PIMCORE_DOCUMENT_ROOT . $source;
                     }
                 }
                 if (is_file($path)) {
                     $scriptContent .= file_get_contents($path) . "\n\n";
                     if ($script->next_sibling()->tag != "script" || !$script->next_sibling()->src) {
                         $scriptPath = $this->writeJsTempFile($scriptContent);
                         $scriptContent = "";
                         $script->outertext = '<script type="text/javascript" src="' . str_replace(PIMCORE_DOCUMENT_ROOT, "", $scriptPath) . '"></script>' . "\n";
                     } else {
                         $script->outertext = "";
                     }
                 } else {
                     if ($script->prev_sibling()->tag == "script") {
                         if (strlen($scriptContent) > 0) {
                             $scriptPath = $this->writeJsTempFile($scriptContent);
                             $scriptContent = "";
                             $script->outertext = '<script type="text/javascript" src="' . str_replace(PIMCORE_DOCUMENT_ROOT, "", $scriptPath) . '"></script>' . "\n" . $script->outertext;
                         }
                     }
                 }
             }
             $body = $html->save();
             $this->getResponse()->setBody($body);
         }
     }
 }
开发者ID:shanky0110,项目名称:pimcore-custom,代码行数:46,代码来源:JavascriptMinify.php

示例6: dispatchLoopShutdown

 public function dispatchLoopShutdown()
 {
     if (!Pimcore_Tool::isHtmlResponse($this->getResponse())) {
         return;
     }
     if ($this->enabled && ($code = Pimcore_Google_Analytics::getCode())) {
         // analytics
         include_once "simple_html_dom.php";
         $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 = strpos($body, "</head>");
         if ($headEndPosition !== false) {
             $body = substr_replace($body, $code . "</head>", $headEndPosition, 7);
         }
         $this->getResponse()->setBody($body);
     }
 }
开发者ID:shanky0110,项目名称:pimcore-custom,代码行数:18,代码来源:Analytics.php

示例7: dispatchLoopShutdown

 public function dispatchLoopShutdown()
 {
     if (!Pimcore_Tool::isHtmlResponse($this->getResponse())) {
         return;
     }
     if ($this->enabled && Pimcore_Google_Analytics::isConfigured()) {
         // analytics
         include_once "simple_html_dom.php";
         $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 = strpos($body, "</head>");
         if ($headEndPosition !== false) {
             $body = substr_replace($body, Pimcore_Google_Analytics::getCode() . "</head>", $headEndPosition, 7);
         }
         // website optimizer
         if ($this->document) {
             $top = Pimcore_Google_Analytics::getOptimizerTop($this->document);
             $bottom = Pimcore_Google_Analytics::getOptimizerBottom($this->document);
             $conversion = Pimcore_Google_Analytics::getOptimizerConversion($this->document);
             if ($top || $bottom || $conversion) {
                 $html = str_get_html($body);
                 if ($html) {
                     $body = $html->find("body", 0);
                     if ($top && $bottom) {
                         $body->innertext = $top . $body->innertext . $bottom;
                     } else {
                         if ($conversion) {
                             $body->innertext = $body->innertext . $conversion;
                         } else {
                             if ($bottom) {
                                 $body->innertext = $body->innertext . $bottom;
                             }
                         }
                     }
                     $body = $html->save();
                 }
             }
         }
         $this->getResponse()->setBody($body);
     }
 }
开发者ID:ngocanh,项目名称:pimcore,代码行数:42,代码来源:Analytics.php

示例8: dispatchLoopShutdown

 public function dispatchLoopShutdown()
 {
     if (!Pimcore_Tool::isHtmlResponse($this->getResponse())) {
         return;
     }
     if ($this->supported && $this->enabled) {
         include_once "simple_html_dom.php";
         $body = $this->getResponse()->getBody();
         $html = str_get_html($body);
         if ($html) {
             $images = $html->find("img");
             foreach ($images as $image) {
                 $source = $image->src;
                 $path = null;
                 if (strpos($source, "http") === false) {
                     // check asset folder
                     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 (is_file($path)) {
                         if (@filesize($path) < 20000) {
                             // only files < 20k because of IE8, 20000 because it's better to be a little bit under the limit
                             try {
                                 $mimetype = MIME_Type::autoDetect($path);
                                 if (is_string($mimetype)) {
                                     $image->src = 'data:' . $mimetype . ';base64,' . base64_encode(file_get_contents($path));
                                 }
                             } catch (Exception $e) {
                             }
                         }
                     }
                 }
             }
             $body = $html->save();
             $this->getResponse()->setBody($body);
         }
     }
 }
开发者ID:shanky0110,项目名称:pimcore-custom,代码行数:42,代码来源:ImageDataUri.php

示例9: dispatchLoopShutdown

 public function dispatchLoopShutdown()
 {
     if (!Pimcore_Tool::isHtmlResponse($this->getResponse())) {
         return;
     }
     $cacheKey = "outputfilter_tagmngt";
     $tags = Pimcore_Model_Cache::load($cacheKey);
     if (!is_array($tags)) {
         $dir = Tool_Tag_Config::getWorkingDir();
         $tags = array();
         $files = scandir($dir);
         foreach ($files as $file) {
             if (strpos($file, ".xml")) {
                 $name = str_replace(".xml", "", $file);
                 $tags[] = Tool_Tag_Config::getByName($name);
             }
         }
         Pimcore_Model_Cache::save($tags, $cacheKey, array("tagmanagement"), null, 100);
     }
     if (empty($tags)) {
         return;
     }
     include_once "simple_html_dom.php";
     $body = $this->getResponse()->getBody();
     $html = str_get_html($body);
     $requestParams = array_merge($_GET, $_POST);
     if ($html) {
         foreach ($tags as $tag) {
             $method = strtolower($tag->getHttpMethod());
             $pattern = $tag->getUrlPattern();
             $textPattern = $tag->getTextPattern();
             if (($method == strtolower($this->getRequest()->getMethod()) || empty($method)) && (empty($pattern) || @preg_match($pattern, $this->getRequest()->getRequestUri())) && (empty($textPattern) || strpos($body, $textPattern) !== false)) {
                 $paramsValid = true;
                 foreach ($tag->getParams() as $param) {
                     if (!empty($param["name"])) {
                         if (!empty($param["value"])) {
                             if (!array_key_exists($param["name"], $requestParams) || $requestParams[$param["name"]] != $param["value"]) {
                                 $paramsValid = false;
                             }
                         } else {
                             if (!array_key_exists($param["name"], $requestParams)) {
                                 $paramsValid = false;
                             }
                         }
                     }
                 }
                 if (is_array($tag->getItems()) && $paramsValid) {
                     foreach ($tag->getItems() as $item) {
                         if (!empty($item["element"]) && !empty($item["code"]) && !empty($item["position"])) {
                             $element = $html->find($item["element"], 0);
                             if ($element) {
                                 if ($item["position"] == "end") {
                                     $element->innertext = $element->innertext . "\n\n" . $item["code"] . "\n\n";
                                 } else {
                                     // beginning
                                     $element->innertext = "\n\n" . $item["code"] . "\n\n" . $element->innertext;
                                 }
                                 // we havve to reinitialize the html object, otherwise it causes problems with nested child selectors
                                 $body = $html->save();
                                 $html = str_get_html($body);
                             }
                         }
                     }
                 }
             }
         }
         $this->getResponse()->setBody($body);
     }
 }
开发者ID:shanky0110,项目名称:pimcore-custom,代码行数:69,代码来源:TagManagement.php

示例10: dispatchLoopShutdown

 public function dispatchLoopShutdown()
 {
     if (!Pimcore_Tool::isHtmlResponse($this->getResponse())) {
         return;
     }
     if ($this->enabled) {
         include_once "simple_html_dom.php";
         $body = $this->getResponse()->getBody();
         $html = str_get_html($body);
         if ($html) {
             $elements = $html->find("link[rel=stylesheet], img, script[src]");
             foreach ($elements as $element) {
                 if ($element->tag == "link") {
                     if ($this->pathMatch($element->href)) {
                         $element->href = $this->rewritePath($element->href);
                     }
                 } else {
                     if ($element->tag == "img") {
                         if ($this->pathMatch($element->src)) {
                             $element->src = $this->rewritePath($element->src);
                         }
                     } else {
                         if ($element->tag == "script") {
                             if ($this->pathMatch($element->src)) {
                                 $element->src = $this->rewritePath($element->src);
                             }
                         }
                     }
                 }
             }
             $body = $html->save();
             $this->getResponse()->setBody($body);
             // save storage
             Pimcore_Model_Cache::save($this->cachedItems, self::cacheKey, array(), 3600);
         }
     }
 }
开发者ID:ngocanh,项目名称:pimcore,代码行数:37,代码来源:CDN.php


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