Changeset 2097 in ExiteCMS
- Timestamp:
- 12/07/08 01:25:48 (3 years ago)
- Location:
- modules/common
- Files:
-
- 4 edited
-
download_statistics/php-files/modules/download_statistics/search.files.php (modified) (2 diffs)
-
download_statistics/php-files/modules/download_statistics/templates/modules.download_statistics.search.files.tpl (modified) (1 diff)
-
wiki/php-files/modules/wiki/search.wiki.php (modified) (2 diffs)
-
wiki/php-files/modules/wiki/templates/modules.wiki.search.wiki.tpl (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
modules/common/download_statistics/php-files/modules/download_statistics/search.files.php
r2091 r2097 18 18 +---------------------------------------------------------------------*/ 19 19 if (eregi("search.files.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 … … 117 114 } 118 115 119 // check if we have a rowstart value120 if (!isset($rowstart)) $rowstart = 0;121 122 116 // check how many rows this would output 123 117 $rptresult = mysql_query($sql.($limit?" LIMIT $limit":"")); 124 $variables['rows'] = dbrows($rptresult); 125 if ($variables['rows']) { 126 // store some row counter for the pager 127 $variables['rowstart'] = $rowstart; 128 $variables['items_per_page'] = $settings['numofthreads']; 118 $rows = dbrows($rptresult); 129 119 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) { 137 122 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 $reportvars['output'][] = $rptdata; 137 } 138 139 // get the score divider for this result set 140 $divider = 0; 141 foreach($reportvars['output'] as $key => $value) { 142 $divider = max($divider, $value['score']); 143 } 144 145 // calculate the relevance for this result set 146 foreach($reportvars['output'] as $key => $value) { 147 $reportvars['output'][$key]['relevance'] = $value['score'] / $divider * 100; 148 } 143 149 } 144 150 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 } 151 } 150 152 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 } 153 // add the amount of rows found to the total rows counter 154 $variables['rows'] += $rows; 155 156 156 } 157 157 158 } 158 159 } -
modules/common/download_statistics/php-files/modules/download_statistics/templates/modules.download_statistics.search.files.tpl
r2043 r2097 19 19 {***************************************************************************} 20 20 {if $action == "search"} 21 {section name=idx loop=$reportvars.output} 22 {if !$smarty.section.idx.first} 23 <br /><br /> 24 {/if} 25 {$locale.dls810}: {$reportvars.output[idx].dlsf_file} 26 <br /> 27 <span class='small'><font class='smallalt'>{$locale.dls811}:</font> {$reportvars.output[idx].dlsf_counter} 28 {/section} 21 <br /><br /> 22 {$locale.dls810}: {$output.dlsf_file} 23 <br /> 24 <span class='small'><font class='smallalt'>{$locale.dls811}:</font> {$output.dlsf_counter} 29 25 {else} 30 26 <input type='radio' name='search_id' value='{$searches[id].search_id}' {if $search_id == $searches[id].search_id || $searches[id].search_order == $default_location}checked='checked'{/if} onclick='javascript:show_filter("{$searches[id].search_filters}");'/> {$searches[id].search_title} {if $searches[id].search_fulltext}<span style='color:red;'>*</span>{/if}<br /> -
modules/common/wiki/php-files/modules/wiki/search.wiki.php
r2091 r2097 34 34 $headerparms = ' <link rel="stylesheet" type="text/css" href="'.$wakka->GetConfigValue("stylesheet").'" />'; 35 35 36 // array to store variables we want to use in the search template37 $reportvars = array();38 39 36 // set the page title 40 $title = $locale['424'];37 if ($search_id != 99999) $title = $locale['424']; 41 38 42 39 // make sure we have an action variable … … 148 145 } 149 146 150 // check if we have a rowstart value151 if (!isset($rowstart)) $rowstart = 0;152 153 147 // check how many rows this would output 154 148 $rptresult = mysql_query($sql.($limit?" LIMIT $limit":"")); 155 $variables['rows'] = dbrows($rptresult); 156 if ($variables['rows']) { 157 // store some row counter for the pager 158 $variables['rowstart'] = $rowstart; 159 $variables['items_per_page'] = $settings['numofthreads']; 160 161 // now add a query limit, make sure not to overshoot the limit requested 162 if ($variables['rows']-$rowstart > $settings['numofthreads']) { 163 $sql .= " LIMIT ".$rowstart.",".$settings['numofthreads']; 164 } else { 165 $sql .= " LIMIT ".$rowstart.",".($variables['rows']-$rowstart); 166 } 167 $rptresult = dbquery($sql); 168 169 // get the results if any 170 if ($variables['rows']) { 171 $reportvars['output'] = array(); 172 $i=0; 173 while ($rptdata = dbarray($rptresult)) { 174 if ($wakka->HasAccess("read",$rptdata["tag"])) { 175 $rptdata['access'] = true; 176 // display portion of the matching body and highlight the search term */ 177 preg_match_all("/(.{0,120})($stext)(.{0,120})/is",$rptdata['body'],$matchString); 178 if (count($matchString[0]) > 3) 179 { 180 $matchString[0] = array_splice($matchString[0], 3, count($matchString)); 149 $rows = dbrows($rptresult); 150 151 // are there any results? 152 if ($rows) { 153 154 // are we interested in these results? 155 if ($lines < $settings['numofthreads'] && $rowstart < $variables['rows'] + $rows) { 156 157 // add a query limit, we might not need all records 158 $sql .= " LIMIT ".(max($rowstart-$variables['rows'],0)).",".min($rows,($settings['numofthreads']-$lines)); 159 160 // launch the query 161 $rptresult = dbquery($sql); 162 163 // get the results if any 164 if ($rptresult) { 165 while ($rptdata = dbarray($rptresult)) { 166 if ($wakka->HasAccess("read",$rptdata["tag"])) { 167 $rptdata['access'] = true; 168 // display portion of the matching body and highlight the search term */ 169 preg_match_all("/(.{0,120})($stext)(.{0,120})/is",$rptdata['body'],$matchString); 170 if (count($matchString[0]) > 3) 171 { 172 $matchString[0] = array_splice($matchString[0], 3, count($matchString)); 173 } 174 $text = $wakka->htmlspecialchars_ent(implode('<br />', $matchString[0])); 175 $text = str_replace('<br />', '…<br />…', $text); 176 // CSS-driven highlighting, tse stands for textsearchexpanded. We highlight $text in 2 steps, 177 // We do not use <span>..</span> with preg_replace to ensure that the tag `span' won't be replaced if 178 // $phrase contains `span'. 179 $highlightMatch = preg_replace('/('.$wakka->htmlspecialchars_ent($stext).')/i','<<$1>>',$text,-1); // -1 = no limit (default!) 180 $rptdata['snippet'] = "…".str_replace(array('<<', '>>'), array('<span class="tse_keywords">', '</span>'), $highlightMatch)."…"; 181 } else { 182 $rptdata['access'] = false; 183 $rptdata['snippet'] = $locale['427']; 181 184 } 182 $text = $wakka->htmlspecialchars_ent(implode('<br />', $matchString[0])); 183 $text = str_replace('<br />', '…<br />…', $text); 184 // CSS-driven highlighting, tse stands for textsearchexpanded. We highlight $text in 2 steps, 185 // We do not use <span>..</span> with preg_replace to ensure that the tag `span' won't be replaced if 186 // $phrase contains `span'. 187 $highlightMatch = preg_replace('/('.$wakka->htmlspecialchars_ent($stext).')/i','<<$1>>',$text,-1); // -1 = no limit (default!) 188 $rptdata['snippet'] = "…".str_replace(array('<<', '>>'), array('<span class="tse_keywords">', '</span>'), $highlightMatch)."…"; 189 } else { 190 $rptdata['access'] = false; 191 $rptdata['snippet'] = $locale['427']; 185 $rptdata['_template'] = $data['template']; 186 $reportvars['output'][] = $rptdata; 192 187 } 193 $reportvars['output'][] = $rptdata; 188 189 // get the score divider for this result set 190 $divider = 0; 191 foreach($reportvars['output'] as $key => $value) { 192 $divider = max($divider, $value['score']); 193 } 194 195 // calculate the relevance for this result set 196 foreach($reportvars['output'] as $key => $value) { 197 $reportvars['output'][$key]['relevance'] = $value['score'] / $divider * 100; 198 } 194 199 } 195 200 196 // get the score divider for this result set 197 $divider = 0; 198 foreach($reportvars['output'] as $key => $value) { 199 $divider = max($divider, $value['score']); 200 } 201 202 // calculate the relevance for this result set 203 foreach($reportvars['output'] as $key => $value) { 204 $reportvars['output'][$key]['relevance'] = $value['score'] / $divider * 100; 205 } 206 } 207 } 201 } 202 203 // add the amount of rows found to the total rows counter 204 $variables['rows'] += $rows; 205 206 } 207 208 208 } 209 209 } -
modules/common/wiki/php-files/modules/wiki/templates/modules.wiki.search.wiki.tpl
r2091 r2097 19 19 {***************************************************************************} 20 20 {if $action == "search"} 21 {section name=idx loop=$reportvars.output} 22 <img src='{$smarty.const.THEME}images/bullet.gif' alt='' /> 23 {if $reportvars.output[idx].access} 24 <a href='{$smarty.const.MODULES}wiki/index.php?wakka={$reportvars.output[idx].tag}'>{$reportvars.output[idx].tag}</a> 21 <br /><br /> 22 <img src='{$smarty.const.THEME}images/bullet.gif' alt='' /> 23 {if $output.access} 24 <a href='{$smarty.const.MODULES}wiki/index.php?wakka={$output.tag}'>{$output.tag}</a> 25 {else} 26 {$output.tag} 27 {/if} 28 <blockquote>{$output.snippet}</blockquote> 29 <span class='small'> 30 <font class='smallalt'>{$locale.425}</font> {$output.time|date_format:"longdate"} - 31 <font class='smallalt'>{$locale.426}</font> 32 {if iMEMBER && $output.user_id} 33 <a href='profile.php?lookup={$output.user_id}'>{$output.owner}</a> 25 34 {else} 26 {$ reportvars.output[idx].tag}35 {$output.owner} 27 36 {/if} 28 <blockquote>{$reportvars.output[idx].snippet}</blockquote> 29 <span class='small'> 30 <font class='smallalt'>{$locale.425}</font> {$reportvars.output[idx].time|date_format:"longdate"} - 31 <font class='smallalt'>{$locale.426}</font> 32 {if iMEMBER && $reportvars.output[idx].user_id} 33 <a href='profile.php?lookup={$reportvars.output[idx].user_id}'>{$reportvars.output[idx].owner}</a> 34 {else} 35 {$reportvars.output[idx].owner} 36 {/if} 37 </span> 38 <br /><br /> 39 {/section} 37 </span> 40 38 {else} 41 39 <input type='radio' name='search_id' value='{$searches[id].search_id}' {if $search_id == $searches[id].search_id || $searches[id].search_order == $default_location}checked='checked'{/if} onclick='javascript:show_filter("{$searches[id].search_filters}");'/> {$searches[id].search_title} {if $searches[id].search_fulltext}<span style='color:red;'>*</span>{/if}<br />
Note: See TracChangeset
for help on using the changeset viewer.
