Ignore:
Timestamp:
Apr 3, 2014, 9:46:10 PM (10 years ago)
Author:
rvelices
Message:

bug 3056: quick search - fix + prepare for scoped/range searches

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/functions_search.inc.php

    r27884 r28064  
    310310{
    311311  var $is_single = true;
    312   var $token; /* the actual word/phrase string*/
     312  var $term; /* the actual word/phrase string*/
    313313  var $idx;
    314314
    315   function __construct($token)
    316   {
    317     $this->token = $token;
     315  function __construct($term)
     316  {
     317    $this->term = $term;
     318  }
     319 
     320  function __toString()
     321  {
     322    return $this->term;
    318323  }
    319324}
     
    350355      else
    351356      {
    352         $s .= $this->tokens[$i]->token;
     357        $s .= $this->tokens[$i];
    353358      }
    354359      if ($modifier & QST_QUOTED)
     
    438443          {
    439444            $crt_modifier |= QST_WILDCARD_END;
    440             $ai++;
     445            $qi++;
    441446          }
    442447          $this->push($crt_token, $crt_modifier);
     
    458463        if ( ($this->token_modifiers[$i]&QST_QUOTED)==0 )
    459464        {
    460           if ('not' == strtolower($token->token))
     465          if ('not' == strtolower($token->term))
    461466          {
    462467            if ($i+1 < count($this->tokens))
    463468              $this->token_modifiers[$i+1] |= QST_NOT;
    464             $token->token = "";
     469            $token->term = "";
    465470          }
    466           if ('or' == strtolower($token->token))
     471          if ('or' == strtolower($token->term))
    467472          {
    468473            if ($i+1 < count($this->tokens))
    469474              $this->token_modifiers[$i+1] |= QST_OR;
    470             $token->token = "";
     475            $token->term = "";
    471476          }
    472           if ('and' == strtolower($token->token))
     477          if ('and' == strtolower($token->term))
    473478          {
    474             $token->token = "";
     479            $token->term = "";
    475480          }
    476           if ( substr($token->token, -1)=='*' )
     481          if ( substr($token->term, -1)=='*' )
    477482          {
    478             $token->token = rtrim($token->token, '*');
     483            $token->term = rtrim($token->term, '*');
    479484            $this->token_modifiers[$i] |= QST_WILDCARD_END;
    480485          }
    481486        }
    482         if (!strlen($token->token))
     487        if (!strlen($token->term))
    483488          $remove = true;
    484489      }
     
    568573      {
    569574        $token->idx = count($this->stokens);
    570         $this->stokens[] = $token->token;
     575        $this->stokens[] = $token;
    571576
    572577        $modifier = $expr->token_modifiers[$i];
     
    614619  for ($i=0; $i<count($expr->stokens); $i++)
    615620  {
    616     $token = $expr->stokens[$i];
     621    $token = $expr->stokens[$i]->term;
    617622    $clauses = array();
    618623
     
    674679  foreach ($tokens as $token)
    675680  {
    676     $transliterated_tokens[] = transliterate($token);
     681    $transliterated_tokens[] = transliterate($token->term);
    677682  }
    678683
     
    844849      $crt_ids = $qsr->iids[$crt->idx] = array_unique( array_merge($qsr->images_iids[$crt->idx], $qsr->tag_iids[$crt->idx]) );
    845850      $crt_qualifies = count($crt_ids)>0 || count($qsr->tag_ids[$crt->idx])>0;
    846       $crt_ignored_terms = $crt_qualifies ? array() : array($crt->token);
     851      $crt_ignored_terms = $crt_qualifies ? array() : array($crt->term);
    847852    }
    848853    else
     
    921926  {
    922927    $debug[] = $expression->stokens[$i].': '.count($qsr->tag_ids[$i]).' tags, '.count($qsr->tag_iids[$i]).' tiids, '.count($qsr->images_iids[$i]).' iiids, '.count($qsr->iids[$i]).' iids'
    923       .( !empty($qsr->variants[$expression->stokens[$i]]) ? ' variants: '.implode(', ',$qsr->variants[$expression->stokens[$i]]): '');
     928      .( !empty($qsr->variants[$expression->stokens[$i]->term]) ? ' variants: '.implode(', ',$qsr->variants[$expression->stokens[$i]->term]): '');
    924929  }
    925930  $debug[] = 'before perms '.count($ids);
Note: See TracChangeset for help on using the changeset viewer.