• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/lib/web/dom/queryselectorengine.php
  • Класс: BitrixMainWebDOMQuerySelectorEngine
  • Вызов: QuerySelectorEngine::queryInternal
public function queryInternal(array $instructionList, Node $node, $limit = 0, $direction = self::DIR_DOWN)
{
	$resultList = array();
	//echo "Instructions: ".print_R($instructionList, true);
	$filter = array();

	$isFilterOnlyChildList = null;

	$length = count($instructionList);
	for($i = 0; $i < $length; $i++)
	{
		$instruction = $instructionList[$i];
		switch($instruction['code'])
		{
			case self::PATH_CODE_NAME:

				$filter[] = array(QueryEngine::FILTER_NODE_NAME => $instruction['value']);
				break;

			case self::PATH_CODE_CLASS:

				$filter[] = array(QueryEngine::FILTER_ATTR_CLASS_NAME => $instruction['value']);
				break;

			case self::PATH_CODE_ATTR:

				$attrInstruction = $instruction['value'];
				if(isset($attrInstruction['value']))
				{
					$filter[] = array(QueryEngine::FILTER_ATTR_VALUE => array($attrInstruction));
				}
				else
				{
					$filter[] = array(QueryEngine::FILTER_ATTR => $attrInstruction['name']);
				}

				break;

			case self::PATH_CODE_DESCENDANT:

				$isFilterOnlyChildList = false;
				break 2;

			case self::PATH_CODE_CHILD:

				$isFilterOnlyChildList = true;
				break 2;

			default:

				//throw new BitrixMainNotSupportedException('Not supported instruction ' . $instruction['code']);
				return array();
		}

	}

	if(empty($filter))
	{
		return $resultList;
	}

	//echo "Filter: ".print_R($filter, true);


	if($i >= $length)
	{
		return $this->walk($filter, null, $node, $limit);
	}
	else
	{
		$findNodeList = array();
		if($isFilterOnlyChildList)
		{
			foreach($node->getChildNodesArray() as $findNode)
			{
				if($this->isNodeFiltered($findNode, $filter))
				{
					$findNodeList[] = $findNode;
				}
			}
		}
		else
		{
			$this->limit = null;
			$this->deep = false;
			$this->direction = $direction;
			$findNodeList = $this->walkInternal($filter, null, $node);
			//echo "findNodeList: " . count($findNodeList) . "nnn";
		}
	}

	if(empty($findNodeList))
	{
		return $resultList;
	}


	$childInstructionList = array();
	while(++$i < $length)
	{
		$childInstructionList[] = $instruction = $instructionList[$i];
	}

	if(empty($childInstructionList))
	{
		return $resultList;
	}

	foreach($findNodeList as $findNode)
	{
		$resultList = array_merge(
			$resultList,
			$this->queryInternal($childInstructionList, $findNode, $limit, $direction)
		);
	}


	return $resultList;
}