r84229 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r84228‎ | r84229 | r84230 >
Date:08:13, 18 March 2011
Author:purodha
Status:resolved (Comments)
Tags:
Comment:
Wrap everything that is not a babel box into <div> 's as well, for consistenty and styling via CSS.
Modified paths:
  • /trunk/extensions/Babel/Babel.class.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Babel/Babel.class.php
@@ -37,19 +37,21 @@
3838 if ( $name === '' ) {
3939 continue;
4040 } elseif ( self::mPageExists( $template ) ) {
 41+ // Existent template page has precedence
4142 if ( count($templateParameters) ) {
4243 $template .= '|'.implode('|', $templateParameters);
4344 }
44 - $content .= $parser->replaceVariables( "{{{$template}}}" );
 45+ $content .= self::mGenerateNotaBox( $parser->replaceVariables( "{{{$template}}}" ) );
4546 } elseif ( $components !== false ) {
 47+ // Non-existent page and valid parameter syntax, babel box
4648 $content .= self::mGenerateBox( $components['code'], $components['level'] );
4749 $content .= self::mGenerateCategories( $components['code'], $components['level'] );
4850 } elseif ( self::mValidTitle( $template ) ) {
4951 // Non-existent page and invalid parameter syntax, red link.
50 - $content .= "\n[[$template]]";
 52+ $content .= self::mGenerateNotaBox( '[['.$template.']]' );
5153 } else {
5254 // Invalid title, output raw.
53 - $content .= "\n$template";
 55+ $content .= self::mGenerateNotaBox( $template );
5456 }
5557 }
5658
@@ -173,6 +175,20 @@
174176 }
175177
176178 /**
 179+ * Generate an inner box which is not a babel box.
 180+ *
 181+ * @param $coontent String: what's inside the box, in wikitext format.
 182+ * @return String: A single non-babel box, in wikitext format.
 183+ */
 184+ protected static function mGenerateNotaBox( $content ) {
 185+ $dir_content = wfMessage( 'babel-directionality' )->inContentLanguage()->text();
 186+ $notabox = <<<EOT
 187+<div class="mw-babel-notabox" dir="$dir_content">$content</div>
 188+EOT;
 189+ return $notabox;
 190+ }
 191+
 192+ /**
177193 * Generate a babel box for the given language and level.
178194 *
179195 * @param $code String: Language code to use.

Follow-up revisions

RevisionCommit summaryAuthorDate
r84248Minor enhancements and fixes following up r84229, r84078, 84027, 84015.purodha14:17, 18 March 2011

Comments

#Comment by Raymond (talk | contribs)   08:44, 18 March 2011

Typo:

+	 * @param $coontent String: what's inside the box, in wikitext format.

Really wikitext? Looks like HTML:

+	 * @return String: A single non-babel box, in wikitext format.

Please use proper functions like Html::rawElement( 'div', .... )

 +		$notabox = <<<EOT
 +<div class="mw-babel-notabox" dir="$dir_content">$content</div>
 +EOT;
#Comment by Purodha (talk | contribs)   20:42, 18 March 2011

1. Fixed in r84248

2. Thoroughly checked: It's Wikitewxt in all possible cases, wrapped into an intented

, which i legal wiki code

3. Postponed. It is ok, as it is. We can change it but for the sake of consistenca, that should be done in one go everywhere in this extension.

#Comment by Siebrand (talk | contribs)   11:57, 21 September 2011

Resolved after consultation with Niklas.

Status & tagging log