plugins/SpecialSearch.php
changeset 229 97ae8e9d5e29
parent 192 9237767a23ae
child 272 e0ec986c0af3
equal deleted inserted replaced
147:d8156d18ac58 229:97ae8e9d5e29
     2 /*
     2 /*
     3 Plugin Name: Search UI/frontend
     3 Plugin Name: Search UI/frontend
     4 Plugin URI: http://enanocms.org/
     4 Plugin URI: http://enanocms.org/
     5 Description: Provides the page Special:Search, which is a frontend to the Enano search engine.
     5 Description: Provides the page Special:Search, which is a frontend to the Enano search engine.
     6 Author: Dan Fuhry
     6 Author: Dan Fuhry
     7 Version: 1.0.1
     7 Version: 1.0.2
     8 Author URI: http://enanocms.org/
     8 Author URI: http://enanocms.org/
     9 */
     9 */
    10 
    10 
    11 /*
    11 /*
    12  * Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
    12  * Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
    13  * Version 1.0 release candidate 2
    13  * Version 1.0.2
    14  * Copyright (C) 2006-2007 Dan Fuhry
    14  * Copyright (C) 2006-2007 Dan Fuhry
    15  *
    15  *
    16  * This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
    16  * This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
    17  * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
    17  * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
    18  *
    18  *
    98   
    98   
    99   $template->header();
    99   $template->header();
   100   if(!empty($q))
   100   if(!empty($q))
   101   {
   101   {
   102     // See if any pages directly match the title
   102     // See if any pages directly match the title
   103           
   103     
   104     for ( $i = 0; $i < count ( $paths->pages ) / 2; $i++ )
   104     if ( strlen($q) >= 4 )
   105     {
   105     {
   106       $pg =& $paths->pages[$i];
   106       for ( $i = 0; $i < count ( $paths->pages ) / 2; $i++ )
   107       $q_lc = strtolower( str_replace(' ', '_', $q) );
       
   108       $q_tl = strtolower( str_replace('_', ' ', $q) );
       
   109       $p_lc = strtolower($pg['urlname']);
       
   110       $p_tl = strtolower($pg['name']);
       
   111       if ( strstr($p_tl, $q_tl) || strstr($p_lc, $q_lc) && $pg['visible'] == 1 )
       
   112       {
   107       {
   113         echo '<div class="usermessage">Perhaps you were looking for <b><a href="' . makeUrl($pg['urlname'], false, true) . '">' . htmlspecialchars($pg['name']) . '</a></b>?</div>';
   108         $pg =& $paths->pages[$i];
   114         break;
   109         $q_lc = strtolower( str_replace(' ', '_', $q) );
       
   110         $q_tl = strtolower( str_replace('_', ' ', $q) );
       
   111         $p_lc = strtolower($pg['urlname']);
       
   112         $p_tl = strtolower($pg['name']);
       
   113         if ( strstr($p_tl, $q_tl) || strstr($p_lc, $q_lc) && $pg['visible'] == 1 )
       
   114         {
       
   115           echo '<div class="usermessage">Perhaps you were looking for <b><a href="' . makeUrl($pg['urlname'], false, true) . '">' . htmlspecialchars($pg['name']) . '</a></b>?</div>';
       
   116           break;
       
   117         }
   115       }
   118       }
   116     }
   119     }
   117           
   120           
   118     switch(SEARCH_MODE)
   121     switch(SEARCH_MODE)
   119     {
   122     {