X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Fapisearchatom.php;h=32ff918da3b6e70e01966cece29d331372060691;hb=8b47400183052873b012dacf4eb5ba841914a886;hp=60bb8b04083864b0816c8c6d588e57e14f616a33;hpb=819d33210d298de74b64dc7ead79e9d9b223b12e;p=quix0rs-gnu-social.git diff --git a/actions/apisearchatom.php b/actions/apisearchatom.php index 60bb8b0408..32ff918da3 100644 --- a/actions/apisearchatom.php +++ b/actions/apisearchatom.php @@ -48,10 +48,8 @@ require_once INSTALLDIR.'/lib/apiprivateauth.php'; * * @see ApiPrivateAuthAction */ - class ApiSearchAtomAction extends ApiPrivateAuthAction { - var $cnt; var $query; var $lang; @@ -70,7 +68,6 @@ class ApiSearchAtomAction extends ApiPrivateAuthAction * * @see Action::__construct */ - function __construct($output='php://output', $indent=null) { parent::__construct($output, $indent); @@ -81,7 +78,6 @@ class ApiSearchAtomAction extends ApiPrivateAuthAction * * @return boolean true */ - function isReadonly() { return true; @@ -93,16 +89,13 @@ 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 +114,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 +132,6 @@ class ApiSearchAtomAction extends ApiPrivateAuthAction * * @return void */ - function handle($args) { parent::handle($args); @@ -154,7 +146,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 +171,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 +197,6 @@ class ApiSearchAtomAction extends ApiPrivateAuthAction * * @return void */ - function showAtom() { $notices = $this->getNotices(); @@ -212,7 +205,6 @@ class ApiSearchAtomAction extends ApiPrivateAuthAction $this->showFeed(); foreach ($notices as $n) { - $profile = $n->getProfile(); // Don't show notices from deleted users @@ -230,7 +222,6 @@ class ApiSearchAtomAction extends ApiPrivateAuthAction * * @return void */ - function showFeed() { // TODO: A9 OpenSearch stuff like search.twitter.com? @@ -278,6 +269,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 +305,6 @@ class ApiSearchAtomAction extends ApiPrivateAuthAction 'rel' => 'previous', 'href' => $previous_uri)); } - } /** @@ -324,7 +315,6 @@ class ApiSearchAtomAction extends ApiPrivateAuthAction * * @return void */ - function showEntry($notice) { $server = common_config('site', 'server'); @@ -356,10 +346,10 @@ class ApiSearchAtomAction extends ApiPrivateAuthAction if ($ns) { 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 +362,7 @@ class ApiSearchAtomAction extends ApiPrivateAuthAction $name = $profile->nickname; if ($profile->fullname) { + // @todo Needs proper i18n? $name .= ' (' . $profile->fullname . ')'; } @@ -387,7 +378,6 @@ class ApiSearchAtomAction extends ApiPrivateAuthAction * * @return void */ - function initAtom() { header('Content-Type: application/atom+xml; charset=utf-8'); @@ -399,10 +389,8 @@ class ApiSearchAtomAction extends ApiPrivateAuthAction * * @return void */ - function endAtom() { $this->elementEnd('feed'); } - }