includes/search.php
changeset 953 323c4cd1aa37
parent 945 c19242d13a49
child 1081 745200a9cc2a
equal deleted inserted replaced
952:d52dfa1f08da 953:323c4cd1aa37
   249               $word_tracking[$match] = array($word_cs);
   249               $word_tracking[$match] = array($word_cs);
   250             }
   250             }
   251             $inc = 1;
   251             $inc = 1;
   252 
   252 
   253             // Is this search term present in the page's title? If so, give extra points
   253             // Is this search term present in the page's title? If so, give extra points
   254             preg_match("/^ns=$ns_list;pid=(.+)$/", $match, $piecesparts);
   254             preg_match("/^ns=$ns_list;pid=(.+)$/", $pages, $piecesparts);
   255             $pathskey = $paths->nslist[ $piecesparts[1] ] . sanitize_page_id($piecesparts[2]);
   255             $title = get_page_title_ns($piecesparts[2], $piecesparts[1]);
   256             if ( isPage($pathskey) )
   256             
   257             {
   257             $test_func = ( $case_sensitive ) ? 'strstr' : 'stristr';
   258               $test_func = ( $case_sensitive ) ? 'strstr' : 'stristr';
   258             if ( $test_func($title, $row['word']) || $test_func($piecesparts[2], $row['word']) )
   259               if ( $test_func($paths->pages[$pathskey]['name'], $row['word']) || $test_func($paths->pages[$pathskey]['urlname_nons'], $row['word']) )
   259             {
   260               {
   260               $inc = 1.5;
   261                 $inc = 1.5;
   261             }
   262               }
   262           
   263             }
       
   264             if ( isset($scores[$match]) )
   263             if ( isset($scores[$match]) )
   265             {
   264             {
   266               $scores[$match] = $scores[$match] + $inc;
   265               $scores[$match] = $scores[$match] + $inc;
   267             }
   266             }
   268             else
   267             else
   390       {
   389       {
   391         $id =& $row['id'];
   390         $id =& $row['id'];
   392         $inc = 1;
   391         $inc = 1;
   393 
   392 
   394         // Is this search term present in the page's title? If so, give extra points
   393         // Is this search term present in the page's title? If so, give extra points
   395         preg_match("/^ns=$ns_list;pid=(.+)$/", $id, $piecesparts);
   394         preg_match("/^ns=$ns_list;pid=(.+)$/", $pages, $piecesparts);
   396         $pathskey = $paths->nslist[ $piecesparts[1] ] . sanitize_page_id($piecesparts[2]);
   395         $title = get_page_title_ns($piecesparts[2], $piecesparts[1]);
   397         if ( isPage($pathskey) )
   396         
   398         {
   397         $test_func = ( $case_sensitive ) ? 'strstr' : 'stristr';
   399           $test_func = ( $case_sensitive ) ? 'strstr' : 'stristr';
   398         if ( $test_func($title, $row['word']) || $test_func($piecesparts[2], $row['word']) )
   400           foreach ( array_merge($query_phrase['any'], $query_phrase['req']) as $term )
   399         {
   401           {
   400           $inc = 1.5;
   402             if ( $test_func($paths->pages[$pathskey]['name'], $term) || $test_func($paths->pages[$pathskey]['urlname_nons'], $term) )
   401         }
   403             {
   402         
   404               $inc = 1.5;
       
   405               break;
       
   406             }
       
   407           }
       
   408         }
       
   409         if ( isset($scores[$id]) )
   403         if ( isset($scores[$id]) )
   410         {
   404         {
   411           $scores[$id] = $scores[$id] + $inc;
   405           $scores[$id] = $scores[$id] + $inc;
   412         }
   406         }
   413         else
   407         else