Changeset 2092 in ExiteCMS for trunk/includes/search/search.downloads.php
- Timestamp:
- 12/05/08 20:23:35 (3 years ago)
- File:
-
- 1 edited
-
trunk/includes/search/search.downloads.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/includes/search/search.downloads.php
r2090 r2092 19 19 if (eregi("search.downloads.php", $_SERVER['PHP_SELF']) || !defined('INIT_CMS_OK')) die(); 20 20 21 // array to store variables we want to use in the search template22 $reportvars = array();21 // shared forum functions include 22 require_once PATH_INCLUDES."forum_functions_include.php"; 23 23 24 24 // make sure we have an action variable … … 135 135 } 136 136 137 // check if we have a rowstart value138 if (!isset($rowstart)) $rowstart = 0;139 140 137 // check how many rows this would output 141 138 $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); 146 140 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) { 154 143 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 } 160 171 } 161 172 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 } 167 174 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 173 178 } 179 174 180 } 175 181 }
Note: See TracChangeset
for help on using the changeset viewer.
