2008-07-10 08:10:31 +09:00
|
|
|
<?php
|
2009-01-23 10:00:57 +09:00
|
|
|
/**
|
|
|
|
* Base search action class.
|
|
|
|
*
|
|
|
|
* PHP version 5
|
|
|
|
*
|
|
|
|
* @category Action
|
|
|
|
* @package Laconica
|
|
|
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
|
|
|
* @author Robin Millette <millette@controlyourself.ca>
|
|
|
|
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
|
|
|
* @link http://laconi.ca/
|
|
|
|
*
|
2008-07-10 08:10:31 +09:00
|
|
|
* Laconica - a distributed open-source microblogging tool
|
|
|
|
* Copyright (C) 2008, Controlez-Vous, Inc.
|
|
|
|
*
|
|
|
|
* 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-01-23 10:00:57 +09:00
|
|
|
if (!defined('LACONICA')) {
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
require_once INSTALLDIR.'/lib/searchgroupnav.php';
|
2008-07-10 08:10:31 +09:00
|
|
|
|
2009-01-23 10:00:57 +09:00
|
|
|
/**
|
|
|
|
* Base search action class.
|
|
|
|
*
|
|
|
|
* @category Action
|
|
|
|
* @package Laconica
|
|
|
|
* @author Evan Prodromou <evan@controlyourself.ca>
|
|
|
|
* @author Robin Millette <millette@controlyourself.ca>
|
|
|
|
* @license http://www.fsf.org/licensing/licenses/agpl.html AGPLv3
|
|
|
|
* @link http://laconi.ca/
|
|
|
|
*/
|
2008-12-24 04:49:23 +09:00
|
|
|
class SearchAction extends Action
|
|
|
|
{
|
2009-01-23 10:00:57 +09:00
|
|
|
/**
|
|
|
|
* Return true if read only.
|
|
|
|
*
|
|
|
|
* @return boolean true
|
|
|
|
*/
|
|
|
|
function isReadOnly()
|
2008-12-24 04:33:23 +09:00
|
|
|
{
|
2008-12-24 04:19:07 +09:00
|
|
|
return true;
|
|
|
|
}
|
2008-07-23 06:20:56 +09:00
|
|
|
|
2008-12-24 04:33:23 +09:00
|
|
|
function handle($args)
|
|
|
|
{
|
2008-12-24 04:19:07 +09:00
|
|
|
parent::handle($args);
|
2009-01-23 10:00:57 +09:00
|
|
|
$this->showPage();
|
2008-12-24 04:19:07 +09:00
|
|
|
}
|
2008-07-10 08:10:31 +09:00
|
|
|
|
2009-01-23 10:00:57 +09:00
|
|
|
/**
|
|
|
|
* Show tabset for this page
|
|
|
|
*
|
|
|
|
* Uses the SearchGroupNav widget
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
* @see SearchGroupNav
|
|
|
|
*/
|
|
|
|
|
|
|
|
function showLocalNav()
|
|
|
|
{
|
2009-01-23 11:00:06 +09:00
|
|
|
$nav = new SearchGroupNav($this, $this->trimmed('q'));
|
2009-01-23 10:00:57 +09:00
|
|
|
$nav->show();
|
|
|
|
}
|
|
|
|
|
|
|
|
function showTop($arr=null)
|
2008-12-24 04:33:23 +09:00
|
|
|
{
|
2008-12-24 04:19:07 +09:00
|
|
|
if ($arr) {
|
|
|
|
$error = $arr[1];
|
|
|
|
}
|
|
|
|
if ($error) {
|
2009-01-23 10:00:57 +09:00
|
|
|
$this->element('p', 'error', $error);
|
2008-12-24 04:19:07 +09:00
|
|
|
} else {
|
2009-01-23 10:00:57 +09:00
|
|
|
$instr = $this->getInstructions();
|
2008-12-24 04:19:07 +09:00
|
|
|
$output = common_markup_to_html($instr);
|
2009-01-23 10:00:57 +09:00
|
|
|
$this->elementStart('div', 'instructions');
|
|
|
|
$this->raw($output);
|
|
|
|
$this->elementEnd('div');
|
2008-12-24 04:19:07 +09:00
|
|
|
}
|
|
|
|
}
|
2008-07-10 08:10:31 +09:00
|
|
|
|
2009-01-23 10:00:57 +09:00
|
|
|
function title()
|
2008-12-24 04:33:23 +09:00
|
|
|
{
|
2008-12-24 04:21:29 +09:00
|
|
|
return null;
|
2008-12-24 04:19:07 +09:00
|
|
|
}
|
2008-07-10 08:42:28 +09:00
|
|
|
|
2009-01-23 10:00:57 +09:00
|
|
|
function showNoticeForm() {
|
|
|
|
// remote post notice form
|
|
|
|
}
|
|
|
|
|
|
|
|
function showContent() {
|
|
|
|
$this->showTop();
|
|
|
|
$this->showForm();
|
|
|
|
}
|
|
|
|
|
|
|
|
function showForm($error=null)
|
2008-12-24 04:33:23 +09:00
|
|
|
{
|
2008-12-24 04:19:07 +09:00
|
|
|
global $config;
|
2008-07-20 13:03:51 +09:00
|
|
|
|
2008-12-24 04:19:07 +09:00
|
|
|
$q = $this->trimmed('q');
|
|
|
|
$page = $this->trimmed('page', 1);
|
2009-01-23 10:00:57 +09:00
|
|
|
$this->elementStart('form', array('method' => 'get',
|
2008-12-24 04:19:07 +09:00
|
|
|
'id' => 'login',
|
|
|
|
'action' => common_local_url($this->trimmed('action'))));
|
2009-01-23 10:00:57 +09:00
|
|
|
$this->elementStart('p');
|
2008-12-24 04:19:07 +09:00
|
|
|
if (!isset($config['site']['fancy']) || !$config['site']['fancy']) {
|
2009-01-23 10:00:57 +09:00
|
|
|
$this->hidden('action', $this->trimmed('action'));
|
2008-12-24 04:19:07 +09:00
|
|
|
}
|
2009-01-23 10:00:57 +09:00
|
|
|
$this->input('q', '', $q);
|
|
|
|
$this->text(' ');
|
|
|
|
$this->submit('search', 'Search');
|
2008-07-10 14:13:31 +09:00
|
|
|
|
2009-01-23 10:00:57 +09:00
|
|
|
$this->elementEnd('p');
|
|
|
|
$this->elementEnd('form');
|
2008-12-24 04:19:07 +09:00
|
|
|
if ($q) {
|
2009-01-23 10:00:57 +09:00
|
|
|
$this->showResults($q, $page);
|
2008-12-24 04:19:07 +09:00
|
|
|
}
|
|
|
|
}
|
2008-07-10 08:10:31 +09:00
|
|
|
}
|
2009-01-23 10:00:57 +09:00
|
|
|
|