• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/lib/web/dom/displayproperties.php
  • Класс: BitrixMainWebDOMDisplayProperties
  • Вызов: DisplayProperties::getNodeProperties
protected function getNodeProperties(Node $node)
{
	$result = [];

	if($this->isHiddenNode($node))
	{
		$result[static::DISPLAY] = static::DISPLAY_HIDDEN;
		return $result;
	}

	if($node instanceof Element)
	{
		$styles = $node->getStyle();
		$display = false;
		$font = [];
		if($styles)
		{
			$stylePairs = explode(';', $styles);
			foreach($stylePairs as $pair)
			{
				list($name, $value) = explode(':', $pair);
				if($name && $value)
				{
					$name = trim($name);
					$value = trim($value);
					if($name == static::DISPLAY)
					{
						if($value == 'none')
						{
							$display = static::DISPLAY_HIDDEN;
						}
						elseif($value == 'block')
						{
							$display = static::DISPLAY_BLOCK;
						}
						elseif($value == 'inline')
						{
							$display = static::DISPLAY_INLINE;
						}
					}
					elseif($name == 'font-weight')
					{
						if(intval($value) > 500 || $value == 'bold')
						{
							$font[static::FONT_BOLD] = true;
						}
						elseif(intval($value) < 500 || $value == 'normal')
						{
							$font[static::FONT_BOLD] = false;
						}
					}
					elseif($name == 'font-style')
					{
						if($value == 'italic' || mb_strpos($value, 'oblique') === 0)
						{
							$font[static::FONT_ITALIC] = true;
						}
						elseif($value == 'normal')
						{
							$font[static::FONT_ITALIC] = false;
						}
					}
					elseif($name == 'text-decoration')
					{
						if(strpos($value, 'underline') !== false)
						{
							$font[static::FONT_UNDERLINED] = true;
						}
						if(strpos($value, 'line-through') !== false)
						{
							$font[static::FONT_DELETED] = true;
						}
						if($value == 'none')
						{
							$font[static::FONT_UNDERLINED] = false;
							$font[static::FONT_DELETED] = false;
						}
					}
				}
			}
		}
		if($display == static::DISPLAY_HIDDEN)
		{
			$result[static::DISPLAY] = $display;
			return $result;
		}
		if(!$display && $this->isBlockTag($node->getTagName()))
		{
			$display = static::DISPLAY_BLOCK;
		}

		if(!isset($font[static::FONT_BOLD]) && $this->isBoldTag($node->getTagName()))
		{
			$font[static::FONT_BOLD] = true;
		}
		if(!isset($font[static::FONT_ITALIC]) && $this->isItalicTag($node->getTagName()))
		{
			$font[static::FONT_ITALIC] = true;
		}
		if(!isset($font[static::FONT_UNDERLINED]) && $this->isUnderlinedTag($node->getTagName()))
		{
			$font[static::FONT_UNDERLINED] = true;
		}
		if($this->isDeletedTag($node->getTagName()))
		{
			$font[static::FONT_DELETED] = true;
		}

		if($display)
		{
			$result[static::DISPLAY] = $display;
		}
		$result['font'] = $font;
	}

	return $result;
}