From 8bc003e538ad7a942407ba6604e796f7a0762f08 Mon Sep 17 00:00:00 2001 From: Siebrand Mazeland Date: Sat, 6 Jun 2009 15:09:19 +0000 Subject: [PATCH] * follow-up to r51301: also add separated date and time as parameters for 'currentrev-asof' for consistency * replace use of deprecated makeKnownLinkObj() by link() * use array type parameter instead of string to escapeLocalUrl(), getFullURL() and getFullUrl() for readability * change return type of htmlDiffArgument(). CHECKME: Should this method be private? (not used anywhere in SVN at the moment) * break a few long lines with parameters --- includes/diff/DifferenceEngine.php | 196 +++++++++++++++++++++++------ 1 file changed, 161 insertions(+), 35 deletions(-) diff --git a/includes/diff/DifferenceEngine.php b/includes/diff/DifferenceEngine.php index 117c2ecc0e..1bce4f4da0 100644 --- a/includes/diff/DifferenceEngine.php +++ b/includes/diff/DifferenceEngine.php @@ -108,8 +108,14 @@ class DifferenceEngine { global $wgInputEncoding,$wgServer,$wgScript,$wgLang; $wgOut->disable(); header ( "Content-type: application/x-external-editor; charset=".$wgInputEncoding ); - $url1=$this->mTitle->getFullURL("action=raw&oldid=".$this->mOldid); - $url2=$this->mTitle->getFullURL("action=raw&oldid=".$this->mNewid); + $url1=$this->mTitle->getFullURL( array( + 'action' => 'raw', + 'oldid' => $this->mOldid + ) ); + $url2=$this->mTitle->getFullURL( array( + 'action' => 'raw', + 'oldid' => $this->mNewid + ) ); $special=$wgLang->getNsText(NS_SPECIAL); $control=<<makeKnownLinkObj( $this->mTitle, - wfMsgHtml( 'markaspatrolleddiff' ), "action=markpatrolled&rcid={$rcid}" ) . ']'; + $patrol = ' [' . $sk->link( + $this->mTitle, + wfMsgHtml( 'markaspatrolleddiff' ), + array(), + array( + 'action' => 'markpatrolled', + 'rcid' => $rcid + ), + array( + 'known', + 'noclasses' + ) + ) . ']'; } else { $patrol = ''; } @@ -227,21 +244,52 @@ CONTROL; $patrol = ''; } - $diffOnlyArg = ''; # Carry over 'diffonly' param via navigation links if( $diffOnly != $wgUser->getBoolOption('diffonly') ) { - $diffOnlyArg = '&diffonly='.$diffOnly; + $query['diffonly'] = $diffOnly; } + $htmldiffarg = $this->htmlDiffArgument(); + + if( $htmldiffarg ) { + $query['htmldiff'] = $htmldiffarg['htmldiff']; + } + # Make "previous revision link" - $prevlink = $sk->makeKnownLinkObj( $this->mTitle, wfMsgHtml( 'previousdiff' ), - "diff=prev&oldid={$this->mOldid}{$htmldiffarg}{$diffOnlyArg}", '', '', 'id="differences-prevlink"' ); + $query['diff'] = 'prev'; + $query['oldid'] = $this->mOldid; + + $prevlink = $sk->link( + $this->mTitle, + wfMsgHtml( 'previousdiff' ), + array( + 'id' => 'differences-prevlink' + ), + $query, + array( + 'known', + 'noclasses' + ) + ); # Make "next revision link" + $query['diff'] = 'next'; + $query['oldid'] = $this->mNewid; + if( $this->mNewRev->isCurrent() ) { $nextlink = ' '; } else { - $nextlink = $sk->makeKnownLinkObj( $this->mTitle, wfMsgHtml( 'nextdiff' ), - "diff=next&oldid={$this->mNewid}{$htmldiffarg}{$diffOnlyArg}", '', '', 'id="differences-nextlink"' ); + $nextlink = $sk->link( + $this->mTitle, + wfMsgHtml( 'nextdiff' ), + array( + 'id' => 'differences-nextlink' + ), + $query, + array( + 'known', + 'noclasses' + ) + ); } $oldminor = ''; @@ -258,7 +306,7 @@ CONTROL; if( $wgUser->isAllowed( 'deleterevision' ) ) { if( !$this->mOldRev->userCan( Revision::DELETED_RESTRICTED ) ) { // If revision was hidden from sysops - $ldel = Xml::tags( 'span', array( 'class'=>'mw-revdelundel-link' ), '('.wfMsgHtml( 'rev-delundel' ).')' ); + $ldel = Xml::tags( 'span', array( 'class' => 'mw-revdelundel-link' ), '(' . wfMsgHtml( 'rev-delundel' ) . ')' ); } else { $query = array( 'type' => 'revision', @@ -310,20 +358,52 @@ CONTROL; array( 'rev-deleted-no-diff' ) ); } else { # Give explanation and add a link to view the diff... - $link = $this->mTitle->getFullUrl( "diff={$this->mNewid}&oldid={$this->mOldid}&unhide=1" ); + $link = $this->mTitle->getFullUrl( array( + 'diff' => $this->mNewid, + 'oldid' => $this->mOldid, + 'unhide' => 1 + ) ); $wgOut->wrapWikiMsg( "\n", array( 'rev-deleted-unhide-diff', $link ) ); } } else if( $wgEnableHtmlDiff && $this->htmldiff ) { $multi = $this->getMultiNotice(); - $wgOut->addHTML('
'.$sk->makeKnownLinkObj( $this->mTitle, wfMsgHtml( 'wikicodecomparison' ), - 'diff='.$this->mNewid.'&oldid='.$this->mOldid.'&htmldiff=0', '', '', 'id="differences-switchtype"' ).'
'); + $wgOut->addHTML( '
' . $sk->link( + $this->mTitle, + wfMsgHtml( 'wikicodecomparison' ), + array( + 'id' => 'differences-switchtype' + ), + array( + 'diff' => $this->mNewid, + 'oldid' => $this->mOldid, + 'htmldiff' => 0 + ), + array( + 'known', + 'noclasses' + ) + ) . '
'); $wgOut->addHTML( $this->addHeader( '', $oldHeader, $newHeader, $multi ) ); $this->renderHtmlDiff(); } else { if( $wgEnableHtmlDiff ) { - $wgOut->addHTML('
'.$sk->makeKnownLinkObj( $this->mTitle, wfMsgHtml( 'visualcomparison' ), - 'diff='.$this->mNewid.'&oldid='.$this->mOldid.'&htmldiff=1', '', '', 'id="differences-switchtype"' ).'
'); + $wgOut->addHTML( '
' . $sk->link( + $this->mTitle, + wfMsgHtml( 'visualcomparison' ), + array( + 'id' => 'differences-switchtype' + ), + array( + 'diff' => $this->mNewid, + 'oldid' => $this->mOldid, + 'htmldiff' => 1 + ), + array( + 'known', + 'noclasses' + ) + ) . '
'); } $this->showDiff( $oldHeader, $newHeader ); if( !$diffOnly ) { @@ -379,9 +459,15 @@ CONTROL; if( $this->mRcidMarkPatrolled && $this->mTitle->quickUserCan('patrol') ) { $sk = $wgUser->getSkin(); $wgOut->addHTML( - "' + "' ); } @@ -491,8 +577,22 @@ CONTROL; if( !$next ) { $nextlink = ''; } else { - $nextlink = '
' . $sk->makeKnownLinkObj( $this->mTitle, wfMsgHtml( 'nextdiff' ), - 'diff=next&oldid=' . $this->mNewid.$this->htmlDiffArgument(), '', '', 'id="differences-nextlink"' ); + $nextlink = '
' . $sk->link( + $this->mTitle, + wfMsgHtml( 'nextdiff' ), + array( + 'id' => 'differences-nextlink' + ), + array( + 'diff' => 'next', + 'oldid' => $this->mNewid, + $this->htmlDiffArgument() + ), + array( + 'known', + 'noclasses' + ) + ); } $header = "
" . $sk->revUserTools( $this->mNewRev ) . "
" . $sk->revComment( $this->mNewRev ) . $nextlink . "
\n"; @@ -509,12 +609,12 @@ CONTROL; global $wgEnableHtmlDiff; if($wgEnableHtmlDiff){ if($this->htmldiff){ - return '&htmldiff=1'; + return array( 'htmldiff' => 1 ); }else{ - return '&htmldiff=0'; + return array( 'htmldiff' => 0 ); } }else{ - return ''; + return array(); } } @@ -849,16 +949,35 @@ CONTROL; $timeofrev = $wgLang->time( $this->mNewRev->getTimestamp(), true ); $this->mNewPage = $this->mNewRev->getTitle(); if( $this->mNewRev->isCurrent() ) { - $newLink = $this->mNewPage->escapeLocalUrl( 'oldid=' . $this->mNewid ); - $this->mPagetitle = htmlspecialchars( wfMsg( 'currentrev-asof', $timestamp ) ); - $newEdit = $this->mNewPage->escapeLocalUrl( 'action=edit' ); + $newLink = $this->mNewPage->escapeLocalUrl( array( + 'oldid' => $this->mNewid + ) ); + $this->mPagetitle = htmlspecialchars( wfMsg( + 'currentrev-asof', + $timestamp, + $dateofrev, + $timeofrev + ) ); + $newEdit = $this->mNewPage->escapeLocalUrl( array( + 'action' => 'edit' + ) ); $this->mNewtitle = "{$this->mPagetitle}"; $this->mNewtitle .= " (" . wfMsgHtml( $editable ? 'editold' : 'viewsourceold' ) . ")"; } else { - $newLink = $this->mNewPage->escapeLocalUrl( 'oldid=' . $this->mNewid ); - $newEdit = $this->mNewPage->escapeLocalUrl( 'action=edit&oldid=' . $this->mNewid ); - $this->mPagetitle = htmlspecialchars( wfMsg( 'revisionasof', $timestamp, $dateofrev, $timeofrev ) ); + $newLink = $this->mNewPage->escapeLocalUrl( array( + 'oldid' => $this->mNewid + ) ); + $newEdit = $this->mNewPage->escapeLocalUrl( array( + 'action' => 'edit', + 'oldid' => $this->mNewid + ) ); + $this->mPagetitle = htmlspecialchars( wfMsg( + 'revisionasof', + $timestamp, + $dateofrev, + $timeofrev + ) ); $this->mNewtitle = "{$this->mPagetitle}"; $this->mNewtitle .= " (" . wfMsgHtml( $editable ? 'editold' : 'viewsourceold' ) . ")"; @@ -895,14 +1014,23 @@ CONTROL; $t = $wgLang->timeanddate( $this->mOldRev->getTimestamp(), true ); $dateofrev = $wgLang->date( $this->mOldRev->getTimestamp(), true ); $timeofrev = $wgLang->time( $this->mOldRev->getTimestamp(), true ); - $oldLink = $this->mOldPage->escapeLocalUrl( 'oldid=' . $this->mOldid ); - $oldEdit = $this->mOldPage->escapeLocalUrl( 'action=edit&oldid=' . $this->mOldid ); + $oldLink = $this->mOldPage->escapeLocalUrl( array( + 'oldid' => $this->mOldid + ) ); + $oldEdit = $this->mOldPage->escapeLocalUrl( array( + 'action' => 'edit', + 'oldid' => $this->mOldid + ) ); $this->mOldPagetitle = htmlspecialchars( wfMsg( 'revisionasof', $t, $dateofrev, $timeofrev ) ); $this->mOldtitle = "{$this->mOldPagetitle}" . " (" . wfMsgHtml( $editable ? 'editold' : 'viewsourceold' ) . ")"; // Add an "undo" link - $newUndo = $this->mNewPage->escapeLocalUrl( 'action=edit&undoafter=' . $this->mOldid . '&undo=' . $this->mNewid); + $newUndo = $this->mNewPage->escapeLocalUrl( array( + 'action' => 'edit', + 'undoafter' => $this->mOldid, + 'undo' => $this->mNewid + ) ); $htmlLink = htmlspecialchars( wfMsg( 'editundo' ) ); $htmlTitle = $wgUser->getSkin()->tooltip( 'undo' ); if( $editable && !$this->mOldRev->isDeleted( Revision::DELETED_TEXT ) && !$this->mNewRev->isDeleted( Revision::DELETED_TEXT ) ) { @@ -963,8 +1091,6 @@ CONTROL; $this->mNewtext = $this->mNewRev->getText( Revision::FOR_THIS_USER ); return true; } - - } // A PHP diff engine for phpwiki. (Taken from phpwiki-1.3.3) -- 2.20.1