root/devel/search/index.php

Revision 895, 4.2 kB (checked in by ben, 2 years ago)

Search queries now show up in the title of search pages.

  • Property svn:eol-style set to native
Line 
1 <?php
2
3     //    ELGG profile search page
4
5         global $PAGE, $db, $search_exclusions;
6     
7     // Run includes
8         require_once(dirname(dirname(__FILE__))."/includes.php");
9         
10         run("search:init");
11         run("search:all:tagtypes");
12
13         define("context","search");
14                 
15         $tag = optional_param('tag');
16         $title = __gettext("Searching") . " : " . $tag;
17         templates_page_setup();
18         
19         $PAGE->search_type_unformatted = optional_param('user_type','');
20         $PAGE->search_type = $db->qstr($PAGE->search_type_unformatted);
21         
22         $PAGE->returned_items = optional_param('returned_items','');
23         
24         $querystring = "";
25         if (isset($_GET) && !empty($_GET)) {
26             foreach($_GET as $key => $value) {
27                 if ($key != 'user_type') {
28                     if (!empty($querystring)) {
29                         $querystring .= "&";
30                     }
31                     $querystring .= urlencode($key);
32                     $querystring .= "=";
33                     $querystring .= urlencode(optional_param($key,''));
34                 }
35             }
36         }
37         $querystring = $CFG->wwwroot . "search/index.php?" . $querystring;
38         
39         $body = "<p>" . __gettext("Search for results from:") . " ";
40         
41         if ($PAGE->search_type  == "''") {
42             $body .= "<b class=\"selected_search_type\">";
43         }
44         $body .= "<a href=\"$querystring\">" . __gettext("All") . "</a> ";
45         if ($PAGE->search_type  == "''") {
46             $body .= "</b>";
47         }
48               
49         if (isset($PAGE->search_menu) && is_array($PAGE->search_menu) && !empty($PAGE->search_menu)) {
50             foreach($PAGE->search_menu as $search_type) {
51                 if ($PAGE->search_type_unformatted == $search_type['user_type']) {
52                     $body .= "<b class=\"selected_search_type\">";
53                 }
54                 $body .= "<a href=\"$querystring&user_type=" . $search_type['user_type'] . "\">" . $search_type['name'] . "</a> ";
55                 if ($PAGE->search_type_unformatted == $search_type['user_type']) {
56                     $body .= "</b>";
57                 }
58             }
59         }
60         $body .= "</p>";
61         
62         
63         
64         $querystring = "";
65         if (isset($_GET) && !empty($_GET)) {
66             foreach($_GET as $key => $value) {
67                 if ($key != 'returned_items') {
68                     if (!empty($querystring)) {
69                         $querystring .= "&";
70                     }
71                     $querystring .= urlencode($key);
72                     $querystring .= "=";
73                     $querystring .= urlencode(optional_param($key,''));
74                 }
75             }
76         }
77         $querystring = $CFG->wwwroot . "search/index.php?" . $querystring;
78         
79         $body .= "<p>" . __gettext("Filter by content type:") . " ";
80         if (empty($PAGE->returned_items)) {
81             $body .= "<b class=\"search_displaying_type\">";
82         }
83         $body .= "<a href=\"$querystring\">" . __gettext("Everything") . "</a> ";
84         if (empty($PAGE->returned_items)) {
85             $body .= "</b>";
86         }
87         if ($PAGE->returned_items == 'accounts') {
88             $body .= "<b class=\"search_displaying_type\">";
89         }
90         $body .= "<a href=\"$querystring&returned_items=accounts\">" . __gettext("Users and communities") . "</a> ";
91         if ($PAGE->returned_items == 'accounts') {
92             $body .= "</b>";
93         }
94         if ($PAGE->returned_items == 'resources') {
95             $body .= "<b class=\"search_displaying_type\">";
96         }
97         $body .= "<a href=\"$querystring&returned_items=resources\">" . __gettext("Resources") . "</a> ";
98         if ($PAGE->returned_items == 'resources') {
99             $body .= "</b>";
100         }
101         
102         
103         $body .= run("search:display");
104         
105         $body = templates_draw(array(
106                         'context' => 'contentholder',
107                         'title' => $title,
108                         'body' => $body
109                     )
110                     );
111                     
112         echo templates_page_draw( array(
113                     $title, $body
114                 )
115                 );
116
117 ?>
Note: See TracBrowser for help on using the browser.