]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - lib/searchaction.php
bf598ea93d2f0a7fb6ae9fba94b69fb43e8ee5ac
[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($error=NULL) {
30                 if ($error) {
31                         common_element('p', 'error', $error);
32                 } else {
33                         $instr = $this->get_instructions();
34                         $output = common_markup_to_html($instr);
35                         common_element_start('div', 'instructions');
36                         common_raw($output);
37                         common_element_end('div');
38                 }
39                 $this->search_menu();
40         }
41
42         function get_title() {
43                 return NULL;
44         }
45         
46         function show_form($error=NULL) {
47                 $q = $this->trimmed('q');
48                 $page = $this->trimmed('page', 1);
49                 
50                 common_show_header($this->get_title(), NULL, $error, array($this, 'show_top'));
51                 common_element_start('form', array('method' => 'post',
52                                                                                    'id' => 'login',
53                                                                                    'action' => common_local_url($this->trimmed('action'))));
54                 common_element_start('p');
55                 common_element('input', array('name' => 'q',
56                                                                           'id' => 'q',
57                                                                           'type' => 'text',
58                                                                           'class' => 'input_text',
59                                                                           'value' => ($q) ? $q : ''));
60                 common_text(' ');
61                 common_element('input', array('type' => 'submit',
62                                                                           'id' => 'search',
63                                                                           'name' => 'search',
64                                                                           'class' => 'submit',
65                                                                           'value' => _t('Search')));
66                                            
67                 common_element_end('p');
68                 common_element_end('form');
69                 if ($q) {
70                         $this->show_results($q, $page);
71                 }
72                 common_show_footer();
73         }
74         
75         function search_menu() {
76         # action => array('prompt', 'title')
77         static $menu =
78         array('peoplesearch' =>
79               array('People',
80                         'Find people on this site'),
81                           'noticesearch' =>
82                           array('Text',
83                                         'Find content of notices'));
84                 $this->nav_menu($menu);
85         }
86 }