r98140 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r98139‎ | r98140 | r98141 >
Date:15:36, 26 September 2011
Author:robin
Status:resolved (Comments)
Tags:
Comment:
Possibility to use the language code as parameter on categories.
Modified paths:
  • /trunk/extensions/Babel/Babel.class.php (modified) (history)
  • /trunk/extensions/Babel/BabelAutoCreate.class.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Babel/BabelAutoCreate.class.php
@@ -23,19 +23,21 @@
2424 * Create category.
2525 *
2626 * @param $category String: Name of category to create.
27 - * @param $language String: Name of language that the category is for.
 27+ * @param $language String: Code of language that the category is for.
2828 * @param $level String: Level that the category is for.
2929 */
30 - public static function create( $category, $language, $level = null ) {
 30+ public static function create( $category, $code, $level = null ) {
3131 $category = strip_tags( $category );
3232 $title = Title::makeTitleSafe( NS_CATEGORY, $category );
3333 if ( $title === null || $title->exists() ) {
3434 return;
3535 }
 36+ global $wgLanguageCode;
 37+ $language = BabelLanguageCodes::getName( $code, $wgLanguageCode );
3638 if ( $level === null ) {
37 - $text = wfMsgForContent( 'babel-autocreate-text-main', $language );
 39+ $text = wfMsgForContent( 'babel-autocreate-text-main', $language, $code );
3840 } else {
39 - $text = wfMsgForContent( 'babel-autocreate-text-levels', $level, $language );
 41+ $text = wfMsgForContent( 'babel-autocreate-text-levels', $level, $language, $code );
4042 }
4143 $article = new Article( $title, 0 );
4244
Index: trunk/extensions/Babel/Babel.class.php
@@ -280,20 +280,20 @@
281281 * @return String: Wikitext to add categories.
282282 */
283283 protected static function mGenerateCategories( $code, $level ) {
284 - global $wgBabelMainCategory, $wgBabelCategoryNames, $wgLanguageCode;
 284+ global $wgBabelMainCategory, $wgBabelCategoryNames;
285285
286286 $r = '';
287287
288288 if ( $wgBabelMainCategory !== false && $wgBabelCategoryNames[$level] !== false ) {
289289 $category = self::mReplaceCategoryVariables( $wgBabelMainCategory, $code );
290290 $r .= "[[Category:$category|$level]]";
291 - BabelAutoCreate::create( $category, BabelLanguageCodes::getName( $code, $wgLanguageCode ) );
 291+ BabelAutoCreate::create( $category, $code );
292292 }
293293
294294 if ( $wgBabelCategoryNames[$level] !== false ) {
295295 $category = self::mReplaceCategoryVariables( $wgBabelCategoryNames[$level], $code );
296296 $r .= "[[Category:$category]]";
297 - BabelAutoCreate::create( $category, BabelLanguageCodes::getName( $code, $wgLanguageCode ), $level );
 297+ BabelAutoCreate::create( $category, $code, $level );
298298 }
299299
300300 return $r;

Follow-up revisions

RevisionCommit summaryAuthorDate
r102786Followup r98140 - fix docsnikerabbit14:40, 11 November 2011
r102998MFT r98140 r100023 r102786 r102802 r102893nikerabbit18:20, 14 November 2011

Comments

#Comment by Santhosh.thottingal (talk | contribs)   05:02, 9 November 2011

For the create method documentation, @param $language should be @param $code since you changed the argument name.

Status & tagging log