function gb2big5($in)
{
    return @MediaWikiZhConverter::convert($in, "zh-tw");
}
Example #2
0
<?php 
/**
 * Define the folder(note the ending slash) containing the mediawiki's files.
 *  
 * YOU SHOULD PLACE THEM OUTSIDE THE DOCUMENT ROOT OF YOUR WEB SERVER!!!
 */
define("MEDIAWIKI_PATH", "/var/lib/mediawiki-1.26.2/");
/* Include our helper class */
require_once "mediawiki-zhconverter.inc.php";
/* Convert it, valid variants such as zh, zh-hans, zh-hant, zh-cn, zh-tw, zh-sg & zh-hk */
echo MediaWikiZhConverter::convert("雪糕", "zh-tw"), ",";
echo MediaWikiZhConverter::convert("記憶體", "zh-cn"), ",";
echo MediaWikiZhConverter::convert("大卫·贝克汉姆", "zh-hk");
Example #3
0
    $y = $row['dy'];
    $ymin = 180 * $y / $wikiminiatlas_zoomsize[$z] - 90.0;
    $ymax = $ymin + 180.0 / $wikiminiatlas_zoomsize[$z];
    $xmin = 180.0 * $x / $wikiminiatlas_zoomsize[$z];
    $ty = intval(($ymax - $row["lat"]) * $wikiminiatlas_zoomsize[$z] * 128 / 180.0);
    $tx = intval(($row["lon"] - $xmin) * $wikiminiatlas_zoomsize[$z] * 128 / 180.0);
    $fy = ($ymax - $row["lat"]) * $wikiminiatlas_zoomsize[$z] * 128 / 180.0 - $ty;
    $fx = ($row["lon"] - $xmin) * $wikiminiatlas_zoomsize[$z] * 128 / 180.0 - $tx;
    $s = $row['style'];
    if ($lang == "commons") {
        $n = explode('|', $row["name"], 4);
        $w = $n[0];
        $h = $n[1];
        $items[] = array("style" => $s, "img" => urlencode($row["title"]), "tx" => $tx, "ty" => $ty, "w" => $n[0], "h" => $n[1], "head" => $n[2], "dx" => $x, "dy" => $y, "wg" => intval($row["wg"]), "fx" => $fx, "fy" => $fy, "m5" => substr(md5($row["title"]), 0, 2));
    } else {
        if ($variant == "") {
            $name = $row['name'];
        } else {
            $name = MediaWikiZhConverter::convert($row['name'], $variant);
        }
        $items[] = array("style" => $s, "lang" => $lang, "page" => urlencode($row["title"]), "tx" => $tx, "ty" => $ty, "name" => $name, "dx" => $x, "dy" => $y, "wg" => intval($row["wg"]), "fx" => $fx, "fy" => $fy);
    }
}
// TODO only send fx,fy,wg for max label zoom!
mysqli_close($db);
//header("Content-type: application/json");
header("Cache-Control: public, max-age=3600");
$result = json_encode(array("label" => $items, "z" => $z));
echo $result;
apc_add($key, $result, 24 * 60 * 60);
// cache 24h
 /**
  * Get all variants available.
  *
  * @return string All available variants, e.g. zh, zh-cn, zh-tw, zh-sg & zh-hk
  */
 function getVariants()
 {
     $converter =& MediaWikiZhConverter::getConverter();
     return $converter->_converter->getVariants();
 }