]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - _darcs/pristine/lib/searchaction.php
f99883b251ec7ca2eed5044f555155c5f1ed5166
[quix0rs-gnu-social.git] / _darcs / pristine / 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 is_readonly() {
25                 return true;
26         }
27
28         function handle($args) {
29                 parent::handle($args);
30                 $this->show_form();
31         }
32
33         function show_top($arr=NULL) {
34                 if ($arr) {
35                         $error = $arr[1];
36                 }
37                 if ($error) {
38                         common_element('p', 'error', $error);
39                 } else {
40                         $instr = $this->get_instructions();
41                         $output = common_markup_to_html($instr);
42                         common_element_start('div', 'instructions');
43                         common_raw($output);
44                         common_element_end('div');
45                 }
46                 $this->search_menu();
47         }
48
49         function get_title() {
50                 return NULL;
51         }
52
53         function show_header($arr) {
54                 return;
55         }
56
57         function show_form($error=NULL) {
58                 global $config;
59
60                 $q = $this->trimmed('q');
61                 $page = $this->trimmed('page', 1);
62
63                 common_show_header($this->get_title(), array($this, 'show_header'), array($q, $error),
64                                                    array($this, 'show_top'));
65                 common_element_start('form', array('method' => 'get',
66                                                                                    'id' => 'login',
67                                                                                    'action' => common_local_url($this->trimmed('action'))));
68                 common_element_start('p');
69                 if (!isset($config['site']['fancy']) || !$config['site']['fancy']) {
70                         common_element('input', array('name' => 'action',
71                                                                                   'type' => 'hidden',
72                                                                                   'value' => $this->trimmed('action')));
73                 }
74                 common_element('input', array('name' => 'q',
75                                                                           'id' => 'q',
76                                                                           'type' => 'text',
77                                                                           'class' => 'input_text',
78                                                                           'value' => ($q) ? $q : ''));
79                 common_text(' ');
80                 common_element('input', array('type' => 'submit',
81                                                                           'id' => 'search',
82                                                                           'name' => 'search',
83                                                                           'class' => 'submit',
84                                                                           'value' => _('Search')));
85
86                 common_element_end('p');
87                 common_element_end('form');
88                 if ($q) {
89                         $this->show_results($q, $page);
90                 }
91                 common_show_footer();
92         }
93
94         function search_menu() {
95                 # action => array('prompt', 'title', $args)
96                 $action = $this->trimmed('action');
97                 $menu =
98                   array('peoplesearch' =>
99                                 array(
100                                           _('People'),
101                                           _('Find people on this site'),
102                                           ($action != 'peoplesearch' && $this->trimmed('q')) ? array('q' => $this->trimmed('q')) : NULL),
103                                 'noticesearch' =>
104                                 array( _('Text'),
105                                            _('Find content of notices'),
106                                            ($action != 'noticesearch' && $this->trimmed('q')) ? array('q' => $this->trimmed('q')) : NULL)
107                                 );
108                 $this->nav_menu($menu);
109         }
110 }