r86124 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86123‎ | r86124 | r86125 >
Date:17:53, 15 April 2011
Author:nimishg
Status:deferred
Tags:
Comment:
Checks for wikitext in normal messages so as not to add unnecessary spacing
Modified paths:
  • /trunk/extensions/CustomUserSignup/CustomUserTemplate.php (modified) (history)

Diff [purge]

Index: trunk/extensions/CustomUserSignup/CustomUserTemplate.php
@@ -16,7 +16,7 @@
1717 function msg( $str ) {
1818 // exists
1919 if( $this->campaign && wfMessage( "customusertemplate-{$this->campaign}-$str" )->exists() ) {
20 - $this->msgWikiCustom( "customusertemplate-{$this->campaign}-$str" );
 20+ $this->msgWikiCustom( "customusertemplate-{$this->campaign}-$str", true );
2121 } else {
2222 parent::msg( $str );
2323 }
@@ -25,21 +25,27 @@
2626 function msgWiki( $str ) {
2727 // exists
2828 if( $this->campaign && wfMessage( "customusertemplate-{$this->campaign}-$str" )->exists() ) {
29 - $this->msgWikiCustom( "customusertemplate-{$this->campaign}-$str" );
 29+ $this->msgWikiCustom( "customusertemplate-{$this->campaign}-$str", false );
3030 } else {
3131 parent::msgWiki( $str );
3232 }
3333 }
3434
35 - function msgWikiCustom( $str ) {
 35+ function msgWikiCustom( $str, $checkifplain ) {
3636 global $wgParser, $wgOut;
3737
3838 $text = $this->translator->translate( $str );
3939 $parserOutput = $wgParser->parse( $text, $wgOut->getTitle(),
4040 $wgOut->parserOptions(), true );
41 - echo $parserOutput->getText();
 41+ $parsedText = $parserOutput->getText();
 42+ if( $checkifplain &&
 43+ ( strlen(strip_tags($parsedText)) == (strlen($parsedText)-7) )) {
 44+ echo htmlspecialchars( $text );
 45+ } else {
 46+ echo $parsedText;
 47+ }
4248 }
43 -
 49+
4450 }
4551
4652 class CustomUsercreateTemplate extends UsercreateTemplate {
@@ -57,7 +63,7 @@
5864 function msg( $str ) {
5965 // exists
6066 if( $this->campaign && wfMessage( "customusertemplate-{$this->campaign}-$str" )->exists() ) {
61 - $this->msgWikiCustom( "customusertemplate-{$this->campaign}-$str" );
 67+ $this->msgWikiCustom( "customusertemplate-{$this->campaign}-$str", true );
6268 } else {
6369 parent::msg( $str );
6470 }
@@ -66,18 +72,25 @@
6773 function msgWiki( $str ) {
6874 // exists
6975 if( $this->campaign && wfMessage( "customusertemplate-{$this->campaign}-$str" )->exists() ) {
70 - $this->msgWikiCustom( "customusertemplate-{$this->campaign}-$str" );
 76+ $this->msgWikiCustom( "customusertemplate-{$this->campaign}-$str", false );
7177 } else {
7278 parent::msgWiki( $str );
7379 }
7480 }
7581
76 - function msgWikiCustom( $str ) {
 82+ function msgWikiCustom( $str, $checkifplain ) {
7783 global $wgParser, $wgOut;
7884
7985 $text = $this->translator->translate( $str );
8086 $parserOutput = $wgParser->parse( $text, $wgOut->getTitle(),
8187 $wgOut->parserOptions(), true );
82 - echo $parserOutput->getText();
 88+ $parsedText = $parserOutput->getText();
 89+ if( $checkifplain &&
 90+ ( strlen(strip_tags($parsedText)) == (strlen($parsedText)-7) )) {
 91+ echo htmlspecialchars( $text );
 92+ } else {
 93+ echo $parsedText;
 94+ }
8395 }
 96+
8497 }
\ No newline at end of file

Status & tagging log