本文整理汇总了PHP中ca_locales::localeIDToCode方法的典型用法代码示例。如果您正苦于以下问题:PHP ca_locales::localeIDToCode方法的具体用法?PHP ca_locales::localeIDToCode怎么用?PHP ca_locales::localeIDToCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ca_locales
的用法示例。
在下文中一共展示了ca_locales::localeIDToCode方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAttributesByElement
/**
*
* @param string $type can be one of: ["ca_objects", "ca_entities", "ca_places", "ca_occurrences", "ca_collections", "ca_list_items", "ca_object_representations", "ca_storage_locations", "ca_movements", "ca_loans", "ca_tours", "ca_tour_stops"]
* @param int $item_id primary key
* @param string $attribute_code_or_id
* @return array
* @throws SoapFault
*/
public function getAttributesByElement($type, $item_id, $attribute_code_or_id)
{
if (!($t_subject_instance = $this->getTableInstance($type, $item_id, true))) {
throw new SoapFault("Server", "Invalid type or item_id");
}
$t_locale = new ca_locales();
$t_element = new ca_metadata_elements();
$va_attrs = $t_subject_instance->getAttributesByElement($attribute_code_or_id);
$va_return = array();
$va_element_type_cfg = ca_metadata_elements::getAttributeTypes();
foreach ($va_attrs as $vo_attr) {
$va_attr = array();
foreach ($vo_attr->getValues() as $vo_value) {
$t_element->load($vo_value->getElementID());
$va_attr[] = array("value_id" => $vo_value->getValueID(), "display_value" => $vo_value->getDisplayValue(), "element_code" => $vo_value->getElementCode(), "element_id" => $vo_value->getElementID(), "attribute_info" => $t_subject_instance->getAttributeLabelAndDescription($vo_value->getElementCode()), "datatype" => $va_element_type_cfg[$t_element->get("datatype")], "locale" => $t_locale->localeIDToCode($vo_attr->getLocaleID()));
}
$va_return[$vo_attr->getAttributeID()] = $va_attr;
}
return $va_return;
}
示例2: getCaptionFileList
/**
* Returns list of caption/subtitle files attached to a representation
* The return value is an array key'ed on the caption_id; array values are arrays
* with keys set to values for each file returned. They keys are:
* path = The absolute file path to the file
* url = The URL for the file
* caption_id = a unique identifier for each attached caption file
*
* @param int $pn_representation_id The representation_id of the representation to return files for. If omitted the currently loaded representation is used. If no representation_id is specified and no row is loaded null will be returned.
* @param array $pa_locale_ids
* @param array $pa_options
* @return array A list of caption files attached to the representations. If no files are associated an empty array is returned.
*/
public function getCaptionFileList($pn_representation_id = null, $pa_locale_ids = null, $pa_options = null)
{
if (!($vn_representation_id = $pn_representation_id)) {
if (!($vn_representation_id = $this->getPrimaryKey())) {
return null;
}
}
$t_locale = new ca_locales();
$va_locale_ids = array();
if ($pa_locale_ids) {
if (!is_array($pa_locale_ids)) {
$pa_locale_ids = array($pa_locale_ids);
}
foreach ($pa_locale_ids as $vn_i => $vm_locale) {
if (is_numeric($vm_locale) && (int) $vm_locale) {
$va_locale_ids[] = (int) $vm_locale;
} else {
if ($vn_locale_id = $t_locale->localeCodeToID($vm_locale)) {
$va_locale_ids[] = $vn_locale_id;
}
}
}
}
$vs_locale_sql = '';
$va_params = array((int) $vn_representation_id);
if (sizeof($va_locale_ids) > 0) {
$vs_locale_sql = " AND locale_id IN (?)";
$va_params[] = $va_locale_ids;
}
$o_db = $this->getDb();
$qr_res = $o_db->query("\n \t\t\tSELECT *\n \t\t\tFROM ca_object_representation_captions\n \t\t\tWHERE\n \t\t\t\trepresentation_id = ?\n \t\t\t{$vs_locale_sql}\n \t\t", $va_params);
$va_files = array();
while ($qr_res->nextRow()) {
$vn_caption_id = $qr_res->get('caption_id');
$vn_locale_id = $qr_res->get('locale_id');
$va_files[$vn_caption_id] = $qr_res->getRow();
unset($va_files[$vn_caption_id]['caption_file']);
$va_files[$vn_caption_id]['path'] = $qr_res->getFilePath('caption_file');
$va_files[$vn_caption_id]['url'] = $qr_res->getFileUrl('caption_file');
$va_files[$vn_caption_id]['filesize'] = caFormatFileSize(filesize($va_files[$vn_caption_id]['path']));
$va_files[$vn_caption_id]['caption_id'] = $vn_caption_id;
$va_files[$vn_caption_id]['locale_id'] = $vn_locale_id;
$va_files[$vn_caption_id]['locale'] = $t_locale->localeIDToName($vn_locale_id);
$va_files[$vn_caption_id]['locale_code'] = $t_locale->localeIDToCode($vn_locale_id);
}
return $va_files;
}
示例3: getValuesForExport
/**
*
*/
public function getValuesForExport($pa_options = null)
{
$va_data = parent::getValuesForExport($pa_options);
// get intrinsics and attributes
$t_locale = new ca_locales();
$t_list = new ca_lists();
// get labels
$va_preferred_labels = $this->get($this->tableName() . ".preferred_labels", array('returnAsArray' => true, 'returnAllLocales' => true));
if (is_array($va_preferred_labels) && sizeof($va_preferred_labels)) {
$va_preferred_labels_for_export = array();
foreach ($va_preferred_labels as $vn_id => $va_labels_by_locale) {
foreach ($va_labels_by_locale as $vn_locale_id => $va_labels) {
if (!($vs_locale = $t_locale->localeIDToCode($vn_locale_id))) {
$vs_locale = 'NONE';
}
$va_preferred_labels_for_export[$vs_locale] = $va_labels[0];
unset($va_preferred_labels_for_export[$vs_locale]['form_element']);
}
}
$va_data['preferred_labels'] = $va_preferred_labels_for_export;
}
$va_nonpreferred_labels = $this->get($this->tableName() . ".nonpreferred_labels", array('returnAsArray' => true, 'returnAllLocales' => true));
if (is_array($va_nonpreferred_labels) && sizeof($va_nonpreferred_labels)) {
$va_nonpreferred_labels_for_export = array();
foreach ($va_nonpreferred_labels as $vn_id => $va_labels_by_locale) {
foreach ($va_labels_by_locale as $vn_locale_id => $va_labels) {
if (!($vs_locale = $t_locale->localeIDToCode($vn_locale_id))) {
$vs_locale = 'NONE';
}
$va_nonpreferred_labels_for_export[$vs_locale] = $va_labels;
foreach ($va_nonpreferred_labels_for_export[$vs_locale] as $vn_i => $va_label) {
unset($va_nonpreferred_labels_for_export[$vs_locale][$vn_i]['form_element']);
}
}
}
$va_data['nonpreferred_labels'] = $va_nonpreferred_labels_for_export;
}
return $va_data;
}
示例4: DownloadCaptionFile
/**
*
*/
public function DownloadCaptionFile()
{
list($pn_representation_id, $t_rep) = $this->_initView();
$pn_caption_id = $this->request->getParameter('caption_id', pString);
$this->view->setVar('representation_id', $pn_representation_id);
$this->view->setVar('caption_id', $pn_caption_id);
$this->view->setVar('t_object_representation', $t_rep);
$t_caption = new ca_object_representation_captions($pn_caption_id);
if (!$t_caption->getPrimaryKey() || (int) $t_caption->get('representation_id') !== (int) $pn_representation_id) {
die(_t("Invalid caption file"));
}
$t_locale = new ca_locales();
$vn_locale_id = $t_caption->get('locale_id');
$vs_locale = $t_locale->localeIDToCode($vn_locale_id);
$this->view->setVar('file_path', $t_caption->getFilePath('caption_file'));
$va_info = $t_caption->getFileInfo("caption_file");
switch ($this->request->user->getPreference('downloaded_file_naming')) {
case 'idno':
$this->view->setVar('download_name', str_replace(' ', '_', $t_rep->get('idno')) . "_captions_{$vs_locale}.vtt");
break;
case 'idno_and_version':
$this->view->setVar('download_name', str_replace(' ', '_', $t_rep->get('idno')) . "_captions_{$vs_locale}.vtt");
break;
case 'idno_and_rep_id_and_version':
$this->view->setVar('download_name', str_replace(' ', '_', $t_rep->get('idno')) . "_representation_{$pn_representation_id}_captions_{$vs_locale}.vtt");
break;
case 'original_name':
default:
if ($va_info['ORIGINAL_FILENAME']) {
$this->view->setVar('download_name', $va_info['ORIGINAL_FILENAME'] . "_captions_{$vs_locale}.vtt");
} else {
$this->view->setVar('download_name', str_replace(' ', '_', $t_rep->get('idno')) . "_representation_{$pn_representation_id}_captions_{$vs_locale}.vtt");
}
break;
}
return $this->render('caption_download_binary.php');
}
示例5: _generateSortableValue
/**
* Returns version of label 'display' field value suitable for sorting
* The sortable value is the same as the display value except when the display value
* starts with a definite article ('the' in English) or indefinite article ('a' or 'an' in English)
* in the locale of the label, in which case the article is moved to the end of the sortable value.
*
* What constitutes an article is defined in the TimeExpressionParser localization files. So if the
* locale of the label doesn't correspond to an existing TimeExpressionParser localization, then
* the users' current locale setting is used.
*/
private function _generateSortableValue()
{
if ($vs_sort_field = $this->getProperty('LABEL_SORT_FIELD')) {
$vs_display_field = $this->getProperty('LABEL_DISPLAY_FIELD');
$o_tep = new TimeExpressionParser();
$t_locale = new ca_locales();
$o_tep->setLanguage($t_locale->localeIDToCode($this->get('locale_id')));
$o_lang_settings = $o_tep->getLanguageSettings();
$vs_display_value = trim(preg_replace('![^\\p{L}0-9 ]+!u', ' ', $this->get($vs_display_field)));
$va_definite_articles = $o_lang_settings->get('definiteArticles');
$va_indefinite_articles = $o_lang_settings->get('indefiniteArticles');
foreach (array($o_lang_settings->get('definiteArticles'), $o_lang_settings->get('indefiniteArticles')) as $va_articles) {
if (is_array($va_articles)) {
foreach ($va_articles as $vs_article) {
if (preg_match('!^(' . $vs_article . ')[ ]+!i', $vs_display_value, $va_matches)) {
$vs_display_value = trim(str_replace($va_matches[1], '', $vs_display_value) . ', ' . $va_matches[1]);
break 2;
}
}
}
}
$this->set($vs_sort_field, $vs_display_value);
}
}
示例6: getRelatedItems
//.........这里部分代码省略.........
}
}
$vs_sql = "\n\t\t\t\t\tSELECT " . join(', ', $va_selects) . "\n\t\t\t\t\tFROM " . $va_path[0] . "\n\t\t\t\t\t" . join("\n", array_merge($va_joins, $va_joins_post_add)) . "\n\t\t\t\t\tWHERE\n\t\t\t\t\t\t" . join(' AND ', array_merge($va_wheres, array('(' . $va_path[1] . '.' . $vs_other_field . ' IN (' . join(',', $va_row_ids) . '))'))) . "\n\t\t\t\t\t{$vs_order_by}";
//print "<pre>$vs_sql</pre>\n";
$qr_res = $o_db->query($vs_sql);
if ($vb_uses_relationship_types) {
$va_rel_types = $t_rel->getRelationshipInfo($va_path[1]);
}
$vn_c = 0;
if ($vn_start > 0) {
$qr_res->seek($vn_start);
}
while ($qr_res->nextRow()) {
if ($vn_c >= $vn_limit) {
break;
}
$va_row = $qr_res->getRow();
$vn_id = $va_row[$vs_key] . '/' . $va_row['row_id'];
$vs_sort_key = $qr_res->get($vs_sort_fld);
$vs_display_label = $va_row[$vs_label_display_field];
//unset($va_row[$vs_label_display_field]);
if (!$va_rels[$vs_sort_key][$vn_id]) {
$va_rels[$vs_sort_key][$vn_id] = $qr_res->getRow();
}
if ($vb_uses_effective_dates) {
// return effective dates as display/parse-able text
if ($va_rels[$vs_sort_key][$vn_id]['sdatetime'] || $va_rels[$vs_sort_key][$vn_id]['edatetime']) {
$o_tep->setHistoricTimestamps($va_rels[$vs_sort_key][$vn_id]['sdatetime'], $va_rels[$vs_sort_key][$vn_id]['edatetime']);
$va_rels[$vs_sort_key][$vn_id]['effective_date'] = $o_tep->getText();
}
}
$vn_locale_id = $qr_res->get('locale_id');
if (isset($pa_options['returnLocaleCodes']) && $pa_options['returnLocaleCodes']) {
$va_rels[$vs_v]['locale_id'] = $vn_locale_id = $t_locale->localeIDToCode($vn_locale_id);
}
$va_rels[$vs_sort_key][$vn_id]['labels'][$vn_locale_id] = $vb_return_labels_as_array ? $va_row : $vs_display_label;
$va_rels[$vs_sort_key][$vn_id]['_key'] = $vs_key;
$va_rels[$vs_sort_key][$vn_id]['direction'] = $vs_direction;
$vn_c++;
if ($vb_uses_relationship_types) {
$va_rels[$vs_sort_key][$vn_id]['relationship_typename'] = $vs_direction == 'ltor' ? $va_rel_types[$va_row['relationship_type_id']]['typename'] : $va_rel_types[$va_row['relationship_type_id']]['typename_reverse'];
$va_rels[$vs_sort_key][$vn_id]['relationship_type_code'] = $va_rel_types[$va_row['relationship_type_id']]['type_code'];
}
//
// Return data in an arrangement more convenient for the data importer
//
if ($pa_options['groupFields']) {
$vs_rel_pk = $t_rel_item->primaryKey();
if ($t_rel_item_label) {
foreach ($t_rel_item_label->getFormFields() as $vs_field => $va_field_info) {
if (!isset($va_rels[$vs_v][$vs_field]) || $vs_field == $vs_rel_pk) {
continue;
}
$va_rels[$vs_v]['preferred_labels'][$vs_field] = $va_rels[$vs_v][$vs_field];
unset($va_rels[$vs_v][$vs_field]);
}
}
foreach ($t_rel_item->getFormFields() as $vs_field => $va_field_info) {
if (!isset($va_rels[$vs_v][$vs_field]) || $vs_field == $vs_rel_pk) {
continue;
}
$va_rels[$vs_v]['intrinsic'][$vs_field] = $va_rels[$vs_v][$vs_field];
unset($va_rels[$vs_v][$vs_field]);
}
unset($va_rels[$vs_v]['_key']);
unset($va_rels[$vs_v]['row_id']);
示例7: getDisplaysAsXML
public function getDisplaysAsXML()
{
$t_display = new ca_bundle_displays();
/** @var Datamodel $o_dm */
$o_dm = Datamodel::load();
$this->opt_locale = new ca_locales();
$va_displays = $t_display->getBundleDisplays();
$vs_buf = "<displays>\n";
foreach ($va_displays as $vn_i => $va_display_by_locale) {
$va_locales = array_keys($va_display_by_locale);
$va_info = $va_display_by_locale[$va_locales[0]];
if (!$t_display->load($va_info['display_id'])) {
continue;
}
$vs_buf .= "\t<display code='" . ($va_info['display_code'] && preg_match('!^[A-Za-z0-9_]+$!', $va_info['display_code']) ? $va_info['display_code'] : 'display_' . $va_info['display_id']) . "' type='" . $o_dm->getTableName($va_info['table_num']) . "' system='" . $t_display->get('is_system') . "'>\n";
$vs_buf .= "\t\t<labels>\n";
foreach ($va_display_by_locale as $vn_locale_id => $va_display_info) {
if (strlen($this->opt_locale->localeIDToCode($vn_locale_id)) > 0) {
$vs_buf .= "\t\t\t<label locale='" . $this->opt_locale->localeIDToCode($vn_locale_id) . "'><name>" . caEscapeForXML($va_display_info['name']) . "</name></label>\n";
}
}
$vs_buf .= "\t\t</labels>\n";
$va_settings = $t_display->getSettings();
if (sizeof($va_settings) > 0) {
$vs_buf .= "\t\t<settings>\n";
foreach ($va_settings as $vs_setting => $vm_val) {
if (is_array($vm_val)) {
foreach ($vm_val as $vn_i => $vn_val) {
$vs_buf .= "\t\t\t<setting name='{$vs_setting}'><![CDATA[" . $vn_val . "]]></setting>\n";
}
} else {
$vs_buf .= "\t\t\t<setting name='{$vs_setting}'><![CDATA[" . $vm_val . "]]></setting>\n";
}
}
$vs_buf .= "\t\t</settings>\n";
}
// User and group access
$va_users = $t_display->getUsers();
if (sizeof($va_users) > 0) {
$vs_buf .= "\t\t<userAccess>\n";
foreach ($va_users as $va_user_info) {
$vs_buf .= "\t\t\t<permission user='" . $va_user_info["user_name"] . "' access='" . $this->_convertUserGroupAccessToString(intval($va_user_info['access'])) . "'/>\n";
}
$vs_buf .= "\t\t</userAccess>\n";
}
$va_groups = $t_display->getUserGroups();
if (sizeof($va_groups) > 0) {
$vs_buf .= "\t\t<groupAccess>\n";
foreach ($va_groups as $va_group_info) {
$vs_buf .= "\t\t\t<permission group='" . $va_group_info["code"] . "' access='" . $this->_convertUserGroupAccessToString(intval($va_group_info['access'])) . "'/>\n";
}
$vs_buf .= "\t\t</groupAccess>\n";
}
$va_placements = $t_display->getPlacements();
$vs_buf .= "<bundlePlacements>\n";
foreach ($va_placements as $vn_placement_id => $va_placement_info) {
$vs_buf .= "\t\t<placement code='" . preg_replace("![^A-Za-z0-9_]+!", "_", $va_placement_info['bundle_name']) . "'><bundle>" . $va_placement_info['bundle_name'] . "</bundle>\n";
$va_settings = caUnserializeForDatabase($va_placement_info['settings']);
if (is_array($va_settings)) {
$vs_buf .= "<settings>\n";
foreach ($va_settings as $vs_setting => $vm_value) {
switch ($vs_setting) {
case 'label':
if (is_array($vm_value)) {
foreach ($vm_value as $vn_locale_id => $vm_locale_specific_value) {
if (preg_match("/^[a-z]{2,3}\\_[A-Z]{2,3}\$/", $vn_locale_id)) {
// locale code
$vs_locale_code = $vn_locale_id;
} else {
if (!($vs_locale_code = $this->opt_locale->localeIDToCode($vn_locale_id))) {
$vs_locale_code = 'en_US';
}
}
$vs_buf .= "<setting name='label' locale='" . $vs_locale_code . "'>" . caEscapeForXML($vm_locale_specific_value) . "</setting>\n";
}
}
break;
case 'restrict_to_relationship_types':
if (is_array($vm_value)) {
foreach ($vm_value as $vn_val) {
$t_rel_type = new ca_relationship_types($vn_val);
if ($t_rel_type->getPrimaryKey()) {
$vs_value = $t_rel_type->get('type_code');
$vs_buf .= "\t\t\t\t<setting name='{$vs_setting}'><![CDATA[" . $vs_value . "]]></setting>\n";
}
}
}
break;
case 'restrict_to_types':
if (is_array($vm_value)) {
foreach ($vm_value as $vn_val) {
$t_item = new ca_list_items($vn_val);
if ($t_item->getPrimaryKey()) {
$vs_value = $t_item->get('idno');
$vs_buf .= "\t\t\t\t<setting name='{$vs_setting}'><![CDATA[" . $vs_value . "]]></setting>\n";
}
}
}
break;
default:
//.........这里部分代码省略.........
示例8: getAttributesByElement
/**
*
* @param string $type can be one of: ["ca_tours", "ca_tour_stops"]
* @param int $item_id primary key
* @param string $attribute_code_or_id
* @return array
* @throws SoapFault
*/
public function getAttributesByElement($type, $item_id, $attribute_code_or_id)
{
if (!($t_subject_instance = $this->getTableInstance($type, $item_id, true))) {
throw new SoapFault("Server", "Invalid type or item_id");
}
$t_locale = new ca_locales();
$va_attrs = $t_subject_instance->getAttributesByElement($attribute_code_or_id);
$va_return = array();
foreach ($va_attrs as $vo_attr) {
$va_attr = array();
foreach ($vo_attr->getValues() as $vo_value) {
$va_attr[] = array("element_id" => $vo_value->getElementID(), "value_id" => $vo_value->getValueID(), "display_value" => $vo_value->getDisplayValue(), "locale" => $t_locale->localeIDToCode($vo_attr->getLocaleID()));
}
$va_return[] = $va_attr;
}
return $va_return;
}
示例9: getValuesForExport
/**
*
*/
public function getValuesForExport($pa_options = null)
{
$va_codes = $this->getApplicableElementCodes();
$va_data = parent::getValuesForExport($pa_options);
// get intrinsics
$t_locale = new ca_locales();
$t_list = new ca_lists();
// get attributes
foreach ($va_codes as $vs_code) {
if ($va_v = $this->get($this->tableName() . '.' . $vs_code, array('returnWithStructure' => true, 'returnAllLocales' => true, 'returnAsArray' => true, 'return' => 'url', 'version' => 'original'))) {
foreach ($va_v as $vn_id => $va_v_by_locale) {
foreach ($va_v_by_locale as $vn_locale_id => $va_v_list) {
if (!is_array($va_v_list)) {
continue;
}
if (!($vs_locale = $t_locale->localeIDToCode($vn_locale_id))) {
$vs_locale = 'NONE';
}
$vn_i = 0;
foreach ($va_v_list as $vn_index => $va_values) {
if (is_array($va_values)) {
foreach ($va_values as $vs_sub_code => $vs_value) {
if (!$vs_sub_code) {
continue;
}
if (!($t_element = $this->_getElementInstance($vs_sub_code))) {
continue;
}
switch ((int) $t_element->get('datatype')) {
case 3:
// list
$va_list_item = $t_list->getItemFromListByItemID($t_element->get('list_id'), $vs_value);
$vs_value = $vs_value . ":" . $va_list_item['idno'];
break;
}
$va_data['ca_attribute_' . $vs_code][$vs_locale]['value_' . $vn_i][$vs_sub_code] = $vs_value;
}
$vn_i++;
} else {
$va_data['ca_attribute_' . $vs_code][$vs_locale]['value_' . $vn_i][$vs_code] = $va_values;
}
}
}
}
}
}
return $va_data;
}
示例10: _generateSortableValue
/**
* Returns version of label 'display' field value suitable for sorting
* The sortable value is the same as the display value except when the display value
* starts with a definite article ('the' in English) or indefinite article ('a' or 'an' in English)
* in the locale of the label, in which case the article is moved to the end of the sortable value.
*
* What constitutes an article is defined in the TimeExpressionParser localization files. So if the
* locale of the label doesn't correspond to an existing TimeExpressionParser localization, then
* the users' current locale setting is used.
*/
private function _generateSortableValue()
{
if ($vs_sort_field = $this->getProperty('LABEL_SORT_FIELD')) {
$vs_display_field = $this->getProperty('LABEL_DISPLAY_FIELD');
$t_locale = new ca_locales();
$vs_display_value = caSortableValue($this->get($vs_display_field), array('locale' => $t_locale->localeIDToCode($this->get('locale_id'))));
$this->set($vs_sort_field, $vs_display_value);
}
}