X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Ftwitapisearchatom.php;h=0ef9d282604fed447cc343acd5f8efd489fbdcb6;hb=f746993c2bfb674d397cf095a2ab2ff7e757818b;hp=eb9ab5d8e9425add9688045321eb62aaa3ba7b05;hpb=622cc150d86265cbb1dcd35ae11f4941d42ffdeb;p=quix0rs-gnu-social.git diff --git a/actions/twitapisearchatom.php b/actions/twitapisearchatom.php index eb9ab5d8e9..0ef9d28260 100644 --- a/actions/twitapisearchatom.php +++ b/actions/twitapisearchatom.php @@ -1,6 +1,6 @@ . * * @category Search - * @package Laconica - * @author Zach Copley - * @copyright 2008-2009 Control Yourself, Inc. + * @package StatusNet + * @author Zach Copley + * @copyright 2008-2009 StatusNet, Inc. * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://laconi.ca/ + * @link http://status.net/ */ -if (!defined('LACONICA')) { +if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } -require_once INSTALLDIR.'/lib/twitterapi.php'; +require_once INSTALLDIR.'/lib/api.php'; /** * Action for outputting search results in Twitter compatible Atom @@ -41,15 +41,15 @@ require_once INSTALLDIR.'/lib/twitterapi.php'; * RSS10Action. * * @category Search - * @package Laconica - * @author Zach Copley + * @package StatusNet + * @author Zach Copley * @license http://www.fsf.org/licensing/licenses/agpl-3.0.html GNU Affero General Public License version 3.0 - * @link http://laconi.ca/ + * @link http://status.net/ * - * @see TwitterapiAction + * @see ApiAction */ -class TwitapisearchatomAction extends TwitterapiAction +class TwitapisearchatomAction extends ApiAction { var $cnt; @@ -165,24 +165,30 @@ class TwitapisearchatomAction extends TwitterapiAction $search_engine->set_sort_mode('chron'); $search_engine->limit(($this->page - 1) * $this->rpp, $this->rpp + 1, true); - $search_engine->query($q); - $this->cnt = $notice->find(); + if (false === $search_engine->query($q)) { + $this->cnt = 0; + } else { + $this->cnt = $notice->find(); + } $cnt = 0; + $this->max_id = 0; - while ($notice->fetch()) { + if ($this->cnt > 0) { + while ($notice->fetch()) { - ++$cnt; + ++$cnt; - if (!$this->max_id) { - $this->max_id = $notice->id; - } + if (!$this->max_id) { + $this->max_id = $notice->id; + } - if ($cnt > $this->rpp) { - break; - } + if ($cnt > $this->rpp) { + break; + } - $notices[] = clone($notice); + $notices[] = clone($notice); + } } return $notices; @@ -221,7 +227,7 @@ class TwitapisearchatomAction extends TwitterapiAction $server = common_config('site', 'server'); $sitename = common_config('site', 'name'); - // XXX: Use xmlns:laconica instead? + // XXX: Use xmlns:statusnet instead? $this->elementStart('feed', array('xmlns' => 'http://www.w3.org/2005/Atom',