本文整理匯總了PHP中CAppUI::addLocales方法的典型用法代碼示例。如果您正苦於以下問題:PHP CAppUI::addLocales方法的具體用法?PHP CAppUI::addLocales怎麽用?PHP CAppUI::addLocales使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CAppUI
的用法示例。
在下文中一共展示了CAppUI::addLocales方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: initLocales
/**
* Inits locale cache
*
* @return void
*/
static function initLocales()
{
if (self::$_locales_ready) {
return;
}
$lang = CAppUI::pref("LOCALE");
$_all_locales = DSHM::get("exclass-locales-{$lang}");
if (!$_all_locales) {
$undefined = CAppUI::tr("Undefined");
$ds = CSQLDataSource::get("std");
$_all_locales = array();
$request = new CRequest();
$request->addTable("ex_class_field_translation");
$request->addWhere(array("lang" => "= '{$lang}'"));
$request->addLJoin(array("ex_class_field" => "ex_class_field.ex_class_field_id = ex_class_field_translation.ex_class_field_id", "ex_concept" => "ex_concept.ex_concept_id = ex_class_field.concept_id", "ex_class_field_group" => "ex_class_field_group.ex_class_field_group_id = ex_class_field.ex_group_id"));
$request->addSelect(array("ex_class_field_translation.std", "IF(ex_class_field_translation.desc IS NOT NULL, ex_class_field_translation.desc, ex_class_field_translation.std) AS `desc`", "IF(ex_class_field_translation.court IS NOT NULL, ex_class_field_translation.court, ex_class_field_translation.std) AS `court`", "ex_class_field.ex_class_field_id AS field_id", "ex_class_field.name", "ex_class_field.prop", "ex_class_field.concept_id", "ex_class_field_group.ex_class_id", "ex_concept.ex_list_id"));
$list = $ds->loadList($request->makeSelect());
// Chargement des list_items par concept, field ou list
$request = new CRequest();
$request->addTable("ex_list_item");
$request->addSelect(array("ex_list_item_id", "list_id", "concept_id", "field_id", "name"));
$list_items = $ds->loadList($request->makeSelect());
// Chargement en une seule requete de toutes les traductions de champs
$enum_list_cache = array("list" => array(), "concept" => array(), "field" => array());
$mapper = array("list_id" => "list", "concept_id" => "concept", "field_id" => "field");
foreach ($list_items as $_item) {
$_item_id = $_item["ex_list_item_id"];
$_item_name = $_item["name"];
foreach ($mapper as $_field_name => $_to) {
if ($_field_value = $_item[$_field_name]) {
$enum_list_cache[$_to][$_field_value][$_item_id] = $_item_name;
}
}
}
foreach ($list as $_item) {
$_locales = array();
$key = "-{$_item['name']}";
$_locales[$key] = $_item["std"];
if ($_item["desc"]) {
$_locales["{$key}-desc"] = $_item["desc"];
}
if ($_item["court"]) {
$_locales["{$key}-court"] = $_item["court"];
}
$_ex_class_id = $_item['ex_class_id'];
$_prefix = "CExObject_{$_ex_class_id}";
$prop = $_item["prop"];
if (strpos($prop, "enum") === false && strpos($prop, "set") === false) {
if (!isset($_all_locales[$_prefix])) {
$_all_locales[$_prefix] = array();
}
$_all_locales[$_prefix] = array_merge($_all_locales[$_prefix], $_locales);
continue;
}
$key = ".{$_item['name']}";
$_locales["{$key}."] = $undefined;
$concept_id = $_item["concept_id"];
$ex_list_id = $_item["ex_list_id"];
$field_id = $_item["field_id"];
$enum_list = array();
if ($concept_id) {
if ($ex_list_id) {
if (isset($enum_list_cache["list"][$ex_list_id])) {
$enum_list = $enum_list_cache["list"][$ex_list_id];
}
} else {
if (isset($enum_list_cache["concept"][$concept_id])) {
$enum_list = $enum_list_cache["concept"][$concept_id];
}
}
} else {
if (isset($enum_list_cache["field"][$field_id])) {
$enum_list = $enum_list_cache["field"][$field_id];
}
}
foreach ($enum_list as $_value => $_locale) {
$_locales["{$key}.{$_value}"] = $_locale;
}
if (!isset($_all_locales[$_prefix])) {
$_all_locales[$_prefix] = array();
}
$_all_locales[$_prefix] = array_merge($_all_locales[$_prefix], $_locales);
}
DSHM::put("exclass-locales-{$lang}", $_all_locales, true);
}
foreach ($_all_locales as $_prefix => $_locales) {
CAppUI::addLocales($_prefix, $_locales);
}
self::$_locales_ready = true;
}