From: Andrew Garrett Date: Wed, 30 Sep 2009 17:35:41 +0000 (+0000) Subject: Re-work feed exposure system. X-Git-Tag: 1.31.0-rc.0~39460 X-Git-Url: https://git.cyclocoop.org/%242?a=commitdiff_plain;h=92d337f1c334f15c1938efc62119153eb1222759;p=lhc%2Fweb%2Fwiklou.git Re-work feed exposure system. * Includes a new, more flexible system which allows you to provide an array of format => URL, but also supports the older system of providing a URL suffix. * Implemented it for the watchlist if a user has set their own token. --- diff --git a/includes/OutputPage.php b/includes/OutputPage.php index 6811a3c486..844496c1f7 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -28,8 +28,9 @@ class OutputPage { var $mContainsOldMagic = 0, $mContainsNewMagic = 0; var $mIsArticleRelated = true; protected $mParserOptions = null; // lazy initialised, use parserOptions() - var $mShowFeedLinks = false; - var $mFeedLinksAppendQuery = false; + + var $mFeedLinks = array(); + var $mEnableClientCache = true; var $mArticleBodyOnly = false; @@ -575,14 +576,30 @@ class OutputPage { public function isArticle() { return $this->mIsarticle; } public function setPrintable() { $this->mPrintable = true; } public function isPrintable() { return $this->mPrintable; } - public function setSyndicated( $show = true ) { $this->mShowFeedLinks = $show; } - public function isSyndicated() { return $this->mShowFeedLinks; } - public function setFeedAppendQuery( $val ) { $this->mFeedLinksAppendQuery = $val; } public function getFeedAppendQuery() { return $this->mFeedLinksAppendQuery; } public function setOnloadHandler( $js ) { $this->mOnloadHandler = $js; } public function getOnloadHandler() { return $this->mOnloadHandler; } public function disable() { $this->mDoNothing = true; } public function isDisabled() { return $this->mDoNothing; } + + public function setSyndicated( $show = true ) { $this->mShowFeedLinks = $show; } + + public function setFeedAppendQuery( $val ) { + global $wgFeedClasses; + + $this->mFeedLinks = array(); + + foreach( $wgFeedClasses as $type => $class ) { + $query = "feed=$type&".$val; + $this->mFeedLinks[$type] = $this->getTitle()->getLocalURL( $query ); + } + } + + public function addFeedLink( $format, $href ) { + $this->mFeedLinks[$format] = $href; + } + + public function isSyndicated() { return count($this->mFeedLinks); } public function setArticleRelated( $v ) { $this->mIsArticleRelated = $v; @@ -1916,22 +1933,8 @@ class OutputPage { * Return URLs for each supported syndication format for this page. * @return array associating format keys with URLs */ - public function getSyndicationLinks() { - global $wgFeedClasses; - $links = array(); - - if( $this->isSyndicated() ) { - if( is_string( $this->getFeedAppendQuery() ) ) { - $appendQuery = "&" . $this->getFeedAppendQuery(); - } else { - $appendQuery = ""; - } - - foreach( $wgFeedClasses as $format => $class ) { - $links[$format] = $this->getTitle()->getLocalUrl( "feed=$format{$appendQuery}" ); - } - } - return $links; + public function getSyndicationLinks() { + return $this->mFeedLinks; } /** diff --git a/includes/specials/SpecialWatchlist.php b/includes/specials/SpecialWatchlist.php index 97fd8d166a..8d3363a9db 100644 --- a/includes/specials/SpecialWatchlist.php +++ b/includes/specials/SpecialWatchlist.php @@ -13,6 +13,21 @@ function wfSpecialWatchlist( $par ) { global $wgUser, $wgOut, $wgLang, $wgRequest; global $wgRCShowWatchingUsers, $wgEnotifWatchlist, $wgShowUpdatedMarker; global $wgEnotifWatchlist; + + // Add feed links + $wlToken = $wgUser->getOption( 'watchlisttoken' ); + if ($wlToken) { + global $wgServer, $wgScriptPath, $wgFeedClasses; + $apiParams = array( 'action' => 'feedwatchlist', 'allrev' => 'allrev', + 'wlowner' => $wgUser->getName(), 'wltoken' => $wlToken ); + $feedTemplate = $wgServer . '/' . $wgScriptPath . '/api.php?'; + + foreach( $wgFeedClasses as $format => $class ) { + $theseParams = $apiParams + array( 'feedformat' => $format ); + $url = $feedTemplate . wfArrayToCGI( $theseParams ); + $wgOut->addFeedLink( $format, $url ); + } + } $skin = $wgUser->getSkin(); $specialTitle = SpecialPage::getTitleFor( 'Watchlist' );