42 lines
1.2 KiB
PHP
42 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Ixrs\Catalog\Support;
|
|
|
|
class IBlock
|
|
{
|
|
static array $operations = [
|
|
'!><' => 'NB', //not between
|
|
'!=' => 'NI', //not Identical
|
|
'!%' => 'NS', //not substring
|
|
'><' => 'B', //between
|
|
'>=' => 'GE', //greater or equal
|
|
'<=' => 'LE', //less or equal
|
|
'=' => 'I', //Identical
|
|
'%' => 'S', //substring
|
|
'?' => '?', //logical
|
|
'>' => 'G', //greater
|
|
'<' => 'L', //less
|
|
'!' => 'N', // not field LIKE val
|
|
'*' => 'FT', // partial full text match
|
|
'*=' => 'FTI', // identical full text match
|
|
'*%' => 'FTL', // partial full text match based on LIKE
|
|
];
|
|
|
|
public static function getOperationFilter($key)
|
|
{
|
|
$re = '/^(!><|!=|!%|><|>=|<=|=|%|\?|>|<|!|\*|\*=|\*%)?(PROPERTY_)(\d+)$/m';
|
|
|
|
$matches = [];
|
|
$r = preg_match($re, $key, $matches);
|
|
|
|
if($r){
|
|
return [
|
|
'FIELD' => mb_strtoupper($matches[2] . $matches[3]),
|
|
'OPERATION' => static::$operations[$matches[1]]??'',
|
|
'PREFIX' => $matches[1],
|
|
'ID' => $matches[3],
|
|
];
|
|
}
|
|
return [];
|
|
}
|
|
} |