• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/lib/framecache.php
  • Класс: BitrixMainFrameCache
  • Вызов: FrameCache::onEndBufferContent
static function onEndBufferContent(&$content)
{

	global $APPLICATION;

	if (self::getUseAppCache() == true) //Do we use html5 application cache?
		BitrixMainDataAppCacheManifest::onEndBufferContent($content);
	else
		BitrixMainDataAppCacheManifest::checkObsoleteManifest();//it checks if the manifest is still alive.

	$selfObject = self::getInstance();
	$ids = $selfObject->getDynamicIDs();


	if (count($ids) > 0) //Do we have any dynamic blocks?
	{
		$match = array();
		$regexp = "/##start_frame_cache_(" . implode("|", $ids) . ")##(.+?)##end_frame_cache_(?:" . implode("|", $ids) . ")##/is";
		preg_match_all($regexp, $content, $match);

		/*
			Notes:
			$match[0] -	array of dynamic blocks with macros'
			$match[1] - ids of the dynamic blocks
			$match[2] - array of dynamic blocks
		*/

		$count = count($match[1]);
		if (self::$isBackgroundRequest)
		{
			//$fcache->arDynamicData = array_combine($match[1], $match[2]);
			for ($i = 0; $i < $count; $i++)
			{
				$selfObject->arDynamicData[] = Array("ID" => $match[1][$i], "CONTENT" => $match[2][$i], "HASH" => md5($match[2][$i]));
			}
		}
		else
		{
			$replacedArray = array();
			for ($i = 0; $i < $count; $i++)
			{
				$replacedArray[] = '
'; } $content = str_replace($match[0], $replacedArray, $content); } } if (self::$isBackgroundRequest) //Is it a check request? { header("Content-Type: application/x-javascript"); $content = Array( "isManifestUpdated" => BitrixMainDataAppCacheManifest::getInstance()->getIsModified(), "dynamicBlocks" => $selfObject->arDynamicData, ); if (!Application::getInstance()->isUtfMode()) //TODO I use it because there is no similar method in the new Bitrix Framework yet $content = $APPLICATION->convertCharsetArray($content, SITE_CHARSET, "UTF-8"); $content = json_encode($content); } }