equal
deleted
inserted
replaced
1 <?php |
1 <?php |
2 /* |
2 /* |
3 Plugin Name: Search UI/frontend |
3 Plugin Name: Search UI/frontend |
4 Plugin URI: http://www.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 |
7 Version: 1.0 |
8 Author URI: http://www.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 release candidate 2 |
84 } |
84 } |
85 } |
85 } |
86 $template->header(); |
86 $template->header(); |
87 if(!empty($q)) |
87 if(!empty($q)) |
88 { |
88 { |
|
89 // See if any pages directly match the title |
|
90 |
|
91 for ( $i = 0; $i < count ( $paths->pages ) / 2; $i++ ) |
|
92 { |
|
93 $pg =& $paths->pages[$i]; |
|
94 $q_lc = strtolower( str_replace(' ', '_', $q) ); |
|
95 $q_tl = strtolower( str_replace('_', ' ', $q) ); |
|
96 $p_lc = strtolower($pg['urlname']); |
|
97 $p_tl = strtolower($pg['name']); |
|
98 if ( strstr($p_tl, $q_tl) || strstr($p_lc, $q_lc) ) |
|
99 { |
|
100 echo '<div class="usermessage">Perhaps you were looking for <b><a href="' . makeUrl($pg['urlname'], false, true) . '">' . htmlspecialchars($pg['name']) . '</a></b>?</div>'; |
|
101 break; |
|
102 } |
|
103 } |
|
104 |
89 switch(SEARCH_MODE) |
105 switch(SEARCH_MODE) |
90 { |
106 { |
91 |
107 |
92 case "FULLTEXT": |
108 case "FULLTEXT": |
93 if ( isset($_GET['offset']) ) |
109 if ( isset($_GET['offset']) ) |
497 $num_results = sizeof($results); |
513 $num_results = sizeof($results); |
498 $slice = array_slice($results, $offset, SEARCH_RESULTS_PER_PAGE); |
514 $slice = array_slice($results, $offset, SEARCH_RESULTS_PER_PAGE); |
499 |
515 |
500 if ( $num_results < 1 ) |
516 if ( $num_results < 1 ) |
501 { |
517 { |
502 echo '<div class="warning-box">No pages that matched your search criteria could be found.</div>'; |
518 echo '<div class="warning-box" style="margin-left: 0;">No page text that matched your search criteria could be found.</div>'; |
503 return null; |
519 return null; |
504 } |
520 } |
505 |
521 |
506 $html = paginate_array($results, sizeof($results), makeUrlNS('Special', 'Search', 'q=' . urlencode($query) . '&offset=%s'), $offset, 10); |
522 $html = paginate_array($results, sizeof($results), makeUrlNS('Special', 'Search', 'q=' . urlencode($query) . '&offset=%s'), $offset, 10); |
507 echo $html . '<br />'; |
523 echo $html . '<br />'; |