Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 88 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
| SpecialAllMessages | |
0.00% |
0 / 87 |
|
0.00% |
0 / 3 |
30 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| execute | |
0.00% |
0 / 85 |
|
0.00% |
0 / 1 |
12 | |||
| getGroupName | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * @license GPL-2.0-or-later |
| 4 | * @file |
| 5 | */ |
| 6 | |
| 7 | namespace MediaWiki\Specials; |
| 8 | |
| 9 | use MediaWiki\Html\FormOptions; |
| 10 | use MediaWiki\Html\Html; |
| 11 | use MediaWiki\HTMLForm\HTMLForm; |
| 12 | use MediaWiki\Language\LocalisationCache; |
| 13 | use MediaWiki\Languages\LanguageFactory; |
| 14 | use MediaWiki\Languages\LanguageNameUtils; |
| 15 | use MediaWiki\MainConfigNames; |
| 16 | use MediaWiki\Pager\AllMessagesTablePager; |
| 17 | use MediaWiki\Parser\ParserOptions; |
| 18 | use MediaWiki\SpecialPage\SpecialPage; |
| 19 | use Wikimedia\Rdbms\IConnectionProvider; |
| 20 | |
| 21 | /** |
| 22 | * List of the MediaWiki interface messages. |
| 23 | * |
| 24 | * @ingroup SpecialPage |
| 25 | */ |
| 26 | class SpecialAllMessages extends SpecialPage { |
| 27 | |
| 28 | public function __construct( |
| 29 | private readonly LanguageFactory $languageFactory, |
| 30 | private readonly LanguageNameUtils $languageNameUtils, |
| 31 | private readonly LocalisationCache $localisationCache, |
| 32 | private readonly IConnectionProvider $dbProvider |
| 33 | ) { |
| 34 | parent::__construct( 'Allmessages' ); |
| 35 | } |
| 36 | |
| 37 | /** |
| 38 | * @param string|null $par Parameter passed to the page or null |
| 39 | */ |
| 40 | public function execute( $par ) { |
| 41 | $out = $this->getOutput(); |
| 42 | |
| 43 | $this->setHeaders(); |
| 44 | |
| 45 | if ( !$this->getConfig()->get( MainConfigNames::UseDatabaseMessages ) ) { |
| 46 | $out->addWikiMsg( 'allmessages-not-supported-database' ); |
| 47 | |
| 48 | return; |
| 49 | } |
| 50 | |
| 51 | $out->addModuleStyles( 'mediawiki.special' ); |
| 52 | $this->addHelpLink( 'Help:System message' ); |
| 53 | |
| 54 | $contLangCode = $this->getContentLanguage()->getCode(); |
| 55 | $lang = $this->getLanguage(); |
| 56 | |
| 57 | $opts = new FormOptions(); |
| 58 | |
| 59 | $opts->add( 'prefix', '' ); |
| 60 | $opts->add( 'filter', 'all' ); |
| 61 | $opts->add( 'lang', $contLangCode ); |
| 62 | $opts->add( 'limit', 50 ); |
| 63 | |
| 64 | $opts->fetchValuesFromRequest( $this->getRequest() ); |
| 65 | $opts->validateIntBounds( 'limit', 0, 5000 ); |
| 66 | |
| 67 | if ( !$this->languageNameUtils->isKnownLanguageTag( $opts->getValue( 'lang' ) ) ) { |
| 68 | // Show a warning message and fallback to content language |
| 69 | $out->addHTML( |
| 70 | Html::warningBox( |
| 71 | $this->msg( 'allmessages-unknown-language' ) |
| 72 | ->plaintextParams( $opts->getValue( 'lang' ) ) |
| 73 | ->parse() |
| 74 | ) |
| 75 | ); |
| 76 | $opts->setValue( 'lang', $contLangCode ); |
| 77 | } |
| 78 | |
| 79 | $pager = new AllMessagesTablePager( |
| 80 | $this->getContext(), |
| 81 | $this->getContentLanguage(), |
| 82 | $this->languageFactory, |
| 83 | $this->getLinkRenderer(), |
| 84 | $this->dbProvider, |
| 85 | $this->localisationCache, |
| 86 | $opts |
| 87 | ); |
| 88 | |
| 89 | $formDescriptor = [ |
| 90 | 'prefix' => [ |
| 91 | 'type' => 'text', |
| 92 | 'name' => 'prefix', |
| 93 | 'label-message' => 'allmessages-prefix', |
| 94 | ], |
| 95 | |
| 96 | 'filter' => [ |
| 97 | 'type' => 'radio', |
| 98 | 'name' => 'filter', |
| 99 | 'label-message' => 'allmessages-filter', |
| 100 | 'options-messages' => [ |
| 101 | 'allmessages-filter-unmodified' => 'unmodified', |
| 102 | 'allmessages-filter-all' => 'all', |
| 103 | 'allmessages-filter-modified' => 'modified', |
| 104 | ], |
| 105 | 'default' => 'all', |
| 106 | 'flatlist' => true, |
| 107 | ], |
| 108 | |
| 109 | 'lang' => [ |
| 110 | 'type' => 'language', |
| 111 | 'name' => 'lang', |
| 112 | 'label-message' => 'allmessages-language', |
| 113 | 'default' => $opts->getValue( 'lang' ), |
| 114 | ], |
| 115 | |
| 116 | 'limit' => [ |
| 117 | 'type' => 'limitselect', |
| 118 | 'name' => 'limit', |
| 119 | 'label-message' => 'table_pager_limit_label', |
| 120 | 'options' => [ |
| 121 | $lang->formatNum( 20 ) => 20, |
| 122 | $lang->formatNum( 50 ) => 50, |
| 123 | $lang->formatNum( 100 ) => 100, |
| 124 | $lang->formatNum( 250 ) => 250, |
| 125 | $lang->formatNum( 500 ) => 500, |
| 126 | $lang->formatNum( 5000 ) => 5000, |
| 127 | ], |
| 128 | 'default' => $opts->getValue( 'limit' ), |
| 129 | ], |
| 130 | ]; |
| 131 | |
| 132 | $htmlForm = HTMLForm::factory( 'ooui', $formDescriptor, $this->getContext() ); |
| 133 | $htmlForm |
| 134 | ->setMethod( 'get' ) |
| 135 | ->setPreHtml( $this->msg( 'allmessagestext' )->parse() ) |
| 136 | ->setWrapperLegendMsg( 'allmessages' ) |
| 137 | ->setSubmitTextMsg( 'allmessages-filter-submit' ) |
| 138 | ->prepareForm() |
| 139 | ->displayForm( false ); |
| 140 | |
| 141 | $out->addParserOutputContent( |
| 142 | $pager->getFullOutput(), |
| 143 | ParserOptions::newFromContext( $this->getContext() ) |
| 144 | ); |
| 145 | } |
| 146 | |
| 147 | /** @inheritDoc */ |
| 148 | protected function getGroupName() { |
| 149 | return 'wiki'; |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | /** @deprecated class alias since 1.41 */ |
| 154 | class_alias( SpecialAllMessages::class, 'SpecialAllMessages' ); |