本文整理汇总了PHP中Pimcore\Tool::isHtmlResponse方法的典型用法代码示例。如果您正苦于以下问题:PHP Tool::isHtmlResponse方法的具体用法?PHP Tool::isHtmlResponse怎么用?PHP Tool::isHtmlResponse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Pimcore\Tool
的用法示例。
在下文中一共展示了Tool::isHtmlResponse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dispatchLoopShutdown
/**
*
*/
public function dispatchLoopShutdown()
{
if (!Tool::isHtmlResponse($this->getResponse())) {
return;
}
$siteKey = \Pimcore\Tool\Frontend::getSiteKey();
$reportConfig = \Pimcore\Config::getReportConfig();
if ($this->enabled && isset($reportConfig->tagmanager->sites->{$siteKey}->containerId)) {
$containerId = $reportConfig->tagmanager->sites->{$siteKey}->containerId;
if ($containerId) {
$code = <<<CODE
<!-- Google Tag Manager -->
<noscript><iframe src="//www.googletagmanager.com/ns.html?id={$containerId}"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','{$containerId}');</script>
<!-- End Google Tag Manager -->
CODE;
$body = $this->getResponse()->getBody();
// insert code after the opening <body> tag
$body = preg_replace("@<body(>|.*?[^?]>)@", "<body\$1\n\n" . $code, $body);
$this->getResponse()->setBody($body);
}
}
}
示例2: 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);
}
}
示例3: 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);
}
}
}
示例4: 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);
}
}
}
示例5: 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);
}
示例6: 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|disable_thumbnail)=\\\"([0-9a-z]+)\\\"/", "", $body);
$this->getResponse()->setBody($body);
}
示例7: dispatchLoopShutdown
/**
*
*/
public function dispatchLoopShutdown()
{
if (!\Pimcore\Tool::isHtmlResponse($this->getResponse())) {
return;
}
if ($this->enabled) {
include_once "simple_html_dom.php";
$body = $this->getResponse()->getBody();
$body = \Pimcore\Tool\Less::processHtml($body);
$this->getResponse()->setBody($body);
}
}
示例8: 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();
}
}
}
示例9: dispatchLoopShutdown
/**
*
*/
public function dispatchLoopShutdown()
{
if (!Tool::isHtmlResponse($this->getResponse())) {
return;
}
if ($this->enabled && ($code = AnalyticsHelper::getCode())) {
// analytics
$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);
}
}
示例10: dispatchLoopShutdown
/**
*
*/
public function dispatchLoopShutdown()
{
if (!Tool::isHtmlResponse($this->getResponse())) {
return;
}
$siteKey = \Pimcore\Tool\Frontend::getSiteKey();
$reportConfig = \Pimcore\Config::getReportConfig();
if ($this->enabled && isset($reportConfig->tagmanager->sites->{$siteKey}->containerId)) {
$containerId = $reportConfig->tagmanager->sites->{$siteKey}->containerId;
if ($containerId) {
$codeHead = <<<CODE
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','{$containerId}');</script>
<!-- End Google Tag Manager -->
CODE;
$codeBody = <<<CODE
<!-- Google Tag Manager (noscript) -->
<noscript><iframe src="https://www.googletagmanager.com/ns.html?id={$containerId}"
height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
<!-- End Google Tag Manager (noscript) -->
CODE;
$body = $this->getResponse()->getBody();
// search for the end <head> tag, and insert the google tag manager 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, $codeHead . "</head>", $headEndPosition, 7);
}
// insert code after the opening <body> tag
$body = preg_replace("@<body(>|.*?[^?]>)@", "<body\$1\n\n" . $codeBody, $body);
$this->getResponse()->setBody($body);
}
}
}
示例11: dispatchLoopShutdown
public function dispatchLoopShutdown()
{
if (!Tool::isHtmlResponse($this->getResponse())) {
return FALSE;
}
$body = $this->getResponse()->getBody();
$htmlData = $this->getEventData();
if (isset($htmlData['header']) && !empty($htmlData['header'])) {
$headEndPosition = stripos($body, "</head>");
if ($headEndPosition !== false) {
$body = substr_replace($body, $htmlData['header'] . "</head>", $headEndPosition, 7);
}
}
if (isset($htmlData['footer']) && !empty($htmlData['footer'])) {
$bodyEndPosition = stripos($body, "</body>");
if ($bodyEndPosition !== false) {
$body = substr_replace($body, $htmlData['footer'] . "</body>", $bodyEndPosition, 7);
}
}
$this->getResponse()->setBody($body);
}
示例12: postDispatch
/**
*
*/
public function postDispatch()
{
if ($this->_shouldRender()) {
if (method_exists($this->getActionController(), "getRenderScript")) {
if ($script = $this->getActionController()->getRenderScript()) {
$this->renderScript($script);
}
}
}
parent::postDispatch();
// append custom styles to response body
if ($this->getActionController() instanceof FrontendController) {
$doc = $this->getActionController()->getDocument();
if (Tool::isHtmlResponse($this->getResponse()) && $doc && method_exists($doc, "getCss") && $doc->getCss() && !$this->getRequest()->getParam("pimcore_editmode")) {
$code = '<style type="text/css" id="pimcore_styles_' . $doc->getId() . '">';
$code .= "\n\n" . $doc->getCss() . "\n\n";
$code .= '</style>';
$name = $this->getResponseSegment();
$this->getResponse()->appendBody($code, $name);
}
}
}
示例13: dispatchLoopShutdown
/**
*
*/
public function dispatchLoopShutdown()
{
if (!Asset\Image\Thumbnail::isPictureElementInUse()) {
return;
}
if (!Asset\Image\Thumbnail::getEmbedPicturePolyfill()) {
return;
}
if (!\Pimcore\Tool::isHtmlResponse($this->getResponse())) {
return;
}
// analytics
$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
$code = '<script type="text/javascript" src="/pimcore/static/js/frontend/picturePolyfill.min.js" defer></script>';
$headEndPosition = stripos($body, "</head>");
if ($headEndPosition !== false) {
$body = substr_replace($body, $code . "</head>", $headEndPosition, 7);
}
$this->getResponse()->setBody($body);
}
示例14: dispatchLoopShutdown
/**
*
*/
public function dispatchLoopShutdown()
{
if (!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();
$html->clear();
unset($html);
$this->getResponse()->setBody($body);
// save storage
CacheManager::save($this->cachedItems, self::cacheKey, array(), 3600);
}
}
}
示例15: dispatchLoopShutdown
/**
*
*/
public function dispatchLoopShutdown()
{
if (!Tool::isHtmlResponse($this->getResponse())) {
return;
}
if ($this->enabled) {
$targets = array();
$personas = array();
$dataPush = array("personas" => $this->personas, "method" => strtolower($this->getRequest()->getMethod()));
if (count($this->events) > 0) {
$dataPush["events"] = $this->events;
}
if ($this->document instanceof Document\Page && !Model\Staticroute::getCurrentRoute()) {
$dataPush["document"] = $this->document->getId();
if ($this->document->getPersonas()) {
if ($_GET["_ptp"]) {
// if a special version is requested only return this id as target group for this page
$dataPush["personas"][] = (int) $_GET["_ptp"];
} else {
$docPersonas = explode(",", trim($this->document->getPersonas(), " ,"));
// cast the values to int
array_walk($docPersonas, function (&$value) {
$value = (int) trim($value);
});
$dataPush["personas"] = array_merge($dataPush["personas"], $docPersonas);
}
}
// check for persona specific variants of this page
$personaVariants = array();
foreach ($this->document->getElements() as $key => $tag) {
if (preg_match("/^persona_-([0-9]+)-_/", $key, $matches)) {
$id = (int) $matches[1];
if (Model\Tool\Targeting\Persona::isIdActive($id)) {
$personaVariants[] = $id;
}
}
}
if (!empty($personaVariants)) {
$personaVariants = array_values(array_unique($personaVariants));
$dataPush["personaPageVariants"] = $personaVariants;
}
}
// no duplicates
$dataPush["personas"] = array_unique($dataPush["personas"]);
$activePersonas = array();
foreach ($dataPush["personas"] as $id) {
if (Model\Tool\Targeting\Persona::isIdActive($id)) {
$activePersonas[] = $id;
}
}
$dataPush["personas"] = $activePersonas;
if ($this->document) {
// @TODO: cache this
$list = new Model\Tool\Targeting\Rule\Listing();
$list->setCondition("active = 1");
foreach ($list->load() as $target) {
$redirectUrl = $target->getActions()->getRedirectUrl();
if (is_numeric($redirectUrl)) {
$doc = \Document::getById($redirectUrl);
if ($doc instanceof \Document) {
$target->getActions()->redirectUrl = $doc->getFullPath();
}
}
$targets[] = $target;
}
$list = new Model\Tool\Targeting\Persona\Listing();
$list->setCondition("active = 1");
foreach ($list->load() as $persona) {
$personas[] = $persona;
}
}
$code = '<script type="text/javascript" src="/pimcore/static/js/frontend/geoip.js/"></script>';
$code .= '<script type="text/javascript">';
$code .= 'var pimcore = pimcore || {};';
$code .= 'pimcore["targeting"] = {};';
$code .= 'pimcore["targeting"]["dataPush"] = ' . \Zend_Json::encode($dataPush) . ';';
$code .= 'pimcore["targeting"]["targetingRules"] = ' . \Zend_Json::encode($targets) . ';';
$code .= 'pimcore["targeting"]["personas"] = ' . \Zend_Json::encode($personas) . ';';
$code .= '</script>';
$code .= '<script type="text/javascript" src="/pimcore/static/js/frontend/targeting.js"></script>';
$code .= "\n";
// analytics
$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, "<head>\n" . $code, $headEndPosition, 7);
}
$this->getResponse()->setBody($body);
}
}