plugins/SpecialSearch.php
changeset 114 47393c6619ea
parent 100 e9a685fb456f
child 115 261f367623af
equal deleted inserted replaced
113:6f357b951f7a 114:47393c6619ea
    82       }
    82       }
    83       $q .= implode(' ', $req);
    83       $q .= implode(' ', $req);
    84     }
    84     }
    85   }
    85   }
    86   $q = trim($q);
    86   $q = trim($q);
       
    87   
       
    88   if ( !empty($q) && !isset($_GET['search']) )
       
    89   {
       
    90     list($pid, $ns) = RenderMan::strToPageID($q);
       
    91     $pid = sanitize_page_id($pid);
       
    92     $key = $paths->nslist[$ns] . $pid;
       
    93     if ( isPage($key) )
       
    94     {
       
    95       redirect(makeUrl($key), 'Results', 'found page', 0);
       
    96     }
       
    97   }
       
    98   
    87   $template->header();
    99   $template->header();
    88   if(!empty($q))
   100   if(!empty($q))
    89   {
   101   {
    90     // See if any pages directly match the title
   102     // See if any pages directly match the title
    91           
   103           
    94       $pg =& $paths->pages[$i];
   106       $pg =& $paths->pages[$i];
    95       $q_lc = strtolower( str_replace(' ', '_', $q) );
   107       $q_lc = strtolower( str_replace(' ', '_', $q) );
    96       $q_tl = strtolower( str_replace('_', ' ', $q) );
   108       $q_tl = strtolower( str_replace('_', ' ', $q) );
    97       $p_lc = strtolower($pg['urlname']);
   109       $p_lc = strtolower($pg['urlname']);
    98       $p_tl = strtolower($pg['name']);
   110       $p_tl = strtolower($pg['name']);
    99       if ( strstr($p_tl, $q_tl) || strstr($p_lc, $q_lc) )
   111       if ( strstr($p_tl, $q_tl) || strstr($p_lc, $q_lc) && $pg['visible'] == 1 )
   100       {
   112       {
   101         echo '<div class="usermessage">Perhaps you were looking for <b><a href="' . makeUrl($pg['urlname'], false, true) . '">' . htmlspecialchars($pg['name']) . '</a></b>?</div>';
   113         echo '<div class="usermessage">Perhaps you were looking for <b><a href="' . makeUrl($pg['urlname'], false, true) . '">' . htmlspecialchars($pg['name']) . '</a></b>?</div>';
   102         break;
   114         break;
   103       }
   115       }
   104     }
   116     }
   227       eval($cmd);
   239       eval($cmd);
   228     }
   240     }
   229     ?>
   241     ?>
   230     <form action="<?php echo makeUrl($paths->page); ?>" method="get">
   242     <form action="<?php echo makeUrl($paths->page); ?>" method="get">
   231       <p>
   243       <p>
   232         <input type="text" name="q" size="40" value="<?php echo htmlspecialchars( $q ); ?>" />  <input type="submit" value="Search" />  <small><a href="<?php echo makeUrlNS('Special', 'Search'); ?>">Advanced Search</a></small>
   244         <?php if ( $session->sid_super ): ?>
       
   245           <input type="hidden" name="auth" value="<?php echo $session->sid_super; ?>" />
       
   246         <?php endif; ?>
       
   247         <input type="text" name="q" size="40" value="<?php echo htmlspecialchars( $q ); ?>" /> <input type="submit" value="Go" style="font-weight: bold;" /> <input name="search" type="submit" value="Search" />  <small><a href="<?php echo makeUrlNS('Special', 'Search'); ?>">Advanced Search</a></small>
   233       </p>
   248       </p>
   234     </form>
   249     </form>
   235     <?php
   250     <?php
   236   }
   251   }
   237   else
   252   else