• Модуль: fileman
  • Путь к файлу: ~/bitrix/modules/fileman/lib/block/content/engine.php
  • Класс: BitrixFilemanBlockContentEngine
  • Вызов: Engine::fill
public function fill()
{
	// prepare blocks
	$blocks = array();
	$grouped = array();
	foreach($this->content->getBlocks() as $item)
	{
		$grouped[$item['place']][] = $item['value'];
	}

	foreach($grouped as $place => $values)
	{
		$blocks[$place] = "n" . implode("n", $values) . "n";
	}
	unset($grouped);


	// unite styles to one string
	$styles = '';
	foreach($this->content->getStyles() as $item)
	{
		$styles .= "n" . $item['value'];
	}

	if($styles && preg_match_all("#([\s\S]*?)#i", $styles, $matchesStyles))
	{
		$styles = '';
		$matchesStylesCount = count($matchesStyles);
		for($i = 0; $i < $matchesStylesCount; $i++)
		{
			$styles .= "n" . $matchesStyles[1][$i];
		}
	}

	// if nothing to replace, return content
	if(!$styles && count($blocks) ===  0)
	{
		return false;
	}

	// add styles block to head of document
	if($styles)
	{
		$this->addStylesToDocumentHead($styles);
	}

	// fill places by blocks
	if($blocks)
	{
		$this->addBlocksToDocument($blocks);
	}

	return true;
}