function ucfirst($string) { if ($string[0] == 'i') { return 'İ' . substr($string, 1); } else { return parent::ucfirst($string); } }
/** * parse the conversion table stored in the cache * * the tables should be in blocks of the following form: * -{ * word => word ; * word => word ; * ... * }- * * to make the tables more manageable, subpages are allowed * and will be parsed recursively if $recursive=true * * @access private */ function parseCachedTable($code, $subpage = '', $recursive = true) { global $wgMessageCache; static $parsed = array(); if (!is_object($wgMessageCache)) { return array(); } $key = 'Conversiontable/' . $code; if ($subpage) { $key .= '/' . $subpage; } if (array_key_exists($key, $parsed)) { return array(); } $txt = $wgMessageCache->get($key, true, true, true); // get all subpage links of the form // [[MediaWiki:conversiontable/zh-xx/...|...]] $linkhead = $this->mLangObj->getNsText(NS_MEDIAWIKI) . ':Conversiontable'; $subs = explode('[[', $txt); $sublinks = array(); foreach ($subs as $sub) { $link = explode(']]', $sub, 2); if (count($link) != 2) { continue; } $b = explode('|', $link[0]); $b = explode('/', trim($b[0]), 3); if (count($b) == 3) { $sublink = $b[2]; } else { $sublink = ''; } if ($b[0] == $linkhead && $b[1] == $code) { $sublinks[] = $sublink; } } // parse the mappings in this page $blocks = explode($this->mMarkup['begin'], $txt); array_shift($blocks); $ret = array(); foreach ($blocks as $block) { $mappings = explode($this->mMarkup['end'], $block, 2); $stripped = str_replace(array("'", '"', '*', '#'), '', $mappings[0]); $table = explode(';', $stripped); foreach ($table as $t) { $m = explode('=>', $t); if (count($m) != 2) { continue; } // trim any trailling comments starting with '//' $tt = explode('//', $m[1], 2); $ret[trim($m[0])] = trim($tt[0]); } } $parsed[$key] = true; // recursively parse the subpages if ($recursive) { foreach ($sublinks as $link) { $s = $this->parseCachedTable($code, $link, $recursive); $ret = array_merge($ret, $s); } } if ($this->mUcfirst) { foreach ($ret as $k => $v) { $ret[LanguageUtf8::ucfirst($k)] = LanguageUtf8::ucfirst($v); } } return $ret; }