- Timestamp:
- Apr 4, 2014, 6:14:38 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/functions_search.inc.php
r28065 r28066 316 316 class QNumericRangeScope extends QSearchScope 317 317 { 318 function __construct($id, $aliases, $allow_empty=false) 318 private $epsilon; 319 function __construct($id, $aliases, $allow_empty=false, $epsilon=0) 319 320 { 320 321 parent::__construct($id, $aliases, $allow_empty, false); 322 $this->epsilon = $epsilon; 321 323 } 322 324 … … 327 329 $range = array( substr($str,0,$pos), substr($str, $pos+2)); 328 330 else 329 $range = array($str, $str); 331 { 332 if ('>' == @$str[0])// ratio:>1 333 $range = array( substr($str,1), ''); 334 elseif ('<' == @$str[0]) // size:<5mp 335 $range = array('', substr($str,1)); 336 else 337 $range = array($str, $str); 338 } 339 330 340 foreach ($range as $i =>&$val) 331 341 { 332 if (preg_match('/^([0-9.]+)([km])?/i', $val, $matches)) 342 if (preg_match('#^([0-9.]+)/([0-9.]+)$#i', $val, $matches)) 343 { 344 $val = floatval($matches[1]/$matches[2]); 345 } 346 elseif (preg_match('/^([0-9.]+)([km])?/i', $val, $matches)) 333 347 { 334 348 $val = floatval($matches[1]); … … 349 363 else 350 364 $val = ''; 365 if (is_numeric($val)) 366 { 367 if ($i) 368 $val += $this->epsilon; 369 else 370 $val -= $this->epsilon; 371 } 351 372 } 352 373 … … 584 605 { 585 606 if ($i+1 < count($this->tokens)) 586 $this->token [$i+1]->modifier |= QST_OR;607 $this->tokens[$i+1]->modifier |= QST_OR; 587 608 $token->term = ""; 588 609 } … … 619 640 } 620 641 642 private function apply_scope(QSearchScope $scope) 643 { 644 for ($i=0; $i<count($this->tokens); $i++) 645 { 646 if ($this->tokens[$i]->is_single) 647 { 648 if (!isset($this->tokens[$i]->scope)) 649 $this->tokens[$i]->scope = $scope; 650 } 651 else 652 $this->tokens[$i]->aooky_scope($scope); 653 } 654 } 655 621 656 private static function priority($modifier) 622 657 { … … 727 762 function qsearch_get_images(QExpression $expr, QResults $qsr) 728 763 { 729 $qsr->images_iids = array_fill(0, count($expr-> tokens), array());764 $qsr->images_iids = array_fill(0, count($expr->stokens), array()); 730 765 731 766 $inflector = null; … … 830 865 foreach ($tokens as $token) 831 866 { 832 if (!isset($token->scope) || 'tag' == $token->scope )867 if (!isset($token->scope) || 'tag' == $token->scope->id) 833 868 { 834 869 $transliterated_tokens[] = transliterate($token->term); … … 1088 1123 $scopes[] = new QNumericRangeScope('width', array()); 1089 1124 $scopes[] = new QNumericRangeScope('height', array()); 1090 $scopes[] = new QNumericRangeScope('ratio', array() );1125 $scopes[] = new QNumericRangeScope('ratio', array(), false, 0.001); 1091 1126 $scopes[] = new QNumericRangeScope('size', array()); 1092 1127 $scopes[] = new QNumericRangeScope('filesize', array());
Note: See TracChangeset
for help on using the changeset viewer.