source: trunk/www.guidonia.net/wp/wp-content/plugins/odlinks/odl_search.php@ 44

Last change on this file since 44 was 44, checked in by luciano, 15 years ago
File size: 3.1 KB
RevLine 
[44]1<?php
2
3/*
4 * odl_search.php
5 * wordpress plugin website directory project
6 * @author Mohammad Forgani
7 * @copyright Copyright 2008, Oh Jung-Su
8 * @version 0.2
9 * @link http://www.forgani.com
10 */
11
12
13function odlinksdisplay_search(){
14 global $_GET, $_POST, $table_prefix, $wpdb, $PHP_SELF;
15
16 $odlinkssettings = get_option('odlinksdata');
17
18 $tpl = new ODLTemplate();
19
20 $tpl->assign('odl_images', get_bloginfo('wpurl') . "/wp-content/plugins/odlinks");
21 $odl_main_link = odlinkscreate_link("index", array("name"=>"Main"));
22 $odl_top_link = odlinkscreate_link("index", array("name"=>$odlinkssettings['page_link_title']));
23 $results_limit = 10;
24 $tpl->assign('results_limit', $results_limit);
25 $tpl->assign('odl_top_link', $odl_top_link);
26 $tpl->assign('odl_main_link', $odl_main_link);
27 $tpl->assign('odl_wpurl', get_bloginfo('url'));
28
29 $type = $_GET['type'];
30 $search_terms = $_GET['search_terms'];
31 $tpl->assign('search_terms',$search_terms);
32
33 if(isset($search_terms)){
34 $search_terms = stripslashes($_GET['search_terms']);
35 $searchwords = addslashes(htmlspecialchars($search_terms));
36 }
37
38 if(!$searchwords){
39 $tpl->assign('odl_search_error', "You didn't search for anything!");
40 } else {
41 if($type == "links"){
42 $sql ='SELECT * FROM ' . $table_prefix . 'odlinks WHERE MATCH (l_url) AGAINST("'.$searchwords.'" IN BOOLEAN MODE)';
43 $results = $wpdb->get_results($sql);
44 if(!$results){
45 $tpl->assign('odl_search_error', "No posts matched your search terms.");
46 } else {
47 for ($i=0; $i<count($result); $i++){
48 $row = $result[$i];
49 $row->fields = round($row->field,3);
50 $row->title = highlight($row->title,$search_terms);
51 $row->description = highlight($row->description,$search_terms);
52 $results[] = $row;
53 }
54 $tpl->assign('search_terms',$search_terms);
55 }
56 } elseif($type == "desc"){
57 $sql ='SELECT * FROM ' . $table_prefix. 'odlinks WHERE MATCH (l_title,l_description) AGAINST("'.$searchwords.'" IN BOOLEAN MODE)';
58 $results = $wpdb->get_results($sql);
59 if(!$results){
60 $tpl->assign('odl_search_error', "No posts matched your search terms.");
61 } else {
62 for ($i=0; $i<count($result); $i++){
63 $row = $result[$i];
64 $row->title = highlight($row->title,$search_terms);
65 $row->description = highlight($row->description,$search_terms);
66 $results[] = $row;
67 }
68 $tpl->assign('search_terms',$search_terms);
69 }
70 } else {
71 $sql = 'SELECT * FROM '.$table_prefix.'odpages WHERE MATCH (l_url,l_title,l_description) AGAINST("'.$searchwords.'")';
72 $results = $wpdb->get_results($sql);
73 for ($i=0; $i<count($result); $i++){
74 $row->fields = round($row->field,3);
75 $row->title = highlight($row->title,$search_terms);
76 $row->description = highlight($row->description,$search_terms);
77 $results[] = $row;
78 }
79 $tpl->assign('search_terms',$search_terms);
80 }
81
82 }
83 $tpl->assign('results', $results);
84 $odl_search_link=odlinkscreate_link("searchform", array());
85 $tpl->assign('odl_search_link', $odl_search_link);
86 //$odl_advanced = odlinkscreate_link("searchlink", array("name"=>'Advanced'));
87 //$tpl->assign('odl_advanced', $odl_advanced);
88 $tpl->display('search.tpl');
89
90}
91?>
Note: See TracBrowser for help on using the repository browser.