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.forumposts.php

    r2090 r2092  
    1818+---------------------------------------------------------------------*/ 
    1919if (eregi("search.forumposts.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 
     
    199196        } 
    200197 
    201         // check if we have a rowstart value 
    202         if (!isset($rowstart)) $rowstart = 0; 
    203  
    204198        // check how many rows this would output 
    205199        $rptresult = mysql_query($sql.($limit?" LIMIT $limit":"")); 
    206         $variables['rows'] = dbrows($rptresult); 
    207         if ($variables['rows']) { 
    208             $variables['rowstart'] = $rowstart; 
    209             $variables['items_per_page'] = $settings['numofthreads']; 
    210  
    211             // now add a query limit, make sure not to overshoot the limit requested 
    212             if ($variables['rows']-$rowstart > $settings['numofthreads']) { 
    213                 $sql .= " LIMIT ".$rowstart.",".$settings['numofthreads']; 
    214             } else { 
    215                 $sql .= " LIMIT ".$rowstart.",".($variables['rows']-$rowstart); 
    216             } 
    217             $rptresult = dbquery($sql); 
    218  
    219             // get the results if any 
    220             if ($variables['rows']) { 
    221                 $reportvars['output'] = array(); 
    222                 while ($rptdata = dbarray($rptresult)) { 
    223                     $reportvars['output'][] = $rptdata; 
     200        $rows = dbrows($rptresult); 
     201 
     202        // are there any results? 
     203        if ($rows) { 
     204 
     205            // are we interested in these results? 
     206            if ($lines < $settings['numofthreads'] && $rowstart < $variables['rows'] + $rows) { 
     207 
     208                // add a query limit, we might not need all records 
     209                $sql .= " LIMIT ".(max($rowstart-$variables['rows'],0)).",".min($rows,($settings['numofthreads']-$lines)); 
     210 
     211                // launch the query 
     212                $rptresult = dbquery($sql); 
     213 
     214                // get the results if any 
     215                if ($rptresult) { 
     216                    while ($rptdata = dbarray($rptresult)) { 
     217                        $rptdata['_template'] = $data['template']; 
     218                        $reportvars['output'][] = $rptdata; 
     219                    } 
     220 
     221                    // get the score divider for this result set 
     222                    $divider = 0; 
     223                    foreach($reportvars['output'] as $key => $value) { 
     224                        $divider = max($divider, $value['score']); 
     225                    } 
     226 
     227                    // calculate the relevance for this result set 
     228                    foreach($reportvars['output'] as $key => $value) { 
     229                        $reportvars['output'][$key]['relevance'] = $value['score'] / $divider * 100; 
     230                    } 
    224231                } 
    225232 
    226                 // get the score divider for this result set 
    227                 $divider = 0; 
    228                 foreach($reportvars['output'] as $key => $value) { 
    229                     $divider = max($divider, $value['score']); 
    230                 } 
    231  
    232                 // calculate the relevance for this result set 
    233                 foreach($reportvars['output'] as $key => $value) { 
    234                     $reportvars['output'][$key]['relevance'] = $value['score'] / $divider * 100; 
    235                 } 
    236             } 
    237         } 
     233            } 
     234 
     235            // add the amount of rows found to the total rows counter 
     236            $variables['rows'] += $rows; 
     237 
     238        } 
     239 
    238240    } 
    239241} 
Note: See TracChangeset for help on using the changeset viewer.