本文整理汇总了PHP中Dict::SetDefaultLanguage方法的典型用法代码示例。如果您正苦于以下问题:PHP Dict::SetDefaultLanguage方法的具体用法?PHP Dict::SetDefaultLanguage怎么用?PHP Dict::SetDefaultLanguage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dict
的用法示例。
在下文中一共展示了Dict::SetDefaultLanguage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: LoadConfig
public static function LoadConfig($oConfiguration, $bAllowCache = false)
{
self::$m_oConfig = $oConfiguration;
// Set log ASAP
if (self::$m_oConfig->GetLogGlobal()) {
if (self::$m_oConfig->GetLogIssue()) {
self::$m_bLogIssue = true;
IssueLog::Enable(APPROOT . 'log/error.log');
}
self::$m_bLogNotification = self::$m_oConfig->GetLogNotification();
self::$m_bLogWebService = self::$m_oConfig->GetLogWebService();
ToolsLog::Enable(APPROOT . 'log/tools.log');
} else {
self::$m_bLogIssue = false;
self::$m_bLogNotification = false;
self::$m_bLogWebService = false;
}
ExecutionKPI::EnableDuration(self::$m_oConfig->Get('log_kpi_duration'));
ExecutionKPI::EnableMemory(self::$m_oConfig->Get('log_kpi_memory'));
ExecutionKPI::SetAllowedUser(self::$m_oConfig->Get('log_kpi_user_id'));
self::$m_bSkipCheckToWrite = self::$m_oConfig->Get('skip_check_to_write');
self::$m_bSkipCheckExtKeys = self::$m_oConfig->Get('skip_check_ext_keys');
self::$m_bUseAPCCache = $bAllowCache && self::$m_oConfig->Get('apc_cache.enabled') && function_exists('apc_fetch') && function_exists('apc_store');
DBSearch::EnableQueryCache(self::$m_oConfig->GetQueryCacheEnabled(), self::$m_bUseAPCCache, self::$m_oConfig->Get('apc_cache.query_ttl'));
DBSearch::EnableQueryTrace(self::$m_oConfig->GetLogQueries());
DBSearch::EnableQueryIndentation(self::$m_oConfig->Get('query_indentation_enabled'));
DBSearch::EnableOptimizeQuery(self::$m_oConfig->Get('query_optimization_enabled'));
// PHP timezone first...
//
$sPHPTimezone = self::$m_oConfig->Get('timezone');
if ($sPHPTimezone == '') {
// Leave as is... up to the admin to set a value somewhere...
//$sPHPTimezone = date_default_timezone_get();
} else {
date_default_timezone_set($sPHPTimezone);
}
// Note: load the dictionary as soon as possible, because it might be
// needed when some error occur
$sAppIdentity = 'itop-' . MetaModel::GetEnvironmentId();
$bDictInitializedFromData = false;
if (!self::$m_bUseAPCCache || !Dict::InCache($sAppIdentity)) {
$bDictInitializedFromData = true;
foreach (self::$m_oConfig->GetDictionaries() as $sModule => $sToInclude) {
self::IncludeModule('dictionaries', $sToInclude);
}
}
// Set the language... after the dictionaries have been loaded!
Dict::SetDefaultLanguage(self::$m_oConfig->GetDefaultLanguage());
// Romain: this is the only way I've found to cope with the fact that
// classes have to be derived from cmdbabstract (to be editable in the UI)
require_once APPROOT . '/application/cmdbabstract.class.inc.php';
foreach (self::$m_oConfig->GetAppModules() as $sModule => $sToInclude) {
self::IncludeModule('application', $sToInclude);
}
foreach (self::$m_oConfig->GetDataModels() as $sModule => $sToInclude) {
self::IncludeModule('business', $sToInclude);
}
foreach (self::$m_oConfig->GetWebServiceCategories() as $sModule => $sToInclude) {
self::IncludeModule('webservice', $sToInclude);
}
foreach (self::$m_oConfig->GetAddons() as $sModule => $sToInclude) {
self::IncludeModule('addons', $sToInclude);
}
$sServer = self::$m_oConfig->GetDBHost();
$sUser = self::$m_oConfig->GetDBUser();
$sPwd = self::$m_oConfig->GetDBPwd();
$sSource = self::$m_oConfig->GetDBName();
$sTablePrefix = self::$m_oConfig->GetDBSubname();
$sCharacterSet = self::$m_oConfig->GetDBCharacterSet();
$sCollation = self::$m_oConfig->GetDBCollation();
if (self::$m_bUseAPCCache) {
$oKPI = new ExecutionKPI();
// Note: For versions of APC older than 3.0.17, fetch() accepts only one parameter
//
$sOqlAPCCacheId = 'itop-' . MetaModel::GetEnvironmentId() . '-metamodel';
$result = apc_fetch($sOqlAPCCacheId);
if (is_array($result)) {
// todo - verifier que toutes les classes mentionnees ici sont chargees dans InitClasses()
self::$m_aExtensionClasses = $result['m_aExtensionClasses'];
self::$m_Category2Class = $result['m_Category2Class'];
self::$m_aRootClasses = $result['m_aRootClasses'];
self::$m_aParentClasses = $result['m_aParentClasses'];
self::$m_aChildClasses = $result['m_aChildClasses'];
self::$m_aClassParams = $result['m_aClassParams'];
self::$m_aAttribDefs = $result['m_aAttribDefs'];
self::$m_aAttribOrigins = $result['m_aAttribOrigins'];
self::$m_aExtKeyFriends = $result['m_aExtKeyFriends'];
self::$m_aIgnoredAttributes = $result['m_aIgnoredAttributes'];
self::$m_aFilterDefs = $result['m_aFilterDefs'];
self::$m_aFilterOrigins = $result['m_aFilterOrigins'];
self::$m_aListInfos = $result['m_aListInfos'];
self::$m_aListData = $result['m_aListData'];
self::$m_aRelationInfos = $result['m_aRelationInfos'];
self::$m_aStates = $result['m_aStates'];
self::$m_aStimuli = $result['m_aStimuli'];
self::$m_aTransitions = $result['m_aTransitions'];
self::$m_aHighlightScales = $result['m_aHighlightScales'];
}
$oKPI->ComputeAndReport('Metamodel APC (fetch + read)');
}
//.........这里部分代码省略.........
示例2: MakeDictionaryTemplate
function MakeDictionaryTemplate($sModules = '', $sLanguage = 'EN US')
{
$sRes = '';
Dict::SetDefaultLanguage($sLanguage);
$aAvailableLanguages = Dict::GetLanguages();
$sDesc = $aAvailableLanguages[$sLanguage]['description'];
$sLocalizedDesc = $aAvailableLanguages[$sLanguage]['localized_description'];
$sRes .= "// Dictionary conventions\n";
$sRes .= htmlentities("// Class:<class_name>\n", ENT_QUOTES, 'UTF-8');
$sRes .= htmlentities("// Class:<class_name>+\n", ENT_QUOTES, 'UTF-8');
$sRes .= htmlentities("// Class:<class_name>/Attribute:<attribute_code>\n", ENT_QUOTES, 'UTF-8');
$sRes .= htmlentities("// Class:<class_name>/Attribute:<attribute_code>+\n", ENT_QUOTES, 'UTF-8');
$sRes .= htmlentities("// Class:<class_name>/Attribute:<attribute_code>/Value:<value>\n", ENT_QUOTES, 'UTF-8');
$sRes .= htmlentities("// Class:<class_name>/Attribute:<attribute_code>/Value:<value>+\n", ENT_QUOTES, 'UTF-8');
$sRes .= htmlentities("// Class:<class_name>/Stimulus:<stimulus_code>\n", ENT_QUOTES, 'UTF-8');
$sRes .= htmlentities("// Class:<class_name>/Stimulus:<stimulus_code>+\n", ENT_QUOTES, 'UTF-8');
$sRes .= "\n";
// Note: I did not use EnumCategories(), because a given class maybe found in several categories
// Need to invent the "module", to characterize the origins of a class
if (strlen($sModules) == 0) {
$aModules = array('bizmodel', 'core/cmdb', 'gui', 'application', 'addon/userrights', 'monitoring');
} else {
$aModules = explode(', ', $sModules);
}
$sRes .= "//////////////////////////////////////////////////////////////////////\n";
$sRes .= "// Note: The classes have been grouped by categories: " . implode(', ', $aModules) . "\n";
$sRes .= "//////////////////////////////////////////////////////////////////////\n";
foreach ($aModules as $sCategory) {
$sRes .= "//////////////////////////////////////////////////////////////////////\n";
$sRes .= "// Classes in '{$sCategory}'\n";
$sRes .= "//////////////////////////////////////////////////////////////////////\n";
$sRes .= "//\n";
$sRes .= "\n";
foreach (MetaModel::GetClasses($sCategory) as $sClass) {
if (!MetaModel::HasTable($sClass)) {
continue;
}
$bNotInDico = false;
$bNotImportant = true;
$sClassRes = "//\n";
$sClassRes .= "// Class: {$sClass}\n";
$sClassRes .= "//\n";
$sClassRes .= "\n";
$sClassRes .= "Dict::Add('{$sLanguage}', '{$sDesc}', '{$sLocalizedDesc}', array(\n";
$sClassRes .= MakeDictEntry("Class:{$sClass}", MetaModel::GetName_Obsolete($sClass), $sClass, $bNotInDico);
$sClassRes .= MakeDictEntry("Class:{$sClass}+", MetaModel::GetClassDescription_Obsolete($sClass), '', $bNotImportant);
foreach (MetaModel::ListAttributeDefs($sClass) as $sAttCode => $oAttDef) {
if ($sAttCode == 'friendlyname') {
continue;
}
// Skip this attribute if not originaly defined in this class
if (MetaModel::GetAttributeOrigin($sClass, $sAttCode) != $sClass) {
continue;
}
$sClassRes .= MakeDictEntry("Class:{$sClass}/Attribute:{$sAttCode}", $oAttDef->GetLabel_Obsolete(), $sAttCode, $bNotInDico);
$sClassRes .= MakeDictEntry("Class:{$sClass}/Attribute:{$sAttCode}+", $oAttDef->GetDescription_Obsolete(), '', $bNotImportant);
if ($oAttDef instanceof AttributeEnum) {
if (MetaModel::GetStateAttributeCode($sClass) == $sAttCode) {
foreach (MetaModel::EnumStates($sClass) as $sStateCode => $aStateData) {
if (array_key_exists('label', $aStateData)) {
$sValue = $aStateData['label'];
} else {
$sValue = MetaModel::GetStateLabel($sClass, $sStateCode);
}
if (array_key_exists('description', $aStateData)) {
$sValuePlus = $aStateData['description'];
} else {
$sValuePlus = MetaModel::GetStateDescription($sClass, $sStateCode);
}
$sClassRes .= MakeDictEntry("Class:{$sClass}/Attribute:{$sAttCode}/Value:{$sStateCode}", $sValue, '', $bNotInDico);
$sClassRes .= MakeDictEntry("Class:{$sClass}/Attribute:{$sAttCode}/Value:{$sStateCode}+", $sValuePlus, '', $bNotImportant);
}
} else {
foreach ($oAttDef->GetAllowedValues() as $sKey => $value) {
$sClassRes .= MakeDictEntry("Class:{$sClass}/Attribute:{$sAttCode}/Value:{$sKey}", $value, '', $bNotInDico);
$sClassRes .= MakeDictEntry("Class:{$sClass}/Attribute:{$sAttCode}/Value:{$sKey}+", $value, '', $bNotImportant);
}
}
}
}
foreach (MetaModel::EnumStimuli($sClass) as $sStimulusCode => $oStimulus) {
$sClassRes .= MakeDictEntry("Class:{$sClass}/Stimulus:{$sStimulusCode}", $oStimulus->GetLabel_Obsolete(), '', $bNotInDico);
$sClassRes .= MakeDictEntry("Class:{$sClass}/Stimulus:{$sStimulusCode}+", $oStimulus->GetDescription_Obsolete(), '', $bNotImportant);
}
$sClassRes .= "));\n";
$sClassRes .= "\n";
$sRes .= $sClassRes;
}
}
return $sRes;
}