コード例 #1
0
 /**
  * Generate categories for the given language and level.
  *
  * @param $code String: Language code to use.
  * @param $level String or Integer: Level of ability to use.
  * @param $createCategories Boolean: If true, creates non existing categories; otherwise, doesn't create them.
  * @return String: Wikitext to add categories.
  */
 protected static function mGenerateCategories($code, $level, $createCategories = true)
 {
     wfProfileIn(__METHOD__);
     global $wgBabelMainCategory, $wgBabelCategoryNames;
     $r = '';
     # Add main category
     if ($wgBabelMainCategory !== false) {
         $category = self::mReplaceCategoryVariables($wgBabelMainCategory, $code);
         $r .= "[[Category:{$category}|{$level}]]";
         if ($createCategories) {
             BabelAutoCreate::create($category, $code);
         }
     }
     # Add level category
     if ($wgBabelCategoryNames[$level] !== false) {
         $category = self::mReplaceCategoryVariables($wgBabelCategoryNames[$level], $code);
         $r .= "[[Category:{$category}]]";
         if ($createCategories) {
             BabelAutoCreate::create($category, $code, $level);
         }
     }
     wfProfileOut(__METHOD__);
     return $r;
 }
コード例 #2
0
 /**
  * Generate categories for the given language and level.
  *
  * @param $code String: Language code to use.
  * @param $level String or Integer: Level of ability to use.
  * @return String: Wikitext to add categories.
  */
 protected static function mGenerateCategories($code, $level)
 {
     global $wgBabelMainCategory, $wgBabelCategoryNames;
     $r = '';
     # Add main category
     if ($wgBabelMainCategory !== false) {
         $category = self::mReplaceCategoryVariables($wgBabelMainCategory, $code);
         $r .= "[[Category:{$category}|{$level}]]";
         BabelAutoCreate::create($category, $code);
     }
     # Add level category
     if ($wgBabelCategoryNames[$level] !== false) {
         $category = self::mReplaceCategoryVariables($wgBabelCategoryNames[$level], $code);
         $r .= "[[Category:{$category}]]";
         BabelAutoCreate::create($category, $code, $level);
     }
     return $r;
 }