X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=actions%2Fapisearchjson.php;h=794f23077bacbc1184c972888dad3c7db2b774c8;hb=a597b2800122be618bbf620eb1e6ae61bf691d15;hp=e44634684ddcd71e3397344fa8915f6a16f38990;hpb=884b26229d74cc5b386406e3e9125629b4e3ecd0;p=quix0rs-gnu-social.git diff --git a/actions/apisearchjson.php b/actions/apisearchjson.php index e44634684d..794f23077b 100644 --- a/actions/apisearchjson.php +++ b/actions/apisearchjson.php @@ -20,19 +20,15 @@ * along with this program. If not, see . * * @category Search - * @package StatusNet + * @package GNUsocial * @author Zach Copley * @copyright 2008-2010 StatusNet, Inc. + * @copyright 2013 Free Software Foundation, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://status.net/ + * @link http://www.gnu.org/software/social/ */ -if (!defined('STATUSNET') && !defined('LACONICA')) { - exit(1); -} - -require_once INSTALLDIR.'/lib/apiprivateauth.php'; -require_once INSTALLDIR.'/lib/jsonsearchresultslist.php'; +if (!defined('GNUSOCIAL')) { exit(1); } /** * Action handler for Twitter-compatible API search @@ -44,7 +40,6 @@ require_once INSTALLDIR.'/lib/jsonsearchresultslist.php'; * @link http://status.net/ * @see ApiAction */ - class ApiSearchJSONAction extends ApiPrivateAuthAction { var $query; @@ -62,11 +57,8 @@ class ApiSearchJSONAction extends ApiPrivateAuthAction * * @return boolean true if nothing goes wrong */ - function prepare($args) { - common_debug("apisearchjson prepare()"); - parent::prepare($args); $this->query = $this->trimmed('q'); @@ -87,6 +79,9 @@ class ApiSearchJSONAction extends ApiPrivateAuthAction $this->page = 1; } + // TODO: Suppport max_id -- we need to tweak the backend + // Search classes to support it. + $this->since_id = $this->trimmed('since_id'); $this->geocode = $this->trimmed('geocode'); @@ -100,7 +95,6 @@ class ApiSearchJSONAction extends ApiPrivateAuthAction * * @return void */ - function handle($args) { parent::handle($args); @@ -112,33 +106,22 @@ class ApiSearchJSONAction extends ApiPrivateAuthAction * * @return void */ - function showResults() { - // TODO: Support search operators like from: and to:, boolean, etc. $notice = new Notice(); - // lcase it for comparison - $q = strtolower($this->query); - + $this->notices = array(); $search_engine = $notice->getSearchEngine('notice'); $search_engine->set_sort_mode('chron'); - $search_engine->limit(($this->page - 1) * $this->rpp, $this->rpp + 1, true); - if (false === $search_engine->query($q)) { - $cnt = 0; - } else { + $search_engine->limit(($this->page - 1) * $this->rpp, $this->rpp + 1); + if ($search_engine->query($this->query)) { $cnt = $notice->find(); + $this->notices = $notice->fetchAll(); } - // TODO: since_id, lang, geocode - - $results = new JSONSearchResultsList($notice, $q, $this->rpp, $this->page); - - $this->initDocument('json'); - $results->show(); - $this->endDocument('json'); + $this->showJsonTimeline($this->notices); } /** @@ -146,7 +129,6 @@ class ApiSearchJSONAction extends ApiPrivateAuthAction * * @return boolean true */ - function isReadOnly($args) { return true;