本文整理汇总了PHP中LanguageUtf8类的典型用法代码示例。如果您正苦于以下问题:PHP LanguageUtf8类的具体用法?PHP LanguageUtf8怎么用?PHP LanguageUtf8使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LanguageUtf8类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: stripForSearch
function stripForSearch($string)
{
$fname = "LanguageZh::stripForSearch";
wfProfileIn($fname);
// eventually this should be a word segmentation
// for now just treat each character as a word
$t = preg_replace("/([\\xc0-\\xff][\\x80-\\xbf]*)/e", "' ' .\"\$1\"", $string);
//always convert to zh-cn before indexing. it should be
//better to use zh-cn for search, since conversion from
//Traditional to Simplified is less ambiguous than the
//other way around
$t = $this->mConverter->autoConvert($t, 'zh-cn');
$t = LanguageUtf8::stripForSearch($t);
wfProfileOut($fname);
return $t;
}
示例2: lc
function lc($str, $first = false)
{
if (function_exists('mb_strtolower')) {
if ($first) {
if (LanguageUtf8::isMultibyte($str)) {
return mb_strtolower(mb_substr($str, 0, 1)) . mb_substr($str, 1);
} else {
return strtolower(substr($str, 0, 1)) . substr($str, 1);
}
} else {
return LanguageUtf8::isMultibyte($str) ? mb_strtolower($str) : strtolower($str);
}
} else {
if (LanguageUtf8::isMultibyte($str)) {
global $wikiLowerChars;
$x = $first ? '^' : '';
return preg_replace("/{$x}([A-Z]|[\\xc0-\\xff][\\x80-\\xbf]*)/e", "strtr( \"\$1\" , \$wikiLowerChars )", $str);
} else {
return $first ? strtolower(substr($str, 0, 1)) . substr($str, 1) : strtolower($str);
}
}
}
示例3: stripForSearch
function stripForSearch($string)
{
# MySQL fulltext index doesn't grok utf-8, so we
# need to fold cases and convert to hex
$s = $string;
# Strip known punctuation ?
#$s = preg_replace( '/\xe3\x80[\x80-\xbf]/', '', $s ); # U3000-303f
# Space strings of like hiragana/katakana/kanji
$hiragana = '(?:\\xe3(?:\\x81[\\x80-\\xbf]|\\x82[\\x80-\\x9f]))';
# U3040-309f
$katakana = '(?:\\xe3(?:\\x82[\\xa0-\\xbf]|\\x83[\\x80-\\xbf]))';
# U30a0-30ff
$kanji = '(?:\\xe3[\\x88-\\xbf][\\x80-\\xbf]' . '|[\\xe4-\\xe8][\\x80-\\xbf]{2}' . '|\\xe9[\\x80-\\xa5][\\x80-\\xbf]' . '|\\xe9\\xa6[\\x80-\\x99])';
# U3200-9999 = \xe3\x88\x80-\xe9\xa6\x99
$s = preg_replace("/({$hiragana}+|{$katakana}+|{$kanji}+)/", ' $1 ', $s);
# Double-width roman characters: ff00-ff5f ~= 0020-007f
$s = preg_replace('/\\xef\\xbc([\\x80-\\xbf])/e', 'chr((ord("$1") & 0x3f) + 0x20)', $s);
$s = preg_replace('/\\xef\\xbd([\\x80-\\x99])/e', 'chr((ord("$1") & 0x3f) + 0x60)', $s);
# Do general case folding and UTF-8 armoring
return LanguageUtf8::stripForSearch($s);
}
示例4: LanguageOs
function LanguageOs()
{
global $wgNamespaceNamesOs, $wgMetaNamespace;
LanguageUtf8::LanguageUtf8();
}
示例5: LanguageCv
function LanguageCv()
{
global $wgNamespaceNamesCv, $wgMetaNamespace;
LanguageUtf8::LanguageUtf8();
}
示例6: LanguageUdm
function LanguageUdm()
{
global $wgNamespaceNamesUdm, $wgMetaNamespace;
LanguageUtf8::LanguageUtf8();
}
示例7: compare
function compare($a, $b)
{
if ($a['name'] === $b['name']) {
return 0;
} else {
return LanguageUtf8::lc($a['name']) > LanguageUtf8::lc($b['name']) ? 1 : -1;
}
}
示例8: parseCachedTable
/**
* 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;
}
示例9: getDefaultUserOptions
function getDefaultUserOptions()
{
$opt = parent::getDefaultUserOptions();
$opt['quickbar'] = 2;
# Right-to-left
return $opt;
}
示例10: getMessage
function getMessage($key)
{
if (isset($this->mMessagesEs[$key])) {
return $this->mMessagesEs[$key];
} else {
return parent::getMessage($key);
}
}
示例11: ucfirst
function ucfirst($string)
{
if ($string[0] == 'i') {
return 'İ' . substr($string, 1);
} else {
return parent::ucfirst($string);
}
}
示例12: getMessage
function getMessage($key)
{
global $wgAllMessagesLa;
if (isset($wgAllMessagesLa[$key])) {
return $wgAllMessagesLa[$key];
}
return parent::getMessage($key);
}
示例13: getMessage
function getMessage($key)
{
global $wgAllMessagesTa;
if (array_key_exists($key, $wgAllMessagesTa)) {
return $wgAllMessagesTa[$key];
} else {
return parent::getMessage($key);
}
}
示例14: timeanddate
function timeanddate($ts, $adj = false, $format = false, $timecorrection = false)
{
$format = $this->dateFormat($format);
if ($format == MW_DATE_ISO) {
return parent::timeanddate($ts, $adj, $format, $timecorrection);
} else {
return $this->date($ts, $adj, $format, $timecorrection) . " kl." . $this->time($ts, $adj, $format, $timecorrection);
}
}
示例15: getMessage
function getMessage($key)
{
global $wgAllMessagesMs;
if (isset($wgAllMessagesMs[$key])) {
return $wgAllMessagesMs[$key];
} else {
return parent::getMessage($key);
}
}