X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiFeedContributions.php;h=9c3945e3cea376b614af089db383e86dd94f011c;hb=7060acd95863d4021afa2701f9e779de61e6a560;hp=20f4d3d3436fca5e4b26aa3b1a77fbf78b2a01a9;hpb=9106ed7710176dd9ce37f61c9ae3e7224e2f7a0c;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiFeedContributions.php b/includes/api/ApiFeedContributions.php index 20f4d3d343..9c3945e3ce 100644 --- a/includes/api/ApiFeedContributions.php +++ b/includes/api/ApiFeedContributions.php @@ -56,7 +56,8 @@ class ApiFeedContributions extends ApiBase { } $msg = wfMessage( 'Contributions' )->inContentLanguage()->text(); - $feedTitle = $config->get( 'Sitename' ) . ' - ' . $msg . ' [' . $config->get( 'LanguageCode' ) . ']'; + $feedTitle = $config->get( 'Sitename' ) . ' - ' . $msg . + ' [' . $config->get( 'LanguageCode' ) . ']'; $feedUrl = SpecialPage::getTitleFor( 'Contributions', $params['user'] )->getFullURL(); $target = $params['user'] == 'newbies' @@ -95,7 +96,10 @@ class ApiFeedContributions extends ApiBase { if ( ++$count > $limit ) { break; } - $feedItems[] = $this->feedItem( $row ); + $item = $this->feedItem( $row ); + if ( $item !== null ) { + $feedItems[] = $item; + } } } @@ -103,6 +107,23 @@ class ApiFeedContributions extends ApiBase { } protected function feedItem( $row ) { + // This hook is the api contributions equivalent to the + // ContributionsLineEnding hook. Hook implementers may cancel + // the hook to signal the user is not allowed to read this item. + $feedItem = null; + $hookResult = Hooks::run( + 'ApiFeedContributions::feedItem', + array( $row, $this->getContext(), &$feedItem ) + ); + // Hook returned a valid feed item + if ( $feedItem instanceof FeedItem ) { + return $feedItem; + // Hook was canceled and did not return a valid feed item + } elseif ( !$hookResult ) { + return null; + } + + // Hook completed and did not return a valid feed item $title = Title::makeTitle( intval( $row->page_namespace ), $row->page_title ); if ( $title && $title->userCan( 'read', $this->getUser() ) ) { $date = $row->rev_timestamp; @@ -143,10 +164,10 @@ class ApiFeedContributions extends ApiBase { // only textual content has a "source view". $html = nl2br( htmlspecialchars( $content->getNativeData() ) ); } else { - //XXX: we could get an HTML representation of the content via getParserOutput, but that may + // XXX: we could get an HTML representation of the content via getParserOutput, but that may // contain JS magic and generally may not be suitable for inclusion in a feed. // Perhaps Content should have a getDescriptiveHtml method and/or a getSourceText method. - //Compare also FeedUtils::formatDiffRow. + // Compare also FeedUtils::formatDiffRow. $html = ''; } @@ -199,7 +220,7 @@ class ApiFeedContributions extends ApiBase { return $ret; } - public function getExamplesMessages() { + protected function getExamplesMessages() { return array( 'action=feedcontributions&user=Example' => 'apihelp-feedcontributions-example-simple',