16 parent::__construct(
'Gadgets',
'',
true );
23 $parts = explode(
'/', $par );
25 if ( count( $parts ) == 2 && $parts[0] ==
'export' ) {
33 return 'gadget-' . Sanitizer::escapeIdForAttribute( $gadgetName );
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 ) {
66 if ( $section !==
false && $section !==
'' ) {
70 [], [
'action' =>
'edit' ] )
71 : htmlspecialchars( $section );
72 $lnk =
"    [$lnkTarget]";
74 $ttext = $this->
msg(
"gadget-section-$section" )->parse();
81 $output->addHTML( Html::rawElement(
'h2', [], $ttext . $lnk ) .
"\n" );
87 foreach ( $entries as $gadget ) {
88 $name = $gadget->getName();
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 ) {
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 ) ) {
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" );
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";
252 ->addHiddenField(
'pages', $exportList )
253 ->addHiddenField(
'wpDownload',
'1' )
254 ->addHiddenField(
'templates',
'1' )
257 ->setSubmitText( $this->
msg(
'gadgets-export-download' )->text() )
259 ->displayForm(
false );