45 const MAX_INCLUDE_SIZE = 50000000;
48 parent::__construct(
'ExpandTemplates' );
61 $titleStr =
$request->getText(
'wpContextTitle' );
67 $input =
$request->getText(
'wpInput' );
68 $this->generateXML =
$request->getBool(
'wpGenerateXml' );
69 $this->generateRawHtml =
$request->getBool(
'wpGenerateRawHtml' );
71 if ( strlen( $input ) ) {
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 ) {
81 $dom = $wgParser->preprocessToDom( $input );
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 );
99 $this->
makeForm( $titleStr, $input );
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' ]
247 return $wgParser->parse( $text, $title, $popts );
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(),
static closeElement($element)
Returns "$element>".
static newFromContext(IContextSource $context)
Get a ParserOptions object from a IContextSource object.
addHTML($text)
Append $text to the body HTML.
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
the array() calling protocol came about after MediaWiki 1.4rc1.
getContext()
Gets the context this SpecialPage is executed in.
showHtmlPreview(Title $title, ParserOutput $pout, OutputPage $out)
Wraps the provided html code in a div and outputs it to the page.
static newFatal($message)
Factory function for fatal errors.
static tidy($text)
Interface with html tidy.
bool $generateXML
Whether or not to show the XML parse tree.
execute($subpage)
Show the special page.
if(!isset($args[0])) $lang
msg()
Wrapper around wfMessage that sets the current context.
addParserOutputContent($parserOutput)
Add the HTML and enhancements for it (like ResourceLoader modules) associated with a ParserOutput obj...
getOutput()
Get the OutputPage being used for this instance.
onSubmitInput(array $values)
Callback for the HTMLForm used in self::makeForm.
static newFromText($text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
when a variable name is used in a it is silently declared as a new local masking the global
bool $generateRawHtml
Whether or not to show the raw HTML code.
setCategoryLinks(array $categories)
Reset the category links (but not the category list) and add $categories.
Parent class for all special pages.
static openElement($element, $attribs=[])
Identical to rawElement(), but has no third parameter and omits the end tag (and the self-closing '/'...
A special page that expands submitted templates, parser functions, and variables, allowing easier deb...
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist 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
setHeaders()
Sets headers - this should be called from the execute() method of all derived classes! ...
bool $removeNowiki
Whether or not to remove tags in the expanded wikitext.
namespace and then decline to actually register it file or subcat img or subcat $title
static newGood($value=null)
Factory function for good results.
This class should be covered by a general architecture document which does not exist as of January 20...
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 local account $user
generateHtml(Title $title, $text)
Renders the supplied wikitext as html.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist 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
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
getPageViewLanguage()
Get the language in which the content of this page is written when viewed by user.
error also a ContextSource you ll probably need to make sure the header is varied on $request
makeOutput($output, $heading= 'expand_templates_output')
Generate a nice little box with a heading for output.
getUser()
Shortcut to get the User executing this instance.
static textarea($name, $content, $cols=40, $rows=5, $attribs=[])
Shortcut for creating textareas.
getPageLanguage()
Get the language in which the content of this page is written in wikitext.
getConfig()
Shortcut to get main config object.
bool $removeComments
Whether or not to remove comments in the expanded wikitext.
this hook is for auditing only RecentChangesLinked and Watchlist RecentChangesLinked and Watchlist e g Watchlist 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
wrapWikiMsg($wrap)
This function takes a number of message/argument specifications, wraps them in some overall structure...
getRequest()
Get the WebRequest being used for this instance.
makeForm($title, $input)
Generate a form allowing users to enter information.
getPageTitle($subpage=false)
Get a self-referential title object.