Page MenuHomePhabricator

ExpandTemplates.patch

Authored By
bzimport
Nov 21 2014, 9:26 PM
Size
3 KB
Referenced Files
None
Subscribers
None

ExpandTemplates.patch

Index: ExpandTemplates.i18n.php
===================================================================
--- ExpandTemplates.i18n.php (revision 23434)
+++ ExpandTemplates.i18n.php (working copy)
@@ -19,6 +19,7 @@
'expand_templates_output' => 'Result:',
'expand_templates_ok' => 'OK',
'expand_templates_remove_comments' => 'Remove comments',
+ 'expand_templates_html_output' => 'HTML output',
);
$wgExpandTemplatesMessages['ar'] = array(
@@ -209,6 +210,7 @@
'expand_templates_output' => 'Результат:',
'expand_templates_ok' => 'OK',
'expand_templates_remove_comments' => 'Удалить комментарии',
+ 'expand_templates_html_output' => 'Результат в HTML',
);
$wgExpandTemplatesMessages['sk'] = array(
'expandtemplates' => 'Substituovať šablóny',
Index: ExpandTemplates_body.php
===================================================================
--- ExpandTemplates_body.php (revision 23434)
+++ ExpandTemplates_body.php (working copy)
@@ -29,17 +29,23 @@
$input = $wgRequest->getText( 'input' );
if ( strlen( $input ) ) {
$removeComments = $wgRequest->getBool( 'removecomments', false );
+ $htmlOutput = $wgRequest->getBool( 'html', false );
$options = new ParserOptions;
$options->setRemoveComments( $removeComments );
$options->setMaxIncludeSize( self::MAX_INCLUDE_SIZE );
- $output = $wgParser->preprocess( $input, $title, $options );
+ if ( $htmlOutput ) {
+ $output = $wgParser->parse( $input, $title, $options )->mText;
+ } else {
+ $output = $wgParser->preprocess( $input, $title, $options );
+ }
} else {
$removeComments = $wgRequest->getBool( 'removecomments', true );
+ $htmlOutput = $wgRequest->getBool( 'html', false );
$output = '';
}
$wgOut->addWikiText( wfMsg( 'expand_templates_intro' ) );
- $wgOut->addHtml( $this->makeForm( $titleStr, $removeComments, $input ) );
+ $wgOut->addHtml( $this->makeForm( $titleStr, $removeComments, $htmlOutput, $input ) );
if( $output )
$wgOut->addHtml( $this->makeOutput( $output ) );
@@ -54,7 +60,7 @@
* @param $input Value for input textbox
* @return string
*/
- private function makeForm( $title, $removeComments, $input ) {
+ private function makeForm( $title, $removeComments, $htmlOutput, $input ) {
$self = $this->getTitle();
$form = Xml::openElement( 'form', array( 'method' => 'post', 'action' => $self->getLocalUrl() ) );
$form .= '<p>' . Xml::inputLabel( wfMsgNoTrans( 'expand_templates_title' ), 'contexttitle', 'contexttitle', 60, $title ) . '</p>';
@@ -62,7 +68,8 @@
$form .= Xml::openElement( 'textarea', array( 'name' => 'input', 'id' => 'input', 'rows' => 10, 'cols' => 10 ) );
$form .= htmlspecialchars( $input );
$form .= Xml::closeElement( 'textarea' );
- $form .= '<p>' . Xml::checkLabel( wfMsg( 'expand_templates_remove_comments' ), 'removecomments', 'removecomments', $removeComments ) . '</p>';
+ $form .= '<p>' . Xml::checkLabel( wfMsg( 'expand_templates_remove_comments' ), 'removecomments', 'removecomments', $removeComments );
+ $form .= Xml::checkLabel( wfMsg( 'expand_templates_html_output' ), 'html', 'html', $htmlOutput ) . '</p>';
$form .= '<p>' . Xml::submitButton( wfMsg( 'expand_templates_ok' ) ) . '</p>';
$form .= Xml::closeElement( 'form' );
return $form;

File Metadata

Mime Type
text/x-diff
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2856
Default Alt Text
ExpandTemplates.patch (3 KB)

Event Timeline