MediaWiki REL1_33
GadgetDefinitionContent.php
Go to the documentation of this file.
1<?php
24
25 public function __construct( $text ) {
26 parent::__construct( $text, 'GadgetDefinition' );
27 }
28
29 public function isValid() {
30 // parent::isValid() is called in validate()
31 return $this->validate()->isOK();
32 }
33
41 public function beautifyJSON() {
42 // @todo we should normalize entries in module.scripts and module.styles
43 return FormatJson::encode( $this->getAssocArray(), "\t", FormatJson::UTF8_OK );
44 }
45
55 protected function fillParserOutput( Title $title, $revId,
57 ) {
58 parent::fillParserOutput( $title, $revId, $options, $generateHtml, $output );
59 $assoc = $this->getAssocArray();
60 foreach ( [ 'scripts', 'styles' ] as $type ) {
61 foreach ( $assoc['module'][$type] as $page ) {
62 $title = Title::makeTitleSafe( NS_GADGET, $page );
63 if ( $title ) {
64 $output->addLink( $title );
65 }
66 }
67 }
68 }
69
73 public function validate() {
74 if ( !parent::isValid() ) {
75 return $this->getData();
76 }
77
78 $validator = new GadgetDefinitionValidator();
79 return $validator->validate( $this->getAssocArray() );
80 }
81
89 public function getAssocArray() {
90 $info = wfObjectToArray( $this->getData()->getValue() );
92 $handler = $this->getContentHandler();
93 $info = wfArrayPlus2d( $info, $handler->getDefaultMetadata() );
94
95 return $info;
96 }
97
103 public function getDeletionUpdates( WikiPage $page, ParserOutput $parserOutput = null ) {
104 return array_merge(
105 parent::getDeletionUpdates( $page, $parserOutput ),
106 [ new GadgetDefinitionDeletionUpdate( $page->getTitle() ) ]
107 );
108 }
109
117 public function getSecondaryDataUpdates( Title $title, Content $old = null,
118 $recursive = true, ParserOutput $parserOutput = null
119 ) {
120 return array_merge(
121 parent::getSecondaryDataUpdates( $title, $old, $recursive, $parserOutput ),
123 );
124 }
125}
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
wfArrayPlus2d(array $baseArray, array $newValues)
Merges two (possibly) 2 dimensional arrays into the target array ($baseArray).
wfObjectToArray( $objOrArray, $recursive=true)
Recursively converts the parameter (an object) to an array with the same data.
fillParserOutput(Title $title, $revId, ParserOptions $options, $generateHtml, ParserOutput &$output)
Register some links.
getSecondaryDataUpdates(Title $title, Content $old=null, $recursive=true, ParserOutput $parserOutput=null)
getDeletionUpdates(WikiPage $page, ParserOutput $parserOutput=null)
getAssocArray()
Get the JSON content as an associative array with all fields filled out, populating defaults as neces...
DataUpdate to run whenever a page in the Gadget definition is deleted.
Class responsible for validating Gadget definition contents.
Represents the content of a JSON content.
getData()
Decodes the JSON string.
Set options of the Parser.
Represents a title within MediaWiki.
Definition Title.php:40
Class representing a MediaWiki article and history.
Definition WikiPage.php:45
this hook is for auditing only or null if authentication failed before getting that far or null if we can t even determine that When $user is not it can be in the form of< username >< more info > e g for bot passwords intended to be added to log contexts Fields it might only if the login was with a bot password 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 modifiable modifiable after all normalizations have been except for the $wgMaxImageArea check set to true or false to override the $wgMaxImageArea check result gives extension the possibility to transform it themselves $handler
Definition hooks.txt:894
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
Definition hooks.txt:1999
static configuration should be added through ResourceLoaderGetConfigVars instead can be used to get the real title e g db for database replication lag or jobqueue for job queue size converted to pseudo seconds It is possible to add more fields and they will be returned to the user in the API response after the basic globals have been set but before ordinary actions take place $output
Definition hooks.txt:2272
Base interface for content objects.
Definition Content.php:34