]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - lib/searchaction.php
Add hidden form value when the site is not in fancy mode so the action is not lost
[quix0rs-gnu-social.git] / lib / searchaction.php
1 <?php
2 /*
3  * Laconica - a distributed open-source microblogging tool
4  * Copyright (C) 2008, Controlez-Vous, Inc.
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Affero General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU Affero General Public License for more details.
15  *
16  * You should have received a copy of the GNU Affero General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19
20 if (!defined('LACONICA')) { exit(1); }
21
22 class SearchAction extends Action {
23
24         function handle($args) {
25                 parent::handle($args);
26                 $this->show_form();
27         }
28
29         function show_top($arr=NULL) {
30                 if ($arr) {
31                         $error = $arr[1];
32                 }
33                 if ($error) {
34                         common_element('p', 'error', $error);
35                 } else {
36                         $instr = $this->get_instructions();
37                         $output = common_markup_to_html($instr);
38                         common_element_start('div', 'instructions');
39                         common_raw($output);
40                         common_element_end('div');
41                 }
42                 $this->search_menu();
43         }
44
45         function get_title() {
46                 return NULL;
47         }
48
49         function show_header($arr) {
50                 return;
51         }
52
53         function show_form($error=NULL) {
54                 global $config;
55
56                 $q = $this->trimmed('q');
57                 $page = $this->trimmed('page', 1);
58
59                 common_show_header($this->get_title(), array($this, 'show_header'), array($q, $error),
60                                                    array($this, 'show_top'));
61                 common_element_start('form', array('method' => 'get',
62                                                                                    'id' => 'login',
63                                                                                    'action' => common_local_url($this->trimmed('action'))));
64                 common_element_start('p');
65                 if (!isset($config['site']['fancy']) || !$config['site']['fancy']) {
66                         common_element('input', array('name' => 'action',
67                                                                                   'type' => 'hidden',
68                                                                                   'value' => $this->trimmed('action')));
69                 }
70                 common_element('input', array('name' => 'q',
71                                                                           'id' => 'q',
72                                                                           'type' => 'text',
73                                                                           'class' => 'input_text',
74                                                                           'value' => ($q) ? $q : ''));
75                 common_text(' ');
76                 common_element('input', array('type' => 'submit',
77                                                                           'id' => 'search',
78                                                                           'name' => 'search',
79                                                                           'class' => 'submit',
80                                                                           'value' => _('Search')));
81
82                 common_element_end('p');
83                 common_element_end('form');
84                 if ($q) {
85                         $this->show_results($q, $page);
86                 }
87                 common_show_footer();
88         }
89
90         function search_menu() {
91         # action => array('prompt', 'title')
92         static $menu =
93         array('peoplesearch' =>
94               array('People',
95                         'Find people on this site'),
96                           'noticesearch' =>
97                           array('Text',
98                                         'Find content of notices'));
99                 $this->nav_menu($menu);
100         }
101 }