Call Linker methods statically
[lhc/web/wiklou.git] / includes / api / ApiQueryWatchlist.php
index 0443eeb..2e45fdf 100644 (file)
@@ -101,20 +101,14 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
                                'rc_last_oldid',
                        ) );
 
-                       $this->addFieldsIf( 'rc_new', $this->fld_flags );
-                       $this->addFieldsIf( 'rc_minor', $this->fld_flags );
-                       $this->addFieldsIf( 'rc_bot', $this->fld_flags );
+                       $this->addFieldsIf( array( 'rc_new', 'rc_minor', 'rc_bot' ), $this->fld_flags );
                        $this->addFieldsIf( 'rc_user', $this->fld_user || $this->fld_userid );
                        $this->addFieldsIf( 'rc_user_text', $this->fld_user );
                        $this->addFieldsIf( 'rc_comment', $this->fld_comment || $this->fld_parsedcomment );
                        $this->addFieldsIf( 'rc_patrolled', $this->fld_patrol );
-                       $this->addFieldsIf( 'rc_old_len', $this->fld_sizes );
-                       $this->addFieldsIf( 'rc_new_len', $this->fld_sizes );
+                       $this->addFieldsIf( array( 'rc_old_len', 'rc_new_len' ), $this->fld_sizes );
                        $this->addFieldsIf( 'wl_notificationtimestamp', $this->fld_notificationtimestamp );
-                       $this->addFieldsIf( 'rc_logid', $this->fld_loginfo );
-                       $this->addFieldsIf( 'rc_log_type', $this->fld_loginfo );
-                       $this->addFieldsIf( 'rc_log_action', $this->fld_loginfo );
-                       $this->addFieldsIf( 'rc_params', $this->fld_loginfo );
+                       $this->addFieldsIf( array( 'rc_logid', 'rc_log_type', 'rc_log_action', 'rc_params' ), $this->fld_loginfo );
                } elseif ( $params['allrev'] ) {
                        $this->addFields( 'rc_this_oldid' );
                } else {
@@ -124,7 +118,6 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
                $this->addTables( array(
                        'recentchanges',
                        'watchlist',
-                       'page',
                ) );
 
                $userId = $user->getId();
@@ -134,19 +127,23 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
                                'wl_namespace=rc_namespace',
                                'wl_title=rc_title'
                ) ) ) );
-               $this->addJoinConds( array( 'page' => array( 'LEFT JOIN','rc_cur_id=page_id' ) ) );
 
                $this->addWhere( array(
                        'rc_deleted' => 0,
                ) );
-               
+
                $db = $this->getDB();
 
-               $this->addWhereRange( 'rc_timestamp', $params['dir'], 
-                       $db->timestamp( $params['start'] ), 
+               $this->addWhereRange( 'rc_timestamp', $params['dir'],
+                       $db->timestamp( $params['start'] ),
                        $db->timestamp( $params['end'] ) );
                $this->addWhereFld( 'wl_namespace', $params['namespace'] );
-               $this->addWhereIf( 'rc_this_oldid=page_latest OR rc_type=' . RC_LOG, !$params['allrev'] );
+
+               if ( !$params['allrev'] ) {
+                       $this->addTables( 'page' );
+                       $this->addJoinConds( array( 'page' => array( 'LEFT JOIN','rc_cur_id=page_id' ) ) );
+                       $this->addWhere( 'rc_this_oldid=page_latest OR rc_type=' . RC_LOG );
+               }
 
                if ( !is_null( $params['show'] ) ) {
                        $show = array_flip( $params['show'] );
@@ -298,8 +295,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
                }
 
                if ( $this->fld_parsedcomment && isset( $row->rc_comment ) ) {
-                       global $wgUser;
-                       $vals['parsedcomment'] = $wgUser->getSkin()->formatComment( $row->rc_comment, $title );
+                       $vals['parsedcomment'] = Linker::formatComment( $row->rc_comment, $title );
                }
 
                if ( $this->fld_loginfo && $row->rc_type == RC_LOG ) {
@@ -443,7 +439,7 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
                ) );
        }
 
-       protected function getExamples() {
+       public function getExamples() {
                return array(
                        'api.php?action=query&list=watchlist',
                        'api.php?action=query&list=watchlist&wlprop=ids|title|timestamp|user|comment',
@@ -454,6 +450,10 @@ class ApiQueryWatchlist extends ApiQueryGeneratorBase {
                );
        }
 
+       public function getHelpUrls() {
+               return 'http://www.mediawiki.org/wiki/API:Watchlist';
+       }
+
        public function getVersion() {
                return __CLASS__ . ': $Id$';
        }