Go to the documentation of this file.
45 const MAX_INCLUDE_SIZE = 50000000;
48 parent::__construct(
'ExpandTemplates' );
61 $titleStr =
$request->getText(
'wpContextTitle' );
68 $this->generateXML =
$request->getBool(
'wpGenerateXml' );
69 $this->generateRawHtml =
$request->getBool(
'wpGenerateRawHtml' );
72 $this->removeComments =
$request->getBool(
'wpRemoveComments',
false );
73 $this->removeNowiki =
$request->getBool(
'wpRemoveNowiki',
false );
75 $options->setRemoveComments( $this->removeComments );
77 $options->setMaxIncludeSize( self::MAX_INCLUDE_SIZE );
79 if ( $this->generateXML ) {
83 if ( method_exists( $dom,
'saveXML' ) ) {
84 $xml = $dom->saveXML();
86 $xml = $dom->__toString();
92 $this->removeComments =
$request->getBool(
'wpRemoveComments',
true );
93 $this->removeNowiki =
$request->getBool(
'wpRemoveNowiki',
false );
102 if ( $this->generateXML && strlen(
$output ) > 0 ) {
103 $out->addHTML( $this->
makeOutput( $xml,
'expand_templates_xml_output' ) );
108 if ( $this->removeNowiki ) {
110 [
'_<nowiki>_',
'_</nowiki>_',
'_<nowiki */>_' ],
117 if ( $config->get(
'UseTidy' ) &&
$options->getTidy() ) {
121 $out->addHTML( $tmp );
124 $rawhtml = $pout->getText();
125 if ( $this->generateRawHtml && strlen( $rawhtml ) > 0 ) {
126 $out->addHTML( $this->
makeOutput( $rawhtml,
'expand_templates_html_output' ) );
143 if ( !strlen( $values[
'input'] ) ) {
160 'label' => $this->
msg(
'expand_templates_title' )->plain(),
161 'name' =>
'wpContextTitle',
162 'id' =>
'contexttitle',
166 'cssclass' =>
'mw-ui-input-inline',
169 'type' =>
'textarea',
171 'label' => $this->
msg(
'expand_templates_input' )->text(),
176 'removecomments' => [
178 'label' => $this->
msg(
'expand_templates_remove_comments' )->text(),
179 'name' =>
'wpRemoveComments',
180 'id' =>
'removecomments',
185 'label' => $this->
msg(
'expand_templates_remove_nowiki' )->text(),
186 'name' =>
'wpRemoveNowiki',
187 'id' =>
'removenowiki',
192 'label' => $this->
msg(
'expand_templates_generate_xml' )->text(),
193 'name' =>
'wpGenerateXml',
194 'id' =>
'generate_xml',
197 'generate_rawhtml' => [
199 'label' => $this->
msg(
'expand_templates_generate_rawhtml' )->text(),
200 'name' =>
'wpGenerateRawHtml',
201 'id' =>
'generate_rawhtml',
208 ->setSubmitTextMsg(
'expand_templates_ok' )
209 ->setWrapperLegendMsg(
'expandtemplates' )
210 ->setHeaderText( $this->
msg(
'expand_templates_intro' )->parse() )
211 ->setSubmitCallback( [ $this,
'onSubmitInput' ] )
223 $out =
"<h2>" . $this->
msg( $heading )->escaped() .
"</h2>\n";
229 [
'id' =>
'output',
'readonly' =>
'readonly' ]
246 $popts->setTargetLanguage(
$title->getPageLanguage() );
259 $out->addHTML(
"<h2>" . $this->
msg(
'expand_templates_preview' )->escaped() .
"</h2>\n" );
261 if ( $this->
getConfig()->
get(
'RawHtml' ) ) {
269 if (
$user->isAnon() && !
$user->isAllowed(
'edit' ) ) {
270 $error = [
'expand_templates_preview_fail_html_anon' ];
272 $error = [
'expand_templates_preview_fail_html' ];
278 $out->wrapWikiMsg(
"<div class='previewnote'>\n$1\n</div>", $error );
284 'class' =>
'mw-content-' .
$lang->getDir(),
285 'dir' =>
$lang->getDir(),
286 'lang' =>
$lang->getHtmlCode(),
288 $out->addParserOutputContent( $pout );
getPageTitle( $subpage=false)
Get a self-referential title object.
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
error also a ContextSource you ll probably need to make sure the header is varied on $request
getOutput()
Get the OutputPage being used for this instance.
bool $generateRawHtml
Whether or not to show the raw HTML code.
if(!isset( $args[0])) $lang
showHtmlPreview(Title $title, ParserOutput $pout, OutputPage $out)
Wraps the provided html code in a div and outputs it to the page.
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
static textarea( $name, $content, $cols=40, $rows=5, $attribs=[])
Shortcut for creating textareas.
execute( $subpage)
Show the special page.
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
static newFatal( $message)
Factory function for fatal errors.
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
makeOutput( $output, $heading='expand_templates_output')
Generate a nice little box with a heading for output.
static closeElement( $element)
Returns "</$element>".
getConfig()
Shortcut to get main config object.
namespace and then decline to actually register it file or subcat img or subcat $title
if(is_array( $mode)) switch( $mode) $input
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 the output can only depend on parameters provided to this hook not on global state indicating whether full HTML should be generated If generation of HTML may be but other information should still be present in the ParserOutput object & $output
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes!
getUser()
Shortcut to get the User executing this instance.
when a variable name is used in a it is silently declared as a new masking the global
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
This class should be covered by a general architecture document which does not exist as of January 20...
getContext()
Gets the context this SpecialPage is executed in.
A special page that expands submitted templates, parser functions, and variables, allowing easier deb...
msg()
Wrapper around wfMessage that sets the current context.
static newFromContext(IContextSource $context)
Get a ParserOptions object from a IContextSource object.
static newGood( $value=null)
Factory function for good results.
Parent class for all special pages.
bool $removeNowiki
Whether or not to remove <nowiki> tags in the expanded wikitext.
getRequest()
Get the WebRequest being used for this instance.
makeForm( $title, $input)
Generate a form allowing users to enter information.
generateHtml(Title $title, $text)
Renders the supplied wikitext as html.
Represents a title within MediaWiki.
bool $generateXML
Whether or not to show the XML parse tree.
onSubmitInput(array $values)
Callback for the HTMLForm used in self::makeForm.
static openElement( $element, $attribs=[])
Identical to rawElement(), but has no third parameter and omits the end tag (and the self-closing '/'...
bool $removeComments
Whether or not to remove comments in the expanded wikitext.
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
the array() calling protocol came about after MediaWiki 1.4rc1.
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
static tidy( $text)
Interface with html tidy.