X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fapisearchatom.php;h=b686edb00aeabb9a89e0243e23f1bf93ec6a59ae;hb=a597b2800122be618bbf620eb1e6ae61bf691d15;hp=60bb8b04083864b0816c8c6d588e57e14f616a33;hpb=004e42e3e0606f0f9e5c8b6cd4512e5d870cd56e;p=quix0rs-gnu-social.git diff --git a/actions/apisearchatom.php b/actions/apisearchatom.php index 60bb8b0408..b686edb00a 100644 --- a/actions/apisearchatom.php +++ b/actions/apisearchatom.php @@ -31,8 +31,6 @@ if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } -require_once INSTALLDIR.'/lib/apiprivateauth.php'; - /** * Action for outputting search results in Twitter compatible Atom * format. @@ -48,10 +46,8 @@ require_once INSTALLDIR.'/lib/apiprivateauth.php'; * * @see ApiPrivateAuthAction */ - class ApiSearchAtomAction extends ApiPrivateAuthAction { - var $cnt; var $query; var $lang; @@ -70,7 +66,6 @@ class ApiSearchAtomAction extends ApiPrivateAuthAction * * @see Action::__construct */ - function __construct($output='php://output', $indent=null) { parent::__construct($output, $indent); @@ -81,7 +76,6 @@ class ApiSearchAtomAction extends ApiPrivateAuthAction * * @return boolean true */ - function isReadonly() { return true; @@ -93,16 +87,11 @@ class ApiSearchAtomAction extends ApiPrivateAuthAction * @param array $args Arguments from $_REQUEST * * @return boolean success - * */ - function prepare($args) { - common_debug("in apisearchatom prepare()"); - parent::prepare($args); - $this->query = $this->trimmed('q'); $this->lang = $this->trimmed('lang'); $this->rpp = $this->trimmed('rpp'); @@ -121,7 +110,7 @@ class ApiSearchAtomAction extends ApiPrivateAuthAction $this->page = 1; } - // TODO: Suppport since_id -- we need to tweak the backend + // TODO: Suppport max_id -- we need to tweak the backend // Search classes to support it. $this->since_id = $this->trimmed('since_id'); @@ -139,7 +128,6 @@ class ApiSearchAtomAction extends ApiPrivateAuthAction * * @return void */ - function handle($args) { parent::handle($args); @@ -154,7 +142,6 @@ class ApiSearchAtomAction extends ApiPrivateAuthAction * * @return array an array of Notice objects sorted in reverse chron */ - function getNotices() { // TODO: Support search operators like from: and to:, boolean, etc. @@ -180,13 +167,16 @@ class ApiSearchAtomAction extends ApiPrivateAuthAction if ($this->cnt > 0) { while ($notice->fetch()) { - ++$cnt; if (!$this->max_id) { $this->max_id = $notice->id; } + if ($this->since_id && $notice->id <= $this->since_id) { + break; + } + if ($cnt > $this->rpp) { break; } @@ -203,7 +193,6 @@ class ApiSearchAtomAction extends ApiPrivateAuthAction * * @return void */ - function showAtom() { $notices = $this->getNotices(); @@ -212,7 +201,6 @@ class ApiSearchAtomAction extends ApiPrivateAuthAction $this->showFeed(); foreach ($notices as $n) { - $profile = $n->getProfile(); // Don't show notices from deleted users @@ -230,7 +218,6 @@ class ApiSearchAtomAction extends ApiPrivateAuthAction * * @return void */ - function showFeed() { // TODO: A9 OpenSearch stuff like search.twitter.com? @@ -278,6 +265,7 @@ class ApiSearchAtomAction extends ApiPrivateAuthAction 'rel' => 'self', 'href' => $self_uri)); + // @todo Needs i18n? $this->element('title', null, "$this->query - $sitename Search"); $this->element('updated', null, common_date_iso8601('now')); @@ -313,7 +301,6 @@ class ApiSearchAtomAction extends ApiPrivateAuthAction 'rel' => 'previous', 'href' => $previous_uri)); } - } /** @@ -324,7 +311,6 @@ class ApiSearchAtomAction extends ApiPrivateAuthAction * * @return void */ - function showEntry($notice) { $server = common_config('site', 'server'); @@ -353,13 +339,13 @@ class ApiSearchAtomAction extends ApiPrivateAuthAction $source = null; $ns = $notice->getSource(); - if ($ns) { + if ($ns instanceof Notice_source) { if (!empty($ns->name) && !empty($ns->url)) { $source = '' - . htmlspecialchars($ns->name) - . ''; + . htmlspecialchars($ns->url) + . '" rel="nofollow">' + . htmlspecialchars($ns->name) + . ''; } else { $source = $ns->code; } @@ -372,6 +358,7 @@ class ApiSearchAtomAction extends ApiPrivateAuthAction $name = $profile->nickname; if ($profile->fullname) { + // @todo Needs proper i18n? $name .= ' (' . $profile->fullname . ')'; } @@ -387,7 +374,6 @@ class ApiSearchAtomAction extends ApiPrivateAuthAction * * @return void */ - function initAtom() { header('Content-Type: application/atom+xml; charset=utf-8'); @@ -399,10 +385,8 @@ class ApiSearchAtomAction extends ApiPrivateAuthAction * * @return void */ - function endAtom() { $this->elementEnd('feed'); } - }