Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like SpecialContributions often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use SpecialContributions, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 29 | class SpecialContributions extends IncludableSpecialPage { |
||
| 30 | protected $opts; |
||
| 31 | |||
| 32 | public function __construct() { |
||
| 35 | |||
| 36 | public function execute( $par ) { |
||
| 37 | $this->setHeaders(); |
||
| 38 | $this->outputHeader(); |
||
| 39 | $out = $this->getOutput(); |
||
| 40 | $out->addModuleStyles( [ |
||
| 41 | 'mediawiki.special', |
||
| 42 | 'mediawiki.special.changeslist', |
||
| 43 | ] ); |
||
| 44 | $this->addHelpLink( 'Help:User contributions' ); |
||
| 45 | |||
| 46 | $this->opts = []; |
||
| 47 | $request = $this->getRequest(); |
||
| 48 | |||
| 49 | if ( $par !== null ) { |
||
| 50 | $target = $par; |
||
| 51 | } else { |
||
| 52 | $target = $request->getVal( 'target' ); |
||
| 53 | } |
||
| 54 | |||
| 55 | if ( $request->getVal( 'contribs' ) == 'newbie' || $par === 'newbies' ) { |
||
| 56 | $target = 'newbies'; |
||
| 57 | $this->opts['contribs'] = 'newbie'; |
||
| 58 | } else { |
||
| 59 | $this->opts['contribs'] = 'user'; |
||
| 60 | } |
||
| 61 | |||
| 62 | $this->opts['deletedOnly'] = $request->getBool( 'deletedOnly' ); |
||
| 63 | |||
| 64 | if ( !strlen( $target ) ) { |
||
| 65 | if ( !$this->including() ) { |
||
| 66 | $out->addHTML( $this->getForm() ); |
||
| 67 | } |
||
| 68 | |||
| 69 | return; |
||
| 70 | } |
||
| 71 | |||
| 72 | $user = $this->getUser(); |
||
| 73 | |||
| 74 | $this->opts['limit'] = $request->getInt( 'limit', $user->getOption( 'rclimit' ) ); |
||
| 75 | $this->opts['target'] = $target; |
||
| 76 | $this->opts['topOnly'] = $request->getBool( 'topOnly' ); |
||
| 77 | $this->opts['newOnly'] = $request->getBool( 'newOnly' ); |
||
| 78 | $this->opts['hideMinor'] = $request->getBool( 'hideMinor' ); |
||
| 79 | |||
| 80 | $nt = Title::makeTitleSafe( NS_USER, $target ); |
||
| 81 | if ( !$nt ) { |
||
| 82 | $out->addHTML( $this->getForm() ); |
||
| 83 | |||
| 84 | return; |
||
| 85 | } |
||
| 86 | $userObj = User::newFromName( $nt->getText(), false ); |
||
| 87 | if ( !$userObj ) { |
||
| 88 | $out->addHTML( $this->getForm() ); |
||
| 89 | |||
| 90 | return; |
||
| 91 | } |
||
| 92 | $id = $userObj->getId(); |
||
| 93 | |||
| 94 | if ( $this->opts['contribs'] != 'newbie' ) { |
||
| 95 | $target = $nt->getText(); |
||
| 96 | $out->addSubtitle( $this->contributionsSub( $userObj ) ); |
||
| 97 | $out->setHTMLTitle( $this->msg( |
||
| 98 | 'pagetitle', |
||
| 99 | $this->msg( 'contributions-title', $target )->plain() |
||
| 100 | )->inContentLanguage() ); |
||
| 101 | $this->getSkin()->setRelevantUser( $userObj ); |
||
| 102 | } else { |
||
| 103 | $out->addSubtitle( $this->msg( 'sp-contributions-newbies-sub' ) ); |
||
| 104 | $out->setHTMLTitle( $this->msg( |
||
| 105 | 'pagetitle', |
||
| 106 | $this->msg( 'sp-contributions-newbies-title' )->plain() |
||
| 107 | )->inContentLanguage() ); |
||
| 108 | } |
||
| 109 | |||
| 110 | $ns = $request->getVal( 'namespace', null ); |
||
| 111 | if ( $ns !== null && $ns !== '' ) { |
||
| 112 | $this->opts['namespace'] = intval( $ns ); |
||
| 113 | } else { |
||
| 114 | $this->opts['namespace'] = ''; |
||
| 115 | } |
||
| 116 | |||
| 117 | $this->opts['associated'] = $request->getBool( 'associated' ); |
||
| 118 | $this->opts['nsInvert'] = (bool)$request->getVal( 'nsInvert' ); |
||
| 119 | $this->opts['tagfilter'] = (string)$request->getVal( 'tagfilter' ); |
||
| 120 | |||
| 121 | // Allows reverts to have the bot flag in recent changes. It is just here to |
||
| 122 | // be passed in the form at the top of the page |
||
| 123 | if ( $user->isAllowed( 'markbotedits' ) && $request->getBool( 'bot' ) ) { |
||
| 124 | $this->opts['bot'] = '1'; |
||
| 125 | } |
||
| 126 | |||
| 127 | $skip = $request->getText( 'offset' ) || $request->getText( 'dir' ) == 'prev'; |
||
| 128 | # Offset overrides year/month selection |
||
| 129 | if ( $skip ) { |
||
| 130 | $this->opts['year'] = ''; |
||
| 131 | $this->opts['month'] = ''; |
||
| 132 | } else { |
||
| 133 | $this->opts['year'] = $request->getIntOrNull( 'year' ); |
||
| 134 | $this->opts['month'] = $request->getIntOrNull( 'month' ); |
||
| 135 | } |
||
| 136 | |||
| 137 | $feedType = $request->getVal( 'feed' ); |
||
| 138 | |||
| 139 | $feedParams = [ |
||
| 140 | 'action' => 'feedcontributions', |
||
| 141 | 'user' => $target, |
||
| 142 | ]; |
||
| 143 | if ( $this->opts['topOnly'] ) { |
||
| 144 | $feedParams['toponly'] = true; |
||
| 145 | } |
||
| 146 | if ( $this->opts['newOnly'] ) { |
||
| 147 | $feedParams['newonly'] = true; |
||
| 148 | } |
||
| 149 | if ( $this->opts['hideMinor'] ) { |
||
| 150 | $feedParams['hideminor'] = true; |
||
| 151 | } |
||
| 152 | if ( $this->opts['deletedOnly'] ) { |
||
| 153 | $feedParams['deletedonly'] = true; |
||
| 154 | } |
||
| 155 | if ( $this->opts['tagfilter'] !== '' ) { |
||
| 156 | $feedParams['tagfilter'] = $this->opts['tagfilter']; |
||
| 157 | } |
||
| 158 | if ( $this->opts['namespace'] !== '' ) { |
||
| 159 | $feedParams['namespace'] = $this->opts['namespace']; |
||
| 160 | } |
||
| 161 | // Don't use year and month for the feed URL, but pass them on if |
||
| 162 | // we redirect to API (if $feedType is specified) |
||
| 163 | View Code Duplication | if ( $feedType && $this->opts['year'] !== null ) { |
|
|
|
|||
| 164 | $feedParams['year'] = $this->opts['year']; |
||
| 165 | } |
||
| 166 | View Code Duplication | if ( $feedType && $this->opts['month'] !== null ) { |
|
| 167 | $feedParams['month'] = $this->opts['month']; |
||
| 168 | } |
||
| 169 | |||
| 170 | if ( $feedType ) { |
||
| 171 | // Maintain some level of backwards compatibility |
||
| 172 | // If people request feeds using the old parameters, redirect to API |
||
| 173 | $feedParams['feedformat'] = $feedType; |
||
| 174 | $url = wfAppendQuery( wfScript( 'api' ), $feedParams ); |
||
| 175 | |||
| 176 | $out->redirect( $url, '301' ); |
||
| 177 | |||
| 178 | return; |
||
| 179 | } |
||
| 180 | |||
| 181 | // Add RSS/atom links |
||
| 182 | $this->addFeedLinks( $feedParams ); |
||
| 183 | |||
| 184 | if ( Hooks::run( 'SpecialContributionsBeforeMainOutput', [ $id, $userObj, $this ] ) ) { |
||
| 185 | if ( !$this->including() ) { |
||
| 186 | $out->addHTML( $this->getForm() ); |
||
| 187 | } |
||
| 188 | $pager = new ContribsPager( $this->getContext(), [ |
||
| 189 | 'target' => $target, |
||
| 190 | 'contribs' => $this->opts['contribs'], |
||
| 191 | 'namespace' => $this->opts['namespace'], |
||
| 192 | 'tagfilter' => $this->opts['tagfilter'], |
||
| 193 | 'year' => $this->opts['year'], |
||
| 194 | 'month' => $this->opts['month'], |
||
| 195 | 'deletedOnly' => $this->opts['deletedOnly'], |
||
| 196 | 'topOnly' => $this->opts['topOnly'], |
||
| 197 | 'newOnly' => $this->opts['newOnly'], |
||
| 198 | 'hideMinor' => $this->opts['hideMinor'], |
||
| 199 | 'nsInvert' => $this->opts['nsInvert'], |
||
| 200 | 'associated' => $this->opts['associated'], |
||
| 201 | ] ); |
||
| 202 | |||
| 203 | if ( !$pager->getNumRows() ) { |
||
| 204 | $out->addWikiMsg( 'nocontribs', $target ); |
||
| 205 | } else { |
||
| 206 | # Show a message about replica DB lag, if applicable |
||
| 207 | $lag = wfGetLB()->safeGetLag( $pager->getDatabase() ); |
||
| 208 | if ( $lag > 0 ) { |
||
| 209 | $out->showLagWarning( $lag ); |
||
| 210 | } |
||
| 211 | |||
| 212 | $output = $pager->getBody(); |
||
| 213 | if ( !$this->including() ) { |
||
| 214 | $output = '<p>' . $pager->getNavigationBar() . '</p>' . |
||
| 215 | $output . |
||
| 216 | '<p>' . $pager->getNavigationBar() . '</p>'; |
||
| 217 | } |
||
| 218 | $out->addHTML( $output ); |
||
| 219 | } |
||
| 220 | $out->preventClickjacking( $pager->getPreventClickjacking() ); |
||
| 221 | |||
| 222 | # Show the appropriate "footer" message - WHOIS tools, etc. |
||
| 223 | if ( $this->opts['contribs'] == 'newbie' ) { |
||
| 224 | $message = 'sp-contributions-footer-newbies'; |
||
| 225 | } elseif ( IP::isIPAddress( $target ) ) { |
||
| 226 | $message = 'sp-contributions-footer-anon'; |
||
| 227 | } elseif ( $userObj->isAnon() ) { |
||
| 228 | // No message for non-existing users |
||
| 229 | $message = ''; |
||
| 230 | } else { |
||
| 231 | $message = 'sp-contributions-footer'; |
||
| 232 | } |
||
| 233 | |||
| 234 | if ( $message ) { |
||
| 235 | if ( !$this->including() ) { |
||
| 236 | if ( !$this->msg( $message, $target )->isDisabled() ) { |
||
| 237 | $out->wrapWikiMsg( |
||
| 238 | "<div class='mw-contributions-footer'>\n$1\n</div>", |
||
| 239 | [ $message, $target ] ); |
||
| 240 | } |
||
| 241 | } |
||
| 242 | } |
||
| 243 | } |
||
| 244 | } |
||
| 245 | |||
| 246 | /** |
||
| 247 | * Generates the subheading with links |
||
| 248 | * @param User $userObj User object for the target |
||
| 249 | * @return string Appropriately-escaped HTML to be output literally |
||
| 250 | * @todo FIXME: Almost the same as getSubTitle in SpecialDeletedContributions.php. |
||
| 251 | * Could be combined. |
||
| 252 | */ |
||
| 253 | protected function contributionsSub( $userObj ) { |
||
| 313 | |||
| 314 | /** |
||
| 315 | * Links to different places. |
||
| 316 | * |
||
| 317 | * @note This function is also called in DeletedContributionsPage |
||
| 318 | * @param SpecialPage $sp SpecialPage instance, for context |
||
| 319 | * @param User $target Target user object |
||
| 320 | * @return array |
||
| 321 | */ |
||
| 322 | public static function getUserLinks( SpecialPage $sp, User $target ) { |
||
| 406 | |||
| 407 | /** |
||
| 408 | * Generates the namespace selector form with hidden attributes. |
||
| 409 | * @return string HTML fragment |
||
| 410 | */ |
||
| 411 | protected function getForm() { |
||
| 412 | $this->opts['title'] = $this->getPageTitle()->getPrefixedText(); |
||
| 413 | if ( !isset( $this->opts['target'] ) ) { |
||
| 414 | $this->opts['target'] = ''; |
||
| 415 | } else { |
||
| 416 | $this->opts['target'] = str_replace( '_', ' ', $this->opts['target'] ); |
||
| 417 | } |
||
| 418 | |||
| 419 | if ( !isset( $this->opts['namespace'] ) ) { |
||
| 420 | $this->opts['namespace'] = ''; |
||
| 421 | } |
||
| 422 | |||
| 423 | if ( !isset( $this->opts['nsInvert'] ) ) { |
||
| 424 | $this->opts['nsInvert'] = ''; |
||
| 425 | } |
||
| 426 | |||
| 427 | if ( !isset( $this->opts['associated'] ) ) { |
||
| 428 | $this->opts['associated'] = false; |
||
| 429 | } |
||
| 430 | |||
| 431 | if ( !isset( $this->opts['contribs'] ) ) { |
||
| 432 | $this->opts['contribs'] = 'user'; |
||
| 433 | } |
||
| 434 | |||
| 435 | if ( !isset( $this->opts['year'] ) ) { |
||
| 436 | $this->opts['year'] = ''; |
||
| 437 | } |
||
| 438 | |||
| 439 | if ( !isset( $this->opts['month'] ) ) { |
||
| 440 | $this->opts['month'] = ''; |
||
| 441 | } |
||
| 442 | |||
| 443 | if ( $this->opts['contribs'] == 'newbie' ) { |
||
| 444 | $this->opts['target'] = ''; |
||
| 445 | } |
||
| 446 | |||
| 447 | if ( !isset( $this->opts['tagfilter'] ) ) { |
||
| 448 | $this->opts['tagfilter'] = ''; |
||
| 449 | } |
||
| 450 | |||
| 451 | if ( !isset( $this->opts['topOnly'] ) ) { |
||
| 452 | $this->opts['topOnly'] = false; |
||
| 453 | } |
||
| 454 | |||
| 455 | if ( !isset( $this->opts['newOnly'] ) ) { |
||
| 456 | $this->opts['newOnly'] = false; |
||
| 457 | } |
||
| 458 | |||
| 459 | if ( !isset( $this->opts['hideMinor'] ) ) { |
||
| 460 | $this->opts['hideMinor'] = false; |
||
| 461 | } |
||
| 462 | |||
| 463 | $form = Html::openElement( |
||
| 464 | 'form', |
||
| 465 | [ |
||
| 466 | 'method' => 'get', |
||
| 467 | 'action' => wfScript(), |
||
| 468 | 'class' => 'mw-contributions-form' |
||
| 469 | ] |
||
| 470 | ); |
||
| 471 | |||
| 472 | # Add hidden params for tracking except for parameters in $skipParameters |
||
| 473 | $skipParameters = [ |
||
| 474 | 'namespace', |
||
| 475 | 'nsInvert', |
||
| 476 | 'deletedOnly', |
||
| 477 | 'target', |
||
| 478 | 'contribs', |
||
| 479 | 'year', |
||
| 480 | 'month', |
||
| 481 | 'topOnly', |
||
| 482 | 'newOnly', |
||
| 483 | 'hideMinor', |
||
| 484 | 'associated', |
||
| 485 | 'tagfilter' |
||
| 486 | ]; |
||
| 487 | |||
| 488 | foreach ( $this->opts as $name => $value ) { |
||
| 489 | if ( in_array( $name, $skipParameters ) ) { |
||
| 490 | continue; |
||
| 491 | } |
||
| 492 | $form .= "\t" . Html::hidden( $name, $value ) . "\n"; |
||
| 493 | } |
||
| 494 | |||
| 495 | $tagFilter = ChangeTags::buildTagFilterSelector( $this->opts['tagfilter'] ); |
||
| 496 | |||
| 497 | if ( $tagFilter ) { |
||
| 498 | $filterSelection = Html::rawElement( |
||
| 499 | 'div', |
||
| 500 | [], |
||
| 501 | implode( ' ', $tagFilter ) |
||
| 502 | ); |
||
| 503 | } else { |
||
| 504 | $filterSelection = Html::rawElement( 'div', [], '' ); |
||
| 505 | } |
||
| 506 | |||
| 507 | $this->getOutput()->addModules( 'mediawiki.userSuggest' ); |
||
| 508 | |||
| 509 | $labelNewbies = Xml::radioLabel( |
||
| 510 | $this->msg( 'sp-contributions-newbies' )->text(), |
||
| 511 | 'contribs', |
||
| 512 | 'newbie', |
||
| 513 | 'newbie', |
||
| 514 | $this->opts['contribs'] == 'newbie', |
||
| 515 | [ 'class' => 'mw-input' ] |
||
| 516 | ); |
||
| 517 | $labelUsername = Xml::radioLabel( |
||
| 518 | $this->msg( 'sp-contributions-username' )->text(), |
||
| 519 | 'contribs', |
||
| 520 | 'user', |
||
| 521 | 'user', |
||
| 522 | $this->opts['contribs'] == 'user', |
||
| 523 | [ 'class' => 'mw-input' ] |
||
| 524 | ); |
||
| 525 | $input = Html::input( |
||
| 526 | 'target', |
||
| 527 | $this->opts['target'], |
||
| 528 | 'text', |
||
| 529 | [ |
||
| 530 | 'size' => '40', |
||
| 531 | 'required' => '', |
||
| 532 | 'class' => [ |
||
| 533 | 'mw-input', |
||
| 534 | 'mw-ui-input-inline', |
||
| 535 | 'mw-autocomplete-user', // used by mediawiki.userSuggest |
||
| 536 | ], |
||
| 537 | ] + ( |
||
| 538 | // Only autofocus if target hasn't been specified or in non-newbies mode |
||
| 539 | ( $this->opts['contribs'] === 'newbie' || $this->opts['target'] ) |
||
| 540 | ? [] : [ 'autofocus' => true ] |
||
| 541 | ) |
||
| 542 | ); |
||
| 543 | |||
| 544 | $targetSelection = Html::rawElement( |
||
| 545 | 'div', |
||
| 546 | [], |
||
| 547 | $labelNewbies . '<br>' . $labelUsername . ' ' . $input . ' ' |
||
| 548 | ); |
||
| 549 | |||
| 550 | $namespaceSelection = Xml::tags( |
||
| 551 | 'div', |
||
| 552 | [], |
||
| 553 | Xml::label( |
||
| 554 | $this->msg( 'namespace' )->text(), |
||
| 555 | 'namespace', |
||
| 556 | '' |
||
| 557 | ) . ' ' . |
||
| 558 | Html::namespaceSelector( |
||
| 559 | [ 'selected' => $this->opts['namespace'], 'all' => '' ], |
||
| 560 | [ |
||
| 561 | 'name' => 'namespace', |
||
| 562 | 'id' => 'namespace', |
||
| 563 | 'class' => 'namespaceselector', |
||
| 564 | ] |
||
| 565 | ) . ' ' . |
||
| 566 | Html::rawElement( |
||
| 567 | 'span', |
||
| 568 | [ 'class' => 'mw-input-with-label' ], |
||
| 569 | Xml::checkLabel( |
||
| 570 | $this->msg( 'invert' )->text(), |
||
| 571 | 'nsInvert', |
||
| 572 | 'nsInvert', |
||
| 573 | $this->opts['nsInvert'], |
||
| 574 | [ |
||
| 575 | 'title' => $this->msg( 'tooltip-invert' )->text(), |
||
| 576 | 'class' => 'mw-input' |
||
| 577 | ] |
||
| 578 | ) . ' ' |
||
| 579 | ) . |
||
| 580 | Html::rawElement( 'span', [ 'class' => 'mw-input-with-label' ], |
||
| 581 | Xml::checkLabel( |
||
| 582 | $this->msg( 'namespace_association' )->text(), |
||
| 583 | 'associated', |
||
| 584 | 'associated', |
||
| 585 | $this->opts['associated'], |
||
| 586 | [ |
||
| 587 | 'title' => $this->msg( 'tooltip-namespace_association' )->text(), |
||
| 588 | 'class' => 'mw-input' |
||
| 589 | ] |
||
| 590 | ) . ' ' |
||
| 591 | ) |
||
| 592 | ); |
||
| 593 | |||
| 594 | $filters = []; |
||
| 595 | |||
| 596 | if ( $this->getUser()->isAllowed( 'deletedhistory' ) ) { |
||
| 597 | $filters[] = Html::rawElement( |
||
| 598 | 'span', |
||
| 599 | [ 'class' => 'mw-input-with-label' ], |
||
| 600 | Xml::checkLabel( |
||
| 601 | $this->msg( 'history-show-deleted' )->text(), |
||
| 602 | 'deletedOnly', |
||
| 603 | 'mw-show-deleted-only', |
||
| 604 | $this->opts['deletedOnly'], |
||
| 605 | [ 'class' => 'mw-input' ] |
||
| 606 | ) |
||
| 607 | ); |
||
| 608 | } |
||
| 609 | |||
| 610 | $filters[] = Html::rawElement( |
||
| 611 | 'span', |
||
| 612 | [ 'class' => 'mw-input-with-label' ], |
||
| 613 | Xml::checkLabel( |
||
| 614 | $this->msg( 'sp-contributions-toponly' )->text(), |
||
| 615 | 'topOnly', |
||
| 616 | 'mw-show-top-only', |
||
| 617 | $this->opts['topOnly'], |
||
| 618 | [ 'class' => 'mw-input' ] |
||
| 619 | ) |
||
| 620 | ); |
||
| 621 | $filters[] = Html::rawElement( |
||
| 622 | 'span', |
||
| 623 | [ 'class' => 'mw-input-with-label' ], |
||
| 624 | Xml::checkLabel( |
||
| 625 | $this->msg( 'sp-contributions-newonly' )->text(), |
||
| 626 | 'newOnly', |
||
| 627 | 'mw-show-new-only', |
||
| 628 | $this->opts['newOnly'], |
||
| 629 | [ 'class' => 'mw-input' ] |
||
| 630 | ) |
||
| 631 | ); |
||
| 632 | $filters[] = Html::rawElement( |
||
| 633 | 'span', |
||
| 634 | [ 'class' => 'mw-input-with-label' ], |
||
| 635 | Xml::checkLabel( |
||
| 636 | $this->msg( 'sp-contributions-hideminor' )->text(), |
||
| 637 | 'hideMinor', |
||
| 638 | 'mw-hide-minor-edits', |
||
| 639 | $this->opts['hideMinor'], |
||
| 640 | [ 'class' => 'mw-input' ] |
||
| 641 | ) |
||
| 642 | ); |
||
| 643 | |||
| 644 | Hooks::run( |
||
| 645 | 'SpecialContributions::getForm::filters', |
||
| 646 | [ $this, &$filters ] |
||
| 647 | ); |
||
| 648 | |||
| 649 | $extraOptions = Html::rawElement( |
||
| 650 | 'div', |
||
| 651 | [], |
||
| 652 | implode( '', $filters ) |
||
| 653 | ); |
||
| 654 | |||
| 655 | $dateSelectionAndSubmit = Xml::tags( 'div', [], |
||
| 656 | Xml::dateMenu( |
||
| 657 | $this->opts['year'] === '' ? MWTimestamp::getInstance()->format( 'Y' ) : $this->opts['year'], |
||
| 658 | $this->opts['month'] |
||
| 659 | ) . ' ' . |
||
| 660 | Html::submitButton( |
||
| 661 | $this->msg( 'sp-contributions-submit' )->text(), |
||
| 662 | [ 'class' => 'mw-submit' ], [ 'mw-ui-progressive' ] |
||
| 663 | ) |
||
| 664 | ); |
||
| 665 | |||
| 666 | $form .= Xml::fieldset( |
||
| 667 | $this->msg( 'sp-contributions-search' )->text(), |
||
| 668 | $targetSelection . |
||
| 669 | $namespaceSelection . |
||
| 670 | $filterSelection . |
||
| 671 | $extraOptions . |
||
| 672 | $dateSelectionAndSubmit, |
||
| 673 | [ 'class' => 'mw-contributions-table' ] |
||
| 674 | ); |
||
| 675 | |||
| 676 | $explain = $this->msg( 'sp-contributions-explain' ); |
||
| 677 | if ( !$explain->isBlank() ) { |
||
| 678 | $form .= "<p id='mw-sp-contributions-explain'>{$explain->parse()}</p>"; |
||
| 679 | } |
||
| 680 | |||
| 681 | $form .= Xml::closeElement( 'form' ); |
||
| 682 | |||
| 683 | return $form; |
||
| 684 | } |
||
| 685 | |||
| 686 | /** |
||
| 687 | * Return an array of subpages beginning with $search that this special page will accept. |
||
| 688 | * |
||
| 689 | * @param string $search Prefix to search for |
||
| 690 | * @param int $limit Maximum number of results to return (usually 10) |
||
| 691 | * @param int $offset Number of results to skip (usually 0) |
||
| 692 | * @return string[] Matching subpages |
||
| 693 | */ |
||
| 694 | View Code Duplication | public function prefixSearchSubpages( $search, $limit, $offset ) { |
|
| 703 | |||
| 704 | protected function getGroupName() { |
||
| 707 | } |
||
| 708 |
In PHP, under loose comparison (like
==, or!=, orswitchconditions), values of different types might be equal.For
stringvalues, the empty string''is a special case, in particular the following results might be unexpected: