- Модуль: tasks
- Путь к файлу: ~/bitrix/modules/tasks/classes/general/task.php
- Класс: CTasks
- Вызов: CTasks::MkOperationFilter
static function MkOperationFilter($key)
{
static $arOperationsMap = null; // will be loaded on demand
$key = ltrim($key);
$firstSymbol = mb_substr($key, 0, 1);
$twoSymbols = mb_substr($key, 0, 2);
if ($firstSymbol == "=") //Identical
{
$key = mb_substr($key, 1);
$cOperationType = "I";
}
elseif ($twoSymbols == "!=") //not Identical
{
$key = mb_substr($key, 2);
$cOperationType = "NI";
}
elseif ($firstSymbol == "%") //substring
{
$key = mb_substr($key, 1);
$cOperationType = "S";
}
elseif ($twoSymbols == "!%") //not substring
{
$key = mb_substr($key, 2);
$cOperationType = "NS";
}
elseif ($firstSymbol == "?") //logical
{
$key = mb_substr($key, 1);
$cOperationType = "?";
}
elseif ($twoSymbols == "><") //between
{
$key = mb_substr($key, 2);
$cOperationType = "B";
}
elseif ($twoSymbols == "*=") // identical full text match
{
$key = mb_substr($key, 2);
$cOperationType = "FTI";
}
elseif ($twoSymbols == "*%") // partial full text match based on LIKE
{
$key = mb_substr($key, 2);
$cOperationType = "FTL";
}
elseif ($firstSymbol == "*") // partial full text match
{
$key = mb_substr($key, 1);
$cOperationType = "FT";
}
elseif (mb_substr($key, 0, 3) == "!><") //not between
{
$key = mb_substr($key, 3);
$cOperationType = "NB";
}
elseif ($twoSymbols == ">=") //greater or equal
{
$key = mb_substr($key, 2);
$cOperationType = "GE";
}
elseif ($firstSymbol == ">") //greater
{
$key = mb_substr($key, 1);
$cOperationType = "G";
}
elseif ($twoSymbols == "<=") //less or equal
{
$key = mb_substr($key, 2);
$cOperationType = "LE";
}
elseif ($firstSymbol == "<") //less
{
$key = mb_substr($key, 1);
$cOperationType = "L";
}
elseif ($firstSymbol == "!") // not field LIKE val
{
$key = mb_substr($key, 1);
$cOperationType = "N";
}
elseif ($firstSymbol === '#')
{
// Preload and cache in static variable
if ($arOperationsMap === null)
{
$arManifest = CTaskFilterCtrl::getManifest();
$arOperationsMap = $arManifest['Operations map'];
}
// Resolve operation code and cutoff operation prefix from item name
$operation = null;
foreach ($arOperationsMap as $operationCode => $operationPrefix)
{
$pattern = '/^' . preg_quote($operationPrefix) . '[A-Za-z]/';
if (preg_match($pattern, $key))
{
$operation = $operationCode;
$key = mb_substr($key, mb_strlen($operationPrefix));
break;
}
}
CTaskAssert::assert($operation !== null);
$cOperationType = "#" . $operation;
}
else
{
$cOperationType = "E";
} // field LIKE val
return ["FIELD" => $key, "OPERATION" => $cOperationType];
}