* (bug 6461) Link to page histories in Special:Newpages
authorRob Church <robchurch@users.mediawiki.org>
Wed, 28 Jun 2006 23:54:29 +0000 (23:54 +0000)
committerRob Church <robchurch@users.mediawiki.org>
Wed, 28 Jun 2006 23:54:29 +0000 (23:54 +0000)
* Clean up this code, it's fucking disgusting :)

RELEASE-NOTES
includes/SpecialNewpages.php

index 6b93c99..358b6f5 100644 (file)
@@ -596,6 +596,7 @@ Some default configuration options have changed:
   we can move over them.
 * Show some error results in moveBatch.php
 * (bug 6479) Allow specification of the skin to use during HTML dumps
+* (bug 6461) Link to page histories in Special:Newpages
 
 == Compatibility ==
 
index cdf1b10..c0c6ba9 100644 (file)
@@ -66,32 +66,37 @@ class NewPagesPage extends QueryPage {
                        $dbo->dataSeek( $res, 0 );
        }
 
+       /**
+        * Format a row, providing the timestamp, links to the page/history, size, user links, and a comment
+        *
+        * @param $skin Skin to use
+        * @param $result Result row
+        * @return string
+        */
        function formatResult( $skin, $result ) {
-               global $wgLang, $wgContLang, $wgUser, $wgUseRCPatrol;
-               $u = $result->user;
-               $ut = $result->user_text;
-               $dirmark = $wgContLang->getDirMark(); // To keep text in correct order
-
-               $length = wfMsgExt( 'nbytes', array('parsemag', 'escape'),
-                       $wgLang->formatNum( $result->length ) );
-               $d = $wgLang->timeanddate( $result->timestamp, true );
-
-               # Since there is no diff link, we need to give users a way to
-               # mark the article as patrolled if it isn't already
-               $ns = $wgContLang->getNsText( $result->namespace );
-               if( $wgUseRCPatrol && !is_null( $result->usepatrol ) && $result->usepatrol && $result->patrolled == 0 && $wgUser->isAllowed( 'patrol' ) ) {
-                       $link = $skin->makeKnownLink( $ns . ':' . $result->title, '', "rcid={$result->rcid}" );
-               } else {
-                       $link = $skin->makeKnownLink( $ns . ':' . $result->title, '' );
-               }
-
-               $userLink = $skin->userLink( $u, $ut );
-               $userTools = $skin->userToolLinks( $u, $ut );
+               global $wgLang, $wgContLang;
+               $dm = $wgContLang->getDirMark();
+
+               $title = Title::makeTitleSafe( $result->namespace, $result->title );
+               $time = $wgLang->timeAndDate( $result->timestamp, true );
+               $plink = $skin->makeKnownLinkObj( $title, '', $this->patrollable( $result ) ? 'rcid=' . $result->rcid : '' );
+               $hist = $skin->makeKnownLinkObj( $title, wfMsgHtml( 'hist' ), 'action=history' );
+               $length = wfMsgHtml( 'nbytes', $wgLang->formatNum( htmlspecialchars( $result->length ) ) );
+               $ulink = $skin->userLink( $result->user, $result->user_text ) . $skin->userToolLinks( $result->user, $result->user_text );
+               $comment = $skin->commentBlock( $result->comment );
+
+               return "{$time} {$dm}{$plink} ({$hist}) {$dm}[{$length}] {$dm}{$ulink} {$comment}";
+       }
 
-               $s = "{$d} {$dirmark}{$link} {$dirmark}({$length}) . . " .
-                       "{$dirmark}{$userLink}{$dirmark}{$userTools}";
-               $s .= $dirmark . $skin->commentBlock( $result->comment );
-               return $s;
+       /**
+        * Should a specific result row provide "patrollable" links?
+        *
+        * @param $result Result row
+        * @return bool
+        */
+       function patrollable( $result ) {
+               global $wgUser, $wgUseRCPatrol;
+               return $wgUseRCPatrol && $wgUser->isAllowed( 'patrol' ) && !$result->patrolled;
        }
 
        function feedItemDesc( $row ) {