Index: HistoryPage.php =================================================================== --- HistoryPage.php (revision 55168) +++ HistoryPage.php (working copy) @@ -20,7 +20,15 @@ const DIR_NEXT = 1; var $article, $title, $skin; + var $formType; + static $formTypes = array( + 'simple' => false, + 'advanced' => false, + 'compare' => 'HistoryPage_CompareForm', + 'hide' => 'HistoryPage_HideForm' + ); + /** * Construct a new HistoryPage. * @@ -50,7 +58,7 @@ function preCacheMessages() { // Precache various messages if( !isset( $this->message ) ) { - foreach( explode(' ', 'cur last rev-delundel' ) as $msg ) { + foreach( explode(' ', 'cur last last-long rev-delundel' ) as $msg ) { $this->message[$msg] = wfMsgExt( $msg, array( 'escape') ); } } @@ -62,7 +70,7 @@ * @returns nothing */ function history() { - global $wgOut, $wgRequest, $wgScript; + global $wgOut, $wgUser, $wgRequest, $wgScript; /* * Allow client caching. @@ -100,6 +108,14 @@ return $this->feed( $feedType ); } + $this->formType = $wgRequest->getVal( 'form' ); + if ( $this->formType == 'hide' && !$wgUser->isAllowed('deleterevision') ) { + $this->formType = 'simple'; + } + if ( !isset( self::$formTypes[$this->formType] ) ) { + $this->formType = 'simple'; + } + /* * Fail if article doesn't exist. */ @@ -312,13 +328,31 @@ * @return string HTML output */ function getStartBody() { - global $wgScript, $wgEnableHtmlDiff, $wgUser; + global $wgScript, $wgEnableHtmlDiff; $this->lastRow = false; $this->counter = 1; $this->oldIdChecked = 0; + $formType = $this->historyPage->formType; $s = wfMsgExt( 'histlegend', array( 'parse') ); - if( $this->getNumRows() > 1 && $wgUser->isAllowed('deleterevision') ) { + $s .= '

'; + $first = true; + foreach ( HistoryPage::$formTypes as $type => $class ) { + if ( $first ) { + $first = false; + } else { + $s .= ' | '; + } + $linkText = wfMsgHtml( "history-form-$type" ); + if ( $type == $formType ) { + $s .= "$linkText"; + } else { + $s .= $this->makeLink( $linkText, array( 'form' => $type ) ); + } + } + $s .= '

'; + + if( $formType == 'hide' ) { $revdel = SpecialPage::getTitleFor( 'Revisiondelete' ); $s .= Xml::openElement( 'form', array( @@ -328,46 +362,47 @@ ) ), 'method' => 'post', 'id' => 'mw-history-revdeleteform', - 'style' => 'visibility:hidden;float:right;' ) ); $s .= Xml::hidden( 'ids', '', array('id'=>'revdel-oldid') ); $s .= Xml::submitButton( wfMsg( 'showhideselectedversions' ) ); - $s .= Xml::closeElement( 'form' ); } - $s .= Xml::openElement( 'form', array( 'action' => $wgScript, - 'id' => 'mw-history-compare' ) ); - $s .= Xml::hidden( 'title', $this->title->getPrefixedDbKey() ); - if( $wgEnableHtmlDiff ) { - $s .= $this->submitButton( wfMsg( 'visualcomparison'), - array( - 'name' => 'htmldiff', - 'class' => 'historysubmit', - 'accesskey' => wfMsg( 'accesskey-visualcomparison' ), - 'title' => wfMsg( 'tooltip-compareselectedversions' ), - ) - ); - $s .= $this->submitButton( wfMsg( 'wikicodecomparison'), - array( - 'class' => 'historysubmit', - 'accesskey' => wfMsg( 'accesskey-compareselectedversions' ), - 'title' => wfMsg( 'tooltip-compareselectedversions' ), - ) - ); - } else { - $s .= $this->submitButton( wfMsg( 'compareselectedversions'), - array( - 'class' => 'historysubmit', - 'accesskey' => wfMsg( 'accesskey-compareselectedversions' ), - 'title' => wfMsg( 'tooltip-compareselectedversions' ), - ) - ); + if ( $formType == 'compare' ) { + $s .= Xml::openElement( 'form', array( 'action' => $wgScript, + 'id' => 'mw-history-compare' ) ); + $s .= Xml::hidden( 'title', $this->title->getPrefixedDbKey() ); + if( $wgEnableHtmlDiff ) { + $s .= $this->submitButton( wfMsg( 'visualcomparison'), + array( + 'name' => 'htmldiff', + 'class' => 'historysubmit', + 'accesskey' => wfMsg( 'accesskey-visualcomparison' ), + 'title' => wfMsg( 'tooltip-compareselectedversions' ), + ) + ); + $s .= $this->submitButton( wfMsg( 'wikicodecomparison'), + array( + 'class' => 'historysubmit', + 'accesskey' => wfMsg( 'accesskey-compareselectedversions' ), + 'title' => wfMsg( 'tooltip-compareselectedversions' ), + ) + ); + } else { + $s .= $this->submitButton( wfMsg( 'compareselectedversions'), + array( + 'class' => 'historysubmit', + 'accesskey' => wfMsg( 'accesskey-compareselectedversions' ), + 'title' => wfMsg( 'tooltip-compareselectedversions' ), + ) + ); + } } $s .= ''; - if( $wgEnableHtmlDiff ) { - $s .= $this->submitButton( wfMsg( 'visualcomparison'), - array( - 'name' => 'htmldiff', - 'class' => 'historysubmit', - 'accesskey' => wfMsg( 'accesskey-visualcomparison' ), - 'title' => wfMsg( 'tooltip-compareselectedversions' ), - ) - ); - $s .= $this->submitButton( wfMsg( 'wikicodecomparison'), - array( - 'class' => 'historysubmit', - 'accesskey' => wfMsg( 'accesskey-compareselectedversions' ), - 'title' => wfMsg( 'tooltip-compareselectedversions' ), - ) - ); - } else { - $s .= $this->submitButton( wfMsg( 'compareselectedversions'), - array( - 'class' => 'historysubmit', - 'accesskey' => wfMsg( 'accesskey-compareselectedversions' ), - 'title' => wfMsg( 'tooltip-compareselectedversions' ), - ) - ); + if ( $this->historyPage->formType == 'compare' ) { + if( $wgEnableHtmlDiff ) { + $s .= $this->submitButton( wfMsg( 'visualcomparison'), + array( + 'name' => 'htmldiff', + 'class' => 'historysubmit', + 'accesskey' => wfMsg( 'accesskey-visualcomparison' ), + 'title' => wfMsg( 'tooltip-compareselectedversions' ), + ) + ); + $s .= $this->submitButton( wfMsg( 'wikicodecomparison'), + array( + 'class' => 'historysubmit', + 'accesskey' => wfMsg( 'accesskey-compareselectedversions' ), + 'title' => wfMsg( 'tooltip-compareselectedversions' ), + ) + ); + } else { + $s .= $this->submitButton( wfMsg( 'compareselectedversions'), + array( + 'class' => 'historysubmit', + 'accesskey' => wfMsg( 'accesskey-compareselectedversions' ), + 'title' => wfMsg( 'tooltip-compareselectedversions' ), + ) + ); + } + $s .= ''; + } elseif ( $this->historyPage->formType == 'hide' ) { + $s .= ''; } - $s .= ''; return $s; } @@ -455,15 +493,23 @@ $rev = new Revision( $row ); $rev->setTitle( $this->title ); - $curlink = $this->curLink( $rev, $latest ); - $lastlink = $this->lastLink( $rev, $next, $counter ); - $diffButtons = $this->diffButtons( $rev, $firstInList, $counter ); + if ( $this->historyPage->formType == 'simple' ) { + $s = '(' . $this->lastLink( $rev, $next, $counter ) . ')'; + } else { + $curlink = $this->curLink( $rev, $latest ); + $lastlink = $this->lastLink( $rev, $next, $counter ); + if ( $this->historyPage->formType == 'compare' ) { + $diffButtons = $this->diffButtons( $rev, $firstInList, $counter ); + } else { + $diffButtons = ''; + } + $s = "($curlink) ($lastlink) $diffButtons"; + } $link = $this->revLink( $rev ); $classes = array(); - $s = "($curlink) ($lastlink) $diffButtons"; - if( $wgUser->isAllowed( 'deleterevision' ) ) { + if( $this->historyPage->formType == 'hide' ) { // Hide JS by default for non-JS browsing $hidden = array( 'style' => 'display:none' ); // If revision was hidden from sysops @@ -491,13 +537,21 @@ } $s .= " $link"; - $s .= " " . $this->getSkin()->revUserTools( $rev, true ) . ""; + if ( $this->historyPage->formType == 'simple' ) { + $userLink = $this->getSkin()->revUserLink( $rev, true ); + } else { + $userLink = $this->getSkin()->revUserTools( $rev, true ); + } + $s .= " $userLink"; if( $rev->isMinor() ) { $s .= ' ' . ChangesList::flag( 'minor' ); } - if( !is_null( $size = $rev->getSize() ) && !$rev->isDeleted( Revision::DELETED_TEXT ) ) { + if( $this->historyPage->formType !== 'simple' + && !is_null( $size = $rev->getSize() ) + && !$rev->isDeleted( Revision::DELETED_TEXT ) ) + { $s .= ' ' . $this->getSkin()->formatRevisionSize( $size ); } @@ -515,7 +569,8 @@ $this->getSkin()->buildRollbackLink( $rev ).''; } - if( $this->title->quickUserCan( 'edit' ) + if( $this->historyPage->formType !== 'simple' + && $this->title->quickUserCan( 'edit' ) && !$rev->isDeleted( Revision::DELETED_TEXT ) && !$next->rev_deleted & Revision::DELETED_TEXT ) { @@ -608,7 +663,11 @@ * @returns string */ function lastLink( $prevRev, $next, $counter ) { - $last = $this->historyPage->message['last']; + if ( $this->historyPage->formType == 'simple' ) { + $last = $this->historyPage->message['last-long']; + } else { + $last = $this->historyPage->message['last']; + } # $next may either be a Row, null, or "unkown" $nextRev = is_object($next) ? new Revision( $next ) : $next; if( is_null($next) ) { Index: languages/messages/MessagesEn.php =================================================================== --- languages/messages/MessagesEn.php (revision 51282) +++ languages/messages/MessagesEn.php (working copy) @@ -1252,6 +1252,9 @@ 'histlast' => 'Latest', 'historysize' => '({{PLURAL:$1|1 byte|$1 bytes}})', 'historyempty' => '(empty)', +'history-form-simple' => 'Simple view', +'history-form-compare' => 'Compare any two revisions', +'history-form-hide' => 'Show or hide revisions', # Revision feed 'history-feed-title' => 'Revision history',