Go to the documentation of this file.
24 use Wikimedia\WrappedString;
52 foreach ( $gadgets as $thisSection ) {
53 foreach ( $thisSection as $gadgetId => $gadget ) {
54 if ( $gadget->isOnByDefault() ) {
55 $defaultOptions[
'gadget-' . $gadgetId] = 1;
75 foreach ( $gadgets as $section => $thisSection ) {
81 foreach ( $thisSection as $gadget ) {
84 && $gadget->isAllowed( $user )
85 && $gadget->isSkinSupported( $skin )
87 $gname = $gadget->getName();
88 # bug 30182: dir="auto" because it's often not translated
89 $desc =
'<span dir="auto">' . $gadget->getDescription() .
'</span>';
90 $available[$desc] = $gname;
91 if ( $gadget->isEnabled( $user ) ) {
97 if ( $section !==
'' ) {
98 $section =
wfMessage(
"gadget-section-$section" )->parse();
100 if ( count( $available ) ) {
101 $options[$section] = $available;
104 $options = array_merge( $options, $available );
108 $preferences[
'gadgets-intro'] =
111 'default' =>
wfMessage(
'gadgets-prefstext' )->parseAsBlock(),
112 'section' =>
'gadgets',
116 $preferences[
'gadgets'] =
118 'type' =>
'multiselect',
119 'options' => $options,
120 'section' =>
'gadgets',
122 'prefix' =>
'gadget-',
123 'default' => $default,
134 $ids = $repo->getGadgetIds();
136 foreach ( $ids as $id ) {
138 'class' =>
'GadgetResourceLoaderModule',
150 $ids = $repo->getGadgetIds();
156 $lb->setCaller( __METHOD__ );
157 $enabledLegacyGadgets = [];
162 $user = $out->getUser();
163 $skin = $out->getSkin();
164 foreach ( $ids as $id ) {
166 $gadget = $repo->getGadget( $id );
167 }
catch ( InvalidArgumentException $e ) {
171 foreach ( $gadget->getPeers() as $peerName ) {
173 $peers[] = $repo->getGadget( $peerName );
174 }
catch ( InvalidArgumentException $e ) {
179 if ( $gadget->isEnabled( $user )
180 && $gadget->isAllowed( $user )
181 && $gadget->isSkinSupported( $skin )
183 if ( $gadget->hasModule() ) {
184 if ( $gadget->getType() ===
'styles' ) {
189 foreach ( $peers as $peer ) {
190 if ( $peer->getType() ===
'styles' ) {
200 if ( $gadget->getLegacyScripts() ) {
201 $enabledLegacyGadgets[] = $id;
207 foreach ( $enabledLegacyGadgets as $id ) {
210 $out->addHTML( WrappedString::join(
"\n", $strings ) );
216 return ResourceLoader::makeInlineScript(
218 "Gadget \"$id\" was not loaded. Please migrate it to use ResourceLoader. " .
219 'See <' . $special->getCanonicalURL() .
'>.'
241 if ( !
$title->inNamespace( NS_GADGET_DEFINITION ) ) {
248 "Tried to save non-GadgetDefinitionContent to {$title->getPrefixedText()}"
252 $validateStatus =
$content->validate();
253 if ( !$validateStatus->isGood() ) {
254 $status->merge( $validateStatus );
268 if ( $page->
getTitle()->inNamespace( NS_GADGET_DEFINITION ) ) {
282 if (
$title->inNamespace( NS_GADGET ) ) {
283 preg_match(
'!\.(css|js)$!u',
$title->getText(),
$ext );
287 $model =
'javascript';
307 if (
$title->hasContentModel(
'GadgetDefinition' ) ) {
320 $queryPages[] = [
'SpecialGadgetUsage',
'GadgetUsage' ];
static getModuleName( $id)
static onContentHandlerDefaultModelFor(Title $title, &$model)
Mark the Title as having a content model of javascript or css for pages in the Gadget namespace based...
Class representing a list of titles The execute() method checks them all for existence and adds them ...
static onPageContentInsertComplete(WikiPage $page)
After a new page is created in the Gadget definition namespace, invalidate the list of gadget ids.
if(!isset( $args[0])) $lang
Class representing a MediaWiki article and history.
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
static getTitleFor( $name, $subpage=false, $fragment='')
Get a localised Title object for a specified special page name If you don't need a full Title object,...
Generic operation result class Has warning/error list, boolean status and arbitrary value.
static encodeJsCall( $name, $args, $pretty=false)
Create a call to a JavaScript function.
getTitle()
Get the title object of the article.
static onDeleteUnknownPreferences(array &$where, IDatabase $db)
Prevent gadget preferences from being deleted.
static singleton()
Get the configured default GadgetRepo.
static onwgQueryPages(array &$queryPages)
Add the GadgetUsage special page to the list of QueryPages.
static beforePageDisplay(OutputPage $out)
BeforePageDisplay hook handler.
static makeLegacyWarning( $id)
static userGetDefaultOptions(array &$defaultOptions)
UserGetDefaultOptions hook handler.
static onEditFilterMergedContent(IContextSource $context, Content $content, Status $status, $summary)
Valid gadget definition page after content is modified.
static getMain()
Get the RequestContext object associated with the main request.
static onCodeEditorGetPageLanguage(Title $title, &$lang)
Set the CodeEditor language for Gadget definition pages.
Interface for objects which can provide a MediaWiki context on request.
Base interface for content objects.
Represents a title within MediaWiki.
static getPreferences(User $user, array &$preferences)
GetPreferences hook handler.
static registerModules(ResourceLoader &$resourceLoader)
ResourceLoaderRegisterModules hook handler.
static onPageContentSaveComplete(WikiPage $wikiPage, $user, $content)
PageContentSaveComplete hook handler.
if(!is_readable( $file)) $ext
The User object encapsulates all of the user-specific settings (user_id, name, rights,...