- Модуль: tasks
- Путь к файлу: ~/bitrix/modules/tasks/classes/general/task.php
- Класс: CTasks
- Вызов: CTasks::parseFieldKey
static function parseFieldKey($key, $fieldName = '', $defaultOperator = '=')
{
$operators = [
'>=' => '>=',
'<=' => '<=',
'!=' => '!=',
'%' => 'like',
'=%' => 'like',
'%=' => 'like',
'=' => '=',
'>' => '>',
'<' => '<',
'!' => '!=',
'@' => 'in',
];
if ($fieldName)
{
$operator = str_replace($fieldName, '', $key);
$operator = ($operator && isset($operators[$operator]) ? $operators[$operator] : $defaultOperator);
}
else
{
$pattern = '/^(' . implode('|', array_keys($operators)) . ')/';
$matches = [];
preg_match($pattern, $key, $matches);
if (!empty($matches))
{
$operator = $operators[$matches[0]];
$fieldName = str_replace($matches[0], '', $key);
}
else
{
$operator = $defaultOperator;
$fieldName = $key;
}
}
return [
'OPERATOR' => $operator,
'FIELD_NAME' => $fieldName,
];
}