From d9022f63880ce039446fba8364f68e656b7bf4cb Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 3 May 2012 13:01:35 +0200 Subject: Update to MediaWiki 1.19.0 --- includes/api/ApiWatch.php | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'includes/api/ApiWatch.php') diff --git a/includes/api/ApiWatch.php b/includes/api/ApiWatch.php index 27846ab7..fa382b3b 100644 --- a/includes/api/ApiWatch.php +++ b/includes/api/ApiWatch.php @@ -24,11 +24,6 @@ * @file */ -if ( !defined( 'MEDIAWIKI' ) ) { - // Eclipse helper - will be ignored in production - require_once( 'ApiBase.php' ); -} - /** * API module to allow users to watch a page * @@ -41,8 +36,8 @@ class ApiWatch extends ApiBase { } public function execute() { - global $wgUser; - if ( !$wgUser->isLoggedIn() ) { + $user = $this->getUser(); + if ( !$user->isLoggedIn() ) { $this->dieUsage( 'You must be logged-in to have a watchlist', 'notloggedin' ); } @@ -53,17 +48,16 @@ class ApiWatch extends ApiBase { $this->dieUsageMsg( array( 'invalidtitle', $params['title'] ) ); } - $article = new Article( $title, 0 ); $res = array( 'title' => $title->getPrefixedText() ); if ( $params['unwatch'] ) { $res['unwatched'] = ''; - $res['message'] = wfMsgExt( 'removedwatchtext', array( 'parse' ), $title->getPrefixedText() ); - $success = WatchAction::doUnwatch( $title, $wgUser ); + $res['message'] = $this->msg( 'removedwatchtext', $title->getPrefixedText() )->title( $title )->parseAsBlock(); + $success = UnwatchAction::doUnwatch( $title, $user ); } else { $res['watched'] = ''; - $res['message'] = wfMsgExt( 'addedwatchtext', array( 'parse' ), $title->getPrefixedText() ); - $success = UnwatchAction::doWatch( $title, $wgUser ); + $res['message'] = $this->msg( 'addedwatchtext', $title->getPrefixedText() )->title( $title )->parseAsBlock(); + $success = WatchAction::doWatch( $title, $user ); } if ( !$success ) { $this->dieUsageMsg( 'hookaborted' ); @@ -118,10 +112,10 @@ class ApiWatch extends ApiBase { ) ); } - protected function getExamples() { + public function getExamples() { return array( - 'api.php?action=watch&title=Main_Page', - 'api.php?action=watch&title=Main_Page&unwatch=', + 'api.php?action=watch&title=Main_Page' => 'Watch the page "Main Page"', + 'api.php?action=watch&title=Main_Page&unwatch=' => 'Unwatch the page "Main Page"', ); } -- cgit v1.2.3-54-g00ecf