• Модуль: tasks
  • Путь к файлу: ~/bitrix/modules/tasks/classes/general/taskfilterctrl.php
  • Класс: CTaskFilterCtrl
  • Вызов: CTaskFilterCtrl::convertItemForExport
static function convertItemForExport($arItem)
{
	static $arFields = null;
	$arResult = array();

	if ($arFields === null)
	{
		$arManifest = self::getManifest();
		$arFields   = $arManifest['Fields'];
	}

	foreach ($arItem as $itemName => $itemData)
	{
		CTaskAssert::assert(mb_strlen($itemName) > 2);

		if ($itemName === '::LOGIC')
		{
			$arResult[$itemName] = $itemData;
			continue;
		}

		if (mb_substr($itemName, 0, 12) === '::SUBFILTER-')
		{
			$arResult[$itemName] = self::convertItemForExport($itemData);
			continue;
		}

		$value = $itemData;

		$itemName = ltrim($itemName);

		// Resolve operation code and cutoff operation prefix from item name
		$operation = null;
		foreach (self::$arOperationsMap as $operationCode => $operationPrefix)
		{
			$pattern = '/^' . preg_quote($operationPrefix) . '[A-Za-z]/';
			if (preg_match($pattern, $itemName))
			{
				$operation = $operationCode;
				$itemName = mb_substr($itemName, mb_strlen($operationPrefix));
				break;
			}
		}

		CTaskAssert::assert($operation !== null);

		// Process values for date fields
		if (isset($arFields[$itemName]['Type']) && ($arFields[$itemName]['Type'] === self::TYPE_DATE))
			$value = self::convertTimestampToDateString($operation, $value);

		$arResult[] = array(
			'field'     => $itemName,
			'operation' => $operation,
			'value'     => $value
		);
	}

	return ($arResult);

	/*
		data in:
		$arFilter = array(
			'::LOGIC' => 'AND',
			'RESPONSIBLE_ID' => 1,
			'::SUBFILTER-1' => array(
				'::LOGIC' => 'OR',
				'CREATED_BY' => 1,
				'!=CREATED_BY' => 2
			),
			'::SUBFILTER-2' => array(
				'::LOGIC' => 'AND',
				'%TITLE' => 'some interesting substring',
				'!%TITLE' => 'some not interesting substring'
			)
		);

		data out:
		array(
			'::LOGIC' => 'AND',
			array(
				'field'     => 'RESPONSIBLE_ID',
				'operation' => CTaskFilterCtrlInterface::OP_EQUAL,
				'value'     => 1
			),
			'::SUBFILTER-1' => array(
				'::LOGIC' => 'OR',
				array(
					'field'     => 'CREATED_BY',
					'operation' => CTaskFilterCtrlInterface::OP_EQUAL,
					'value'     => 1
				),
				array(
					'field'     => 'CREATED_BY',
					'operation' => CTaskFilterCtrlInterface::OP_NOT_EQUAL,
					'value'     => 2
				)
			),
			'::SUBFILTER-2' => array(
				'::LOGIC' => 'AND',
				array(
					'field'     => 'TITLE',
					'operation' => CTaskFilterCtrlInterface::OP_SUBSTRING,
					'value'     => 1
				),
				array(
					'field'     => 'TITLE',
					'operation' => CTaskFilterCtrlInterface::OP_NOT_SUBSTRING,
					'value'     => 2
				)
			)
		)
	*/
}