]> git.mxchange.org Git - quix0rs-gnu-social.git/blob - lib/searchaction.php
Merge branch 'master' of ../trunk
[quix0rs-gnu-social.git] / lib / searchaction.php
1 <?php
2 /**
3  * Base search action class.
4  *
5  * PHP version 5
6  *
7  * @category Action
8  * @package  Laconica
9  * @author   Evan Prodromou <evan@controlyourself.ca>
10  * @author   Robin Millette <millette@controlyourself.ca>
11  * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
12  * @link     http://laconi.ca/
13  *
14  * Laconica - a distributed open-source microblogging tool
15  * Copyright (C) 2008, Controlez-Vous, Inc.
16  *
17  * This program is free software: you can redistribute it and/or modify
18  * it under the terms of the GNU Affero General Public License as published by
19  * the Free Software Foundation, either version 3 of the License, or
20  * (at your option) any later version.
21  *
22  * This program is distributed in the hope that it will be useful,
23  * but WITHOUT ANY WARRANTY; without even the implied warranty of
24  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
25  * GNU Affero General Public License for more details.
26  *
27  * You should have received a copy of the GNU Affero General Public License
28  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
29  */
30
31 if (!defined('LACONICA')) {
32     exit(1);
33 }
34
35 require_once INSTALLDIR.'/lib/searchgroupnav.php';
36
37 /**
38  * Base search action class.
39  *
40  * @category Action
41  * @package  Laconica
42  * @author   Evan Prodromou <evan@controlyourself.ca>
43  * @author   Robin Millette <millette@controlyourself.ca>
44  * @license  http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
45  * @link     http://laconi.ca/
46  */
47 class SearchAction extends Action
48 {
49     /**
50      * Return true if read only.
51      *
52      * @return boolean true
53      */
54     function isReadOnly()
55     {
56         return true;
57     }
58
59     function handle($args)
60     {
61         parent::handle($args);
62         $this->showPage();
63     }
64
65     /**
66      * Show tabset for this page
67      *
68      * Uses the SearchGroupNav widget
69      *
70      * @return void
71      * @see SearchGroupNav
72      */
73
74     function showLocalNav()
75     {
76         $nav = new SearchGroupNav($this);
77         $nav->show();
78     }
79
80     function showTop($arr=null)
81     {
82         if ($arr) {
83             $error = $arr[1];
84         }
85         if ($error) {
86             $this->element('p', 'error', $error);
87         } else {
88             $instr = $this->getInstructions();
89             $output = common_markup_to_html($instr);
90             $this->elementStart('div', 'instructions');
91             $this->raw($output);
92             $this->elementEnd('div');
93         }
94     }
95
96     function title()
97     {
98         return null;
99     }
100
101     function show_header($arr)
102     {
103         return;
104     }
105
106     function showNoticeForm() {
107         // remote post notice form
108     }
109
110     function showContent() {
111         $this->showTop();
112         $this->showForm();
113     }
114
115     function showForm($error=null)
116     {
117         global $config;
118
119         $q = $this->trimmed('q');
120         $page = $this->trimmed('page', 1);
121         $this->elementStart('form', array('method' => 'get',
122                                            'id' => 'login',
123                                            'action' => common_local_url($this->trimmed('action'))));
124         $this->elementStart('p');
125         if (!isset($config['site']['fancy']) || !$config['site']['fancy']) {
126             $this->hidden('action', $this->trimmed('action'));
127         }
128         $this->input('q', '', $q);
129         $this->text(' ');
130         $this->submit('search', 'Search');
131
132         $this->elementEnd('p');
133         $this->elementEnd('form');
134         if ($q) {
135             $this->showResults($q, $page);
136         }
137     }
138 }
139