Changeset 2092 in ExiteCMS for trunk/includes/search/search.news.php
- Timestamp:
- 12/05/08 20:23:35 (3 years ago)
- File:
-
- 1 edited
-
trunk/includes/search/search.news.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/includes/search/search.news.php
r2090 r2092 18 18 +---------------------------------------------------------------------*/ 19 19 if (eregi("search.news.php", $_SERVER['PHP_SELF']) || !defined('INIT_CMS_OK')) die(); 20 21 // array to store variables we want to use in the search template22 $reportvars = array();23 20 24 21 // make sure we have an action variable … … 152 149 } 153 150 154 // check if we have a rowstart value155 if (!isset($rowstart)) $rowstart = 0;156 157 151 // check how many rows this would output 158 152 $rptresult = mysql_query($sql.($limit?" LIMIT $limit":"")); 159 $variables['rows'] = dbrows($rptresult); 160 if ($variables['rows']) { 161 $variables['rowstart'] = $rowstart; 162 $variables['items_per_page'] = $settings['numofthreads']; 153 $rows = dbrows($rptresult); 163 154 164 // now add a query limit, make sure not to overshoot the limit requested 165 if ($variables['rows']-$rowstart > $settings['numofthreads']) { 166 $sql .= " LIMIT ".$rowstart.",".$settings['numofthreads']; 167 } else { 168 $sql .= " LIMIT ".$rowstart.",".($variables['rows']-$rowstart); 169 } 170 $rptresult = dbquery($sql); 155 // are there any results? 156 if ($rows) { 171 157 172 // get the results if any 173 if ($variables['rows']) { 174 $reportvars['output'] = array(); 175 while ($rptdata = dbarray($rptresult)) { 176 $reportvars['output'][] = $rptdata; 158 // are we interested in these results? 159 if ($lines < $settings['numofthreads'] && $rowstart < $variables['rows'] + $rows) { 160 161 // add a query limit, we might not need all records 162 $sql .= " LIMIT ".(max($rowstart-$variables['rows'],0)).",".min($rows,($settings['numofthreads']-$lines)); 163 164 // launch the query 165 $rptresult = dbquery($sql); 166 167 // get the results if any 168 if ($rptresult) { 169 while ($rptdata = dbarray($rptresult)) { 170 $rptdata['_template'] = $data['template']; 171 $reportvars['output'][] = $rptdata; 172 } 173 174 // get the score divider for this result set 175 $divider = 0; 176 foreach($reportvars['output'] as $key => $value) { 177 $divider = max($divider, $value['score']); 178 } 179 180 // calculate the relevance for this result set 181 foreach($reportvars['output'] as $key => $value) { 182 $reportvars['output'][$key]['relevance'] = $value['score'] / $divider * 100; 183 } 177 184 } 178 185 179 // get the score divider for this result set 180 $divider = 0; 181 foreach($reportvars['output'] as $key => $value) { 182 $divider = max($divider, $value['score']); 183 } 186 } 184 187 185 // calculate the relevance for this result set 186 foreach($reportvars['output'] as $key => $value) { 187 $reportvars['output'][$key]['relevance'] = $value['score'] / $divider * 100; 188 } 189 } 188 // add the amount of rows found to the total rows counter 189 $variables['rows'] += $rows; 190 190 191 } 192 191 193 } 192 194 }
Note: See TracChangeset
for help on using the changeset viewer.
