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

    r2090 r2092  
    1919if (eregi("search.members.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(); 
    23  
    2421// make sure we have an action variable 
    2522if (isset($action)) { 
     
    2926        // add the possible  search filters ($data is defined in the calling script!) 
    3027        $data['search_filters' ] = ""; 
    31  
    3228 
    3329    } else { 
     
    118114        } 
    119115 
    120         // check if we have a rowstart value 
    121         if (!isset($rowstart)) $rowstart = 0; 
    122      
    123116        // check how many rows this would output 
    124117        $rptresult = mysql_query($sql.($limit?" LIMIT $limit":"")); 
    125         $variables['rows'] = dbrows($rptresult); 
    126         if ($variables['rows']) { 
    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                        $rptdata['download_description'] = parsemessage(array(), $rptdata['download_description'], true, true); 
     137                        $reportvars['output'][] = $rptdata; 
     138                    } 
     139 
     140                    // get the score divider for this result set 
     141                    $divider = 0; 
     142                    foreach($reportvars['output'] as $key => $value) { 
     143                        $divider = max($divider, $value['score']); 
     144                    } 
     145 
     146                    // calculate the relevance for this result set 
     147                    foreach($reportvars['output'] as $key => $value) { 
     148                        $reportvars['output'][$key]['relevance'] = $value['score'] / $divider * 100; 
     149                    } 
    143150                } 
    144151 
    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                 } 
     152            } 
    150153 
    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             } 
     154            // add the amount of rows found to the total rows counter 
     155            $variables['rows'] += $rows; 
     156 
    156157        } 
     158 
    157159    } 
    158160} 
Note: See TracChangeset for help on using the changeset viewer.