Index: trunk/phase3/RELEASE-NOTES-1.19 |
— | — | @@ -105,6 +105,7 @@ |
106 | 106 | * jQuery UI upgraded to 1.8.17 |
107 | 107 | * Extensions can use the 'Language::getMessagesFileName' hook to define new |
108 | 108 | languages using messages files outside of core. |
| 109 | +* (bug 32512) Include 'associated namespace' checkbox on Special:Contributions |
109 | 110 | |
110 | 111 | === Bug fixes in 1.19 === |
111 | 112 | * $wgUploadNavigationUrl should be used for file redlinks if. |
Index: trunk/phase3/includes/Namespace.php |
— | — | @@ -126,7 +126,7 @@ |
127 | 127 | public static function getAssociated( $index ) { |
128 | 128 | self::isMethodValidFor( $index, __METHOD__ ); |
129 | 129 | |
130 | | - if( self::isMain( $index ) ) { |
| 130 | + if( self::isSubject( $index ) ) { |
131 | 131 | return self::getTalk( $index ); |
132 | 132 | } elseif( self::isTalk( $index ) ) { |
133 | 133 | return self::getSubject( $index ); |
— | — | @@ -139,7 +139,7 @@ |
140 | 140 | * Returns whether the specified namespace exists |
141 | 141 | * |
142 | 142 | * @param $index |
143 | | - * |
| 143 | + * |
144 | 144 | * @return bool |
145 | 145 | * @since 1.19 |
146 | 146 | */ |
Index: trunk/phase3/includes/specials/SpecialContributions.php |
— | — | @@ -98,6 +98,8 @@ |
99 | 99 | $this->opts['namespace'] = ''; |
100 | 100 | } |
101 | 101 | |
| 102 | + $this->opts['associated'] = $request->getBool( 'associated' ); |
| 103 | + |
102 | 104 | $this->opts['nsInvert'] = (bool) $request->getVal( 'nsInvert' ); |
103 | 105 | |
104 | 106 | $this->opts['tagfilter'] = (string) $request->getVal( 'tagfilter' ); |
— | — | @@ -168,6 +170,7 @@ |
169 | 171 | 'deletedOnly' => $this->opts['deletedOnly'], |
170 | 172 | 'topOnly' => $this->opts['topOnly'], |
171 | 173 | 'nsInvert' => $this->opts['nsInvert'], |
| 174 | + 'associated' => $this->opts['associated'], |
172 | 175 | ) ); |
173 | 176 | if( !$pager->getNumRows() ) { |
174 | 177 | $out->addWikiMsg( 'nocontribs', $target ); |
— | — | @@ -357,6 +360,10 @@ |
358 | 361 | $this->opts['nsInvert'] = ''; |
359 | 362 | } |
360 | 363 | |
| 364 | + if( !isset( $this->opts['associated'] ) ) { |
| 365 | + $this->opts['associated'] = false; |
| 366 | + } |
| 367 | + |
361 | 368 | if( !isset( $this->opts['contribs'] ) ) { |
362 | 369 | $this->opts['contribs'] = 'user'; |
363 | 370 | } |
— | — | @@ -381,49 +388,143 @@ |
382 | 389 | $this->opts['topOnly'] = false; |
383 | 390 | } |
384 | 391 | |
385 | | - $f = Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript, 'class' => 'mw-contributions-form' ) ); |
| 392 | + $form = Xml::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript, 'class' => 'mw-contributions-form' ) ); |
386 | 393 | |
387 | 394 | # Add hidden params for tracking except for parameters in $skipParameters |
388 | | - $skipParameters = array( 'namespace', 'nsInvert', 'deletedOnly', 'target', 'contribs', 'year', 'month', 'topOnly' ); |
| 395 | + $skipParameters = array( 'namespace', 'nsInvert', 'deletedOnly', 'target', 'contribs', 'year', 'month', 'topOnly', 'associated' ); |
389 | 396 | foreach ( $this->opts as $name => $value ) { |
390 | 397 | if( in_array( $name, $skipParameters ) ) { |
391 | 398 | continue; |
392 | 399 | } |
393 | | - $f .= "\t" . Html::hidden( $name, $value ) . "\n"; |
| 400 | + $form .= "\t" . Html::hidden( $name, $value ) . "\n"; |
394 | 401 | } |
395 | 402 | |
396 | 403 | $tagFilter = ChangeTags::buildTagFilterSelector( $this->opts['tagfilter'] ); |
397 | 404 | |
398 | | - $f .= Xml::fieldset( wfMsg( 'sp-contributions-search' ) ) . |
399 | | - Xml::radioLabel( wfMsgExt( 'sp-contributions-newbies', array( 'parsemag' ) ), |
400 | | - 'contribs', 'newbie' , 'newbie', $this->opts['contribs'] == 'newbie' ) . '<br />' . |
401 | | - Xml::radioLabel( wfMsgExt( 'sp-contributions-username', array( 'parsemag' ) ), |
402 | | - 'contribs' , 'user', 'user', $this->opts['contribs'] == 'user' ) . ' ' . |
403 | | - Html::input( 'target', $this->opts['target'], 'text', array( |
404 | | - 'size' => '20', |
405 | | - 'required' => '' |
406 | | - ) + ( $this->opts['target'] ? array() : array( 'autofocus' ) ) ) . ' '. |
| 405 | + if ($tagFilter) { |
| 406 | + $filterSelection = |
| 407 | + Xml::tags( 'td', array( 'class' => 'mw-label' ), array_shift( $tagFilter ) ) . |
| 408 | + Xml::tags( 'td', array( 'class' => 'mw-input' ), implode( ' ', $tagFilter ) ); |
| 409 | + } else { |
| 410 | + $filterSelection = Xml::tags( 'td', array( 'colspan' => 2 ), '' ); |
| 411 | + } |
| 412 | + |
| 413 | + $targetSelection = Xml::tags( 'td', array( 'colspan' => 2 ), |
| 414 | + Xml::radioLabel( |
| 415 | + wfMsgExt( 'sp-contributions-newbies', array( 'parsemag' ) ), |
| 416 | + 'contribs', |
| 417 | + 'newbie' , |
| 418 | + 'newbie', |
| 419 | + $this->opts['contribs'] == 'newbie', |
| 420 | + array( 'class' => 'mw-input' ) |
| 421 | + ) . '<br />' . |
| 422 | + Xml::radioLabel( |
| 423 | + wfMsgExt( 'sp-contributions-username', array( 'parsemag' ) ), |
| 424 | + 'contribs', |
| 425 | + 'user', |
| 426 | + 'user', |
| 427 | + $this->opts['contribs'] == 'user', |
| 428 | + array( 'class' => 'mw-input' ) |
| 429 | + ) . ' ' . |
| 430 | + Html::input( |
| 431 | + 'target', |
| 432 | + $this->opts['target'], |
| 433 | + 'text', |
| 434 | + array( 'size' => '20', 'required' => '', 'class' => 'mw-input' ) + |
| 435 | + ( $this->opts['target'] ? array() : array( 'autofocus' ) |
| 436 | + ) |
| 437 | + ) . ' ' |
| 438 | + ) ; |
| 439 | + |
| 440 | + $namespaceSelection = |
| 441 | + Xml::tags( 'td', array( 'class' => 'mw-label' ), |
| 442 | + Xml::label( |
| 443 | + wfMsg( 'namespace' ), |
| 444 | + 'namespace', |
| 445 | + '' |
| 446 | + ) |
| 447 | + ) . |
| 448 | + Xml::tags( 'td', null, |
| 449 | + Xml::namespaceSelector( $this->opts['namespace'], '' ) . ' ' . |
| 450 | + Html::rawElement( 'span', array( 'style' => 'white-space: nowrap' ), |
| 451 | + Xml::checkLabel( |
| 452 | + wfMsg('invert'), |
| 453 | + 'nsInvert', |
| 454 | + 'nsInvert', |
| 455 | + $this->opts['nsInvert'], |
| 456 | + array( 'title' => wfMsg( 'tooltip-invert' ), 'class' => 'mw-input' ) |
| 457 | + ) . ' ' |
| 458 | + ) . |
| 459 | + Html::rawElement( 'span', array( 'style' => 'white-space: nowrap' ), |
| 460 | + Xml::checkLabel( |
| 461 | + wfMsg('namespace_association'), |
| 462 | + 'associated', |
| 463 | + 'associated', |
| 464 | + $this->opts['associated'], |
| 465 | + array( 'title' => wfMsg( 'tooltip-namespace_association' ), 'class' => 'mw-input' ) |
| 466 | + ) . ' ' |
| 467 | + ) |
| 468 | + ) ; |
| 469 | + |
| 470 | + $extraOptions = Xml::tags( 'td', array( 'colspan' => 2 ), |
407 | 471 | Html::rawElement( 'span', array( 'style' => 'white-space: nowrap' ), |
408 | | - Xml::label( wfMsg( 'namespace' ), 'namespace' ) . ' ' . |
409 | | - Xml::namespaceSelector( $this->opts['namespace'], '' ) |
| 472 | + Xml::checkLabel( |
| 473 | + wfMsg( 'history-show-deleted' ), |
| 474 | + 'deletedOnly', |
| 475 | + 'mw-show-deleted-only', |
| 476 | + $this->opts['deletedOnly'], |
| 477 | + array( 'class' => 'mw-input' ) |
| 478 | + ) |
410 | 479 | ) . |
411 | | - Xml::checkLabel( wfMsg('invert'), 'nsInvert', 'nsInvert', $this->opts['nsInvert'] ) . ' ' . |
412 | | - Xml::checkLabel( wfMsg( 'history-show-deleted' ), |
413 | | - 'deletedOnly', 'mw-show-deleted-only', $this->opts['deletedOnly'] ) . '<br />' . |
414 | | - Xml::tags( 'p', null, Xml::checkLabel( wfMsg( 'sp-contributions-toponly' ), |
415 | | - 'topOnly', 'mw-show-top-only', $this->opts['topOnly'] ) ) . |
416 | | - ( $tagFilter ? Xml::tags( 'p', null, implode( ' ', $tagFilter ) ) : '' ) . |
417 | | - Html::rawElement( 'p', array( 'style' => 'white-space: nowrap' ), |
418 | | - Xml::dateMenu( $this->opts['year'], $this->opts['month'] ) . ' ' . |
419 | | - Xml::submitButton( wfMsg( 'sp-contributions-submit' ) ) |
420 | | - ) . ' '; |
| 480 | + Html::rawElement( 'span', array( 'style' => 'white-space: nowrap' ), |
| 481 | + Xml::checkLabel( |
| 482 | + wfMsg( 'sp-contributions-toponly' ), |
| 483 | + 'topOnly', |
| 484 | + 'mw-show-top-only', |
| 485 | + $this->opts['topOnly'], |
| 486 | + array( 'class' => 'mw-input' ) |
| 487 | + ) |
| 488 | + ) |
| 489 | + ) ; |
| 490 | + |
| 491 | + $dateSelectionAndSubmit = Xml::tags( 'td', array( 'colspan' => 2 ), |
| 492 | + Xml::dateMenu( |
| 493 | + $this->opts['year'], |
| 494 | + $this->opts['month'] |
| 495 | + ) . ' ' . |
| 496 | + Xml::submitButton( |
| 497 | + wfMsg( 'sp-contributions-submit' ), |
| 498 | + array( 'class' => 'mw-submit' ) |
| 499 | + ) |
| 500 | + ) ; |
| 501 | + |
| 502 | + $form .= |
| 503 | + Xml::fieldset( wfMsg( 'sp-contributions-search' ) ) . |
| 504 | + Xml::openElement( 'table', array( 'class' => 'mw-contributions-table' ) ) . |
| 505 | + Xml::openElement( 'tr' ) . |
| 506 | + $targetSelection . |
| 507 | + Xml::closeElement( 'tr' ) . |
| 508 | + Xml::openElement( 'tr' ) . |
| 509 | + $namespaceSelection . |
| 510 | + Xml::closeElement( 'tr' ) . |
| 511 | + Xml::openElement( 'tr' ) . |
| 512 | + $filterSelection . |
| 513 | + Xml::closeElement( 'tr' ) . |
| 514 | + Xml::openElement( 'tr' ) . |
| 515 | + $extraOptions . |
| 516 | + Xml::closeElement( 'tr' ) . |
| 517 | + Xml::openElement( 'tr' ) . |
| 518 | + $dateSelectionAndSubmit . |
| 519 | + Xml::closeElement( 'tr' ) . |
| 520 | + Xml::closeElement( 'table' ); |
| 521 | + |
421 | 522 | $explain = wfMessage( 'sp-contributions-explain' ); |
422 | 523 | if ( $explain->exists() ) { |
423 | | - $f .= "<p id='mw-sp-contributions-explain'>{$explain}</p>"; |
| 524 | + $form .= "<p id='mw-sp-contributions-explain'>{$explain}</p>"; |
424 | 525 | } |
425 | | - $f .= Xml::closeElement('fieldset' ) . |
| 526 | + $form .= Xml::closeElement('fieldset' ) . |
426 | 527 | Xml::closeElement( 'form' ); |
427 | | - return $f; |
| 528 | + return $form; |
428 | 529 | } |
429 | 530 | } |
430 | 531 | |
— | — | @@ -451,6 +552,7 @@ |
452 | 553 | $this->namespace = isset( $options['namespace'] ) ? $options['namespace'] : ''; |
453 | 554 | $this->tagFilter = isset( $options['tagfilter'] ) ? $options['tagfilter'] : false; |
454 | 555 | $this->nsInvert = isset( $options['nsInvert'] ) ? $options['nsInvert'] : false; |
| 556 | + $this->associated = isset( $options['associated'] ) ? $options['associated'] : false; |
455 | 557 | |
456 | 558 | $this->deletedOnly = !empty( $options['deletedOnly'] ); |
457 | 559 | $this->topOnly = !empty( $options['topOnly'] ); |
— | — | @@ -545,11 +647,23 @@ |
546 | 648 | |
547 | 649 | function getNamespaceCond() { |
548 | 650 | if( $this->namespace !== '' ) { |
549 | | - if ( $this->nsInvert ) { |
550 | | - return array( 'page_namespace != ' . (int)$this->namespace ); |
| 651 | + $selectedNS = $this->mDb->addQuotes( $this->namespace ); |
| 652 | + $eq_op = $this->nsInvert ? '!=' : '='; |
| 653 | + $bool_op = $this->nsInvert ? 'AND' : 'OR'; |
| 654 | + |
| 655 | + if( !$this->associated ) { |
| 656 | + return array( "page_namespace $eq_op $selectedNS" ); |
551 | 657 | } else { |
552 | | - return array( 'page_namespace' => (int)$this->namespace ); |
| 658 | + $associatedNS = $this->mDb->addQuotes ( |
| 659 | + MWNamespace::getAssociated( $this->namespace ) |
| 660 | + ); |
| 661 | + return array( |
| 662 | + "page_namespace $eq_op $selectedNS " . |
| 663 | + $bool_op . |
| 664 | + " page_namespace $eq_op $associatedNS" |
| 665 | + ); |
553 | 666 | } |
| 667 | + |
554 | 668 | } else { |
555 | 669 | return array(); |
556 | 670 | } |