Page MenuHomePhabricator

unclutter-history-page.patch

Authored By
bzimport
Nov 21 2014, 10:37 PM
Size
9 KB
Referenced Files
None
Subscribers
None

unclutter-history-page.patch

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 .= '<p>';
+ $first = true;
+ foreach ( HistoryPage::$formTypes as $type => $class ) {
+ if ( $first ) {
+ $first = false;
+ } else {
+ $s .= ' | ';
+ }
+ $linkText = wfMsgHtml( "history-form-$type" );
+ if ( $type == $formType ) {
+ $s .= "<strong>$linkText</strong>";
+ } else {
+ $s .= $this->makeLink( $linkText, array( 'form' => $type ) );
+ }
+ }
+ $s .= '</p>';
+
+ 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 .= '<ul id="pagehistory">' . "\n";
return $s;
}
function getEndBody() {
+ global $wgEnableHtmlDiff;
if( $this->lastRow ) {
$latest = $this->counter == 1 && $this->mIsFirst;
@@ -389,34 +424,37 @@
$s = '';
}
- global $wgEnableHtmlDiff;
$s .= '</ul>';
- 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 .= '</form>';
+ } elseif ( $this->historyPage->formType == 'hide' ) {
+ $s .= '</form>';
}
- $s .= '</form>';
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 .= " <span class='history-user'>" . $this->getSkin()->revUserTools( $rev, true ) . "</span>";
+ if ( $this->historyPage->formType == 'simple' ) {
+ $userLink = $this->getSkin()->revUserLink( $rev, true );
+ } else {
+ $userLink = $this->getSkin()->revUserTools( $rev, true );
+ }
+ $s .= " <span class='history-user'>$userLink</span>";
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 ).'</span>';
}
- 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',

File Metadata

Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5248
Default Alt Text
unclutter-history-page.patch (9 KB)

Event Timeline