Index: trunk/phase3/skins/common/history.js |
— | — | @@ -9,16 +9,6 @@ |
10 | 10 | return radios; |
11 | 11 | } |
12 | 12 | |
13 | | -function deleteCheck(parent) { |
14 | | - var inputs = parent.getElementsByTagName('input'); |
15 | | - for (var i = 0; i < inputs.length; i++) { |
16 | | - if (inputs[i].name == "showhiderevisions") { |
17 | | - return inputs[i]; |
18 | | - } |
19 | | - } |
20 | | - return null; |
21 | | -} |
22 | | - |
23 | 13 | // check selection and tweak visibility/class onclick |
24 | 14 | function diffcheck() { |
25 | 15 | var dli = false; // the li where the diff radio is checked |
— | — | @@ -90,8 +80,6 @@ |
91 | 81 | function histrowinit() { |
92 | 82 | var hf = document.getElementById('pagehistory'); |
93 | 83 | if (!hf) return; |
94 | | - var df = document.getElementById('mw-history-revdeleteform'); |
95 | | - if( df ) df.style.visibility = 'visible'; // Enable JS form |
96 | 84 | var lis = hf.getElementsByTagName('li'); |
97 | 85 | for (var i = 0; i < lis.length; i++) { |
98 | 86 | var inputs = historyRadios(lis[i]); |
— | — | @@ -99,28 +87,8 @@ |
100 | 88 | inputs[0].onclick = diffcheck; |
101 | 89 | inputs[1].onclick = diffcheck; |
102 | 90 | } |
103 | | - var check = deleteCheck(lis[i]); |
104 | | - if( df && check ) { |
105 | | - check.style.display = 'inline'; // Enable JS form |
106 | | - } |
107 | 91 | } |
108 | 92 | diffcheck(); |
109 | 93 | } |
110 | 94 | |
111 | | -// Multi-item revision delete. 'checked' is the *previous* state. |
112 | | -function updateShowHideForm( oldid, checked ) { |
113 | | - var formOldids = document.getElementById('revdel-oldid'); |
114 | | - if( !formOldids ) return; |
115 | | - if( checked ) { // add on oldid if checked |
116 | | - if( formOldids.value ) { |
117 | | - formOldids.value += ',' + oldid; |
118 | | - } else { |
119 | | - formOldids.value = oldid; |
120 | | - } |
121 | | - } else if( formOldids.value ) { // remove oldid if unchecked |
122 | | - var reg = new RegExp( '(^|,)'+oldid+'($|,)' ); |
123 | | - formOldids.value = formOldids.value.replace( reg, '' ); |
124 | | - } |
125 | | -} |
126 | | - |
127 | 95 | hookEvent("load", histrowinit); |
Index: trunk/phase3/includes/Article.php |
— | — | @@ -937,7 +937,7 @@ |
938 | 938 | $rcid = $wgRequest->getVal( 'rcid' ); |
939 | 939 | $diffOnly = $wgRequest->getBool( 'diffonly', $wgUser->getOption( 'diffonly' ) ); |
940 | 940 | $purge = $wgRequest->getVal( 'action' ) == 'purge'; |
941 | | - $htmldiff = $wgRequest->getVal( 'htmldiff' , false); |
| 941 | + $htmldiff = $wgRequest->getBool( 'htmldiff' ); |
942 | 942 | $unhide = $wgRequest->getInt('unhide') == 1; |
943 | 943 | $oldid = $this->getOldID(); |
944 | 944 | |
Index: trunk/phase3/includes/HistoryPage.php |
— | — | @@ -260,7 +260,7 @@ |
261 | 261 | * @ingroup Pager |
262 | 262 | */ |
263 | 263 | class HistoryPager extends ReverseChronologicalPager { |
264 | | - public $lastRow = false, $counter, $historyPage, $title; |
| 264 | + public $lastRow = false, $counter, $historyPage, $title, $buttons; |
265 | 265 | protected $oldIdChecked; |
266 | 266 | |
267 | 267 | function __construct( $historyPage, $year='', $month='', $tagFilter = '' ) { |
— | — | @@ -323,58 +323,56 @@ |
324 | 324 | $this->oldIdChecked = 0; |
325 | 325 | |
326 | 326 | $wgOut->wrapWikiMsg( "<div class='mw-history-legend'>\n$1</div>", 'histlegend' ); |
327 | | - $s = ''; |
328 | | - if( $this->getNumRows() > 1 && $wgUser->isAllowed('deleterevision') ) { |
329 | | - $revdel = SpecialPage::getTitleFor( 'Revisiondelete' ); |
330 | | - $s .= Xml::openElement( 'form', |
| 327 | + $s = Xml::openElement( 'form', array( 'action' => $wgScript, |
| 328 | + 'id' => 'mw-history-compare' ) ) . "\n"; |
| 329 | + $s .= Xml::hidden( 'title', $this->title->getPrefixedDbKey() ) . "\n"; |
| 330 | + |
| 331 | + $this->buttons = '<div>'; |
| 332 | + if( $wgUser->isAllowed('deleterevision') ) { |
| 333 | + $this->buttons .= Xml::element( 'button', |
331 | 334 | array( |
332 | | - 'action' => $revdel->getLocalURL( array( |
333 | | - 'type' => 'revision', |
334 | | - 'target' => $this->title->getPrefixedDbKey() |
335 | | - ) ), |
336 | | - 'method' => 'post', |
337 | | - 'id' => 'mw-history-revdeleteform', |
338 | | - 'style' => 'visibility:hidden;float:right;' |
339 | | - ) |
340 | | - ); |
341 | | - $s .= Xml::hidden( 'ids', '', array('id'=>'revdel-oldid') ); |
342 | | - $s .= Xml::submitButton( wfMsg( 'showhideselectedversions' ) ); |
343 | | - $s .= Xml::closeElement( 'form' ); |
| 335 | + 'type' => 'submit', |
| 336 | + 'name' => 'action', |
| 337 | + 'value' => 'revisiondelete', |
| 338 | + 'style' => 'float: right', |
| 339 | + ), |
| 340 | + wfMsg( 'showhideselectedversions' ) |
| 341 | + ) . "\n"; |
344 | 342 | } |
345 | | - $s .= Xml::openElement( 'form', array( 'action' => $wgScript, |
346 | | - 'id' => 'mw-history-compare' ) ); |
347 | | - $s .= Xml::hidden( 'title', $this->title->getPrefixedDbKey() ); |
348 | 343 | if( $wgEnableHtmlDiff ) { |
349 | | - $s .= $this->submitButton( wfMsg( 'visualcomparison'), |
| 344 | + $this->buttons .= Xml::element( 'button', |
350 | 345 | array( |
351 | | - 'name' => 'htmldiff', |
| 346 | + 'type' => 'submit', |
| 347 | + 'name' => 'htmldiff', |
| 348 | + 'value' => '1', |
352 | 349 | 'class' => 'historysubmit', |
353 | 350 | 'accesskey' => wfMsg( 'accesskey-visualcomparison' ), |
354 | 351 | 'title' => wfMsg( 'tooltip-compareselectedversions' ), |
355 | | - ) |
356 | | - ); |
357 | | - $s .= $this->submitButton( wfMsg( 'wikicodecomparison'), |
| 352 | + ), |
| 353 | + wfMsg( 'visualcomparison') |
| 354 | + ) . "\n"; |
| 355 | + $this->buttons .= $this->submitButton( wfMsg( 'wikicodecomparison'), |
358 | 356 | array( |
359 | 357 | 'class' => 'historysubmit', |
360 | 358 | 'accesskey' => wfMsg( 'accesskey-compareselectedversions' ), |
361 | 359 | 'title' => wfMsg( 'tooltip-compareselectedversions' ), |
362 | 360 | ) |
363 | | - ); |
| 361 | + ) . "\n"; |
364 | 362 | } else { |
365 | | - $s .= $this->submitButton( wfMsg( 'compareselectedversions'), |
| 363 | + $this->buttons .= $this->submitButton( wfMsg( 'compareselectedversions'), |
366 | 364 | array( |
367 | 365 | 'class' => 'historysubmit', |
368 | 366 | 'accesskey' => wfMsg( 'accesskey-compareselectedversions' ), |
369 | 367 | 'title' => wfMsg( 'tooltip-compareselectedversions' ), |
370 | 368 | ) |
371 | | - ); |
| 369 | + ) . "\n"; |
372 | 370 | } |
373 | | - $s .= '<ul id="pagehistory">' . "\n"; |
| 371 | + $this->buttons .= '</div>'; |
| 372 | + $s .= $this->buttons . '<ul id="pagehistory">' . "\n"; |
374 | 373 | return $s; |
375 | 374 | } |
376 | 375 | |
377 | 376 | function getEndBody() { |
378 | | - |
379 | 377 | if( $this->lastRow ) { |
380 | 378 | $latest = $this->counter == 1 && $this->mIsFirst; |
381 | 379 | $firstInList = $this->counter == 1; |
— | — | @@ -394,34 +392,8 @@ |
395 | 393 | } else { |
396 | 394 | $s = ''; |
397 | 395 | } |
398 | | - |
399 | | - global $wgEnableHtmlDiff; |
400 | | - $s .= '</ul>'; |
401 | | - if( $wgEnableHtmlDiff ) { |
402 | | - $s .= $this->submitButton( wfMsg( 'visualcomparison'), |
403 | | - array( |
404 | | - 'name' => 'htmldiff', |
405 | | - 'class' => 'historysubmit', |
406 | | - 'accesskey' => wfMsg( 'accesskey-visualcomparison' ), |
407 | | - 'title' => wfMsg( 'tooltip-compareselectedversions' ), |
408 | | - ) |
409 | | - ); |
410 | | - $s .= $this->submitButton( wfMsg( 'wikicodecomparison'), |
411 | | - array( |
412 | | - 'class' => 'historysubmit', |
413 | | - 'accesskey' => wfMsg( 'accesskey-compareselectedversions' ), |
414 | | - 'title' => wfMsg( 'tooltip-compareselectedversions' ), |
415 | | - ) |
416 | | - ); |
417 | | - } else { |
418 | | - $s .= $this->submitButton( wfMsg( 'compareselectedversions'), |
419 | | - array( |
420 | | - 'class' => 'historysubmit', |
421 | | - 'accesskey' => wfMsg( 'accesskey-compareselectedversions' ), |
422 | | - 'title' => wfMsg( 'tooltip-compareselectedversions' ), |
423 | | - ) |
424 | | - ); |
425 | | - } |
| 396 | + $s .= "</ul>\n"; |
| 397 | + $s .= $this->buttons; |
426 | 398 | $s .= '</form>'; |
427 | 399 | return $s; |
428 | 400 | } |
— | — | @@ -470,26 +442,19 @@ |
471 | 443 | $s = "($curlink) ($lastlink) $diffButtons"; |
472 | 444 | |
473 | 445 | if( $wgUser->isAllowed( 'deleterevision' ) ) { |
474 | | - // Hide JS by default for non-JS browsing |
475 | | - $hidden = array( 'style' => 'display:none' ); |
476 | 446 | // If revision was hidden from sysops |
477 | 447 | if( !$rev->userCan( Revision::DELETED_RESTRICTED ) ) { |
478 | | - $del = Xml::check( 'deleterevisions', false, |
479 | | - $hidden + array('disabled' => 'disabled') ); |
| 448 | + $del = Xml::check( 'deleterevisions', false, array('disabled' => 'disabled') ); |
480 | 449 | $del .= Xml::tags( 'span', array( 'class'=>'mw-revdelundel-link' ), |
481 | 450 | '(' . $this->historyPage->message['rev-delundel'] . ')' ); |
482 | 451 | // Otherwise, show the link... |
483 | 452 | } else { |
484 | 453 | $id = $rev->getId(); |
485 | | - $jsCall = "updateShowHideForm($id,this.checked)"; |
486 | | - $del = Xml::check( 'showhiderevisions', false, |
487 | | - $hidden + array( |
488 | | - 'onchange' => $jsCall, |
489 | | - 'id' => "mw-revdel-$id" ) ); |
| 454 | + $del = Xml::check( 'showhiderevisions', false, array( 'name' => "ids[$id]" ) ); |
490 | 455 | $query = array( |
491 | 456 | 'type' => 'revision', |
492 | 457 | 'target' => $this->title->getPrefixedDbkey(), |
493 | | - 'ids' => $rev->getId() ); |
| 458 | + 'ids' => $id ); |
494 | 459 | $del .= $this->getSkin()->revDeleteLink( $query, |
495 | 460 | $rev->isDeleted( Revision::DELETED_RESTRICTED ) ); |
496 | 461 | } |
Index: trunk/phase3/includes/Wiki.php |
— | — | @@ -535,6 +535,11 @@ |
536 | 536 | $history = new HistoryPage( $article ); |
537 | 537 | $history->history(); |
538 | 538 | break; |
| 539 | + case 'revisiondelete': |
| 540 | + # For show/hide submission from history page |
| 541 | + $special = SpecialPage::getPage( 'Revisiondelete' ); |
| 542 | + $special->execute( '' ); |
| 543 | + break; |
539 | 544 | default: |
540 | 545 | if( wfRunHooks( 'UnknownAction', array( $action, $article ) ) ) { |
541 | 546 | $output->showErrorPage( 'nosuchaction', 'nosuchactiontext' ); |
Index: trunk/phase3/includes/specials/SpecialRevisiondelete.php |
— | — | @@ -107,11 +107,26 @@ |
108 | 108 | $this->outputHeader(); |
109 | 109 | $this->submitClicked = $wgRequest->wasPosted() && $wgRequest->getBool( 'wpSubmit' ); |
110 | 110 | # Handle our many different possible input types. |
111 | | - # Use CSV, since the cgi handling will break on arrays. |
112 | | - $this->ids = explode( ',', $wgRequest->getVal('ids') ); |
| 111 | + $ids = $wgRequest->getVal( 'ids' ); |
| 112 | + if ( !is_null( $ids ) ) { |
| 113 | + # Allow CSV, for backwards compatibility, or a single ID for show/hide links |
| 114 | + $this->ids = explode( ',', $ids ); |
| 115 | + } else { |
| 116 | + # Array input |
| 117 | + $this->ids = array_keys( $wgRequest->getArray( 'ids' ) ); |
| 118 | + } |
| 119 | + $this->ids = array_map( 'intval', $this->ids ); |
113 | 120 | $this->ids = array_unique( array_filter( $this->ids ) ); |
114 | | - $this->targetObj = Title::newFromText( $wgRequest->getText( 'target' ) ); |
115 | 121 | |
| 122 | + if ( $wgRequest->getVal( 'action' ) == 'revisiondelete' ) { |
| 123 | + # For show/hide form submission from history page |
| 124 | + $this->targetObj = $GLOBALS['wgTitle']; |
| 125 | + $this->typeName = 'revision'; |
| 126 | + } else { |
| 127 | + $this->typeName = $wgRequest->getVal( 'type' ); |
| 128 | + $this->targetObj = Title::newFromText( $wgRequest->getText( 'target' ) ); |
| 129 | + } |
| 130 | + |
116 | 131 | # For reviewing deleted files... |
117 | 132 | $this->archiveName = $wgRequest->getVal( 'file' ); |
118 | 133 | $this->token = $wgRequest->getVal( 'token' ); |
— | — | @@ -120,7 +135,6 @@ |
121 | 136 | return; |
122 | 137 | } |
123 | 138 | |
124 | | - $this->typeName = $wgRequest->getVal( 'type' ); |
125 | 139 | if ( isset( self::$deprecatedTypeMap[$this->typeName] ) ) { |
126 | 140 | $this->typeName = self::$deprecatedTypeMap[$this->typeName]; |
127 | 141 | } |