• Модуль: landing
  • Путь к файлу: ~/bitrix/modules/landing/lib/note/source/parser.php
  • Класс: BitrixLandingNoteSourceParser
  • Вызов: Parser::getBlockFromNode
static function getBlockFromNode(BitrixMainWebDOMNode $node, array $params = []): ?array
{
	$type = 'text';
	$content = $node->getOuterHTML();
	$attrs = $node->getAttributes();

	// quote / code
	if (isset($attrs['class']) && in_array($attrs['class']->getValue(), ['quote', 'code']))
	{
		$type = $attrs['class']->getValue();
		$regExp = '#^
s*
' . '(.*?)
$#is'; if (preg_match($regExp, $content, $matches)) { $content = $matches[1]; } if ($type == 'code' && preg_match('#^
(.*?)
$#is', $content, $matches)) { $content = $matches[1]; } } // table else if (isset($attrs['class']) && $attrs['class']->getValue() == 'data-table') { $type = 'table'; } // video else if (($node->getNodeName() == 'IFRAME') && isset($attrs['src'])) { $type = 'video'; $content = self::getVideoContent( $attrs['src']->getValue() ); } // picture / file on a single line else if (preg_match('/^[DISK FILE ID=([^]]+)]/is', trim($content), $matches)) { $type = 'img'; $content = self::getImgContent($matches[1], $params['files']);; } // replace files in content if ( $type == 'text' && isset($params['files']) && is_array($params['files']) ) { $content = self::replaceFilesInContent($content, $params['files']); } if ($content) { return [ 'type' => $type, 'content' => $content ]; } return null; }