2007-07-31 10:21:34 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2023-10-25 22:32:58 +00:00
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
2008-02-04 08:08:43 +00:00
|
|
|
*
|
2010-06-06 15:12:22 +00:00
|
|
|
* @file
|
2007-07-31 10:21:34 +00:00
|
|
|
*/
|
|
|
|
|
2023-10-30 15:36:33 +00:00
|
|
|
namespace MediaWiki\Extension\Gadgets\Special;
|
2022-02-06 18:54:47 +00:00
|
|
|
|
|
|
|
use HTMLForm;
|
|
|
|
use InvalidArgumentException;
|
2023-10-30 15:36:33 +00:00
|
|
|
use MediaWiki\Extension\Gadgets\Gadget;
|
|
|
|
use MediaWiki\Extension\Gadgets\GadgetRepo;
|
2024-01-06 16:45:07 +00:00
|
|
|
use MediaWiki\Html\Html;
|
2018-08-04 22:47:17 +00:00
|
|
|
use MediaWiki\MediaWikiServices;
|
2024-01-06 16:45:07 +00:00
|
|
|
use MediaWiki\Parser\Sanitizer;
|
|
|
|
use MediaWiki\SpecialPage\SpecialPage;
|
2023-08-19 04:15:51 +00:00
|
|
|
use MediaWiki\Title\Title;
|
2018-08-04 22:47:17 +00:00
|
|
|
|
2023-10-25 22:32:58 +00:00
|
|
|
/**
|
|
|
|
* Special:Gadgets renders the data of MediaWiki:Gadgets-definition.
|
|
|
|
*
|
|
|
|
* @copyright 2007 Daniel Kinzler
|
|
|
|
*/
|
2007-07-31 10:21:34 +00:00
|
|
|
class SpecialGadgets extends SpecialPage {
|
2022-08-16 15:24:01 +00:00
|
|
|
private GadgetRepo $gadgetRepo;
|
|
|
|
|
|
|
|
public function __construct( GadgetRepo $gadgetRepo ) {
|
2022-08-08 15:44:05 +00:00
|
|
|
parent::__construct( 'Gadgets' );
|
2022-08-16 15:24:01 +00:00
|
|
|
$this->gadgetRepo = $gadgetRepo;
|
2007-07-31 10:21:34 +00:00
|
|
|
}
|
2008-02-04 08:08:43 +00:00
|
|
|
|
2024-02-07 13:04:41 +00:00
|
|
|
/**
|
|
|
|
* Return title for Special:Gadgets heading and Special:Specialpages link.
|
|
|
|
*
|
|
|
|
* @return \Message
|
|
|
|
*/
|
|
|
|
public function getDescription() {
|
|
|
|
return $this->msg( 'special-gadgets' );
|
|
|
|
}
|
|
|
|
|
2007-07-31 10:21:34 +00:00
|
|
|
/**
|
2019-06-04 15:32:42 +00:00
|
|
|
* @param string|null $par Parameters passed to the page
|
2007-07-31 10:21:34 +00:00
|
|
|
*/
|
2015-06-17 18:21:27 +00:00
|
|
|
public function execute( $par ) {
|
2022-06-29 00:37:36 +00:00
|
|
|
$parts = $par !== null ? explode( '/', $par ) : [];
|
2011-09-23 06:48:37 +00:00
|
|
|
|
2023-07-01 13:26:33 +00:00
|
|
|
if ( count( $parts ) === 2 && $parts[0] === 'export' ) {
|
2010-09-16 17:28:21 +00:00
|
|
|
$this->showExportForm( $parts[1] );
|
2010-08-08 18:22:22 +00:00
|
|
|
} else {
|
|
|
|
$this->showMainForm();
|
|
|
|
}
|
|
|
|
}
|
2011-09-23 06:48:37 +00:00
|
|
|
|
2020-10-12 09:32:09 +00:00
|
|
|
/**
|
|
|
|
* @param string $gadgetName
|
|
|
|
* @return string
|
|
|
|
*/
|
2016-11-18 04:54:17 +00:00
|
|
|
private function makeAnchor( $gadgetName ) {
|
2019-02-22 20:25:45 +00:00
|
|
|
return 'gadget-' . Sanitizer::escapeIdForAttribute( $gadgetName );
|
2016-11-18 04:54:17 +00:00
|
|
|
}
|
|
|
|
|
2010-08-08 18:22:22 +00:00
|
|
|
/**
|
|
|
|
* Displays form showing the list of installed gadgets
|
|
|
|
*/
|
|
|
|
public function showMainForm() {
|
2012-07-11 22:18:10 +00:00
|
|
|
$output = $this->getOutput();
|
2008-01-14 22:46:14 +00:00
|
|
|
$this->setHeaders();
|
2019-07-17 19:39:36 +00:00
|
|
|
$this->addHelpLink( 'Extension:Gadgets' );
|
2024-02-17 01:57:11 +00:00
|
|
|
$output->setPageTitleMsg( $this->msg( 'gadgets-title' ) );
|
2012-07-11 22:18:10 +00:00
|
|
|
$output->addWikiMsg( 'gadgets-pagetext' );
|
2007-07-31 10:21:34 +00:00
|
|
|
|
2022-08-16 15:24:01 +00:00
|
|
|
$gadgets = $this->gadgetRepo->getStructuredList();
|
2012-07-11 22:18:10 +00:00
|
|
|
if ( !$gadgets ) {
|
|
|
|
return;
|
|
|
|
}
|
2007-07-31 10:21:34 +00:00
|
|
|
|
2020-08-23 07:27:14 +00:00
|
|
|
$services = MediaWikiServices::getInstance();
|
|
|
|
|
2015-08-03 06:37:32 +00:00
|
|
|
$output->disallowUserJs();
|
2012-07-11 22:18:10 +00:00
|
|
|
$lang = $this->getLanguage();
|
|
|
|
$langSuffix = "";
|
2020-08-23 07:27:14 +00:00
|
|
|
if ( !$lang->equals( $services->getContentLanguage() ) ) {
|
2012-07-11 22:18:10 +00:00
|
|
|
$langSuffix = "/" . $lang->getCode();
|
2008-08-17 15:42:26 +00:00
|
|
|
}
|
|
|
|
|
2007-11-16 20:13:25 +00:00
|
|
|
$listOpen = false;
|
2007-07-31 10:21:34 +00:00
|
|
|
|
2021-12-26 21:23:06 +00:00
|
|
|
$editDefinitionMessage = $this->getUser()->isAllowed( 'gadgets-definition-edit' )
|
2012-05-18 09:49:15 +00:00
|
|
|
? 'edit'
|
|
|
|
: 'viewsource';
|
2021-12-26 21:23:06 +00:00
|
|
|
$editInterfaceMessage = $this->getUser()->isAllowed( 'editinterface' )
|
|
|
|
? 'gadgets-editdescription'
|
|
|
|
: 'gadgets-viewdescription';
|
2011-09-23 06:48:37 +00:00
|
|
|
|
2017-02-04 21:06:01 +00:00
|
|
|
$linkRenderer = $this->getLinkRenderer();
|
2020-08-23 07:27:14 +00:00
|
|
|
$skinFactory = $services->getSkinFactory();
|
2007-07-31 10:21:34 +00:00
|
|
|
foreach ( $gadgets as $section => $entries ) {
|
|
|
|
if ( $section !== false && $section !== '' ) {
|
2024-01-17 16:09:14 +00:00
|
|
|
if ( $listOpen ) {
|
|
|
|
$output->addHTML( Html::closeElement( 'ul' ) . "\n" );
|
|
|
|
$listOpen = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// H2 section heading
|
2024-01-17 16:18:01 +00:00
|
|
|
$headingText = Html::rawElement(
|
|
|
|
'span',
|
|
|
|
[ 'class' => 'mw-headline' ],
|
|
|
|
$this->msg( "gadget-section-$section" )->parse()
|
|
|
|
);
|
2024-01-17 15:59:17 +00:00
|
|
|
$title = Title::makeTitleSafe( NS_MEDIAWIKI, "Gadget-section-$section$langSuffix" );
|
2024-01-17 16:18:01 +00:00
|
|
|
$leftBracket = Html::rawElement(
|
|
|
|
'span',
|
|
|
|
[ 'class' => 'mw-editsection-bracket' ],
|
|
|
|
'['
|
|
|
|
);
|
2024-01-17 15:59:17 +00:00
|
|
|
$linkTarget = $title
|
|
|
|
? $linkRenderer->makeLink( $title, $this->msg( $editInterfaceMessage )->text(),
|
2017-02-04 21:06:01 +00:00
|
|
|
[], [ 'action' => 'edit' ] )
|
2012-05-18 09:49:15 +00:00
|
|
|
: htmlspecialchars( $section );
|
2024-01-17 16:18:01 +00:00
|
|
|
$rightBracket = Html::rawElement(
|
|
|
|
'span',
|
|
|
|
[ 'class' => 'mw-editsection-bracket' ],
|
|
|
|
']'
|
|
|
|
);
|
|
|
|
$editDescriptionLink = Html::rawElement(
|
|
|
|
'span',
|
|
|
|
[ 'class' => 'mw-editsection' ],
|
|
|
|
$leftBracket . $linkTarget . $rightBracket
|
|
|
|
);
|
|
|
|
$output->addHTML( Html::rawElement( 'h2', [], $headingText . $editDescriptionLink ) . "\n" );
|
2007-07-31 10:21:34 +00:00
|
|
|
}
|
2008-02-04 08:08:43 +00:00
|
|
|
|
2012-02-17 21:23:46 +00:00
|
|
|
/**
|
2024-01-17 15:52:04 +00:00
|
|
|
* @var Gadget $gadget
|
2012-02-17 21:23:46 +00:00
|
|
|
*/
|
2010-11-11 18:19:57 +00:00
|
|
|
foreach ( $entries as $gadget ) {
|
2016-11-18 04:54:17 +00:00
|
|
|
$name = $gadget->getName();
|
2024-01-17 15:59:17 +00:00
|
|
|
$title = Title::makeTitleSafe( NS_MEDIAWIKI, "Gadget-{$name}$langSuffix" );
|
|
|
|
if ( !$title ) {
|
2011-09-23 06:48:37 +00:00
|
|
|
continue;
|
|
|
|
}
|
2007-07-31 10:21:34 +00:00
|
|
|
|
2016-12-28 10:25:47 +00:00
|
|
|
$links = [];
|
2022-08-16 15:24:01 +00:00
|
|
|
$definitionTitle = $this->gadgetRepo->getGadgetDefinitionTitle( $name );
|
2021-12-26 21:23:06 +00:00
|
|
|
if ( $definitionTitle ) {
|
|
|
|
$links[] = $linkRenderer->makeLink(
|
|
|
|
$definitionTitle,
|
|
|
|
$this->msg( $editDefinitionMessage )->text(),
|
|
|
|
[],
|
|
|
|
[ 'action' => 'edit' ]
|
|
|
|
);
|
|
|
|
}
|
2017-02-04 21:06:01 +00:00
|
|
|
$links[] = $linkRenderer->makeLink(
|
2024-01-17 15:59:17 +00:00
|
|
|
$title,
|
2017-02-04 21:06:01 +00:00
|
|
|
$this->msg( $editInterfaceMessage )->text(),
|
2016-12-28 10:25:47 +00:00
|
|
|
[],
|
|
|
|
[ 'action' => 'edit' ]
|
2012-09-02 23:10:23 +00:00
|
|
|
);
|
2017-02-04 21:06:01 +00:00
|
|
|
$links[] = $linkRenderer->makeLink(
|
2016-11-18 04:54:17 +00:00
|
|
|
$this->getPageTitle( "export/{$name}" ),
|
2017-02-04 21:06:01 +00:00
|
|
|
$this->msg( 'gadgets-export' )->text()
|
2012-09-02 23:10:23 +00:00
|
|
|
);
|
2011-09-23 06:48:37 +00:00
|
|
|
|
2018-09-17 22:28:15 +00:00
|
|
|
$nameHtml = $this->msg( "gadget-{$name}" )->parse();
|
2008-07-07 18:50:47 +00:00
|
|
|
|
2011-09-23 06:48:37 +00:00
|
|
|
if ( !$listOpen ) {
|
2007-11-16 20:13:25 +00:00
|
|
|
$listOpen = true;
|
2018-09-17 22:28:15 +00:00
|
|
|
$output->addHTML( Html::openElement( 'ul' ) );
|
2007-11-16 20:13:25 +00:00
|
|
|
}
|
2011-09-23 06:48:37 +00:00
|
|
|
|
2018-09-17 22:28:15 +00:00
|
|
|
$actionsHtml = '  ' .
|
2015-02-07 13:31:19 +00:00
|
|
|
$this->msg( 'parentheses' )->rawParams( $lang->pipeList( $links ) )->escaped();
|
2016-11-18 04:54:17 +00:00
|
|
|
$output->addHTML(
|
2018-09-17 22:28:15 +00:00
|
|
|
Html::openElement( 'li', [ 'id' => $this->makeAnchor( $name ) ] ) .
|
|
|
|
$nameHtml . $actionsHtml
|
2010-01-12 19:45:49 +00:00
|
|
|
);
|
2018-09-17 22:28:15 +00:00
|
|
|
// Whether the next portion of the list item contents needs
|
|
|
|
// a line break between it and the next portion.
|
|
|
|
// This is set to false after lists, but true after lines of text.
|
|
|
|
$needLineBreakAfter = true;
|
2007-07-31 10:21:34 +00:00
|
|
|
|
2018-09-17 22:28:15 +00:00
|
|
|
// Portion: Show files, dependencies, speers
|
2018-09-26 02:45:07 +00:00
|
|
|
if ( $needLineBreakAfter ) {
|
|
|
|
$output->addHTML( '<br />' );
|
|
|
|
}
|
2018-09-17 22:28:15 +00:00
|
|
|
$output->addHTML(
|
|
|
|
$this->msg( 'gadgets-uses' )->escaped() .
|
|
|
|
$this->msg( 'colon-separator' )->escaped()
|
|
|
|
);
|
2024-01-17 15:59:17 +00:00
|
|
|
$links = [];
|
2016-11-18 04:54:17 +00:00
|
|
|
foreach ( $gadget->getPeers() as $peer ) {
|
2024-01-17 15:59:17 +00:00
|
|
|
$links[] = Html::element(
|
2016-11-18 04:54:17 +00:00
|
|
|
'a',
|
|
|
|
[ 'href' => '#' . $this->makeAnchor( $peer ) ],
|
|
|
|
$peer
|
|
|
|
);
|
|
|
|
}
|
2010-11-11 18:19:57 +00:00
|
|
|
foreach ( $gadget->getScriptsAndStyles() as $codePage ) {
|
2024-01-17 15:59:17 +00:00
|
|
|
$title = Title::newFromText( $codePage );
|
|
|
|
if ( !$title ) {
|
2011-09-23 06:48:37 +00:00
|
|
|
continue;
|
|
|
|
}
|
2024-01-17 15:59:17 +00:00
|
|
|
$links[] = $linkRenderer->makeLink( $title, $title->getText() );
|
2007-07-31 10:21:34 +00:00
|
|
|
}
|
2024-01-17 15:59:17 +00:00
|
|
|
$output->addHTML( $lang->commaList( $links ) );
|
2018-09-26 02:45:07 +00:00
|
|
|
|
2021-10-17 13:05:15 +00:00
|
|
|
if ( $gadget->isPackaged() ) {
|
|
|
|
if ( $needLineBreakAfter ) {
|
|
|
|
$output->addHTML( '<br />' );
|
|
|
|
}
|
|
|
|
$output->addHTML( $this->msg( 'gadgets-packaged',
|
2022-08-16 15:24:01 +00:00
|
|
|
$this->gadgetRepo->titleWithoutPrefix( $gadget->getScripts()[0] ) ) );
|
2021-10-17 13:05:15 +00:00
|
|
|
$needLineBreakAfter = true;
|
|
|
|
}
|
|
|
|
|
2018-09-26 02:45:07 +00:00
|
|
|
// Portion: Legacy scripts
|
2015-08-07 00:05:29 +00:00
|
|
|
if ( $gadget->getLegacyScripts() ) {
|
2018-09-17 22:28:15 +00:00
|
|
|
if ( $needLineBreakAfter ) {
|
|
|
|
$output->addHTML( '<br />' );
|
|
|
|
}
|
2022-03-24 14:22:40 +00:00
|
|
|
$output->addHTML( Html::errorBox(
|
|
|
|
$this->msg( 'gadgets-legacy' )->parse(),
|
|
|
|
'',
|
|
|
|
'mw-gadget-legacy'
|
2015-08-07 00:05:29 +00:00
|
|
|
) );
|
2022-03-24 14:22:40 +00:00
|
|
|
$needLineBreakAfter = false;
|
2015-08-07 00:05:29 +00:00
|
|
|
}
|
2011-10-22 19:09:25 +00:00
|
|
|
|
2022-01-30 13:15:25 +00:00
|
|
|
if ( $gadget->requiresES6() ) {
|
|
|
|
if ( $needLineBreakAfter ) {
|
|
|
|
$output->addHTML( '<br />' );
|
|
|
|
}
|
|
|
|
$output->addHTML(
|
|
|
|
$this->msg( 'gadgets-requires-es6' )->parse()
|
|
|
|
);
|
|
|
|
$needLineBreakAfter = true;
|
|
|
|
}
|
|
|
|
|
2018-09-17 22:28:15 +00:00
|
|
|
// Portion: Show required rights (optional)
|
2016-12-28 10:25:47 +00:00
|
|
|
$rights = [];
|
2011-10-20 13:48:06 +00:00
|
|
|
foreach ( $gadget->getRequiredRights() as $right ) {
|
2018-09-17 22:17:44 +00:00
|
|
|
$rights[] = '* ' . Html::element(
|
|
|
|
'code',
|
|
|
|
[ 'title' => $this->msg( "right-$right" )->plain() ],
|
|
|
|
$right
|
|
|
|
);
|
2011-10-20 13:48:06 +00:00
|
|
|
}
|
2018-09-17 22:28:15 +00:00
|
|
|
if ( $rights ) {
|
|
|
|
if ( $needLineBreakAfter ) {
|
|
|
|
$output->addHTML( '<br />' );
|
|
|
|
}
|
|
|
|
$output->addHTML(
|
|
|
|
$this->msg( 'gadgets-required-rights', implode( "\n", $rights ), count( $rights ) )->parse()
|
2011-04-12 18:09:50 +00:00
|
|
|
);
|
2018-09-17 22:28:15 +00:00
|
|
|
$needLineBreakAfter = false;
|
2011-04-12 18:09:50 +00:00
|
|
|
}
|
2011-09-23 06:48:37 +00:00
|
|
|
|
2018-09-17 22:28:15 +00:00
|
|
|
// Portion: Show required skins (optional)
|
2015-08-03 06:37:32 +00:00
|
|
|
$requiredSkins = $gadget->getRequiredSkins();
|
2023-07-24 12:36:59 +00:00
|
|
|
$skins = [];
|
|
|
|
$validskins = $skinFactory->getSkinNames();
|
|
|
|
foreach ( $requiredSkins as $skinid ) {
|
|
|
|
if ( isset( $validskins[$skinid] ) ) {
|
|
|
|
$skins[] = $this->msg( "skinname-$skinid" )->plain();
|
|
|
|
} else {
|
|
|
|
$skins[] = $skinid;
|
2015-08-03 06:37:32 +00:00
|
|
|
}
|
2023-07-24 12:36:59 +00:00
|
|
|
}
|
|
|
|
if ( $skins ) {
|
|
|
|
if ( $needLineBreakAfter ) {
|
|
|
|
$output->addHTML( '<br />' );
|
2012-01-18 02:44:37 +00:00
|
|
|
}
|
2023-07-24 12:36:59 +00:00
|
|
|
$output->addHTML(
|
|
|
|
$this->msg( 'gadgets-required-skins', $lang->commaList( $skins ) )
|
|
|
|
->numParams( count( $skins ) )->parse()
|
|
|
|
);
|
|
|
|
$needLineBreakAfter = true;
|
2011-10-22 19:09:25 +00:00
|
|
|
}
|
|
|
|
|
2021-12-14 13:10:22 +00:00
|
|
|
// Portion: Show required actions (optional)
|
|
|
|
$actions = $gadget->getRequiredActions();
|
|
|
|
if ( $actions ) {
|
|
|
|
if ( $needLineBreakAfter ) {
|
|
|
|
$output->addHTML( '<br />' );
|
|
|
|
}
|
|
|
|
$output->addHTML(
|
|
|
|
$this->msg( 'gadgets-required-actions', $lang->commaList( $actions ) )
|
|
|
|
->numParams( count( $actions ) )->parse()
|
|
|
|
);
|
|
|
|
$needLineBreakAfter = true;
|
|
|
|
}
|
|
|
|
|
2020-09-04 03:42:31 +00:00
|
|
|
// Portion: Show required namespaces (optional)
|
|
|
|
$namespaces = $gadget->getRequiredNamespaces();
|
|
|
|
if ( $namespaces ) {
|
|
|
|
if ( $needLineBreakAfter ) {
|
|
|
|
$output->addHTML( '<br />' );
|
|
|
|
}
|
|
|
|
$output->addHTML(
|
|
|
|
$this->msg(
|
|
|
|
'gadgets-required-namespaces',
|
|
|
|
$lang->commaList( array_map( function ( int $ns ) use ( $lang ) {
|
|
|
|
return $ns == NS_MAIN
|
|
|
|
? $this->msg( 'blanknamespace' )->text()
|
|
|
|
: $lang->getFormattedNsText( $ns );
|
|
|
|
}, $namespaces ) )
|
|
|
|
)->numParams( count( $namespaces ) )->parse()
|
|
|
|
);
|
|
|
|
$needLineBreakAfter = true;
|
|
|
|
}
|
|
|
|
|
2023-05-22 08:41:15 +00:00
|
|
|
// Portion: Show required content models (optional)
|
|
|
|
$contentModels = $gadget->getRequiredContentModels();
|
|
|
|
if ( $contentModels ) {
|
|
|
|
if ( $needLineBreakAfter ) {
|
|
|
|
$output->addHTML( '<br />' );
|
|
|
|
}
|
|
|
|
$output->addHTML(
|
|
|
|
$this->msg( 'gadgets-required-contentmodels', $lang->commaList( $contentModels ) )
|
|
|
|
->numParams( count( $contentModels ) )->parse()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-01-11 09:03:44 +00:00
|
|
|
if ( $gadget->supportsUrlLoad() ) {
|
|
|
|
if ( $needLineBreakAfter ) {
|
|
|
|
$output->addHTML( '<br />' );
|
|
|
|
}
|
|
|
|
$output->addHTML( $this->msg( 'gadgets-supports-urlload' )->parse() );
|
|
|
|
$needLineBreakAfter = true;
|
|
|
|
}
|
|
|
|
|
2018-09-17 22:28:15 +00:00
|
|
|
// Portion: Show on by default (optional)
|
2011-04-12 18:09:50 +00:00
|
|
|
if ( $gadget->isOnByDefault() ) {
|
2018-09-17 22:28:15 +00:00
|
|
|
if ( $needLineBreakAfter ) {
|
|
|
|
$output->addHTML( '<br />' );
|
|
|
|
}
|
|
|
|
$output->addHTML( $this->msg( 'gadgets-default' )->parse() );
|
|
|
|
$needLineBreakAfter = true;
|
2011-04-03 19:01:52 +00:00
|
|
|
}
|
2011-09-23 06:48:37 +00:00
|
|
|
|
2021-12-28 21:29:05 +00:00
|
|
|
// Show warnings
|
|
|
|
$warnings = GadgetRepo::singleton()->validationWarnings( $gadget );
|
|
|
|
|
|
|
|
if ( count( $warnings ) > 0 ) {
|
|
|
|
$output->addHTML( Html::warningBox( implode( '<br/>', array_map( static function ( $msg ) {
|
|
|
|
return $msg->parse();
|
|
|
|
}, $warnings ) ) ) );
|
|
|
|
$needLineBreakAfter = false;
|
|
|
|
}
|
|
|
|
|
2018-09-17 22:28:15 +00:00
|
|
|
$output->addHTML( Html::closeElement( 'li' ) . "\n" );
|
2007-07-31 10:21:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-23 06:48:37 +00:00
|
|
|
if ( $listOpen ) {
|
2018-09-17 22:28:15 +00:00
|
|
|
$output->addHTML( Html::closeElement( 'ul' ) . "\n" );
|
2007-11-16 20:13:25 +00:00
|
|
|
}
|
2007-07-31 10:21:34 +00:00
|
|
|
}
|
2010-08-08 18:22:22 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Exports a gadget with its dependencies in a serialized form
|
2017-08-27 14:07:08 +00:00
|
|
|
* @param string $gadget Name of gadget to export
|
2010-08-08 18:22:22 +00:00
|
|
|
*/
|
|
|
|
public function showExportForm( $gadget ) {
|
2012-07-11 22:18:10 +00:00
|
|
|
global $wgScript;
|
2010-08-08 18:22:22 +00:00
|
|
|
|
2019-07-17 19:39:36 +00:00
|
|
|
$this->addHelpLink( 'Extension:Gadgets' );
|
2012-07-11 22:18:10 +00:00
|
|
|
$output = $this->getOutput();
|
2015-07-18 22:40:42 +00:00
|
|
|
try {
|
2022-08-16 15:24:01 +00:00
|
|
|
$g = $this->gadgetRepo->getGadget( $gadget );
|
2015-07-18 22:40:42 +00:00
|
|
|
} catch ( InvalidArgumentException $e ) {
|
2016-12-28 10:25:47 +00:00
|
|
|
$output->showErrorPage( 'error', 'gadgets-not-found', [ $gadget ] );
|
2010-08-08 18:22:22 +00:00
|
|
|
return;
|
|
|
|
}
|
2011-09-23 06:48:37 +00:00
|
|
|
|
2010-08-08 18:22:22 +00:00
|
|
|
$this->setHeaders();
|
2024-02-17 01:57:11 +00:00
|
|
|
$output->setPageTitleMsg( $this->msg( 'gadgets-export-title' ) );
|
2012-07-11 22:18:10 +00:00
|
|
|
$output->addWikiMsg( 'gadgets-export-text', $gadget, $g->getDefinition() );
|
2010-08-08 18:22:22 +00:00
|
|
|
|
|
|
|
$exportList = "MediaWiki:gadget-$gadget\n";
|
2010-11-11 18:19:57 +00:00
|
|
|
foreach ( $g->getScriptsAndStyles() as $page ) {
|
2015-08-03 06:37:32 +00:00
|
|
|
$exportList .= "$page\n";
|
2010-08-08 18:22:22 +00:00
|
|
|
}
|
|
|
|
|
2018-04-09 17:49:46 +00:00
|
|
|
$htmlForm = HTMLForm::factory( 'ooui', [], $this->getContext() );
|
|
|
|
$htmlForm
|
2022-03-20 14:07:38 +00:00
|
|
|
->setTitle( SpecialPage::getTitleFor( 'Export' ) )
|
2018-04-09 17:49:46 +00:00
|
|
|
->addHiddenField( 'pages', $exportList )
|
|
|
|
->addHiddenField( 'wpDownload', '1' )
|
|
|
|
->addHiddenField( 'templates', '1' )
|
|
|
|
->setAction( $wgScript )
|
|
|
|
->setMethod( 'get' )
|
|
|
|
->setSubmitText( $this->msg( 'gadgets-export-download' )->text() )
|
|
|
|
->prepareForm()
|
|
|
|
->displayForm( false );
|
2010-08-08 18:22:22 +00:00
|
|
|
}
|
2015-05-15 19:55:50 +00:00
|
|
|
|
2020-10-12 09:10:15 +00:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
2015-05-15 19:55:50 +00:00
|
|
|
protected function getGroupName() {
|
|
|
|
return 'wiki';
|
|
|
|
}
|
2007-07-31 10:21:34 +00:00
|
|
|
}
|