Your IP : 18.216.182.53


Current Path : /home/bitrix/ext_www/klimatlend.ua/bitrix/modules/landing/lib/node/
Upload File :
Current File : /home/bitrix/ext_www/klimatlend.ua/bitrix/modules/landing/lib/node/text.php

<?php
namespace Bitrix\Landing\Node;

class Text extends \Bitrix\Landing\Node
{
	/**
	 * Get class - frontend handler.
	 * @return string
	 */
	public static function getHandlerJS()
	{
		return 'BX.Landing.Block.Node.Text';
	}

	/**
	 * Sanitize bad html.
	 * @param string $str Very bad html.
	 * @return string
	 */
	private static function sanitize($str)
	{
		static $sanitizer = null;

		if ($sanitizer === null)
		{
			$sanitizer = new \CBXSanitizer;
			$sanitizer->addTags(array(
				'b' => array(),
				'i' => array(),
				'u' => array(),
				'br' => array(),
				'li' => array('class'),
				'p' => array('style'),
				'a' => array('href', 'target'),
				'span' => array('style')
			));
		}

		return $sanitizer->sanitizeHtml($str);
	}

	/**
	 * Save data for this node.
	 * @param \Bitrix\Landing\Block &$block Block instance.
	 * @param string $selector Selector.
	 * @param array $data Data array.
	 * @return void
	 */
	public static function saveNode(\Bitrix\Landing\Block &$block, $selector, array $data)
	{
		$doc = $block->getDom();

		foreach ($data as $pos => $value)
		{
			$value = trim($value);
			if ($value != '')
			{
				$resultList = $doc->querySelectorAll($selector);
				if (isset($resultList[$pos]))
				{
					$value = self::sanitize($value);
					// clear some amp
					$value = preg_replace('/&amp;([^\s]+)/is', '&$1', $value);
					$resultList[$pos]->setInnerHTML($value);
				}
			}
		}
	}
}