r105909 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r105908‎ | r105909 | r105910 >
Date:17:38, 12 December 2011
Author:nikerabbit
Status:ok
Tags:
Comment:
Modified paths:
  • /branches/wmf/1.18wmf1/extensions/Babel/Babel.class.php (modified) (history)

Diff [purge]

Index: branches/wmf/1.18wmf1/extensions/Babel/Babel.class.php
@@ -38,15 +38,15 @@
3939 $template = wfMessage( 'babel-template', $name )->inContentLanguage()->text();
4040 if ( $name === '' ) {
4141 continue;
42 - } elseif ( self::mPageExists( $template ) ) {
43 - // Existent template page has precedence
44 - $templateParameters[0] = $template;
45 - $template = implode('|', $templateParameters);
46 - $content .= self::mGenerateNotaBox( $parser->replaceVariables( "{{{$template}}}" ) );
4742 } elseif ( $components !== false ) {
4843 // Non-existent page and valid parameter syntax, babel box
4944 $content .= self::mGenerateBox( $components['code'], $components['level'] );
5045 $content .= self::mGenerateCategories( $components['code'], $components['level'] );
 46+ } elseif ( self::mPageExists( $template ) ) {
 47+ // Check for a template
 48+ $templateParameters[0] = $template;
 49+ $template = implode('|', $templateParameters);
 50+ $content .= self::mGenerateNotaBox( $parser->replaceVariables( "{{{$template}}}" ) );
5151 } elseif ( self::mValidTitle( $template ) ) {
5252 // Non-existent page and invalid parameter syntax, red link.
5353 $content .= self::mGenerateNotaBox( '[['.$template.']]' );
@@ -68,15 +68,10 @@
6969 $top = '! class="mw-babel-header" | ' . $top;
7070 }
7171 $footer = wfMessage( 'babel-footer', self::$title->getDBkey() )->inContentLanguage(); // TODO: allow user language
72 - if ( $footer->isDisabled() ) {
73 - $footer = '';
74 - } else {
75 - $footer = $footer->text();
76 - $url = wfMessage( 'babel-footer-url' )->inContentLanguage();
77 - if ( ! $url->isDisabled() ) {
78 - $footer = '[['.$url->text().'|'.$footer.']]';
79 - }
80 - $footer = '! class="mw-babel-footer" | ' . $footer;
 72+ $url = wfMessage( 'babel-footer-url' )->inContentLanguage();
 73+ $showfooter = '';
 74+ if ( !$footer->isDisabled() && !$url->isDisabled() ) {
 75+ $showfooter = '! class="mw-babel-footer" | [['.$url->text().'|'.$footer->text().']]';
8176 }
8277 $cellspacing = Babel::mHtmlAttrib( 'cellspacing', 'babel-box-cellspacing' );
8378 $cellpadding = Babel::mHtmlAttrib( 'cellpadding', 'babel-box-cellpadding' );
@@ -87,7 +82,7 @@
8883 |-
8984 | $content
9085 |-
91 -$footer
 86+$showfooter
9287 |}
9388 EOT;
9489 return $tower;
@@ -254,18 +249,18 @@
255250
256251 $text = wfMsgExt( "babel-$level-n",
257252 array( 'language' => $language, 'parsemag' ),
258 - $categoryMain, $categoryMain, '', self::$title->getDBkey()
 253+ $categoryLevel, $categoryMain, '', self::$title->getDBkey()
259254 );
260255
261256 $fallback = wfMsgExt( "babel-$level-n",
262257 array( 'language' => Language::getFallbackfor( $language ), 'parsemag' ),
263 - $categoryMain, $categoryMain, '', self::$title->getDBkey()
 258+ $categoryLevel, $categoryMain, '', self::$title->getDBkey()
264259 );
265260
266261 if ( $text == $fallback ) {
267262 $text = wfMsgExt( "babel-$level",
268263 array( 'language' => $language, 'parsemag' ),
269 - $categoryMain, $categoryMain, $name, self::$title->getDBkey()
 264+ $categoryLevel, $categoryMain, $name, self::$title->getDBkey()
270265 );
271266 }
272267
@@ -284,12 +279,14 @@
285280
286281 $r = '';
287282
288 - if ( $wgBabelMainCategory !== false && $wgBabelCategoryNames[$level] !== false ) {
 283+ # Add main category
 284+ if ( $wgBabelMainCategory !== false ) {
289285 $category = self::mReplaceCategoryVariables( $wgBabelMainCategory, $code );
290286 $r .= "[[Category:$category|$level]]";
291287 BabelAutoCreate::create( $category, $code );
292288 }
293289
 290+ # Add level category
294291 if ( $wgBabelCategoryNames[$level] !== false ) {
295292 $category = self::mReplaceCategoryVariables( $wgBabelCategoryNames[$level], $code );
296293 $r .= "[[Category:$category]]";

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r102899Do not depend on the level category being configured, when adding the main ca...robin15:37, 13 November 2011
r102900The first parameter should be the level... $categoryLevel wasn't used, and $c...robin17:06, 13 November 2011
r102912Don't show the "Users by language" footer if it doesn't link to a page. (The ...robin21:47, 13 November 2011
r105540Bug 31330 - Do not prefer templates over built-in language boxes....nikerabbit11:53, 8 December 2011

Status & tagging log