/** * * There are two variants of content's modification in this method. * The first one: * If it's ajax-hit the content will be replaced by json data with dynamic blocks, * javascript files and etc. - dynamic part * * The second one: * If it's simple hit the content will be modified also, * all dynamic blocks will be cutted out of the content - static part. * * @param string $content Html page content. * * @return string */ public function processPageContent($content) { global $APPLICATION; $dividedData = $this->getDividedPageData($content); $htmlCacheChanged = false; if (self::getUseHTMLCache()) { $isLicenseExpired = self::isLicenseExpired(); $staticHTMLCache = StaticHtmlCache::getInstance(); if ($staticHTMLCache->isCacheable()) { $cacheExists = $staticHTMLCache->exists(); if ((!$cacheExists || $staticHTMLCache->getMd5() !== $dividedData["md5"]) && !\CHTMLPagesCache::isIE9()) { if ($cacheExists) { $staticHTMLCache->delete(); } if (!$isLicenseExpired) { $success = $staticHTMLCache->write($dividedData["static"], $dividedData["md5"]); if ($success) { $htmlCacheChanged = true; $staticHTMLCache->setUserPrivateKey(); } } } else { if ($isLicenseExpired) { $staticHTMLCache->delete(); } } $dividedData["static"] = $this->replaceInjections($content); } else { $staticHTMLCache->delete(); return $this->getAjaxError("not_cacheable"); } } if (self::getUseAppCache() == true) { AppCacheManifest::getInstance()->generate($dividedData["static"]); } else { AppCacheManifest::checkObsoleteManifest(); } if (self::isAjaxRequest()) { self::sendRandHeader(); header("Content-Type: application/x-javascript; charset=" . SITE_CHARSET); header("X-Bitrix-Composite: Ajax " . ($htmlCacheChanged ? "(changed)" : "(stable)")); $content = array("js" => $APPLICATION->arHeadScripts, "additional_js" => $APPLICATION->arAdditionalJS, "lang" => \CJSCore::GetCoreMessages(), "css" => $APPLICATION->GetCSSArray(), "htmlCacheChanged" => $htmlCacheChanged, "isManifestUpdated" => AppCacheManifest::getInstance()->getIsModified(), "dynamicBlocks" => $dividedData["dynamic"], "spread" => array_map(array("CUtil", "JSEscape"), $APPLICATION->GetSpreadCookieUrls())); $content = \CUtil::PhpToJSObject($content); } else { $content = $dividedData["static"]; } return $content; }
/** * Returns true if the current request was sent by IE9 and above * * @return bool */ public static function isIE9() { if (self::$isIE9 === null) { self::$isIE9 = false; $userAgent = isset($_SERVER["HTTP_USER_AGENT"]) ? $_SERVER["HTTP_USER_AGENT"] : false; if ($userAgent && strpos($userAgent, "Opera") === false && preg_match('#(MSIE|Internet Explorer) ([0-9]+)\\.([0-9]+)#', $userAgent, $version) ) { if (intval($version[2]) > 0 && doubleval($version[2].".".$version[3]) < 10) { self::$isIE9 = true; } } } return self::$isIE9; }