This class attempts to provide safe yet simple means for managing data that is relevant for the final HTML output of MediaWiki. In particular, this concerns additions to the HTML header in the form of scripts of stylesheets.
The problem is that many components in SMW create hypertext that should eventually be displayed. The normal way of accessing such text are functions of the form getText() which return a (hypertext) string. Such a string, however, might refer to styles or scripts that are also needed. It is not possible to directly add those scripts to the MediaWiki output, since the form of this output depends on the context in which the function is called. Many functions might be called both during parsing and directly in special pages that do not use the usual parsing and caching mechanisms.
Ideally, all functions that generate hypertext with dependencies would also include parameters to record required scripts. Since this would require major API changes, the current solution is to have a "temporal" global storage for the required items, managed in this class. It is not safe to use such a global store across hooks – you never know what happens in between! Hence, every function that creates SMW outputs that may require head items must afterwards clear the temporal store by writing its contents to the according output.
- Author
- Markus Krötzsch
static SMWOutputs::commitToParser |
( |
Parser |
$parser | ) |
|
|
static |
Actually commit the collected requirements to a given parser that is about to parse what will later be the HTML output. This makes sure that HTML output based on the parser results contains all required output items.
If the parser creates output for a normal wiki page, then the committed items will also become part of the page cache so that they will correctly be added to all page outputs built from this cache later on.
- Parameters
-
TODO find out and document when this b/c code can go away
static SMWOutputs::requireFromParserOutput |
( |
ParserOutput |
$parserOutput | ) |
|
|
static |
This function takes output requirements as can be found in a given ParserOutput object and puts them back in to the internal temporal requirement list from which they can be committed to some other output. It is needed when code that would normally call SMWOutputs::requireHeadItem() has need to use a full independent parser call (Parser::parse()) that produces its own parseroutput. If omitted, all output items potentially committed to this parseroutput during parsing will not be passed on to higher levels.
Note that this is not required if the $parseroutput is further processed by MediaWiki, but there are cases where the output is discarded and only its text is used.
- Parameters
-
ParserOutput | $parserOutput | |
TODO Is the following needed?