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

    r2090 r2092  
    1919if (eregi("search.downloads.php", $_SERVER['PHP_SELF']) || !defined('INIT_CMS_OK')) die(); 
    2020 
    21 // array to store variables we want to use in the search template 
    22 $reportvars = array(); 
     21// shared forum functions include 
     22require_once PATH_INCLUDES."forum_functions_include.php"; 
    2323 
    2424// make sure we have an action variable 
     
    135135        } 
    136136 
    137         // check if we have a rowstart value 
    138         if (!isset($rowstart)) $rowstart = 0; 
    139  
    140137        // check how many rows this would output 
    141138        $rptresult = mysql_query($sql.($limit?" LIMIT $limit":"")); 
    142         $variables['rows'] = dbrows($rptresult); 
    143         if ($variables['rows']) { 
    144             $variables['rowstart'] = $rowstart; 
    145             $variables['items_per_page'] = $settings['numofthreads']; 
     139        $rows = dbrows($rptresult); 
    146140 
    147             // now add a query limit, make sure not to overshoot the limit requested 
    148             if ($variables['rows']-$rowstart > $settings['numofthreads']) { 
    149                 $sql .= " LIMIT ".$rowstart.",".$settings['numofthreads']; 
    150             } else { 
    151                 $sql .= " LIMIT ".$rowstart.",".($variables['rows']-$rowstart); 
    152             } 
    153             $rptresult = dbquery($sql); 
     141        // are there any results? 
     142        if ($rows) { 
    154143 
    155             // get the results if any 
    156             if ($rptresult) { 
    157                 $reportvars['output'] = array(); 
    158                 while ($rptdata = dbarray($rptresult)) { 
    159                     $reportvars['output'][] = $rptdata; 
     144            // are we interested in these results? 
     145            if ($lines < $settings['numofthreads'] && $rowstart < $variables['rows'] + $rows) { 
     146 
     147                // add a query limit, we might not need all records 
     148                $sql .= " LIMIT ".(max($rowstart-$variables['rows'],0)).",".min($rows,($settings['numofthreads']-$lines)); 
     149 
     150                // launch the query 
     151                $rptresult = dbquery($sql); 
     152 
     153                // get the results if any 
     154                if ($rptresult) { 
     155                    while ($rptdata = dbarray($rptresult)) { 
     156                        $rptdata['_template'] = $data['template']; 
     157                        $rptdata['download_description'] = parsemessage(array(), $rptdata['download_description'], true, true); 
     158                        $reportvars['output'][] = $rptdata; 
     159                    } 
     160 
     161                    // get the score divider for this result set 
     162                    $divider = 0; 
     163                    foreach($reportvars['output'] as $key => $value) { 
     164                        $divider = max($divider, $value['score']); 
     165                    } 
     166 
     167                    // calculate the relevance for this result set 
     168                    foreach($reportvars['output'] as $key => $value) { 
     169                        $reportvars['output'][$key]['relevance'] = $value['score'] / $divider * 100; 
     170                    } 
    160171                } 
    161172 
    162                 // get the score divider for this result set 
    163                 $divider = 0; 
    164                 foreach($reportvars['output'] as $key => $value) { 
    165                     $divider = max($divider, $value['score']); 
    166                 } 
     173            } 
    167174 
    168                 // calculate the relevance for this result set 
    169                 foreach($reportvars['output'] as $key => $value) { 
    170                     $reportvars['output'][$key]['relevance'] = $value['score'] / $divider * 100; 
    171                 } 
    172             } 
     175            // add the amount of rows found to the total rows counter 
     176            $variables['rows'] += $rows; 
     177 
    173178        } 
     179 
    174180    } 
    175181} 
Note: See TracChangeset for help on using the changeset viewer.