Ignore:
Timestamp:
12/05/08 20:23:35 (3 years ago)
Author:
WanWizard
Message:

ticket #58: added "search entire site" to the search module
added missing svn properties to several files

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/search/search.articles.php

    r2090 r2092  
    1818+---------------------------------------------------------------------*/ 
    1919if (eregi("search.articles.php", $_SERVER['PHP_SELF']) || !defined('INIT_CMS_OK')) die(); 
    20  
    21 // array to store variables we want to use in the search template 
    22 $reportvars = array(); 
    2320 
    2421// make sure we have an action variable 
     
    154151        } 
    155152 
    156         // check if we have a rowstart value 
    157         if (!isset($rowstart)) $rowstart = 0; 
    158      
    159153        // check how many rows this would output 
    160154        $rptresult = mysql_query($sql.($limit?" LIMIT $limit":"")); 
    161         $variables['rows'] = dbrows($rptresult); 
    162         if ($variables['rows']) { 
    163             $variables['rowstart'] = $rowstart; 
    164             $variables['items_per_page'] = $settings['numofthreads']; 
     155        $rows = dbrows($rptresult); 
    165156 
    166             // now add a query limit, make sure not to overshoot the limit requested 
    167             if ($variables['rows']-$rowstart > $settings['numofthreads']) { 
    168                 $sql .= " LIMIT ".$rowstart.",".$settings['numofthreads']; 
    169             } else { 
    170                 $sql .= " LIMIT ".$rowstart.",".($variables['rows']-$rowstart); 
    171             } 
    172             $rptresult = dbquery($sql); 
     157        // are there any results? 
     158        if ($rows) { 
    173159 
    174             // get the results if any 
    175             if ($rptresult) { 
    176                 $reportvars['output'] = array(); 
    177                 while ($rptdata = dbarray($rptresult)) { 
    178                     $reportvars['output'][] = $rptdata; 
     160            // are we interested in these results? 
     161            if ($lines < $settings['numofthreads'] && $rowstart < $variables['rows'] + $rows) { 
     162 
     163                // add a query limit, we might not need all records 
     164                $sql .= " LIMIT ".(max($rowstart-$variables['rows'],0)).",".min($rows,($settings['numofthreads']-$lines)); 
     165 
     166                // launch the query 
     167                $rptresult = dbquery($sql); 
     168 
     169                // get the results if any 
     170                if ($rptresult) { 
     171                    while ($rptdata = dbarray($rptresult)) { 
     172                        $rptdata['_template'] = $data['template']; 
     173                        $reportvars['output'][] = $rptdata; 
     174                    } 
     175 
     176                    // get the score divider for this result set 
     177                    $divider = 0; 
     178                    foreach($reportvars['output'] as $key => $value) { 
     179                        $divider = max($divider, $value['score']); 
     180                    } 
     181 
     182                    // calculate the relevance for this result set 
     183                    foreach($reportvars['output'] as $key => $value) { 
     184                        $reportvars['output'][$key]['relevance'] = $value['score'] / $divider * 100; 
     185                    } 
    179186                } 
    180187 
    181                 // get the score divider for this result set 
    182                 $divider = 0; 
    183                 foreach($reportvars['output'] as $key => $value) { 
    184                     $divider = max($divider, $value['score']); 
    185                 } 
     188            } 
    186189 
    187                 // calculate the relevance for this result set 
    188                 foreach($reportvars['output'] as $key => $value) { 
    189                     $reportvars['output'][$key]['relevance'] = $value['score'] / $divider * 100; 
    190                 } 
    191             } 
     190            // add the amount of rows found to the total rows counter 
     191            $variables['rows'] += $rows; 
     192 
    192193        } 
     194 
    193195    } 
    194196} 
Note: See TracChangeset for help on using the changeset viewer.