* PageHistory::diffButtons
[lhc/web/wiklou.git] / includes / PageHistory.php
index 932ab61..5f1388a 100644 (file)
@@ -37,20 +37,6 @@ class PageHistory {
                $this->mTitle =& $article->mTitle;
                $this->mNotificationTimestamp = NULL;
                $this->mSkin = $wgUser->getSkin();
-               $this->preCacheMessages();
-       }
-       
-       /**
-        * As we use the same small set of messages in various methods and that
-        * they are called often, we call them once and save them in $this->message
-        */
-       function preCacheMessages() {
-               // Precache various messages
-               if( !isset( $this->message ) ) {
-                       foreach( explode(' ', 'cur last rev-delundel' ) as $msg ) {
-                               $this->message[$msg] = wfMsgExt( $msg, array( 'escape') );
-                       }
-               }
        }
 
        /**
@@ -84,9 +70,7 @@ class PageHistory {
 
                $logPage = SpecialPage::getTitleFor( 'Log' );
                $logLink = $this->mSkin->makeKnownLinkObj( $logPage, wfMsgHtml( 'viewpagelogs' ), 'page=' . $this->mTitle->getPrefixedUrl() );
-
-               $subtitle = wfMsgHtml( 'revhistory' ) . '<br />' . $logLink;
-               $wgOut->setSubtitle( $subtitle );
+               $wgOut->setSubtitle( $logLink );
 
                $feedType = $wgRequest->getVal( 'feed' );
                if( $feedType ) {
@@ -103,7 +87,6 @@ class PageHistory {
                        return;
                }
 
-               
                /*
                 * "go=first" means to jump to the last (earliest) history page.
                 * This is deprecated, it no longer appears in the user interface
@@ -113,7 +96,7 @@ class PageHistory {
                        $wgOut->redirect( $wgTitle->getLocalURL( "action=history&limit={$limit}&dir=prev" ) );
                        return;
                }
-               
+
                wfRunHooks( 'PageHistoryBeforeList', array( &$this->mArticle ) );
 
                /** 
@@ -203,40 +186,44 @@ class PageHistory {
                $arbitrary = $this->diffButtons( $rev, $firstInList, $counter );
                $link = $this->revLink( $rev );
                
+               $user = $this->mSkin->userLink( $rev->getUser(), $rev->getUserText() )
+                               . $this->mSkin->userToolLinks( $rev->getUser(), $rev->getUserText() );
+               
                $s .= "($curlink) ($lastlink) $arbitrary";
                
                if( $wgUser->isAllowed( 'deleterevision' ) ) {
                        $revdel = SpecialPage::getTitleFor( 'Revisiondelete' );
                        if( $firstInList ) {
-                       // We don't currently handle well changing the top revision's settings
-                               $del = $this->message['rev-delundel'];
+                               // We don't currently handle well changing the top revision's settings
+                               $del = wfMsgHtml( 'rev-delundel' );
                        } else if( !$rev->userCan( Revision::DELETED_RESTRICTED ) ) {
                        // If revision was hidden from sysops
-                               $del = $this->message['rev-delundel'];  
+                               $del = wfMsgHtml( 'rev-delundel' );                     
                        } else {
                                $del = $this->mSkin->makeKnownLinkObj( $revdel,
-                                       $this->message['rev-delundel'],
+                                       wfMsg( 'rev-delundel' ),
                                        'target=' . urlencode( $this->mTitle->getPrefixedDbkey() ) .
                                        '&oldid=' . urlencode( $rev->getId() ) );
-                               // Bolden oversighted content
-                               if( $rev->isDeleted( Revision::DELETED_RESTRICTED ) )
-                                       $del = "<strong>$del</strong>";
                        }
-                       $s .= " <tt>(<small>$del</small>)</tt> ";
+                       $s .= " (<small>$del</small>) ";
                }
                
                $s .= " $link";
-               $s .= ' '.$this->mSkin->revUserTools( $rev, true);
-               
+               #getUser is safe, but this avoids making the invalid untargeted contribs links
+               if( $row->rev_deleted & Revision::DELETED_USER ) {
+                       $user = '<span class="history-deleted">' . wfMsg('rev-deleted-user') . '</span>';
+               }
+               $s .= " <span class='history-user'>$user</span>";
+
                if( $row->rev_minor_edit ) {
                        $s .= ' ' . wfElement( 'span', array( 'class' => 'minor' ), wfMsg( 'minoreditletter') );
                }
 
-               if (!is_null($size = $rev->getSize())) {
-                       if ($size == 0)
-                               $stxt = wfMsgHtml('historyempty');
+               if ( !is_null( $size = $rev->getSize() ) ) {
+                       if ( $size == 0 )
+                               $stxt = wfMsgHtml( 'historyempty' );
                        else
-                               $stxt = wfMsgHtml('historysize', $wgLang->formatNum( $size ) );
+                               $stxt = wfMsgExt( 'historysize', array( 'parsemag' ), $wgLang->formatNum( $size ) );
                        $s .= " <span class=\"history-size\">$stxt</span>";
                }
 
@@ -253,7 +240,7 @@ class PageHistory {
                }
                #add blurb about text having been deleted
                if( $row->rev_deleted & Revision::DELETED_TEXT ) {
-                       $s .= ' <tt>' . wfMsgHtml( 'deletedrev' ) . '</tt>';
+                       $s .= ' ' . wfMsgHtml( 'deletedrev' );
                }
                
                $tools = array();
@@ -302,7 +289,7 @@ class PageHistory {
 
        /** @todo document */
        function curLink( $rev, $latest ) {
-               $cur = $this->message['cur'];
+               $cur = wfMsgExt( 'cur', array( 'escape') );
                if( $latest || !$rev->userCan( Revision::DELETED_TEXT ) ) {
                        return $cur;
                } else {
@@ -315,7 +302,7 @@ class PageHistory {
 
        /** @todo document */
        function lastLink( $rev, $next, $counter ) {
-               $last = $this->message['last'];
+               $last = wfMsgExt( 'last', array( 'escape' ) );
                if ( is_null( $next ) ) {
                        # Probably no next row
                        return $last;
@@ -339,14 +326,19 @@ class PageHistory {
                }
        }
 
-       /** @todo document */
+       /**
+        * Create radio buttons for page history
+        *
+        * @param object $rev Revision
+        * @param bool $firstInList Is this version the first one?
+        * @param int $counter A counter of what row number we're at, counted from the top row = 1.
+        * @return string HTML output for the radio buttons
+        */
        function diffButtons( $rev, $firstInList, $counter ) {
                if( $this->linesonpage > 1) {
                        $radio = array(
                                'type'  => 'radio',
                                'value' => $rev->getId(),
-# do we really need to flood this on every item?
-#                              'title' => wfMsgHtml( 'selectolderversionfordiff' )
                        );
 
                        if( !$rev->userCan( Revision::DELETED_TEXT ) ) {
@@ -355,7 +347,7 @@ class PageHistory {
 
                        /** @todo: move title texts to javascript */
                        if ( $firstInList ) {
-                               $first = wfElement( 'input', array_merge(
+                               $first = Xml::element( 'input', array_merge(
                                        $radio,
                                        array(
                                                'style' => 'visibility:hidden',
@@ -367,13 +359,13 @@ class PageHistory {
                                } else {
                                        $checkmark = array();
                                }
-                               $first = wfElement( 'input', array_merge(
+                               $first = Xml::element( 'input', array_merge(
                                        $radio,
                                        $checkmark,
                                        array( 'name'  => 'oldid' ) ) );
                                $checkmark = array();
                        }
-                       $second = wfElement( 'input', array_merge(
+                       $second = Xml::element( 'input', array_merge(
                                $radio,
                                $checkmark,
                                array( 'name'  => 'diff' ) ) );