* @ingroup Pager
*/
class HistoryPager extends ReverseChronologicalPager {
- public $lastRow = false, $counter, $historyPage, $title;
+ public $lastRow = false, $counter, $historyPage, $title, $buttons;
protected $oldIdChecked;
function __construct( $historyPage, $year='', $month='', $tagFilter = '' ) {
$this->oldIdChecked = 0;
$wgOut->wrapWikiMsg( "<div class='mw-history-legend'>\n$1</div>", 'histlegend' );
- $s = '';
- if( $this->getNumRows() > 1 && $wgUser->isAllowed('deleterevision') ) {
- $revdel = SpecialPage::getTitleFor( 'Revisiondelete' );
- $s .= Xml::openElement( 'form',
+ $s = Xml::openElement( 'form', array( 'action' => $wgScript,
+ 'id' => 'mw-history-compare' ) ) . "\n";
+ $s .= Xml::hidden( 'title', $this->title->getPrefixedDbKey() ) . "\n";
+
+ $this->buttons = '<div>';
+ if( $wgUser->isAllowed('deleterevision') ) {
+ $this->buttons .= Xml::element( 'button',
array(
- 'action' => $revdel->getLocalURL( array(
- 'type' => 'revision',
- 'target' => $this->title->getPrefixedDbKey()
- ) ),
- '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' );
+ 'type' => 'submit',
+ 'name' => 'action',
+ 'value' => 'revisiondelete',
+ 'style' => 'float: right',
+ ),
+ wfMsg( 'showhideselectedversions' )
+ ) . "\n";
}
- $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'),
+ $this->buttons .= Xml::element( 'button',
array(
- 'name' => 'htmldiff',
+ 'type' => 'submit',
+ 'name' => 'htmldiff',
+ 'value' => '1',
'class' => 'historysubmit',
'accesskey' => wfMsg( 'accesskey-visualcomparison' ),
'title' => wfMsg( 'tooltip-compareselectedversions' ),
- )
- );
- $s .= $this->submitButton( wfMsg( 'wikicodecomparison'),
+ ),
+ wfMsg( 'visualcomparison')
+ ) . "\n";
+ $this->buttons .= $this->submitButton( wfMsg( 'wikicodecomparison'),
array(
'class' => 'historysubmit',
'accesskey' => wfMsg( 'accesskey-compareselectedversions' ),
'title' => wfMsg( 'tooltip-compareselectedversions' ),
)
- );
+ ) . "\n";
} else {
- $s .= $this->submitButton( wfMsg( 'compareselectedversions'),
+ $this->buttons .= $this->submitButton( wfMsg( 'compareselectedversions'),
array(
'class' => 'historysubmit',
'accesskey' => wfMsg( 'accesskey-compareselectedversions' ),
'title' => wfMsg( 'tooltip-compareselectedversions' ),
)
- );
+ ) . "\n";
}
- $s .= '<ul id="pagehistory">' . "\n";
+ $this->buttons .= '</div>';
+ $s .= $this->buttons . '<ul id="pagehistory">' . "\n";
return $s;
}
function getEndBody() {
-
if( $this->lastRow ) {
$latest = $this->counter == 1 && $this->mIsFirst;
$firstInList = $this->counter == 1;
} else {
$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' ),
- )
- );
- }
+ $s .= "</ul>\n";
+ $s .= $this->buttons;
$s .= '</form>';
return $s;
}
$s = "($curlink) ($lastlink) $diffButtons";
if( $wgUser->isAllowed( 'deleterevision' ) ) {
- // Hide JS by default for non-JS browsing
- $hidden = array( 'style' => 'display:none' );
// If revision was hidden from sysops
if( !$rev->userCan( Revision::DELETED_RESTRICTED ) ) {
- $del = Xml::check( 'deleterevisions', false,
- $hidden + array('disabled' => 'disabled') );
+ $del = Xml::check( 'deleterevisions', false, array('disabled' => 'disabled') );
$del .= Xml::tags( 'span', array( 'class'=>'mw-revdelundel-link' ),
'(' . $this->historyPage->message['rev-delundel'] . ')' );
// Otherwise, show the link...
} else {
$id = $rev->getId();
- $jsCall = "updateShowHideForm($id,this.checked)";
- $del = Xml::check( 'showhiderevisions', false,
- $hidden + array(
- 'onchange' => $jsCall,
- 'id' => "mw-revdel-$id" ) );
+ $del = Xml::check( 'showhiderevisions', false, array( 'name' => "ids[$id]" ) );
$query = array(
'type' => 'revision',
'target' => $this->title->getPrefixedDbkey(),
- 'ids' => $rev->getId() );
+ 'ids' => $id );
$del .= $this->getSkin()->revDeleteLink( $query,
$rev->isDeleted( Revision::DELETED_RESTRICTED ) );
}
$this->outputHeader();
$this->submitClicked = $wgRequest->wasPosted() && $wgRequest->getBool( 'wpSubmit' );
# Handle our many different possible input types.
- # Use CSV, since the cgi handling will break on arrays.
- $this->ids = explode( ',', $wgRequest->getVal('ids') );
+ $ids = $wgRequest->getVal( 'ids' );
+ if ( !is_null( $ids ) ) {
+ # Allow CSV, for backwards compatibility, or a single ID for show/hide links
+ $this->ids = explode( ',', $ids );
+ } else {
+ # Array input
+ $this->ids = array_keys( $wgRequest->getArray( 'ids' ) );
+ }
+ $this->ids = array_map( 'intval', $this->ids );
$this->ids = array_unique( array_filter( $this->ids ) );
- $this->targetObj = Title::newFromText( $wgRequest->getText( 'target' ) );
+
+ if ( $wgRequest->getVal( 'action' ) == 'revisiondelete' ) {
+ # For show/hide form submission from history page
+ $this->targetObj = $GLOBALS['wgTitle'];
+ $this->typeName = 'revision';
+ } else {
+ $this->typeName = $wgRequest->getVal( 'type' );
+ $this->targetObj = Title::newFromText( $wgRequest->getText( 'target' ) );
+ }
# For reviewing deleted files...
$this->archiveName = $wgRequest->getVal( 'file' );
return;
}
- $this->typeName = $wgRequest->getVal( 'type' );
if ( isset( self::$deprecatedTypeMap[$this->typeName] ) ) {
$this->typeName = self::$deprecatedTypeMap[$this->typeName];
}
return radios;
}
-function deleteCheck(parent) {
- var inputs = parent.getElementsByTagName('input');
- for (var i = 0; i < inputs.length; i++) {
- if (inputs[i].name == "showhiderevisions") {
- return inputs[i];
- }
- }
- return null;
-}
-
// check selection and tweak visibility/class onclick
function diffcheck() {
var dli = false; // the li where the diff radio is checked
function histrowinit() {
var hf = document.getElementById('pagehistory');
if (!hf) return;
- var df = document.getElementById('mw-history-revdeleteform');
- if( df ) df.style.visibility = 'visible'; // Enable JS form
var lis = hf.getElementsByTagName('li');
for (var i = 0; i < lis.length; i++) {
var inputs = historyRadios(lis[i]);
inputs[0].onclick = diffcheck;
inputs[1].onclick = diffcheck;
}
- var check = deleteCheck(lis[i]);
- if( df && check ) {
- check.style.display = 'inline'; // Enable JS form
- }
}
diffcheck();
}
-// Multi-item revision delete. 'checked' is the *previous* state.
-function updateShowHideForm( oldid, checked ) {
- var formOldids = document.getElementById('revdel-oldid');
- if( !formOldids ) return;
- if( checked ) { // add on oldid if checked
- if( formOldids.value ) {
- formOldids.value += ',' + oldid;
- } else {
- formOldids.value = oldid;
- }
- } else if( formOldids.value ) { // remove oldid if unchecked
- var reg = new RegExp( '(^|,)'+oldid+'($|,)' );
- formOldids.value = formOldids.value.replace( reg, '' );
- }
-}
-
hookEvent("load", histrowinit);