43 $output->setPageTitle( $this->
msg(
'gadgets-title' ) );
44 $output->addWikiMsg(
'gadgets-pagetext' );
54 if ( !
$lang->equals( MediaWikiServices::getInstance()->getContentLanguage() ) ) {
55 $langSuffix =
"/" .
$lang->getCode();
60 $editInterfaceMessage = $this->
getUser()->isAllowed(
'editinterface' )
65 foreach ( $gadgets as
$section => $entries ) {
67 $t = Title::makeTitleSafe( NS_MEDIAWIKI,
"Gadget-section-$section$langSuffix" );
70 [], [
'action' =>
'edit' ] )
72 $lnk =
"    [$lnkTarget]";
74 $ttext = $this->
msg(
"gadget-section-$section" )->parse();
77 $output->addHTML( Xml::closeElement(
'ul' ) .
"\n" );
81 $output->addHTML( Html::rawElement(
'h2', [], $ttext . $lnk ) .
"\n" );
87 foreach ( $entries as $gadget ) {
88 $name = $gadget->getName();
89 $t = Title::makeTitleSafe( NS_MEDIAWIKI,
"Gadget-{$name}$langSuffix" );
97 $this->
msg( $editInterfaceMessage )->
text(),
99 [
'action' =>
'edit' ]
103 $this->
msg(
'gadgets-export' )->
text()
106 $nameHtml = $this->
msg(
"gadget-{$name}" )->parse();
110 $output->addHTML( Html::openElement(
'ul' ) );
113 $actionsHtml =
'  ' .
114 $this->
msg(
'parentheses' )->rawParams(
$lang->pipeList( $links ) )->escaped();
116 Html::openElement(
'li', [
'id' => $this->
makeAnchor( $name ) ] ) .
117 $nameHtml . $actionsHtml
122 $needLineBreakAfter =
true;
125 if ( $needLineBreakAfter ) {
129 $this->
msg(
'gadgets-uses' )->escaped() .
130 $this->
msg(
'colon-separator' )->escaped()
133 foreach ( $gadget->getPeers() as $peer ) {
134 $lnk[] = Html::element(
136 [
'href' =>
'#' . $this->
makeAnchor( $peer ) ],
140 foreach ( $gadget->getScriptsAndStyles() as $codePage ) {
141 $t = Title::newFromText( $codePage );
150 if ( $gadget->getLegacyScripts() ) {
151 if ( $needLineBreakAfter ) {
154 $output->addHTML( Html::rawElement(
156 [
'class' =>
'mw-gadget-legacy errorbox' ],
157 $this->
msg(
'gadgets-legacy' )->parse()
159 $needLineBreakAfter =
true;
164 foreach ( $gadget->getRequiredRights() as $right ) {
165 $rights[] =
'* ' . Html::element(
167 [
'title' => $this->
msg(
"right-$right" )->
plain() ],
172 if ( $needLineBreakAfter ) {
176 $this->
msg(
'gadgets-required-rights', implode(
"\n", $rights ), count( $rights ) )->parse()
178 $needLineBreakAfter =
false;
182 $requiredSkins = $gadget->getRequiredSkins();
184 if ( is_array( $requiredSkins ) ) {
186 $validskins = Skin::getSkinNames();
187 foreach ( $requiredSkins as $skinid ) {
188 if ( isset( $validskins[$skinid] ) ) {
189 $skins[] = $this->
msg(
"skinname-$skinid" )->plain();
195 if ( $needLineBreakAfter ) {
199 $this->
msg(
'gadgets-required-skins',
$lang->commaList( $skins ) )
200 ->numParams( count( $skins ) )->parse()
202 $needLineBreakAfter =
true;
207 if ( $gadget->isOnByDefault() ) {
208 if ( $needLineBreakAfter ) {
211 $output->addHTML( $this->
msg(
'gadgets-default' )->parse() );
212 $needLineBreakAfter =
true;
215 $output->addHTML( Html::closeElement(
'li' ) .
"\n" );
220 $output->addHTML( Html::closeElement(
'ul' ) .
"\n" );
234 }
catch ( InvalidArgumentException
$e ) {
235 $output->showErrorPage(
'error',
'gadgets-not-found', [ $gadget ] );
240 $output->setPageTitle( $this->
msg(
'gadgets-export-title' ) );
241 $output->addWikiMsg(
'gadgets-export-text', $gadget, $g->getDefinition() );
243 $exportList =
"MediaWiki:gadget-$gadget\n";
244 foreach ( $g->getScriptsAndStyles() as $page ) {
245 $exportList .=
"$page\n";
248 $htmlForm = HTMLForm::factory(
'ooui', [], $this->
getContext() );
251 ->addHiddenField(
'pages', $exportList )
252 ->addHiddenField(
'wpDownload',
'1' )
253 ->addHiddenField(
'templates',
'1' )
256 ->setSubmitText( $this->
msg(
'gadgets-export-download' )->
text() )
258 ->displayForm(
false );