Florianschmidtwelzow has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/260060

Change subject: Add a new hook AfterBuildFeedLinks to manipulate feed links
......................................................................

Add a new hook AfterBuildFeedLinks to manipulate feed links

Some extensions may want to replace, remove or manipulate a specific
feed link after it was build. For this purpose: Add a new hook to enable
this. The hook isn't meant for adding new feed links, this is already
easily possible using OutputPage::addFeedLink().

Bug: T121774
Change-Id: If48bd07a0e7e67fd1c1a94ebaa28ca9dae146c55
---
M includes/OutputPage.php
1 file changed, 12 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/60/260060/1

diff --git a/includes/OutputPage.php b/includes/OutputPage.php
index 67c54bb..78eb458 100644
--- a/includes/OutputPage.php
+++ b/includes/OutputPage.php
@@ -3502,13 +3502,15 @@
 
                # Feeds
                if ( $config->get( 'Feed' ) ) {
+                       $feedLinks = array();
+
                        foreach ( $this->getSyndicationLinks() as $format => 
$link ) {
                                # Use the page name for the title.  In 
principle, this could
                                # lead to issues with having the same name for 
different feeds
                                # corresponding to the same page, but we can't 
avoid that at
                                # this low a level.
 
-                               $tags[] = $this->feedLink(
+                               $feedLinks[] = $this->feedLink(
                                        $format,
                                        $link,
                                        # Used messages: 'page-rss-feed' and 
'page-atom-feed' (for an easier grep)
@@ -3529,7 +3531,7 @@
                        if ( $config->get( 'OverrideSiteFeed' ) ) {
                                foreach ( $config->get( 'OverrideSiteFeed' ) as 
$type => $feedUrl ) {
                                        // Note, this->feedLink escapes the url.
-                                       $tags[] = $this->feedLink(
+                                       $feedLinks[] = $this->feedLink(
                                                $type,
                                                $feedUrl,
                                                $this->msg( 
"site-{$type}-feed", $sitename )->text()
@@ -3538,7 +3540,7 @@
                        } elseif ( !$this->getTitle()->isSpecial( 
'Recentchanges' ) ) {
                                $rctitle = SpecialPage::getTitleFor( 
'Recentchanges' );
                                foreach ( $config->get( 'AdvertisedFeedTypes' ) 
as $format ) {
-                                       $tags[] = $this->feedLink(
+                                       $feedLinks[] = $this->feedLink(
                                                $format,
                                                $rctitle->getLocalURL( array( 
'feed' => $format ) ),
                                                # For grep: 'site-rss-feed', 
'site-atom-feed'
@@ -3546,6 +3548,13 @@
                                        );
                                }
                        }
+
+                       # Allow extensions to change the list pf feeds. This 
hook is primarily for changing,
+                       # manipulating or removing existing feed tags. If you 
want to add new feeds, you should
+                       # use OutputPage::addFeedLink() instead.
+                       Hooks::run( 'AfterBuildFeedLinks', array( &$feedLinks ) 
);
+
+                       $tags += $feedLinks;
                }
 
                # Canonical URL

-- 
To view, visit https://gerrit.wikimedia.org/r/260060
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: If48bd07a0e7e67fd1c1a94ebaa28ca9dae146c55
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Florianschmidtwelzow <florian.schmidt.stargatewis...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to