3 * Laconica - a distributed open-source microblogging tool
4 * Copyright (C) 2008, Controlez-Vous, Inc.
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.
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.
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/>.
20 if (!defined('LACONICA')) { exit(1); }
22 class SearchAction extends Action
25 function is_readonly()
30 function handle($args)
32 parent::handle($args);
36 function show_top($arr=null)
42 common_element('p', 'error', $error);
44 $instr = $this->get_instructions();
45 $output = common_markup_to_html($instr);
46 common_element_start('div', 'instructions');
48 common_element_end('div');
58 function show_header($arr)
63 function show_form($error=null)
67 $q = $this->trimmed('q');
68 $page = $this->trimmed('page', 1);
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',
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',
79 'value' => $this->trimmed('action')));
81 common_element('input', array('name' => 'q',
84 'class' => 'input_text',
85 'value' => ($q) ? $q : ''));
87 common_element('input', array('type' => 'submit',
91 'value' => _('Search')));
93 common_element_end('p');
94 common_element_end('form');
96 $this->show_results($q, $page);
101 function search_menu()
103 # action => array('prompt', 'title', $args)
104 $action = $this->trimmed('action');
106 array('peoplesearch' =>
109 _('Find people on this site'),
110 ($action != 'peoplesearch' && $this->trimmed('q')) ? array('q' => $this->trimmed('q')) : null),
113 _('Find content of notices'),
114 ($action != 'noticesearch' && $this->trimmed('q')) ? array('q' => $this->trimmed('q')) : null)
116 $this->nav_menu($menu);