本文整理汇总了PHP中MantisEnum::getLocalizedLabel方法的典型用法代码示例。如果您正苦于以下问题:PHP MantisEnum::getLocalizedLabel方法的具体用法?PHP MantisEnum::getLocalizedLabel怎么用?PHP MantisEnum::getLocalizedLabel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MantisEnum
的用法示例。
在下文中一共展示了MantisEnum::getLocalizedLabel方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetLocalizedLabel
/**
* Tests getLocalizedLabel() method.
*/
public function testGetLocalizedLabel()
{
// Test existing case
$this->assertEquals('viewer_x', MantisEnum::getLocalizedLabel(MantisEnumTest::ACCESS_LEVELS_ENUM, MantisEnumTest::ACCESS_LEVELS_LOCALIZED_ENUM, 10));
// Test unknown case
$this->assertEquals('@5@', MantisEnum::getLocalizedLabel(MantisEnumTest::ACCESS_LEVELS_ENUM, MantisEnumTest::ACCESS_LEVELS_LOCALIZED_ENUM, 5));
// Test the case where the value is in the localized enum but not the standard one. In this case it should be treated
// as unknown.
$this->assertEquals('@95@', MantisEnum::getLocalizedLabel(MantisEnumTest::ACCESS_LEVELS_ENUM, MantisEnumTest::ACCESS_LEVELS_LOCALIZED_ENUM, 95));
}
示例2: testGetLocalizedLabel
/**
* Tests getLocalizedLabel() method.
* @return void
*/
public function testGetLocalizedLabel()
{
# Test existing case
$this->assertEquals('viewer_x', MantisEnum::getLocalizedLabel(MantisEnumTest::ACCESS_LEVELS_ENUM, MantisEnumTest::ACCESS_LEVELS_LOCALIZED_ENUM, 10));
# Test unknown case
$this->assertEquals('@5@', MantisEnum::getLocalizedLabel(MantisEnumTest::ACCESS_LEVELS_ENUM, MantisEnumTest::ACCESS_LEVELS_LOCALIZED_ENUM, 5));
# Test the case where the value is in the localized enumeration but not the standard one.
# In this case it should be treated as unknown.
$this->assertEquals('@95@', MantisEnum::getLocalizedLabel(MantisEnumTest::ACCESS_LEVELS_ENUM, MantisEnumTest::ACCESS_LEVELS_LOCALIZED_ENUM, 95));
# Test the case where the value is in the standard enumeration but not in the localized one.
# In this case we should fall back to the standard enumeration (as we do with language strings)
# as the value is a known good value - just that it has not yet been localized.
$this->assertEquals('missing', MantisEnum::getLocalizedLabel(MantisEnumTest::ACCESS_LEVELS_ENUM_EXTRA, MantisEnumTest::ACCESS_LEVELS_LOCALIZED_ENUM, 100));
}
示例3: mci_explode_to_objectref
/**
* Explode a configuration enumeration name into an array structure that can
* be safely converted into an ObjectRef structure.
*
* @param string $p_enumeration_name The name of the enumeration to convert
* @return Array The converted enumeration
*/
function mci_explode_to_objectref($p_enumeration_name)
{
$t_config_var_name = $p_enumeration_name . '_enum_string';
$t_config_var_value = config_get($t_config_var_name);
$t_translated_values = lang_get($t_config_var_name, mci_get_user_lang(auth_get_current_user_id()));
$t_enum_values = MantisEnum::getValues($t_config_var_value);
$t_result = array();
foreach ($t_enum_values as $t_key) {
$t_translated = MantisEnum::getLocalizedLabel($t_config_var_value, $t_translated_values, $t_key);
$t_result[] = array('id' => $t_key, 'name' => $t_translated);
}
return $t_result;
}
示例4: mci_get_enum_element
/**
* Given a enum string and num, return the appropriate localized string
* @param string $p_enum_name Enumeration name.
* @param string $p_val Enumeration value.
* @param string $p_lang Language string.
* @return string
*/
function mci_get_enum_element($p_enum_name, $p_val, $p_lang)
{
$t_enum_string = config_get($p_enum_name . '_enum_string');
$t_localized_enum_string = lang_get($p_enum_name . '_enum_string', $p_lang);
return MantisEnum::getLocalizedLabel($t_enum_string, $t_localized_enum_string, $p_val);
}
示例5: get_enum_element
/**
* Given a enum string and num, return the appropriate string for the
* specified user/project
* @param string $p_enum_name
* @param int $p_val
* @param int|null $p_user user id, defaults to null (all users)
* @param int|null $p_project project id, defaults to null (all projects)
* @return string
*/
function get_enum_element($p_enum_name, $p_val, $p_user = null, $p_project = null)
{
$config_var = config_get($p_enum_name . '_enum_string', null, $p_user, $p_project);
$string_var = lang_get($p_enum_name . '_enum_string');
return MantisEnum::getLocalizedLabel($config_var, $string_var, $p_val);
}