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