Go to the documentation of this file.
23 use WrappedString\WrappedString;
41 $repo->purgeDefinitionCache();
60 foreach ( $gadgets
as $thisSection ) {
61 foreach ( $thisSection
as $gadgetId => $gadget ) {
62 if ( $gadget->isOnByDefault() ) {
63 $defaultOptions[
'gadget-' . $gadgetId] = 1;
85 foreach ( $gadgets
as $section => $thisSection ) {
91 foreach ( $thisSection
as $gadget ) {
92 if ( !$gadget->isHidden() && $gadget->isAllowed(
$user ) ) {
94 # bug 30182: dir="auto" because it's often not translated
95 $desc =
'<span dir="auto">' . $gadget->getDescription() .
'</span>';
96 $available[$desc] = $gname;
97 if ( $gadget->isEnabled(
$user ) ) {
106 if (
count ( $available ) ) {
114 $preferences[
'gadgets-intro'] =
120 wfMessage(
'gadgets-prefstext' )->parseAsBlock() ) ),
121 'section' =>
'gadgets',
126 $preferences[
'gadgets'] =
128 'type' =>
'multiselect',
130 'section' =>
'gadgets',
132 'prefix' =>
'gadget-',
133 'default' => $default,
146 $ids = $repo->getGadgetIds();
148 foreach ( $ids
as $id ) {
150 'class' =>
'GadgetResourceLoaderModule',
165 $ids = $repo->getGadgetIds();
171 $lb->setCaller( __METHOD__ );
172 $enabledLegacyGadgets = [];
173 $typelessMixedGadgets = [];
179 foreach ( $ids
as $id ) {
181 $gadget = $repo->getGadget( $id );
182 }
catch ( InvalidArgumentException
$e ) {
186 foreach ( $gadget->getPeers()
as $peerName ) {
188 $peers[] = $repo->getGadget( $peerName );
189 }
catch ( InvalidArgumentException
$e ) {
194 if ( $gadget->isEnabled(
$user ) && $gadget->isAllowed(
$user ) ) {
195 if ( $gadget->hasModule() ) {
196 if ( $gadget->getType() ===
'styles' ) {
198 } elseif ( $gadget->getType() ===
'general' ) {
201 foreach ( $peers
as $peer ) {
202 if ( $peer->getType() ===
'styles' ) {
213 $typelessMixedGadgets[] = $id;
217 if ( $gadget->getLegacyScripts() ) {
218 $enabledLegacyGadgets[] = $id;
224 foreach ( $enabledLegacyGadgets
as $id ) {
227 foreach ( $typelessMixedGadgets
as $id ) {
230 $out->addHTML( WrappedString::join(
"\n", $strings ) );
238 return ResourceLoader::makeInlineScript(
240 "Gadget \"$id\" was not loaded. Please migrate it to use ResourceLoader. " .
241 'See <' .
$special->getCanonicalURL() .
'>.'
248 "Gadget \"$id\" styles loaded twice. Migrate to type=general. " .
249 'See <https://www.mediawiki.org/wiki/RL/MGU#Gadget_type>.'
266 if ( !
$title->inNamespace( NS_GADGET_DEFINITION ) ) {
272 throw new Exception(
"Tried to save non-GadgetDefinitionContent to {$title->getPrefixedText()}" );
291 if (
$page->getTitle()->inNamespace( NS_GADGET_DEFINITION ) ) {
294 $repo->purgeGadgetIdsList();
308 if (
$title->inNamespace( NS_GADGET ) ) {
309 preg_match(
'!\.(css|js)$!u',
$title->getText(),
$ext );
313 $model =
'javascript';
333 if (
$title->hasContentModel(
'GadgetDefinition' ) ) {
347 $queryPages[] = [
'SpecialGadgetUsage',
'GadgetUsage' ];
error also a ContextSource you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext $context
static makeTypelessWarning( $id)
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 tags( $element, $attribs=null, $contents)
Same as Xml::element(), but does not escape contents.
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
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set $status
as see the revision history and available at free of to any person obtaining a copy of this software and associated documentation to deal in the Software without including without limitation the rights to use
please add to it if you re going to add events to the MediaWiki code where normally authentication against an external auth plugin would be creating a account $user
Class representing a MediaWiki article and history.
static userGetDefaultOptions(&$defaultOptions)
UserGetDefaultOptions hook handler.
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,...
getTitle()
Get the Title object.
static onPageContentSaveComplete( $article, $user, $content)
PageContentSaveComplete hook handler.
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
static registerModules(&$resourceLoader)
ResourceLoaderRegisterModules hook handler.
static encodeJsCall( $name, $args, $pretty=false)
Create a call to a JavaScript function.
namespace and then decline to actually register it file or subcat img or subcat $title
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content $content
do that in ParserLimitReportFormat instead use this to modify the parameters of the image and a DIV can begin in one section and end in another Make sure your code can handle that case gracefully See the EditSectionClearerLink extension for an example zero but section is usually empty its values are the globals values before the output is cached $page
static singleton()
Get the configured default GadgetRepo.
static makeLegacyWarning( $id)
static getPreferences( $user, &$preferences)
GetPreferences hook handler.
static onEditFilterMergedContent( $context, $content, $status, $summary)
Valid gadget definition page after content is modified.
div flags Integer display flags(NO_ACTION_LINK, NO_EXTRA_USER_LINKS) 'LogException' returning false will NOT prevent logging $e
GadgetRepo implementation where each gadget has a page in the Gadget definition namespace,...
static onCodeEditorGetPageLanguage(Title $title, &$lang)
Set the CodeEditor language for Gadget definition pages.
error also a ContextSource you ll probably need to make sure the header is varied on and they can depend only on the ResourceLoaderContext such as when responding to a resource loader request or generating HTML output & $resourceLoader
Represents a title within MediaWiki.
static onwgQueryPages(&$queryPages)
Add the GadgetUsage special page to the list of QueryPages.
usually copyright or history_copyright This message must be in HTML not wikitext if the section is included from a template $section
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Using a hook running we can avoid having all this option specific stuff in our mainline code Using the function array $article
this hook is for auditing only RecentChangesLinked and Watchlist $special
either a unescaped string or a HtmlArmor object after in associative array form externallinks including delete and has completed for all link tables whether this was an auto creation default is conds Array Extra conditions for the No matching items in log is displayed if loglist is empty msgKey Array If you want a nice box with a set this to the key of the message First element is the message additional optional elements are parameters for the key that are processed with wfMessage() -> params() ->parseAsBlock() - offset Set to overwrite offset parameter in $wgRequest set to '' to unset offset - wrap String Wrap the message in html(usually something like "<
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist Do not use this to implement individual filters if they are compatible with the ChangesListFilter and ChangesListFilterGroup structure use sub classes of those in conjunction with the ChangesListSpecialPageStructuredFilters hook This hook can be used to implement filters that do not implement that or custom behavior that is not an individual filter e g Watchlist and Watchlist you will want to construct new ChangesListBooleanFilter or ChangesListStringOptionsFilter objects When constructing you specify which group they belong to You can reuse existing or create your you must register them with $special registerFilterGroup removed from all revisions and log entries to which it was applied This gives extensions a chance to take it off their books as the deletion has already been partly carried out by this point or something similar the user will be unable to create the tag set and then return false from the hook function Ensure you consume the ChangeTagAfterDelete hook to carry out custom deletion actions as context called by AbstractContent::getParserOutput May be used to override the normal model specific rendering of page content as context as context $options
static beforePageDisplay( $out)
BeforePageDisplay hook handler.
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that probably a stub it is not rendered in wiki pages or galleries in category pages allow injecting custom HTML after the section Any uses of the hook need to handle escaping see BaseTemplate::getToolbox and BaseTemplate::makeListItem for details on the format of individual items inside of this array or by returning and letting standard HTTP rendering take place modifiable or by returning false and taking over the output $out