plugins/SpecialSearch.php
changeset 304 e2cb5f1432c8
parent 292 b3cfaf0a505c
child 317 f8356d9c3481
equal deleted inserted replaced
280:dc08c70ca550 304:e2cb5f1432c8
    40 function page_Special_SearchRebuild()
    40 function page_Special_SearchRebuild()
    41 {
    41 {
    42   global $db, $session, $paths, $template, $plugins; // Common objects
    42   global $db, $session, $paths, $template, $plugins; // Common objects
    43   if(!$session->get_permissions('mod_misc')) die_friendly('Unauthorized', '<p>You need to be an administrator to rebuild the search index</p>');
    43   if(!$session->get_permissions('mod_misc')) die_friendly('Unauthorized', '<p>You need to be an administrator to rebuild the search index</p>');
    44   $template->header();
    44   $template->header();
    45   if($paths->rebuild_search_index())
    45   @set_time_limit(0);
       
    46   if($paths->rebuild_search_index(true))
    46     echo '<p>Index rebuilt!</p>';
    47     echo '<p>Index rebuilt!</p>';
    47   else
    48   else
    48     echo '<p>Index was not rebuilt due to an error.';
    49     echo '<p>Index was not rebuilt due to an error.';
    49   $template->footer();
    50   $template->footer();
    50 }
    51 }
    92   
    93   
    93   $template->header();
    94   $template->header();
    94   
    95   
    95   $qin = ( isset($q) ) ? str_replace('"', '\"', htmlspecialchars($q)) : '';
    96   $qin = ( isset($q) ) ? str_replace('"', '\"', htmlspecialchars($q)) : '';
    96   $search_form = '<form action="' . makeUrlNS('Special', 'Search') . '">
    97   $search_form = '<form action="' . makeUrlNS('Special', 'Search') . '">
    97   <input type="text" tabindex="1" name="q" size="50" value="' . $qin . '" />&nbsp;<input tabindex="2" type="submit" value="Search" />
    98   <input type="text" tabindex="1" name="q" size="50" value="' . $qin . '" />&nbsp;<input tabindex="2" type="submit" value="Search" />&nbsp;<a href="' . makeUrlNS('Special', 'Search') . '">Advanced search</a>
    98   ' . ( $session->auth_level > USER_LEVEL_MEMBER ? '<input type="hidden" name="auth" value="' . $session->sid_super . '" />' : '' ) . '
    99   ' . ( $session->auth_level > USER_LEVEL_MEMBER ? '<input type="hidden" name="auth" value="' . $session->sid_super . '" />' : '' ) . '
    99   </form>';
   100   </form>';
   100   
   101   
   101   if ( !empty($q) )
   102   if ( !empty($q) )
   102   {
   103   {
   131       $parser = $template->makeParserText($tpl_code);
   132       $parser = $template->makeParserText($tpl_code);
   132     }
   133     }
   133     foreach ( $results as $i => $_ )
   134     foreach ( $results as $i => $_ )
   134     {
   135     {
   135       $result =& $results[$i];
   136       $result =& $results[$i];
   136       $result['page_text'] = str_replace(array('<highlight>', '</highlight>'), array('<span class="highlight">', '</span>'), $result['page_text']);
   137       $result['page_text'] = str_replace(array('<highlight>', '</highlight>'), array('<span class="search-term">', '</span>'), $result['page_text']);
   137       if ( !empty($result['page_text']) )
   138       if ( !empty($result['page_text']) )
   138         $result['page_text'] .= '<br />';
   139         $result['page_text'] .= '<br />';
   139       $result['page_name'] = str_replace(array('<highlight>', '</highlight>'), array('<span class="highlight">', '</span>'), $result['page_name']);
   140       $result['page_name'] = str_replace(array('<highlight>', '</highlight>'), array('<span class="title-search-term">', '</span>'), $result['page_name']);
   140       if ( $result['page_length'] >= 1048576 )
   141       if ( $result['page_length'] >= 1048576 )
   141       {
   142       {
   142         $result['page_length'] = round($result['page_length'] / 1048576, 1);
   143         $result['page_length'] = round($result['page_length'] / 1048576, 1);
   143         $length_unit = 'MB';
   144         $length_unit = 'MB';
   144       }
   145       }