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