Go to the documentation of this file.
42 foreach ( $options as $member => $option ) {
51 case 'resourceLoaded':
52 case 'requiredRights':
59 $this->{$member} = $option;
62 throw new InvalidArgumentException(
"Unrecognized '$member' parameter" );
76 $prefixGadgetNs =
function ( $page ) {
77 return 'Gadget:' . $page;
81 'resourceLoaded' =>
true,
82 'requiredRights' => $data[
'settings'][
'rights'],
83 'onByDefault' => $data[
'settings'][
'default'],
84 'hidden' => $data[
'settings'][
'hidden'],
85 'requiredSkins' => $data[
'settings'][
'skins'],
86 'category' => $data[
'settings'][
'category'],
87 'scripts' => array_map( $prefixGadgetNs, $data[
'module'][
'scripts'] ),
88 'styles' => array_map( $prefixGadgetNs, $data[
'module'][
'styles'] ),
89 'dependencies' => $data[
'module'][
'dependencies'],
90 'peers' => $data[
'module'][
'peers'],
91 'messages' => $data[
'module'][
'messages'],
92 'type' => $data[
'module'][
'type'],
95 return new self( $info );
105 return new self( [
'name' => $id ] );
115 return strlen( $id ) > 0 && ResourceLoader::isValidModuleName( self::getModuleName( $id ) );
129 return wfMessage(
"gadget-{$this->getName()}" )->parse();
136 return wfMessage(
"gadget-{$this->getName()}" )->plain();
151 return "ext.gadget.{$id}";
161 return (
bool)$user->getOption(
"gadget-{$this->name}", $this->onByDefault );
196 return ( count( $this->requiredSkins ) === 0
212 return count( $this->styles )
242 return array_merge( $this->scripts, $this->styles );
312 if ( $this->type ===
'styles' || $this->type ===
'general' ) {
316 if ( $this->styles && !$this->scripts && !$this->dependencies ) {
isAllowed(User $user)
Checks whether given user has permissions to use this gadget.
static getModuleName( $id)
isSkinSupported(Skin $skin)
Check if this gadget is compatible with a skin.
getRequiredRights()
Returns array of permissions required by this gadget.
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
static newFromDefinitionContent( $id, GadgetDefinitionContent $content)
Create a object based on the metadata in a GadgetDefinitionContent object.
getPeers()
Get list of extra modules that should be loaded when this gadget is enabled.
__construct(array $options)
isAllowedAll(... $permissions)
getRequiredSkins()
Returns array of skins where this gadget works.
static newEmptyGadget( $id)
Get a placeholder object to use if a gadget doesn't exist.
getType()
Returns the load type of this Gadget's ResourceLoader module.
getLegacyScripts()
Returns list of scripts that don't support ResourceLoader.
static isValidGadgetID( $id)
Whether the provided gadget id is valid.
isEnabled( $user)
Checks whether this gadget is enabled for given user.
The main skin class which provides methods and properties for all other skins.
The User object encapsulates all of the user-specific settings (user_id, name, rights,...
const GADGET_CLASS_VERSION
Increment this when changing class structure.
getDependencies()
Returns names of resources this gadget depends on.