Revision: 51536
Author:   siebrand
Date:     2009-06-06 15:09:19 +0000 (Sat, 06 Jun 2009)

Log Message:
-----------
* 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

Modified Paths:
--------------
    trunk/phase3/includes/diff/DifferenceEngine.php

Modified: trunk/phase3/includes/diff/DifferenceEngine.php
===================================================================
--- trunk/phase3/includes/diff/DifferenceEngine.php     2009-06-06 14:45:14 UTC 
(rev 51535)
+++ trunk/phase3/includes/diff/DifferenceEngine.php     2009-06-06 15:09:19 UTC 
(rev 51536)
@@ -108,8 +108,14 @@
                        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=<<<CONTROL
                        [Process]
@@ -218,8 +224,19 @@
                        }
                        // Build the link
                        if( $rcid ) {
-                               $patrol = ' <span class="patrollink">[' . 
$sk->makeKnownLinkObj( $this->mTitle, 
-                                       wfMsgHtml( 'markaspatrolleddiff' ), 
"action=markpatrolled&rcid={$rcid}" ) . ']</span>';
+                               $patrol = ' <span class="patrollink">[' . 
$sk->link(
+                                       $this->mTitle, 
+                                       wfMsgHtml( 'markaspatrolleddiff' ),
+                                       array(),
+                                       array(
+                                               'action' => 'markpatrolled',
+                                               'rcid' => $rcid
+                                       ),
+                                       array(
+                                               'known',
+                                               'noclasses'
+                                       )
+                               ) . ']</span>';
                        } else {
                                $patrol = '';
                        }
@@ -227,21 +244,52 @@
                        $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 = '&nbsp;';
                } 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 @@
                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 @@
                                        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( "<div class='mw-warning 
plainlinks'>\n$1</div>\n",
                                        array( 'rev-deleted-unhide-diff', $link 
) );
                        }
                } else if( $wgEnableHtmlDiff && $this->htmldiff ) {
                        $multi = $this->getMultiNotice();
-                       $wgOut->addHTML('<div 
class="diff-switchtype">'.$sk->makeKnownLinkObj( $this->mTitle, wfMsgHtml( 
'wikicodecomparison' ),
-                               
'diff='.$this->mNewid.'&oldid='.$this->mOldid.'&htmldiff=0', '', '', 
'id="differences-switchtype"' ).'</div>');
+                       $wgOut->addHTML( '<div class="diff-switchtype">' . 
$sk->link(
+                               $this->mTitle,
+                               wfMsgHtml( 'wikicodecomparison' ),
+                               array(
+                                       'id' => 'differences-switchtype'
+                               ),
+                               array(
+                                       'diff' => $this->mNewid,
+                                       'oldid' => $this->mOldid,
+                                       'htmldiff' => 0
+                               ),
+                               array(
+                                       'known',
+                                       'noclasses'
+                               )
+                       ) . '</div>');
                        $wgOut->addHTML( $this->addHeader( '', $oldHeader, 
$newHeader, $multi ) );
                        $this->renderHtmlDiff();
                } else {
                        if( $wgEnableHtmlDiff ) {
-                               $wgOut->addHTML('<div 
class="diff-switchtype">'.$sk->makeKnownLinkObj( $this->mTitle, wfMsgHtml( 
'visualcomparison' ),
-                                       
'diff='.$this->mNewid.'&oldid='.$this->mOldid.'&htmldiff=1', '', '', 
'id="differences-switchtype"' ).'</div>');
+                               $wgOut->addHTML( '<div 
class="diff-switchtype">' . $sk->link(
+                                       $this->mTitle,
+                                       wfMsgHtml( 'visualcomparison' ),
+                                       array(
+                                               'id' => 'differences-switchtype'
+                                       ),
+                                       array(
+                                               'diff' => $this->mNewid,
+                                               'oldid' => $this->mOldid,
+                                               'htmldiff' => 1
+                                       ),
+                                       array(
+                                               'known',
+                                               'noclasses'
+                                       )
+                               ) . '</div>');
                        }
                        $this->showDiff( $oldHeader, $newHeader );
                        if( !$diffOnly ) {
@@ -379,9 +459,15 @@
                if( $this->mRcidMarkPatrolled && 
$this->mTitle->quickUserCan('patrol') ) {
                        $sk = $wgUser->getSkin();
                        $wgOut->addHTML(
-                               "<div class='patrollink'>[" . 
$sk->makeKnownLinkObj( $this->mTitle, 
-                                       wfMsgHtml( 'markaspatrolleddiff' ), 
"action=markpatrolled&rcid={$this->mRcidMarkPatrolled}" ) .
-                               ']</div>'
+                               "<div class='patrollink'>[" . $sk->link(
+                                       $this->mTitle,
+                                       wfMsgHtml( 'markaspatrolleddiff' ),
+                                       array(),
+                                       array(
+                                               'action' => 'markpatrolled',
+                                               'rcid' => 
$this->mRcidMarkPatrolled
+                                       )
+                               ) . ']</div>'
                         );
                }
 
@@ -491,8 +577,22 @@
                if( !$next ) {
                        $nextlink = '';
                } else {
-                       $nextlink = '<br/>' . $sk->makeKnownLinkObj( 
$this->mTitle, wfMsgHtml( 'nextdiff' ), 
-                               'diff=next&oldid=' . 
$this->mNewid.$this->htmlDiffArgument(), '', '', 'id="differences-nextlink"' );
+                       $nextlink = '<br/>' . $sk->link(
+                               $this->mTitle,
+                               wfMsgHtml( 'nextdiff' ),
+                               array(
+                                       'id' => 'differences-nextlink'
+                               ),
+                               array(
+                                       'diff' => 'next',
+                                       'oldid' => $this->mNewid,
+                                       $this->htmlDiffArgument()
+                               ),
+                               array(
+                                       'known',
+                                       'noclasses'
+                               )
+                       );
                }
                $header = "<div class=\"firstrevisionheader\" 
style=\"text-align: center\">" .
                        $sk->revUserTools( $this->mNewRev ) . "<br/>" . 
$sk->revComment( $this->mNewRev ) . $nextlink . "</div>\n";
@@ -509,12 +609,12 @@
                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 @@
                $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 = "<a 
href='$newLink'>{$this->mPagetitle}</a>";
                        $this->mNewtitle .= " (<a href='$newEdit'>" . 
wfMsgHtml( $editable ? 'editold' : 'viewsourceold' ) . "</a>)";
                } 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 = "<a 
href='$newLink'>{$this->mPagetitle}</a>";
                        $this->mNewtitle .= " (<a href='$newEdit'>" . 
wfMsgHtml( $editable ? 'editold' : 'viewsourceold' ) . "</a>)";
@@ -895,14 +1014,23 @@
                        $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 = "<a 
href='$oldLink'>{$this->mOldPagetitle}</a>"
                        . " (<a href='$oldEdit'>" . wfMsgHtml( $editable ? 
'editold' : 'viewsourceold' ) . "</a>)";
                        // 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 @@
                $this->mNewtext = $this->mNewRev->getText( 
Revision::FOR_THIS_USER );
                return true;
        }
-
-
 }
 
 // A PHP diff engine for phpwiki. (Taken from phpwiki-1.3.3)



_______________________________________________
MediaWiki-CVS mailing list
MediaWiki-CVS@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs

Reply via email to