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

    r2090 r2092  
    1818+---------------------------------------------------------------------*/ 
    1919if (eregi("search.forumattachments.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 
     
    176173        } 
    177174 
    178         // check if we have a rowstart value 
    179         if (!isset($rowstart)) $rowstart = 0; 
    180  
    181175        // check how many rows this would output 
    182176        $rptresult = mysql_query($sql.($limit?" LIMIT $limit":"")); 
    183         $variables['rows'] = dbrows($rptresult); 
    184         if ($variables['rows']) { 
    185             $variables['rowstart'] = $rowstart; 
    186             $variables['items_per_page'] = $settings['numofthreads']; 
    187  
    188             // now add a query limit, make sure not to overshoot the limit requested 
    189             if ($variables['rows']-$rowstart > $settings['numofthreads']) { 
    190                 $sql .= " LIMIT ".$rowstart.",".$settings['numofthreads']; 
    191             } else { 
    192                 $sql .= " LIMIT ".$rowstart.",".($variables['rows']-$rowstart); 
    193             } 
    194             $rptresult = dbquery($sql); 
    195  
    196             // get the results if any 
    197             if ($rptresult) { 
    198                 $reportvars['output'] = array(); 
    199                 while ($rptdata = dbarray($rptresult)) { 
    200                     $reportvars['output'][] = $rptdata; 
     177        $rows = dbrows($rptresult); 
     178 
     179        // are there any results? 
     180        if ($rows) { 
     181 
     182            // are we interested in these results? 
     183            if ($lines < $settings['numofthreads'] && $rowstart < $variables['rows'] + $rows) { 
     184 
     185                // add a query limit, we might not need all records 
     186                $sql .= " LIMIT ".(max($rowstart-$variables['rows'],0)).",".min($rows,($settings['numofthreads']-$lines)); 
     187 
     188                // launch the query 
     189                $rptresult = dbquery($sql); 
     190 
     191                // get the results if any 
     192                if ($rptresult) { 
     193                    while ($rptdata = dbarray($rptresult)) { 
     194                        $rptdata['_template'] = $data['template']; 
     195                        $rptdata['download_description'] = parsemessage(array(), $rptdata['download_description'], true, true); 
     196                        $reportvars['output'][] = $rptdata; 
     197                    } 
     198 
     199                    // get the score divider for this result set 
     200                    $divider = 0; 
     201                    foreach($reportvars['output'] as $key => $value) { 
     202                        $divider = max($divider, $value['score']); 
     203                    } 
     204 
     205                    // calculate the relevance for this result set 
     206                    foreach($reportvars['output'] as $key => $value) { 
     207                        $reportvars['output'][$key]['relevance'] = $value['score'] / $divider * 100; 
     208                    } 
    201209                } 
    202210 
    203                 // get the score divider for this result set 
    204                 $divider = 0; 
    205                 foreach($reportvars['output'] as $key => $value) { 
    206                     $divider = max($divider, $value['score']); 
    207                 } 
    208  
    209                 // calculate the relevance for this result set 
    210                 foreach($reportvars['output'] as $key => $value) { 
    211                     $reportvars['output'][$key]['relevance'] = $value['score'] / $divider * 100; 
    212                 } 
    213             } 
    214         } 
     211            } 
     212 
     213            // add the amount of rows found to the total rows counter 
     214            $variables['rows'] += $rows; 
     215 
     216        } 
     217 
    215218    } 
    216219} 
Note: See TracChangeset for help on using the changeset viewer.