From 6059b4d6adef361cb6d5469fd738e554c2eaf3c4 Mon Sep 17 00:00:00 2001 From: Aaron Schulz Date: Fri, 9 Jan 2009 23:18:47 +0000 Subject: [PATCH] Minor code style tweaks & cleanup --- includes/ChangesList.php | 12 +++++------- includes/LogPage.php | 20 ++++++++------------ includes/RecentChange.php | 18 ++++-------------- 3 files changed, 17 insertions(+), 33 deletions(-) diff --git a/includes/ChangesList.php b/includes/ChangesList.php index a8f5fff01e..66bd8d99bd 100644 --- a/includes/ChangesList.php +++ b/includes/ChangesList.php @@ -508,10 +508,8 @@ class EnhancedChangesList extends ChangesList { if( !$showdifflinks ) { $curLink = $this->message['cur']; $diffLink = $this->message['diff']; - } else if( $rc_type == RC_NEW || $rc_type == RC_LOG || $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) { - if( $rc_type != RC_NEW ) { - $curLink = $this->message['cur']; - } + } else if( in_array( $rc_type, array(RC_NEW,RC_LOG,RC_MOVE,RC_MOVE_OVER_REDIRECT) ) ) { + $curLink = ($rc_type != RC_NEW) ? $this->message['cur'] : $curLink; $diffLink = $this->message['diff']; } else { $diffLink = $this->skin->makeKnownLinkObj( $rc->getTitle(), $this->message['diff'], @@ -519,9 +517,9 @@ class EnhancedChangesList extends ChangesList { } # Make "last" link - if( !$showdifflinks ) { + if( !$showdifflinks || !$rc_last_oldid ) { $lastLink = $this->message['last']; - } else if( $rc_last_oldid == 0 || $rc_type == RC_LOG || $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) { + } else if( $rc_type == RC_LOG || $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT ) { $lastLink = $this->message['last']; } else { $lastLink = $this->skin->makeKnownLinkObj( $rc->getTitle(), $this->message['last'], @@ -633,7 +631,7 @@ class EnhancedChangesList extends ChangesList { $expandTitle = htmlspecialchars( wfMsg('rc-enhanced-expand') ); $closeTitle = htmlspecialchars( wfMsg('rc-enhanced-hide') ); - $tl = ""; + $tl = ""; $tl .= ""; $r .= ''.$tl.' '; diff --git a/includes/LogPage.php b/includes/LogPage.php index f0220a9dd3..63f081ecc0 100644 --- a/includes/LogPage.php +++ b/includes/LogPage.php @@ -47,15 +47,14 @@ class LogPage { * @param bool $rc Whether to update recent changes as well as the logging table * @param bool $udp Whether to send to the UDP feed */ - function __construct( $type, $rc = true, $udp = true ) { + public function __construct( $type, $rc = true, $udp = true ) { $this->type = $type; $this->updateRecentChanges = $rc; $this->sendToUDP = $udp; } protected function saveContent() { - global $wgUser, $wgLogRestrictions; - $fname = 'LogPage::saveContent'; + global $wgLogRestrictions; $dbw = wfGetDB( DB_MASTER ); $log_id = $dbw->nextSequenceValue( 'log_log_id_seq' ); @@ -72,12 +71,9 @@ class LogPage { 'log_comment' => $this->comment, 'log_params' => $this->params ); - $dbw->insert( 'logging', $data, $fname ); + $dbw->insert( 'logging', $data, __METHOD__ ); $newId = !is_null($log_id) ? $log_id : $dbw->insertId(); - if( !($dbw->affectedRows() > 0) ) { - wfDebugLog( "logging", "LogPage::saveContent failed to insert row - Error {$dbw->lastErrno()}: {$dbw->lastError()}" ); - } # And update recentchanges if( $this->updateRecentChanges ) { $titleObj = SpecialPage::getTitleFor( 'Log', $this->type ); @@ -157,7 +153,7 @@ class LogPage { * @param string $type logtype * @return string Headertext of this logtype */ - static function logHeader( $type ) { + public static function logHeader( $type ) { global $wgLogHeaders, $wgMessageCache; $wgMessageCache->loadAllMessages(); return wfMsgExt($wgLogHeaders[$type],array('parseinline')); @@ -167,7 +163,7 @@ class LogPage { * @static * @return HTML string */ - static function actionText( $type, $action, $title = NULL, $skin = NULL, + public static function actionText( $type, $action, $title = NULL, $skin = NULL, $params = array(), $filterWikilinks = false ) { global $wgLang, $wgContLang, $wgLogActions, $wgMessageCache; @@ -308,7 +304,7 @@ class LogPage { * @param array $params Parameters passed later to wfMsg.* functions * @param User $doer The user doing the action */ - function addEntry( $action, $target, $comment, $params = array(), $doer = null ) { + public function addEntry( $action, $target, $comment, $params = array(), $doer = null ) { if ( !is_array( $params ) ) { $params = array( $params ); } @@ -336,7 +332,7 @@ class LogPage { * Create a blob from a parameter array * @static */ - static function makeParamBlob( $params ) { + public static function makeParamBlob( $params ) { return implode( "\n", $params ); } @@ -344,7 +340,7 @@ class LogPage { * Extract a parameter array from a blob * @static */ - static function extractParams( $blob ) { + public static function extractParams( $blob ) { if ( $blob === '' ) { return array(); } else { diff --git a/includes/RecentChange.php b/includes/RecentChange.php index 17f06cc323..885ff45532 100644 --- a/includes/RecentChange.php +++ b/includes/RecentChange.php @@ -318,9 +318,7 @@ class RecentChange { if( !$ip ) { $ip = wfGetIP(); - if( !$ip ) { - $ip = ''; - } + if( !$ip ) $ip = ''; } $rc = new RecentChange; @@ -372,9 +370,7 @@ class RecentChange { if( !$ip ) { $ip = wfGetIP(); - if( !$ip ) { - $ip = ''; - } + if( !$ip ) $ip = ''; } $rc = new RecentChange; @@ -420,12 +416,9 @@ class RecentChange public static function notifyMove( $timestamp, &$oldTitle, &$newTitle, &$user, $comment, $ip='', $overRedir = false ) { global $wgRequest; - if( !$ip ) { $ip = wfGetIP(); - if( !$ip ) { - $ip = ''; - } + if( !$ip ) $ip = ''; } $rc = new RecentChange; @@ -491,12 +484,9 @@ class RecentChange $type, $action, $target, $logComment, $params, $newId=0 ) { global $wgRequest; - if( !$ip ) { $ip = wfGetIP(); - if( !$ip ) { - $ip = ''; - } + if( !$ip ) $ip = ''; } $rc = new RecentChange; -- 2.20.1