r51536 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r51535‎ | r51536 | r51537 >
Date:15:09, 6 June 2009
Author:siebrand
Status:ok
Tags:
Comment:
* 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) (history)

Diff [purge]

Index: trunk/phase3/includes/diff/DifferenceEngine.php
@@ -108,8 +108,14 @@
109109 global $wgInputEncoding,$wgServer,$wgScript,$wgLang;
110110 $wgOut->disable();
111111 header ( "Content-type: application/x-external-editor; charset=".$wgInputEncoding );
112 - $url1=$this->mTitle->getFullURL("action=raw&oldid=".$this->mOldid);
113 - $url2=$this->mTitle->getFullURL("action=raw&oldid=".$this->mNewid);
 112+ $url1=$this->mTitle->getFullURL( array(
 113+ 'action' => 'raw',
 114+ 'oldid' => $this->mOldid
 115+ ) );
 116+ $url2=$this->mTitle->getFullURL( array(
 117+ 'action' => 'raw',
 118+ 'oldid' => $this->mNewid
 119+ ) );
114120 $special=$wgLang->getNsText(NS_SPECIAL);
115121 $control=<<<CONTROL
116122 [Process]
@@ -218,8 +224,19 @@
219225 }
220226 // Build the link
221227 if( $rcid ) {
222 - $patrol = ' <span class="patrollink">[' . $sk->makeKnownLinkObj( $this->mTitle,
223 - wfMsgHtml( 'markaspatrolleddiff' ), "action=markpatrolled&rcid={$rcid}" ) . ']</span>';
 228+ $patrol = ' <span class="patrollink">[' . $sk->link(
 229+ $this->mTitle,
 230+ wfMsgHtml( 'markaspatrolleddiff' ),
 231+ array(),
 232+ array(
 233+ 'action' => 'markpatrolled',
 234+ 'rcid' => $rcid
 235+ ),
 236+ array(
 237+ 'known',
 238+ 'noclasses'
 239+ )
 240+ ) . ']</span>';
224241 } else {
225242 $patrol = '';
226243 }
@@ -227,21 +244,52 @@
228245 $patrol = '';
229246 }
230247
231 - $diffOnlyArg = '';
232248 # Carry over 'diffonly' param via navigation links
233249 if( $diffOnly != $wgUser->getBoolOption('diffonly') ) {
234 - $diffOnlyArg = '&diffonly='.$diffOnly;
 250+ $query['diffonly'] = $diffOnly;
235251 }
 252+
236253 $htmldiffarg = $this->htmlDiffArgument();
 254+
 255+ if( $htmldiffarg ) {
 256+ $query['htmldiff'] = $htmldiffarg['htmldiff'];
 257+ }
 258+
237259 # Make "previous revision link"
238 - $prevlink = $sk->makeKnownLinkObj( $this->mTitle, wfMsgHtml( 'previousdiff' ),
239 - "diff=prev&oldid={$this->mOldid}{$htmldiffarg}{$diffOnlyArg}", '', '', 'id="differences-prevlink"' );
 260+ $query['diff'] = 'prev';
 261+ $query['oldid'] = $this->mOldid;
 262+
 263+ $prevlink = $sk->link(
 264+ $this->mTitle,
 265+ wfMsgHtml( 'previousdiff' ),
 266+ array(
 267+ 'id' => 'differences-prevlink'
 268+ ),
 269+ $query,
 270+ array(
 271+ 'known',
 272+ 'noclasses'
 273+ )
 274+ );
240275 # Make "next revision link"
 276+ $query['diff'] = 'next';
 277+ $query['oldid'] = $this->mNewid;
 278+
241279 if( $this->mNewRev->isCurrent() ) {
242280 $nextlink = '&nbsp;';
243281 } else {
244 - $nextlink = $sk->makeKnownLinkObj( $this->mTitle, wfMsgHtml( 'nextdiff' ),
245 - "diff=next&oldid={$this->mNewid}{$htmldiffarg}{$diffOnlyArg}", '', '', 'id="differences-nextlink"' );
 282+ $nextlink = $sk->link(
 283+ $this->mTitle,
 284+ wfMsgHtml( 'nextdiff' ),
 285+ array(
 286+ 'id' => 'differences-nextlink'
 287+ ),
 288+ $query,
 289+ array(
 290+ 'known',
 291+ 'noclasses'
 292+ )
 293+ );
246294 }
247295
248296 $oldminor = '';
@@ -258,7 +306,7 @@
259307 if( $wgUser->isAllowed( 'deleterevision' ) ) {
260308 if( !$this->mOldRev->userCan( Revision::DELETED_RESTRICTED ) ) {
261309 // If revision was hidden from sysops
262 - $ldel = Xml::tags( 'span', array( 'class'=>'mw-revdelundel-link' ), '('.wfMsgHtml( 'rev-delundel' ).')' );
 310+ $ldel = Xml::tags( 'span', array( 'class' => 'mw-revdelundel-link' ), '(' . wfMsgHtml( 'rev-delundel' ) . ')' );
263311 } else {
264312 $query = array(
265313 'type' => 'revision',
@@ -310,20 +358,52 @@
311359 array( 'rev-deleted-no-diff' ) );
312360 } else {
313361 # Give explanation and add a link to view the diff...
314 - $link = $this->mTitle->getFullUrl( "diff={$this->mNewid}&oldid={$this->mOldid}&unhide=1" );
 362+ $link = $this->mTitle->getFullUrl( array(
 363+ 'diff' => $this->mNewid,
 364+ 'oldid' => $this->mOldid,
 365+ 'unhide' => 1
 366+ ) );
315367 $wgOut->wrapWikiMsg( "<div class='mw-warning plainlinks'>\n$1</div>\n",
316368 array( 'rev-deleted-unhide-diff', $link ) );
317369 }
318370 } else if( $wgEnableHtmlDiff && $this->htmldiff ) {
319371 $multi = $this->getMultiNotice();
320 - $wgOut->addHTML('<div class="diff-switchtype">'.$sk->makeKnownLinkObj( $this->mTitle, wfMsgHtml( 'wikicodecomparison' ),
321 - 'diff='.$this->mNewid.'&oldid='.$this->mOldid.'&htmldiff=0', '', '', 'id="differences-switchtype"' ).'</div>');
 372+ $wgOut->addHTML( '<div class="diff-switchtype">' . $sk->link(
 373+ $this->mTitle,
 374+ wfMsgHtml( 'wikicodecomparison' ),
 375+ array(
 376+ 'id' => 'differences-switchtype'
 377+ ),
 378+ array(
 379+ 'diff' => $this->mNewid,
 380+ 'oldid' => $this->mOldid,
 381+ 'htmldiff' => 0
 382+ ),
 383+ array(
 384+ 'known',
 385+ 'noclasses'
 386+ )
 387+ ) . '</div>');
322388 $wgOut->addHTML( $this->addHeader( '', $oldHeader, $newHeader, $multi ) );
323389 $this->renderHtmlDiff();
324390 } else {
325391 if( $wgEnableHtmlDiff ) {
326 - $wgOut->addHTML('<div class="diff-switchtype">'.$sk->makeKnownLinkObj( $this->mTitle, wfMsgHtml( 'visualcomparison' ),
327 - 'diff='.$this->mNewid.'&oldid='.$this->mOldid.'&htmldiff=1', '', '', 'id="differences-switchtype"' ).'</div>');
 392+ $wgOut->addHTML( '<div class="diff-switchtype">' . $sk->link(
 393+ $this->mTitle,
 394+ wfMsgHtml( 'visualcomparison' ),
 395+ array(
 396+ 'id' => 'differences-switchtype'
 397+ ),
 398+ array(
 399+ 'diff' => $this->mNewid,
 400+ 'oldid' => $this->mOldid,
 401+ 'htmldiff' => 1
 402+ ),
 403+ array(
 404+ 'known',
 405+ 'noclasses'
 406+ )
 407+ ) . '</div>');
328408 }
329409 $this->showDiff( $oldHeader, $newHeader );
330410 if( !$diffOnly ) {
@@ -379,9 +459,15 @@
380460 if( $this->mRcidMarkPatrolled && $this->mTitle->quickUserCan('patrol') ) {
381461 $sk = $wgUser->getSkin();
382462 $wgOut->addHTML(
383 - "<div class='patrollink'>[" . $sk->makeKnownLinkObj( $this->mTitle,
384 - wfMsgHtml( 'markaspatrolleddiff' ), "action=markpatrolled&rcid={$this->mRcidMarkPatrolled}" ) .
385 - ']</div>'
 463+ "<div class='patrollink'>[" . $sk->link(
 464+ $this->mTitle,
 465+ wfMsgHtml( 'markaspatrolleddiff' ),
 466+ array(),
 467+ array(
 468+ 'action' => 'markpatrolled',
 469+ 'rcid' => $this->mRcidMarkPatrolled
 470+ )
 471+ ) . ']</div>'
386472 );
387473 }
388474
@@ -491,8 +577,22 @@
492578 if( !$next ) {
493579 $nextlink = '';
494580 } else {
495 - $nextlink = '<br/>' . $sk->makeKnownLinkObj( $this->mTitle, wfMsgHtml( 'nextdiff' ),
496 - 'diff=next&oldid=' . $this->mNewid.$this->htmlDiffArgument(), '', '', 'id="differences-nextlink"' );
 581+ $nextlink = '<br/>' . $sk->link(
 582+ $this->mTitle,
 583+ wfMsgHtml( 'nextdiff' ),
 584+ array(
 585+ 'id' => 'differences-nextlink'
 586+ ),
 587+ array(
 588+ 'diff' => 'next',
 589+ 'oldid' => $this->mNewid,
 590+ $this->htmlDiffArgument()
 591+ ),
 592+ array(
 593+ 'known',
 594+ 'noclasses'
 595+ )
 596+ );
497597 }
498598 $header = "<div class=\"firstrevisionheader\" style=\"text-align: center\">" .
499599 $sk->revUserTools( $this->mNewRev ) . "<br/>" . $sk->revComment( $this->mNewRev ) . $nextlink . "</div>\n";
@@ -509,12 +609,12 @@
510610 global $wgEnableHtmlDiff;
511611 if($wgEnableHtmlDiff){
512612 if($this->htmldiff){
513 - return '&htmldiff=1';
 613+ return array( 'htmldiff' => 1 );
514614 }else{
515 - return '&htmldiff=0';
 615+ return array( 'htmldiff' => 0 );
516616 }
517617 }else{
518 - return '';
 618+ return array();
519619 }
520620 }
521621
@@ -849,16 +949,35 @@
850950 $timeofrev = $wgLang->time( $this->mNewRev->getTimestamp(), true );
851951 $this->mNewPage = $this->mNewRev->getTitle();
852952 if( $this->mNewRev->isCurrent() ) {
853 - $newLink = $this->mNewPage->escapeLocalUrl( 'oldid=' . $this->mNewid );
854 - $this->mPagetitle = htmlspecialchars( wfMsg( 'currentrev-asof', $timestamp ) );
855 - $newEdit = $this->mNewPage->escapeLocalUrl( 'action=edit' );
 953+ $newLink = $this->mNewPage->escapeLocalUrl( array(
 954+ 'oldid' => $this->mNewid
 955+ ) );
 956+ $this->mPagetitle = htmlspecialchars( wfMsg(
 957+ 'currentrev-asof',
 958+ $timestamp,
 959+ $dateofrev,
 960+ $timeofrev
 961+ ) );
 962+ $newEdit = $this->mNewPage->escapeLocalUrl( array(
 963+ 'action' => 'edit'
 964+ ) );
856965
857966 $this->mNewtitle = "<a href='$newLink'>{$this->mPagetitle}</a>";
858967 $this->mNewtitle .= " (<a href='$newEdit'>" . wfMsgHtml( $editable ? 'editold' : 'viewsourceold' ) . "</a>)";
859968 } else {
860 - $newLink = $this->mNewPage->escapeLocalUrl( 'oldid=' . $this->mNewid );
861 - $newEdit = $this->mNewPage->escapeLocalUrl( 'action=edit&oldid=' . $this->mNewid );
862 - $this->mPagetitle = htmlspecialchars( wfMsg( 'revisionasof', $timestamp, $dateofrev, $timeofrev ) );
 969+ $newLink = $this->mNewPage->escapeLocalUrl( array(
 970+ 'oldid' => $this->mNewid
 971+ ) );
 972+ $newEdit = $this->mNewPage->escapeLocalUrl( array(
 973+ 'action' => 'edit',
 974+ 'oldid' => $this->mNewid
 975+ ) );
 976+ $this->mPagetitle = htmlspecialchars( wfMsg(
 977+ 'revisionasof',
 978+ $timestamp,
 979+ $dateofrev,
 980+ $timeofrev
 981+ ) );
863982
864983 $this->mNewtitle = "<a href='$newLink'>{$this->mPagetitle}</a>";
865984 $this->mNewtitle .= " (<a href='$newEdit'>" . wfMsgHtml( $editable ? 'editold' : 'viewsourceold' ) . "</a>)";
@@ -895,14 +1014,23 @@
8961015 $t = $wgLang->timeanddate( $this->mOldRev->getTimestamp(), true );
8971016 $dateofrev = $wgLang->date( $this->mOldRev->getTimestamp(), true );
8981017 $timeofrev = $wgLang->time( $this->mOldRev->getTimestamp(), true );
899 - $oldLink = $this->mOldPage->escapeLocalUrl( 'oldid=' . $this->mOldid );
900 - $oldEdit = $this->mOldPage->escapeLocalUrl( 'action=edit&oldid=' . $this->mOldid );
 1018+ $oldLink = $this->mOldPage->escapeLocalUrl( array(
 1019+ 'oldid' => $this->mOldid
 1020+ ) );
 1021+ $oldEdit = $this->mOldPage->escapeLocalUrl( array(
 1022+ 'action' => 'edit',
 1023+ 'oldid' => $this->mOldid
 1024+ ) );
9011025 $this->mOldPagetitle = htmlspecialchars( wfMsg( 'revisionasof', $t, $dateofrev, $timeofrev ) );
9021026
9031027 $this->mOldtitle = "<a href='$oldLink'>{$this->mOldPagetitle}</a>"
9041028 . " (<a href='$oldEdit'>" . wfMsgHtml( $editable ? 'editold' : 'viewsourceold' ) . "</a>)";
9051029 // Add an "undo" link
906 - $newUndo = $this->mNewPage->escapeLocalUrl( 'action=edit&undoafter=' . $this->mOldid . '&undo=' . $this->mNewid);
 1030+ $newUndo = $this->mNewPage->escapeLocalUrl( array(
 1031+ 'action' => 'edit',
 1032+ 'undoafter' => $this->mOldid,
 1033+ 'undo' => $this->mNewid
 1034+ ) );
9071035 $htmlLink = htmlspecialchars( wfMsg( 'editundo' ) );
9081036 $htmlTitle = $wgUser->getSkin()->tooltip( 'undo' );
9091037 if( $editable && !$this->mOldRev->isDeleted( Revision::DELETED_TEXT ) && !$this->mNewRev->isDeleted( Revision::DELETED_TEXT ) ) {
@@ -963,8 +1091,6 @@
9641092 $this->mNewtext = $this->mNewRev->getText( Revision::FOR_THIS_USER );
9651093 return true;
9661094 }
967 -
968 -
9691095 }
9701096
9711097 // A PHP diff engine for phpwiki. (Taken from phpwiki-1.3.3)

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r51301Update README and CHANGELOGsiebrand18:00, 1 June 2009

Status & tagging log