Merge "Making listToText() not break if passed a 1-item list."
[lhc/web/wiklou.git] / includes / api / ApiWatch.php
index 3518ea8..0509f1f 100644 (file)
@@ -4,7 +4,7 @@
  *
  * Created on Jan 4, 2008
  *
- * Copyright © 2008 Yuri Astrakhan <Firstname><Lastname>@gmail.com,
+ * Copyright © 2008 Yuri Astrakhan "<Firstname><Lastname>@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
  * @file
  */
 
-if ( !defined( 'MEDIAWIKI' ) ) {
-       // Eclipse helper - will be ignored in production
-       require_once( 'ApiBase.php' );
-}
-
 /**
  * API module to allow users to watch a page
  *
@@ -53,16 +48,15 @@ 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() );
+                       $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() );
+                       $res['message'] = $this->msg( 'addedwatchtext', $title->getPrefixedText() )->title( $title )->parseAsBlock();
                        $success = WatchAction::doWatch( $title, $user );
                }
                if ( !$success ) {
@@ -94,7 +88,10 @@ class ApiWatch extends ApiBase {
                                ApiBase::PARAM_REQUIRED => true
                        ),
                        'unwatch' => false,
-                       'token' => null,
+                       'token' => array(
+                               ApiBase::PARAM_TYPE => 'string',
+                               ApiBase::PARAM_REQUIRED => true
+                       ),
                );
        }
 
@@ -106,6 +103,17 @@ class ApiWatch extends ApiBase {
                );
        }
 
+       public function getResultProperties() {
+               return array(
+                       '' => array(
+                               'title' => 'string',
+                               'unwatched' => 'boolean',
+                               'watched' => 'boolean',
+                               'message' => 'string'
+                       )
+               );
+       }
+
        public function getDescription() {
                return 'Add or remove a page from/to the current user\'s watchlist';
        }
@@ -120,13 +128,13 @@ class ApiWatch extends ApiBase {
 
        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"',
                );
        }
 
        public function getHelpUrls() {
-               return 'http://www.mediawiki.org/wiki/API:Watch';
+               return 'https://www.mediawiki.org/wiki/API:Watch';
        }
 
        public function getVersion() {