X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fapisearchatom.php;h=c1aa43483e4549b1cc04b2b45d48997e301a78a8;hb=d6b28c64830f632bb2f4b6f3c9369b9e56ad217a;hp=60bb8b04083864b0816c8c6d588e57e14f616a33;hpb=884b26229d74cc5b386406e3e9125629b4e3ecd0;p=quix0rs-gnu-social.git diff --git a/actions/apisearchatom.php b/actions/apisearchatom.php index 60bb8b0408..c1aa43483e 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) + function prepare(array $args=array()) { - 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,8 +128,7 @@ class ApiSearchAtomAction extends ApiPrivateAuthAction * * @return void */ - - function handle($args) + function handle(array $args=array()) { parent::handle($args); common_debug("In apisearchatom handle()"); @@ -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,6 +167,11 @@ class ApiSearchAtomAction extends ApiPrivateAuthAction if ($this->cnt > 0) { while ($notice->fetch()) { + // Check scope of notice to current profile (including guests) + if (!$notice->isCurrentProfileInScope()) { + // Not in scope + continue; + } ++$cnt; @@ -187,6 +179,10 @@ class ApiSearchAtomAction extends ApiPrivateAuthAction $this->max_id = $notice->id; } + if ($this->since_id && $notice->id <= $this->since_id) { + break; + } + if ($cnt > $this->rpp) { break; } @@ -203,7 +199,6 @@ class ApiSearchAtomAction extends ApiPrivateAuthAction * * @return void */ - function showAtom() { $notices = $this->getNotices(); @@ -212,7 +207,6 @@ class ApiSearchAtomAction extends ApiPrivateAuthAction $this->showFeed(); foreach ($notices as $n) { - $profile = $n->getProfile(); // Don't show notices from deleted users @@ -230,7 +224,6 @@ class ApiSearchAtomAction extends ApiPrivateAuthAction * * @return void */ - function showFeed() { // TODO: A9 OpenSearch stuff like search.twitter.com? @@ -278,6 +271,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 +307,6 @@ class ApiSearchAtomAction extends ApiPrivateAuthAction 'rel' => 'previous', 'href' => $previous_uri)); } - } /** @@ -324,7 +317,6 @@ class ApiSearchAtomAction extends ApiPrivateAuthAction * * @return void */ - function showEntry($notice) { $server = common_config('site', 'server'); @@ -353,13 +345,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 +364,7 @@ class ApiSearchAtomAction extends ApiPrivateAuthAction $name = $profile->nickname; if ($profile->fullname) { + // @todo Needs proper i18n? $name .= ' (' . $profile->fullname . ')'; } @@ -387,7 +380,6 @@ class ApiSearchAtomAction extends ApiPrivateAuthAction * * @return void */ - function initAtom() { header('Content-Type: application/atom+xml; charset=utf-8'); @@ -399,10 +391,8 @@ class ApiSearchAtomAction extends ApiPrivateAuthAction * * @return void */ - function endAtom() { $this->elementEnd('feed'); } - }