Changeset 2097 in ExiteCMS


Ignore:
Timestamp:
12/07/08 01:25:48 (3 years ago)
Author:
WanWizard
Message:

updated the module search plugin to work with the new 'search entire site' option

Location:
modules/common
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • modules/common/download_statistics/php-files/modules/download_statistics/search.files.php

    r2091 r2097  
    1818+---------------------------------------------------------------------*/ 
    1919if (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 template 
    22 $reportvars = array(); 
    2320 
    2421// make sure we have an action variable 
     
    117114        } 
    118115 
    119         // check if we have a rowstart value 
    120         if (!isset($rowstart)) $rowstart = 0; 
    121  
    122116        // check how many rows this would output 
    123117        $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); 
    129119 
    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) { 
    137122 
    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                    } 
    143149                } 
    144150 
    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            } 
    150152 
    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 
    156156        } 
     157 
    157158    } 
    158159} 
  • modules/common/download_statistics/php-files/modules/download_statistics/templates/modules.download_statistics.search.files.tpl

    r2043 r2097  
    1919{***************************************************************************} 
    2020{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} 
    2925{else} 
    3026    <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  
    3434$headerparms = '    <link rel="stylesheet" type="text/css" href="'.$wakka->GetConfigValue("stylesheet").'" />'; 
    3535 
    36 // array to store variables we want to use in the search template 
    37 $reportvars = array(); 
    38  
    3936// set the page title 
    40 $title = $locale['424']; 
     37if ($search_id != 99999) $title = $locale['424']; 
    4138 
    4239// make sure we have an action variable 
     
    148145        } 
    149146 
    150         // check if we have a rowstart value 
    151         if (!isset($rowstart)) $rowstart = 0; 
    152  
    153147        // check how many rows this would output 
    154148        $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('&lt;br /&gt;', '&hellip;<br />&hellip;', $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'] = "&hellip;".str_replace(array('<<', '>>'), array('<span class="tse_keywords">', '</span>'), $highlightMatch)."&hellip;"; 
     181                        } else { 
     182                            $rptdata['access'] = false; 
     183                            $rptdata['snippet'] = $locale['427']; 
    181184                        } 
    182                         $text = $wakka->htmlspecialchars_ent(implode('<br />', $matchString[0])); 
    183                         $text = str_replace('&lt;br /&gt;', '&hellip;<br />&hellip;', $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'] = "&hellip;".str_replace(array('<<', '>>'), array('<span class="tse_keywords">', '</span>'), $highlightMatch)."&hellip;"; 
    189                     } else { 
    190                         $rptdata['access'] = false; 
    191                         $rptdata['snippet'] = $locale['427']; 
     185                        $rptdata['_template'] = $data['template']; 
     186                        $reportvars['output'][] = $rptdata; 
    192187                    } 
    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                    } 
    194199                } 
    195200 
    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 
    208208    } 
    209209} 
  • modules/common/wiki/php-files/modules/wiki/templates/modules.wiki.search.wiki.tpl

    r2091 r2097  
    1919{***************************************************************************} 
    2020{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    &nbsp;<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> 
    2534        {else} 
    26             {$reportvars.output[idx].tag} 
     35            {$output.owner} 
    2736        {/if} 
    28         <blockquote>{$reportvars.output[idx].snippet}</blockquote> 
    29         &nbsp;<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> 
    4038{else} 
    4139    <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.