Wikia code/includes/api/ApiQueryWatchlist.php

< Wikia code‎ | includes‎ | api
--- D:\Programming\SVN\mediawiki\branches\REL1_16\phase3\includes\api\ApiQueryWatchlist.php	2011-07-18 22:31:07.105468800 +0100
+++ D:\Programming\SVN\wikia\trunk\includes\api\ApiQueryWatchlist.php	2011-08-17 15:28:14.324218700 +0100
@@ -77,6 +77,7 @@
 		if ( !is_null( $params['prop'] ) && is_null( $resultPageSet ) ) {
 
 			$prop = array_flip( $params['prop'] );
+			$this->fld_wikiamode = isset($prop['wikiamode']);
 
 			$this->fld_ids = isset( $prop['ids'] );
 			$this->fld_title = isset( $prop['title'] );
@@ -107,18 +108,29 @@
 				'rc_this_oldid'
 			) );
 
+			$this->addFieldsIf('rc_type', $this->fld_wikiamode);
+			$this->addFieldsIf('rc_params', $this->fld_wikiamode);
+			$this->addFieldsIf('rc_logid', $this->fld_wikiamode);
+			$this->addFieldsIf('rc_log_type', $this->fld_wikiamode);
+			$this->addFieldsIf('rc_log_action', $this->fld_wikiamode);
+			$this->addFieldsIf('rc_last_oldid', $this->fld_wikiamode);
 			$this->addFieldsIf( 'rc_new', $this->fld_flags );
 			$this->addFieldsIf( 'rc_minor', $this->fld_flags );
 			$this->addFieldsIf( 'rc_bot', $this->fld_flags );
 			$this->addFieldsIf( 'rc_user', $this->fld_user );
 			$this->addFieldsIf( 'rc_user_text', $this->fld_user );
-			$this->addFieldsIf( 'rc_comment', $this->fld_comment || $this->fld_parsedcomment );
+			$this->addFieldsIf('rc_comment', $this->fld_comment);
 			$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( 'wl_notificationtimestamp', $this->fld_notificationtimestamp );
-		} elseif ( $params['allrev'] ) {
-			$this->addFields( 'rc_this_oldid' );
+		}
+		elseif ($params['allrev']) {
+			$this->addFields(array (
+				'rc_this_oldid',
+				'rc_namespace',
+				'rc_title',
+				'rc_timestamp'
+			));
 		} else {
 			$this->addFields( 'rc_cur_id' );
 		}
@@ -138,9 +150,28 @@
 			'rc_deleted' => 0,
 		) );
 
+		if(!$this->fld_wikiamode) {
+			$this->addWhere(array (
+				'wl_namespace = rc_namespace',
+				'wl_title = rc_title',
+				'rc_cur_id = page_id',
+				'wl_user' => $userId,
+				'rc_deleted' => 0,
+			));
+		} else {
+			$this->addJoinConds(array(
+				'watchlist' => array('INNER JOIN', array('wl_namespace=rc_namespace AND wl_title=rc_title',	'wl_user' => $userId)),
+				'page' => array('LEFT JOIN', array('rc_cur_id=page_id')),
+			));
+		}
+
 		$this->addWhereRange( 'rc_timestamp', $params['dir'], $params['start'], $params['end'] );
 		$this->addWhereFld( 'wl_namespace', $params['namespace'] );
+		if(!$this->fld_wikiamode) {
 		$this->addWhereIf( 'rc_this_oldid=page_latest', !$params['allrev'] );
+		} else {
+			$this->addWhereIf('(rc_this_oldid=page_latest OR rc_type=3)', !$params['allrev']);
+		}
 
 		if ( !is_null( $params['show'] ) ) {
 			$show = array_flip( $params['show'] );
@@ -228,6 +259,24 @@
 
 		$vals = array ();
 
+		if ($this->fld_wikiamode) {
+			$vals['rc_params'] = $row->rc_params;
+			$type = intval ( $row->rc_type );
+			switch ( $type ) {
+				case RC_EDIT:  $vals['type'] = 'edit'; break;
+				case RC_NEW:   $vals['type'] = 'new'; break;
+				case RC_MOVE:  $vals['type'] = 'move'; break;
+				case RC_LOG:   $vals['type'] = 'log'; break;
+				case RC_MOVE_OVER_REDIRECT: $vals['type'] = 'move over redirect'; break;
+				default: $vals['type'] = $type;
+			}
+			if($row->rc_type == RC_LOG) {
+				$vals['logtype'] = $row->rc_log_type;
+				$vals['logaction'] = $row->rc_log_action;
+			}
+			$vals['old_revid'] = $row->rc_last_oldid;
+		}
+
 		if ( $this->fld_ids ) {
 			$vals['pageid'] = intval( $row->rc_cur_id );
 			$vals['revid'] = intval( $row->rc_this_oldid );
@@ -324,6 +373,7 @@
 					'timestamp',
 					'patrol',
 					'sizes',
+					'wikiamode',
 					'notificationtimestamp'
 				)
 			),