43 $output->setPageTitle( $this->
msg(
'gadgets-title' ) );
44 $output->addWikiMsg(
'gadgets-pagetext' );
51 $output->disallowUserJs();
54 if ( !
$lang->equals( MediaWikiServices::getInstance()->getContentLanguage() ) ) {
55 $langSuffix =
"/" .
$lang->getCode();
60 $editInterfaceMessage = $this->
getUser()->isAllowed(
'editinterface' )
65 foreach ( $gadgets as $section => $entries ) {
66 if ( $section !==
false && $section !==
'' ) {
67 $t = Title::makeTitleSafe(
NS_MEDIAWIKI,
"Gadget-section-$section$langSuffix" );
70 [], [
'action' =>
'edit' ] )
71 : htmlspecialchars( $section );
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 ) {
126 $output->addHTML(
'<br />' );
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 );
147 $output->addHTML(
$lang->commaList( $lnk ) );
150 if ( $gadget->getLegacyScripts() ) {
151 if ( $needLineBreakAfter ) {
152 $output->addHTML(
'<br />' );
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 ) {
173 $output->addHTML(
'<br />' );
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 ) {
196 $output->addHTML(
'<br />' );
199 $this->
msg(
'gadgets-required-skins',
$lang->commaList( $skins ) )
200 ->numParams( count( $skins ) )->parse()
202 $needLineBreakAfter =
true;
207 if ( $gadget->isOnByDefault() ) {
208 if ( $needLineBreakAfter ) {
209 $output->addHTML(
'<br />' );
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" );
235 }
catch ( InvalidArgumentException $e ) {
236 $output->showErrorPage(
'error',
'gadgets-not-found', [ $gadget ] );
241 $output->setPageTitle( $this->
msg(
'gadgets-export-title' ) );
242 $output->addWikiMsg(
'gadgets-export-text', $gadget, $g->getDefinition() );
244 $exportList =
"MediaWiki:gadget-$gadget\n";
245 foreach ( $g->getScriptsAndStyles() as $page ) {
246 $exportList .=
"$page\n";
249 $htmlForm = HTMLForm::factory(
'ooui', [], $this->
getContext() );
252 ->addHiddenField(
'pages', $exportList )
253 ->addHiddenField(
'wpDownload',
'1' )
254 ->addHiddenField(
'templates',
'1' )
257 ->setSubmitText( $this->
msg(
'gadgets-export-download' )->text() )
259 ->displayForm(
false );