X-Git-Url: https://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiFeedWatchlist.php;h=34c6650bddddc53b8f1e2cb28d8a6e446bdd605f;hb=1d28b9ed350ae3d9c351273fb61b60453a88e04d;hp=a96fc31e475b91f82592c9f620f60a312561de3a;hpb=2081a0693fdad9f99e0cb17c94edf0cddbc353a6;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiFeedWatchlist.php b/includes/api/ApiFeedWatchlist.php index a96fc31e47..34c6650bdd 100644 --- a/includes/api/ApiFeedWatchlist.php +++ b/includes/api/ApiFeedWatchlist.php @@ -1,11 +1,11 @@ @gmail.com + * Copyright © 2006 Yuri Astrakhan @gmail.com * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,13 +19,13 @@ * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * http://www.gnu.org/copyleft/gpl.html */ if ( !defined( 'MEDIAWIKI' ) ) { // Eclipse helper - will be ignored in production - require_once ( "ApiBase.php" ); + require_once( "ApiBase.php" ); } /** @@ -38,7 +38,7 @@ if ( !defined( 'MEDIAWIKI' ) ) { class ApiFeedWatchlist extends ApiBase { public function __construct( $main, $action ) { - parent :: __construct( $main, $action ); + parent::__construct( $main, $action ); } /** @@ -53,7 +53,6 @@ class ApiFeedWatchlist extends ApiBase { * Wrap the result as an RSS/Atom feed. */ public function execute() { - global $wgFeedClasses, $wgFeedLimit, $wgSitename, $wgContLanguageCode; try { @@ -64,27 +63,31 @@ class ApiFeedWatchlist extends ApiBase { $dbr = wfGetDB( DB_SLAVE ); // Prepare parameters for nested request - $fauxReqArr = array ( + $fauxReqArr = array( 'action' => 'query', 'meta' => 'siteinfo', 'siprop' => 'general', 'list' => 'watchlist', 'wlprop' => 'title|user|comment|timestamp', - 'wldir' => 'older', // reverse order - from newest to oldest + 'wldir' => 'older', // reverse order - from newest to oldest 'wlend' => $dbr->timestamp( $endTime ), // stop at this time 'wllimit' => ( 50 > $wgFeedLimit ) ? $wgFeedLimit : 50 ); - if ( !is_null( $params['wlowner'] ) ) + if ( !is_null( $params['wlowner'] ) ) { $fauxReqArr['wlowner'] = $params['wlowner']; - if ( !is_null( $params['wltoken'] ) ) + } + if ( !is_null( $params['wltoken'] ) ) { $fauxReqArr['wltoken'] = $params['wltoken']; + } // Check for 'allrev' parameter, and if found, show all revisions to each page on wl. - if ( ! is_null ( $params['allrev'] ) ) $fauxReqArr['wlallrev'] = ''; + if ( !is_null( $params['allrev'] ) ) { + $fauxReqArr['wlallrev'] = ''; + } // Create the request - $fauxReq = new FauxRequest ( $fauxReqArr ); + $fauxReq = new FauxRequest( $fauxReqArr ); // Execute $module = new ApiMain( $fauxReq ); @@ -93,17 +96,17 @@ class ApiFeedWatchlist extends ApiBase { // Get data array $data = $module->getResultData(); - $feedItems = array (); + $feedItems = array(); foreach ( (array)$data['query']['watchlist'] as $info ) { $feedItems[] = $this->createFeedItem( $info ); } $feedTitle = $wgSitename . ' - ' . wfMsgForContent( 'watchlist' ) . ' [' . $wgContLanguageCode . ']'; - $feedUrl = SpecialPage::getTitleFor( 'Watchlist' )->getFullUrl(); + $feedUrl = SpecialPage::getTitleFor( 'Watchlist' )->getFullURL(); $feed = new $wgFeedClasses[$params['feedformat']] ( $feedTitle, htmlspecialchars( wfMsgForContent( 'watchlist' ) ), $feedUrl ); - ApiFormatFeedWrapper :: setResult( $this->getResult(), $feed, $feedItems ); + ApiFormatFeedWrapper::setResult( $this->getResult(), $feed, $feedItems ); } catch ( Exception $e ) { @@ -111,7 +114,7 @@ class ApiFeedWatchlist extends ApiBase { $this->getMain()->setCacheMaxAge( 0 ); $feedTitle = $wgSitename . ' - Error - ' . wfMsgForContent( 'watchlist' ) . ' [' . $wgContLanguageCode . ']'; - $feedUrl = SpecialPage::getTitleFor( 'Watchlist' )->getFullUrl(); + $feedUrl = SpecialPage::getTitleFor( 'Watchlist' )->getFullURL(); $feedFormat = isset( $params['feedformat'] ) ? $params['feedformat'] : 'rss'; $feed = new $wgFeedClasses[$feedFormat] ( $feedTitle, htmlspecialchars( wfMsgForContent( 'watchlist' ) ), $feedUrl ); @@ -124,15 +127,15 @@ class ApiFeedWatchlist extends ApiBase { } $errorText = $e->getMessage(); - $feedItems[] = new FeedItem( "Error ($errorCode)", $errorText, "", "", "" ); - ApiFormatFeedWrapper :: setResult( $this->getResult(), $feed, $feedItems ); + $feedItems[] = new FeedItem( "Error ($errorCode)", $errorText, '', '', '' ); + ApiFormatFeedWrapper::setResult( $this->getResult(), $feed, $feedItems ); } } private function createFeedItem( $info ) { $titleStr = $info['title']; - $title = Title :: newFromText( $titleStr ); - $titleUrl = $title->getFullUrl(); + $title = Title::newFromText( $titleStr ); + $titleUrl = $title->getFullURL(); $comment = isset( $info['comment'] ) ? $info['comment'] : null; $timestamp = $info['timestamp']; $user = $info['user']; @@ -146,32 +149,32 @@ class ApiFeedWatchlist extends ApiBase { global $wgFeedClasses; $feedFormatNames = array_keys( $wgFeedClasses ); return array ( - 'feedformat' => array ( - ApiBase :: PARAM_DFLT => 'rss', - ApiBase :: PARAM_TYPE => $feedFormatNames + 'feedformat' => array( + ApiBase::PARAM_DFLT => 'rss', + ApiBase::PARAM_TYPE => $feedFormatNames ), - 'hours' => array ( - ApiBase :: PARAM_DFLT => 24, - ApiBase :: PARAM_TYPE => 'integer', - ApiBase :: PARAM_MIN => 1, - ApiBase :: PARAM_MAX => 72, + 'hours' => array( + ApiBase::PARAM_DFLT => 24, + ApiBase::PARAM_TYPE => 'integer', + ApiBase::PARAM_MIN => 1, + ApiBase::PARAM_MAX => 72, ), 'allrev' => null, - 'wlowner' => array ( - ApiBase :: PARAM_TYPE => 'user' + 'wlowner' => array( + ApiBase::PARAM_TYPE => 'user' ), - 'wltoken' => array ( - ApiBase :: PARAM_TYPE => 'string' + 'wltoken' => array( + ApiBase::PARAM_TYPE => 'string' ) ); } public function getParamDescription() { - return array ( + return array( 'feedformat' => 'The format of the feed', 'hours' => 'List pages modified within this many hours from now', - 'allrev' => 'Include multiple revisions of the same page within given timeframe.', - 'wlowner' => "The user whose watchlist you want (must be accompanied by wltoken if it's not you)", + 'allrev' => 'Include multiple revisions of the same page within given timeframe', + 'wlowner' => "The user whose watchlist you want (must be accompanied by {$this->getModulePrefix()}token if it's not you)", 'wltoken' => 'Security token that requested user set in their preferences' ); } @@ -181,7 +184,7 @@ class ApiFeedWatchlist extends ApiBase { } protected function getExamples() { - return array ( + return array( 'api.php?action=feedwatchlist' ); }