2008-07-10 00:10:31 +01:00
|
|
|
<?php
|
2009-01-23 01:00:57 +00:00
|
|
|
/**
|
|
|
|
* Base search action class.
|
|
|
|
*
|
|
|
|
* PHP version 5
|
|
|
|
*
|
|
|
|
* @category Action
|
2009-08-25 23:12:20 +01:00
|
|
|
* @package StatusNet
|
2009-08-25 23:19:04 +01:00
|
|
|
* @author Evan Prodromou <evan@status.net>
|
|
|
|
* @author Robin Millette <millette@status.net>
|
2009-01-23 01:00:57 +00:00
|
|
|
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
2009-08-25 23:16:46 +01:00
|
|
|
* @link http://status.net/
|
2009-01-23 01:00:57 +00:00
|
|
|
*
|
2009-08-25 23:14:12 +01:00
|
|
|
* StatusNet - the distributed open-source microblogging tool
|
2009-08-25 23:12:20 +01:00
|
|
|
* Copyright (C) 2008, 2009, StatusNet, Inc.
|
2008-07-10 00:10:31 +01:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2009-08-26 15:41:36 +01:00
|
|
|
if (!defined('STATUSNET') && !defined('LACONICA')) {
|
2009-01-23 01:00:57 +00:00
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
require_once INSTALLDIR.'/lib/searchgroupnav.php';
|
2008-07-10 00:10:31 +01:00
|
|
|
|
2009-01-23 01:00:57 +00:00
|
|
|
/**
|
|
|
|
* Base search action class.
|
|
|
|
*
|
|
|
|
* @category Action
|
2009-08-25 23:12:20 +01:00
|
|
|
* @package StatusNet
|
2009-08-25 23:19:04 +01:00
|
|
|
* @author Evan Prodromou <evan@status.net>
|
|
|
|
* @author Robin Millette <millette@status.net>
|
2009-01-23 01:00:57 +00:00
|
|
|
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
2009-08-25 23:16:46 +01:00
|
|
|
* @link http://status.net/
|
2009-01-23 01:00:57 +00:00
|
|
|
*/
|
2008-12-23 19:49:23 +00:00
|
|
|
class SearchAction extends Action
|
|
|
|
{
|
2009-01-23 01:00:57 +00:00
|
|
|
/**
|
|
|
|
* Return true if read only.
|
|
|
|
*
|
|
|
|
* @return boolean true
|
|
|
|
*/
|
2009-04-13 20:49:26 +01:00
|
|
|
function isReadOnly($args)
|
2008-12-23 19:33:23 +00:00
|
|
|
{
|
2008-12-23 19:19:07 +00:00
|
|
|
return true;
|
|
|
|
}
|
2008-07-22 22:20:56 +01:00
|
|
|
|
2008-12-23 19:33:23 +00:00
|
|
|
function handle($args)
|
|
|
|
{
|
2008-12-23 19:19:07 +00:00
|
|
|
parent::handle($args);
|
2009-01-23 01:00:57 +00:00
|
|
|
$this->showPage();
|
2008-12-23 19:19:07 +00:00
|
|
|
}
|
2008-07-10 00:10:31 +01:00
|
|
|
|
2009-01-23 01:00:57 +00:00
|
|
|
function showTop($arr=null)
|
2008-12-23 19:33:23 +00:00
|
|
|
{
|
2009-02-20 21:51:39 +00:00
|
|
|
$error = null;
|
2008-12-23 19:19:07 +00:00
|
|
|
if ($arr) {
|
|
|
|
$error = $arr[1];
|
|
|
|
}
|
2009-02-20 21:51:39 +00:00
|
|
|
if (!empty($error)) {
|
2009-01-23 01:00:57 +00:00
|
|
|
$this->element('p', 'error', $error);
|
2008-12-23 19:19:07 +00:00
|
|
|
} else {
|
2009-01-23 01:00:57 +00:00
|
|
|
$instr = $this->getInstructions();
|
2008-12-23 19:19:07 +00:00
|
|
|
$output = common_markup_to_html($instr);
|
2009-01-23 01:00:57 +00:00
|
|
|
$this->elementStart('div', 'instructions');
|
|
|
|
$this->raw($output);
|
|
|
|
$this->elementEnd('div');
|
2008-12-23 19:19:07 +00:00
|
|
|
}
|
|
|
|
}
|
2008-07-10 00:10:31 +01:00
|
|
|
|
2009-01-23 01:00:57 +00:00
|
|
|
function title()
|
2008-12-23 19:33:23 +00:00
|
|
|
{
|
2008-12-23 19:21:29 +00:00
|
|
|
return null;
|
2008-12-23 19:19:07 +00:00
|
|
|
}
|
2008-07-10 00:42:28 +01:00
|
|
|
|
2009-01-23 01:00:57 +00:00
|
|
|
function showContent() {
|
|
|
|
$this->showTop();
|
|
|
|
$this->showForm();
|
|
|
|
}
|
|
|
|
|
|
|
|
function showForm($error=null)
|
2008-12-23 19:33:23 +00:00
|
|
|
{
|
2008-12-23 19:19:07 +00:00
|
|
|
$q = $this->trimmed('q');
|
|
|
|
$page = $this->trimmed('page', 1);
|
2009-01-23 01:00:57 +00:00
|
|
|
$this->elementStart('form', array('method' => 'get',
|
2009-01-24 00:58:12 +00:00
|
|
|
'id' => 'form_search',
|
|
|
|
'class' => 'form_settings',
|
2008-12-23 19:19:07 +00:00
|
|
|
'action' => common_local_url($this->trimmed('action'))));
|
2009-01-24 00:58:12 +00:00
|
|
|
$this->elementStart('fieldset');
|
2010-09-12 16:44:28 +01:00
|
|
|
// TRANS: Fieldset legend for the search form.
|
2009-01-24 00:58:12 +00:00
|
|
|
$this->element('legend', null, _('Search site'));
|
|
|
|
$this->elementStart('ul', 'form_data');
|
|
|
|
$this->elementStart('li');
|
2009-03-10 01:01:35 +00:00
|
|
|
if (!common_config('site', 'fancy')) {
|
2009-01-23 01:00:57 +00:00
|
|
|
$this->hidden('action', $this->trimmed('action'));
|
2008-12-23 19:19:07 +00:00
|
|
|
}
|
2010-09-12 16:44:28 +01:00
|
|
|
// TRANS: Used as a field label for the field where one or more keywords
|
|
|
|
// TRANS: for searching can be entered.
|
2009-11-21 14:59:54 +00:00
|
|
|
$this->input('q', _('Keyword(s)'), $q);
|
2010-11-01 12:55:24 +00:00
|
|
|
// TRANS: Button text for searching site.
|
2014-05-18 19:18:18 +01:00
|
|
|
$this->element('input', array('type'=>'submit', 'class'=>'submit', 'value'=>_m('BUTTON','Search')));
|
2009-01-24 00:58:12 +00:00
|
|
|
$this->elementEnd('li');
|
|
|
|
$this->elementEnd('ul');
|
|
|
|
$this->elementEnd('fieldset');
|
2009-01-23 01:00:57 +00:00
|
|
|
$this->elementEnd('form');
|
2008-12-23 19:19:07 +00:00
|
|
|
if ($q) {
|
2009-01-23 01:00:57 +00:00
|
|
|
$this->showResults($q, $page);
|
2008-12-23 19:19:07 +00:00
|
|
|
}
|
|
|
|
}
|
2009-04-06 02:14:59 +01:00
|
|
|
|
|
|
|
function searchSuggestions($q) {
|
2011-04-03 23:37:39 +01:00
|
|
|
// Don't change these long strings to HEREDOC; xgettext won't pick them up.
|
|
|
|
// TRANS: Standard search suggestions shown when a search does not give any results.
|
|
|
|
$message = _("* Make sure all words are spelled correctly.
|
2009-04-06 02:14:59 +01:00
|
|
|
* Try different keywords.
|
|
|
|
* Try more general keywords.
|
2011-05-05 11:36:56 +01:00
|
|
|
* Try fewer keywords.");
|
|
|
|
$message .= "\n";
|
|
|
|
|
2009-10-08 05:49:30 +01:00
|
|
|
if (!common_config('site', 'private')) {
|
|
|
|
$qe = urlencode($q);
|
2011-05-05 11:36:56 +01:00
|
|
|
$message .= "\n";
|
2011-04-03 23:37:39 +01:00
|
|
|
// Don't change these long strings to HEREDOC; xgettext won't pick them up.
|
2010-09-12 16:44:28 +01:00
|
|
|
// TRANS: Standard search suggestions shown when a search does not give any results.
|
2011-05-05 11:36:56 +01:00
|
|
|
$message .= sprintf(_("You can also try your search on other engines:
|
2009-04-06 02:14:59 +01:00
|
|
|
|
2014-12-04 03:48:28 +00:00
|
|
|
* [DuckDuckGo](https://duckduckgo.com/?q=site%%3A%%%%site.server%%%%+%s)
|
2014-12-04 03:54:27 +00:00
|
|
|
* [Ixquick](https://ixquick.com/do/search?query=site%%3A%%%%site.server%%%%+%s)
|
2009-04-06 06:04:11 +01:00
|
|
|
* [Google](http://www.google.com/search?q=site%%3A%%%%site.server%%%%+%s)
|
2014-12-04 03:46:50 +00:00
|
|
|
* [Yahoo!](http://search.yahoo.com/search?p=site%%3A%%%%site.server%%%%+%s)
|
2014-12-04 03:54:27 +00:00
|
|
|
"), $qe, $qe, $qe, $qe);
|
2011-05-05 11:36:56 +01:00
|
|
|
$message .= "\n";
|
2009-10-08 05:49:30 +01:00
|
|
|
}
|
2011-01-14 20:36:06 +00:00
|
|
|
$this->elementStart('div', 'help instructions');
|
2009-04-06 02:14:59 +01:00
|
|
|
$this->raw(common_markup_to_html($message));
|
2011-01-14 20:36:06 +00:00
|
|
|
$this->elementEnd('div');
|
2009-04-06 02:14:59 +01:00
|
|
|
}
|
2008-07-10 00:10:31 +01:00
|
|
|
}
|