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