Ignore:
Timestamp:
12/07/08 01:25:48 (3 years ago)
Author:
WanWizard
Message:

updated the module search plugin to work with the new 'search entire site' option

File:
1 edited

Legend:

Unmodified
Added
Removed
  • modules/common/download_statistics/php-files/modules/download_statistics/search.files.php

    r2091 r2097  
    1818+---------------------------------------------------------------------*/ 
    1919if (eregi("search.files.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 
     
    117114        } 
    118115 
    119         // check if we have a rowstart value 
    120         if (!isset($rowstart)) $rowstart = 0; 
    121  
    122116        // check how many rows this would output 
    123117        $rptresult = mysql_query($sql.($limit?" LIMIT $limit":"")); 
    124         $variables['rows'] = dbrows($rptresult); 
    125         if ($variables['rows']) { 
    126             // store some row counter for the pager 
    127             $variables['rowstart'] = $rowstart; 
    128             $variables['items_per_page'] = $settings['numofthreads']; 
     118        $rows = dbrows($rptresult); 
    129119 
    130             // now add a query limit, make sure not to overshoot the limit requested 
    131             if ($variables['rows']-$rowstart > $settings['numofthreads']) { 
    132                 $sql .= " LIMIT ".$rowstart.",".$settings['numofthreads']; 
    133             } else { 
    134                 $sql .= " LIMIT ".$rowstart.",".($variables['rows']-$rowstart); 
    135             } 
    136             $rptresult = dbquery($sql); 
     120        // are there any results? 
     121        if ($rows) { 
    137122 
    138             // get the results if any 
    139             if ($variables['rows']) { 
    140                 $reportvars['output'] = array(); 
    141                 while ($rptdata = dbarray($rptresult)) { 
    142                     $reportvars['output'][] = $rptdata; 
     123            // are we interested in these results? 
     124            if ($lines < $settings['numofthreads'] && $rowstart < $variables['rows'] + $rows) { 
     125 
     126                // add a query limit, we might not need all records 
     127                $sql .= " LIMIT ".(max($rowstart-$variables['rows'],0)).",".min($rows,($settings['numofthreads']-$lines)); 
     128 
     129                // launch the query 
     130                $rptresult = dbquery($sql); 
     131 
     132                // get the results if any 
     133                if ($rptresult) { 
     134                    while ($rptdata = dbarray($rptresult)) { 
     135                        $rptdata['_template'] = $data['template']; 
     136                        $reportvars['output'][] = $rptdata; 
     137                    } 
     138 
     139                    // get the score divider for this result set 
     140                    $divider = 0; 
     141                    foreach($reportvars['output'] as $key => $value) { 
     142                        $divider = max($divider, $value['score']); 
     143                    } 
     144 
     145                    // calculate the relevance for this result set 
     146                    foreach($reportvars['output'] as $key => $value) { 
     147                        $reportvars['output'][$key]['relevance'] = $value['score'] / $divider * 100; 
     148                    } 
    143149                } 
    144150 
    145                 // get the score divider for this result set 
    146                 $divider = 0; 
    147                 foreach($reportvars['output'] as $key => $value) { 
    148                     $divider = max($divider, $value['score']); 
    149                 } 
     151            } 
    150152 
    151                 // calculate the relevance for this result set 
    152                 foreach($reportvars['output'] as $key => $value) { 
    153                     $reportvars['output'][$key]['relevance'] = $value['score'] / $divider * 100; 
    154                 } 
    155             } 
     153            // add the amount of rows found to the total rows counter 
     154            $variables['rows'] += $rows; 
     155 
    156156        } 
     157 
    157158    } 
    158159} 
Note: See TracChangeset for help on using the changeset viewer.