Minor code style tweaks & cleanup
authorAaron Schulz <aaron@users.mediawiki.org>
Fri, 9 Jan 2009 23:18:47 +0000 (23:18 +0000)
committerAaron Schulz <aaron@users.mediawiki.org>
Fri, 9 Jan 2009 23:18:47 +0000 (23:18 +0000)
includes/ChangesList.php
includes/LogPage.php
includes/RecentChange.php

index a8f5fff..66bd8d9 100644 (file)
@@ -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  = "<span id='mw-rc-openarrow-$jsid' class='mw-changeslist-expanded' style='visibility:hidden'><a href='#' $toggleLink title='$expandTitle'>" . $this->sideArrow() . "</a></span>";
+               $tl = "<span id='mw-rc-openarrow-$jsid' class='mw-changeslist-expanded' style='visibility:hidden'><a href='#' $toggleLink title='$expandTitle'>" . $this->sideArrow() . "</a></span>";
                $tl .= "<span id='mw-rc-closearrow-$jsid' class='mw-changeslist-hidden' style='display:none'><a href='#' $toggleLink title='$closeTitle'>" . $this->downArrow() . "</a></span>";
                $r .= '<td valign="top" style="white-space: nowrap"><tt>'.$tl.'&nbsp;';
 
index f0220a9..63f081e 100644 (file)
@@ -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 {
index 17f06cc..885ff45 100644 (file)
@@ -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;