3 * Base search action class.
9 * @author Evan Prodromou <evan@status.net>
10 * @author Robin Millette <millette@status.net>
11 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
12 * @link http://status.net/
14 * StatusNet - the distributed open-source microblogging tool
15 * Copyright (C) 2008, 2009, StatusNet, Inc.
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.
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.
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/>.
31 if (!defined('STATUSNET') && !defined('LACONICA')) {
35 require_once INSTALLDIR.'/lib/searchgroupnav.php';
38 * Base search action class.
42 * @author Evan Prodromou <evan@status.net>
43 * @author Robin Millette <millette@status.net>
44 * @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
45 * @link http://status.net/
47 class SearchAction extends Action
50 * Return true if read only.
52 * @return boolean true
54 function isReadOnly($args)
59 function handle($args)
61 parent::handle($args);
66 * Show tabset for this page
68 * Uses the SearchGroupNav widget
74 function showLocalNav()
76 $nav = new SearchGroupNav($this, $this->trimmed('q'));
80 function showTop($arr=null)
87 $this->element('p', 'error', $error);
89 $instr = $this->getInstructions();
90 $output = common_markup_to_html($instr);
91 $this->elementStart('div', 'instructions');
93 $this->elementEnd('div');
102 function showNoticeForm() {
103 // remote post notice form
106 function showContent() {
111 function showForm($error=null)
113 $q = $this->trimmed('q');
114 $page = $this->trimmed('page', 1);
115 $this->elementStart('form', array('method' => 'get',
116 'id' => 'form_search',
117 'class' => 'form_settings',
118 'action' => common_local_url($this->trimmed('action'))));
119 $this->elementStart('fieldset');
120 $this->element('legend', null, _('Search site'));
121 $this->elementStart('ul', 'form_data');
122 $this->elementStart('li');
123 if (!common_config('site', 'fancy')) {
124 $this->hidden('action', $this->trimmed('action'));
126 $this->input('q', _('Keyword(s)'), $q);
127 $this->submit('search', _('Search'));
128 $this->elementEnd('li');
129 $this->elementEnd('ul');
130 $this->elementEnd('fieldset');
131 $this->elementEnd('form');
133 $this->showResults($q, $page);
137 function searchSuggestions($q) {
138 $message = _(<<<E_O_T
139 * Make sure all words are spelled correctly.
140 * Try different keywords.
141 * Try more general keywords.
142 * Try fewer keywords.
146 if (!common_config('site', 'private')) {
148 $message .= sprintf(_(<<<E_O_T
150 You can also try your search on other engines:
152 * [Twingly](http://www.twingly.com/search?q=%s&content=microblog&site=%%%%site.server%%%%)
153 * [Tweet scan](http://www.tweetscan.com/indexi.php?s=%s)
154 * [Google](http://www.google.com/search?q=site%%3A%%%%site.server%%%%+%s)
155 * [Yahoo](http://search.yahoo.com/search?p=site%%3A%%%%site.server%%%%+%s)
156 * [Collecta](http://collecta.com/#q=%s)
159 ), $qe, $qe, $qe, $qe, $qe);
161 $this->elementStart('dl', array('id' => 'help_search', 'class' => 'help'));
162 $this->element('dt', null, _('Search help'));
163 $this->elementStart('dd', 'instructions');
164 $this->raw(common_markup_to_html($message));
165 $this->elementEnd('dd');
166 $this->elementEnd('div');