From 71e01d2769cb53f739a0e1504087fb1f957479f1 Mon Sep 17 00:00:00 2001 From: Rob Church Date: Wed, 28 Jun 2006 23:54:29 +0000 Subject: [PATCH] * (bug 6461) Link to page histories in Special:Newpages * Clean up this code, it's fucking disgusting :) --- RELEASE-NOTES | 1 + includes/SpecialNewpages.php | 53 ++++++++++++++++++++---------------- 2 files changed, 30 insertions(+), 24 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 6b93c9968a..358b6f5c7c 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 == diff --git a/includes/SpecialNewpages.php b/includes/SpecialNewpages.php index cdf1b10f8c..c0c6ba96ba 100644 --- a/includes/SpecialNewpages.php +++ b/includes/SpecialNewpages.php @@ -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 ) { -- 2.20.1