From 0470a55b77c9441e74371e98204c5d6d78ad3678 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Mon, 18 Nov 2013 23:07:49 +0100 Subject: [PATCH] Update formatting Change-Id: I7586c4d50f7332c515b8377749c4250cc9e04d83 --- includes/changes/ChangesList.php | 8 +- includes/changes/EnhancedChangesList.php | 23 ++-- includes/changes/OldChangesList.php | 2 + includes/changes/RCCacheEntry.php | 1 + includes/changes/RecentChange.php | 152 +++++++++++++---------- 5 files changed, 106 insertions(+), 80 deletions(-) diff --git a/includes/changes/ChangesList.php b/includes/changes/ChangesList.php index a45bc5974a..aa3519b13d 100644 --- a/includes/changes/ChangesList.php +++ b/includes/changes/ChangesList.php @@ -61,6 +61,7 @@ class ChangesList extends ContextSource { $list = null; if ( wfRunHooks( 'FetchChangesList', array( $user, &$sk, &$list ) ) ) { $new = $context->getRequest()->getBool( 'enhanced', $user->getOption( 'usenewrc' ) ); + return $new ? new EnhancedChangesList( $context ) : new OldChangesList( $context ); } else { return $list; @@ -104,6 +105,7 @@ class ChangesList extends ContextSource { ? self::flag( $flag ) : $nothing; } + return $f; } @@ -155,6 +157,7 @@ class ChangesList extends ContextSource { $this->lastdate = ''; $this->rclistOpen = false; $this->getOutput()->addModuleStyles( 'mediawiki.special.changeslist' ); + return ''; } @@ -400,6 +403,7 @@ class ChangesList extends ContextSource { $formatter->setContext( $this->getContext() ); $formatter->setShowUserToolLinks( true ); $mark = $this->getLanguage()->getDirMark(); + return $formatter->getActionText() . " $mark" . $formatter->getComment(); } @@ -417,6 +421,7 @@ class ChangesList extends ContextSource { return Linker::commentBlock( $rc->mAttribs['rc_comment'], $rc->getTitle() ); } } + return ''; } @@ -445,6 +450,7 @@ class ChangesList extends ContextSource { $cache[$count] = $this->msg( 'number_of_watching_users_RCview' ) ->numParams( $count )->escaped(); } + return $cache[$count]; } else { return ''; @@ -502,7 +508,7 @@ class ChangesList extends ContextSource { ) { $page = $rc->getTitle(); /** Check for rollback and edit permissions, disallow special pages, and only - * show a link on the top-most revision */ + * show a link on the top-most revision */ if ( $this->getUser()->isAllowed( 'rollback' ) && $rc->mAttribs['page_latest'] == $rc->mAttribs['rc_this_oldid'] ) { diff --git a/includes/changes/EnhancedChangesList.php b/includes/changes/EnhancedChangesList.php index 4d6a4e7c84..4837525641 100644 --- a/includes/changes/EnhancedChangesList.php +++ b/includes/changes/EnhancedChangesList.php @@ -220,10 +220,10 @@ class EnhancedChangesList extends ChangesList { if ( $block[0]->mAttribs['rc_log_type'] ) { # Log entry $classes[] = Sanitizer::escapeClass( 'mw-changeslist-log-' - . $block[0]->mAttribs['rc_log_type'] . '-' . $block[0]->mAttribs['rc_title'] ); + . $block[0]->mAttribs['rc_log_type'] . '-' . $block[0]->mAttribs['rc_title'] ); } else { $classes[] = Sanitizer::escapeClass( 'mw-changeslist-ns' - . $block[0]->mAttribs['rc_namespace'] . '-' . $block[0]->mAttribs['rc_title'] ); + . $block[0]->mAttribs['rc_namespace'] . '-' . $block[0]->mAttribs['rc_title'] ); } $classes[] = $block[0]->watched && $block[0]->mAttribs['rc_timestamp'] >= $block[0]->watched ? 'mw-changeslist-line-watched' : 'mw-changeslist-line-not-watched'; @@ -467,11 +467,11 @@ class EnhancedChangesList extends ChangesList { } else { $link = Linker::linkKnown( - $rcObj->getTitle(), - $rcObj->timestamp, - array(), - $params - ); + $rcObj->getTitle(), + $rcObj->timestamp, + array(), + $params + ); if ( $this->isDeleted( $rcObj, Revision::DELETED_TEXT ) ) { $link = '' . $link . ' '; } @@ -532,6 +532,7 @@ class EnhancedChangesList extends ChangesList { $encUrl = htmlspecialchars( $wgStylePath . '/common/images/Arr_' . $dir . '.png' ); $encAlt = htmlspecialchars( $alt ); $encTitle = htmlspecialchars( $title ); + return "\"$encAlt\""; } @@ -542,6 +543,7 @@ class EnhancedChangesList extends ChangesList { */ protected function sideArrow() { $dir = $this->getLanguage()->isRTL() ? 'l' : 'r'; + return $this->arrow( $dir, '+', $this->msg( 'rc-enhanced-expand' )->text() ); } @@ -580,10 +582,10 @@ class EnhancedChangesList extends ChangesList { if ( $logType ) { # Log entry $classes[] = Sanitizer::escapeClass( 'mw-changeslist-log-' - . $logType . '-' . $rcObj->mAttribs['rc_title'] ); + . $logType . '-' . $rcObj->mAttribs['rc_title'] ); } else { $classes[] = Sanitizer::escapeClass( 'mw-changeslist-ns' . - $rcObj->mAttribs['rc_namespace'] . '-' . $rcObj->mAttribs['rc_title'] ); + $rcObj->mAttribs['rc_namespace'] . '-' . $rcObj->mAttribs['rc_title'] ); } $classes[] = $rcObj->watched && $rcObj->mAttribs['rc_timestamp'] >= $rcObj->watched ? 'mw-changeslist-line-watched' : 'mw-changeslist-line-not-watched'; @@ -660,7 +662,7 @@ class EnhancedChangesList extends ChangesList { * @return string */ protected function recentChangesBlock() { - if ( count ( $this->rc_cache ) == 0 ) { + if ( count( $this->rc_cache ) == 0 ) { return ''; } @@ -688,5 +690,4 @@ class EnhancedChangesList extends ChangesList { public function endRecentChangesList() { return $this->recentChangesBlock() . parent::endRecentChangesList(); } - } diff --git a/includes/changes/OldChangesList.php b/includes/changes/OldChangesList.php index e9a6a43544..bcdb33edd2 100644 --- a/includes/changes/OldChangesList.php +++ b/includes/changes/OldChangesList.php @@ -122,10 +122,12 @@ class OldChangesList extends ChangesList { if ( !wfRunHooks( 'OldChangesListRecentChangesLine', array( &$this, &$s, $rc, &$classes ) ) ) { wfProfileOut( __METHOD__ ); + return false; } wfProfileOut( __METHOD__ ); + return "$dateheader
  • " . $s . "
  • \n"; } } diff --git a/includes/changes/RCCacheEntry.php b/includes/changes/RCCacheEntry.php index 9aef3d30e2..3fa5c32986 100644 --- a/includes/changes/RCCacheEntry.php +++ b/includes/changes/RCCacheEntry.php @@ -30,6 +30,7 @@ class RCCacheEntry extends RecentChange { $rc2 = new RCCacheEntry; $rc2->mAttribs = $rc->mAttribs; $rc2->mExtra = $rc->mExtra; + return $rc2; } } diff --git a/includes/changes/RecentChange.php b/includes/changes/RecentChange.php index 5c5907ddc0..a6920f64ef 100644 --- a/includes/changes/RecentChange.php +++ b/includes/changes/RecentChange.php @@ -100,6 +100,7 @@ class RecentChange { public static function newFromRow( $row ) { $rc = new RecentChange; $rc->loadFromRow( $row ); + return $rc; } @@ -114,6 +115,7 @@ class RecentChange { $rc->loadFromCurRow( $row ); $rc->notificationtimestamp = false; $rc->numberofWatchingusers = false; + return $rc; } @@ -203,6 +205,7 @@ class RecentChange { if ( $this->mTitle === false ) { $this->mTitle = Title::makeTitle( $this->mAttribs['rc_namespace'], $this->mAttribs['rc_title'] ); } + return $this->mTitle; } @@ -219,6 +222,7 @@ class RecentChange { $this->mPerformer = User::newFromName( $this->mAttribs['rc_user_text'], false ); } } + return $this->mPerformer; } @@ -380,6 +384,7 @@ class RecentChange { */ public static function cleanupForIRC( $text ) { wfDeprecated( __METHOD__, '1.22' ); + return IRCColourfulRCFeedFormatter::cleanupForIRC( $text ); } @@ -400,6 +405,7 @@ class RecentChange { if ( !$change instanceof RecentChange ) { return null; } + return $change->doMarkPatrolled( $wgUser, $auto ); } @@ -445,6 +451,7 @@ class RecentChange { // Log this patrol event PatrolLog::record( $this, $auto, $user ); wfRunHooks( 'MarkPatrolledComplete', array( $this->getAttribute( 'rc_id' ), &$user, false ) ); + return array(); } @@ -467,6 +474,7 @@ class RecentChange { // Invalidate the page cache after the page has been patrolled // to make sure that the Patrol link isn't visible any longer! $this->getTitle()->invalidateCache(); + return $dbw->affectedRows(); } @@ -494,39 +502,40 @@ class RecentChange { $rc->mTitle = $title; $rc->mPerformer = $user; $rc->mAttribs = array( - 'rc_timestamp' => $timestamp, - 'rc_namespace' => $title->getNamespace(), - 'rc_title' => $title->getDBkey(), - 'rc_type' => RC_EDIT, - 'rc_source' => self::SRC_EDIT, - 'rc_minor' => $minor ? 1 : 0, - 'rc_cur_id' => $title->getArticleID(), - 'rc_user' => $user->getId(), - 'rc_user_text' => $user->getName(), - 'rc_comment' => $comment, + 'rc_timestamp' => $timestamp, + 'rc_namespace' => $title->getNamespace(), + 'rc_title' => $title->getDBkey(), + 'rc_type' => RC_EDIT, + 'rc_source' => self::SRC_EDIT, + 'rc_minor' => $minor ? 1 : 0, + 'rc_cur_id' => $title->getArticleID(), + 'rc_user' => $user->getId(), + 'rc_user_text' => $user->getName(), + 'rc_comment' => $comment, 'rc_this_oldid' => $newId, 'rc_last_oldid' => $oldId, - 'rc_bot' => $bot ? 1 : 0, - 'rc_ip' => self::checkIPAddress( $ip ), - 'rc_patrolled' => intval( $patrol ), - 'rc_new' => 0, # obsolete - 'rc_old_len' => $oldSize, - 'rc_new_len' => $newSize, - 'rc_deleted' => 0, - 'rc_logid' => 0, - 'rc_log_type' => null, + 'rc_bot' => $bot ? 1 : 0, + 'rc_ip' => self::checkIPAddress( $ip ), + 'rc_patrolled' => intval( $patrol ), + 'rc_new' => 0, # obsolete + 'rc_old_len' => $oldSize, + 'rc_new_len' => $newSize, + 'rc_deleted' => 0, + 'rc_logid' => 0, + 'rc_log_type' => null, 'rc_log_action' => '', - 'rc_params' => '' + 'rc_params' => '' ); $rc->mExtra = array( 'prefixedDBkey' => $title->getPrefixedDBkey(), 'lastTimestamp' => $lastTimestamp, - 'oldSize' => $oldSize, - 'newSize' => $newSize, - 'pageStatus' => 'changed' + 'oldSize' => $oldSize, + 'newSize' => $newSize, + 'pageStatus' => 'changed' ); $rc->save(); + return $rc; } @@ -553,29 +562,29 @@ class RecentChange { $rc->mTitle = $title; $rc->mPerformer = $user; $rc->mAttribs = array( - 'rc_timestamp' => $timestamp, - 'rc_namespace' => $title->getNamespace(), - 'rc_title' => $title->getDBkey(), - 'rc_type' => RC_NEW, - 'rc_source' => self::SRC_NEW, - 'rc_minor' => $minor ? 1 : 0, - 'rc_cur_id' => $title->getArticleID(), - 'rc_user' => $user->getId(), - 'rc_user_text' => $user->getName(), - 'rc_comment' => $comment, - 'rc_this_oldid' => $newId, - 'rc_last_oldid' => 0, - 'rc_bot' => $bot ? 1 : 0, - 'rc_ip' => self::checkIPAddress( $ip ), - 'rc_patrolled' => intval( $patrol ), - 'rc_new' => 1, # obsolete - 'rc_old_len' => 0, - 'rc_new_len' => $size, - 'rc_deleted' => 0, - 'rc_logid' => 0, - 'rc_log_type' => null, - 'rc_log_action' => '', - 'rc_params' => '' + 'rc_timestamp' => $timestamp, + 'rc_namespace' => $title->getNamespace(), + 'rc_title' => $title->getDBkey(), + 'rc_type' => RC_NEW, + 'rc_source' => self::SRC_NEW, + 'rc_minor' => $minor ? 1 : 0, + 'rc_cur_id' => $title->getArticleID(), + 'rc_user' => $user->getId(), + 'rc_user_text' => $user->getName(), + 'rc_comment' => $comment, + 'rc_this_oldid' => $newId, + 'rc_last_oldid' => 0, + 'rc_bot' => $bot ? 1 : 0, + 'rc_ip' => self::checkIPAddress( $ip ), + 'rc_patrolled' => intval( $patrol ), + 'rc_new' => 1, # obsolete + 'rc_old_len' => 0, + 'rc_new_len' => $size, + 'rc_deleted' => 0, + 'rc_logid' => 0, + 'rc_log_type' => null, + 'rc_log_action' => '', + 'rc_params' => '' ); $rc->mExtra = array( @@ -586,6 +595,7 @@ class RecentChange { 'pageStatus' => 'created' ); $rc->save(); + return $rc; } @@ -616,6 +626,7 @@ class RecentChange { $rc = self::newLogEntry( $timestamp, $title, $user, $actionComment, $ip, $type, $action, $target, $logComment, $params, $newId, $actionCommentIRC ); $rc->save(); + return true; } @@ -663,38 +674,39 @@ class RecentChange { $rc->mTitle = $target; $rc->mPerformer = $user; $rc->mAttribs = array( - 'rc_timestamp' => $timestamp, - 'rc_namespace' => $target->getNamespace(), - 'rc_title' => $target->getDBkey(), - 'rc_type' => RC_LOG, - 'rc_source' => self::SRC_LOG, - 'rc_minor' => 0, - 'rc_cur_id' => $target->getArticleID(), - 'rc_user' => $user->getId(), - 'rc_user_text' => $user->getName(), - 'rc_comment' => $logComment, + 'rc_timestamp' => $timestamp, + 'rc_namespace' => $target->getNamespace(), + 'rc_title' => $target->getDBkey(), + 'rc_type' => RC_LOG, + 'rc_source' => self::SRC_LOG, + 'rc_minor' => 0, + 'rc_cur_id' => $target->getArticleID(), + 'rc_user' => $user->getId(), + 'rc_user_text' => $user->getName(), + 'rc_comment' => $logComment, 'rc_this_oldid' => 0, 'rc_last_oldid' => 0, - 'rc_bot' => $user->isAllowed( 'bot' ) ? $wgRequest->getBool( 'bot', true ) : 0, - 'rc_ip' => self::checkIPAddress( $ip ), - 'rc_patrolled' => 1, - 'rc_new' => 0, # obsolete - 'rc_old_len' => null, - 'rc_new_len' => null, - 'rc_deleted' => 0, - 'rc_logid' => $newId, - 'rc_log_type' => $type, + 'rc_bot' => $user->isAllowed( 'bot' ) ? $wgRequest->getBool( 'bot', true ) : 0, + 'rc_ip' => self::checkIPAddress( $ip ), + 'rc_patrolled' => 1, + 'rc_new' => 0, # obsolete + 'rc_old_len' => null, + 'rc_new_len' => null, + 'rc_deleted' => 0, + 'rc_logid' => $newId, + 'rc_log_type' => $type, 'rc_log_action' => $action, - 'rc_params' => $params + 'rc_params' => $params ); $rc->mExtra = array( 'prefixedDBkey' => $title->getPrefixedDBkey(), 'lastTimestamp' => 0, 'actionComment' => $actionComment, // the comment appended to the action, passed from LogPage - 'pageStatus' => $pageStatus, + 'pageStatus' => $pageStatus, 'actionCommentIRC' => $actionCommentIRC ); + return $rc; } @@ -780,6 +792,7 @@ class RecentChange { } else { $trail = ''; } + return $trail; } @@ -800,6 +813,7 @@ class RecentChange { if ( $old === null || $new === null ) { return ''; } + return ChangesList::showCharacterDifference( $old, $new ); } @@ -814,7 +828,7 @@ class RecentChange { $method = __METHOD__; $dbw = wfGetDB( DB_MASTER ); - $dbw->onTransactionIdle( function() use ( $dbw, $method ) { + $dbw->onTransactionIdle( function () use ( $dbw, $method ) { global $wgRCMaxAge; $cutoff = $dbw->timestamp( time() - $wgRCMaxAge ); @@ -839,6 +853,7 @@ class RecentChange { $ip = ''; } } + return $ip; } @@ -853,6 +868,7 @@ class RecentChange { */ public static function isInRCLifespan( $timestamp, $tolerance = 0 ) { global $wgRCMaxAge; + return wfTimestamp( TS_UNIX, $timestamp ) > time() - $tolerance - $wgRCMaxAge; } } -- 2.20.1