function globallink_get_taxonomy_xml_for_I18N_MODE_TRANSLATE in GlobalLink Connect for Drupal 7.5
2 calls to globallink_get_taxonomy_xml_for_I18N_MODE_TRANSLATE()
- globallink_taxonomy_get_translations_for_row_id in globallink_taxonomy/
globallink_taxonomy_receive.inc - Gets taxonomy translations by row ID.
- globallink_taxonomy_send_for_translations in globallink_taxonomy/
globallink_taxonomy.inc - Sends taxonomies for translation.
File
- globallink_taxonomy/
globallink_taxonomy.inc, line 103
Code
function globallink_get_taxonomy_xml_for_I18N_MODE_TRANSLATE($term, $path) {
$dom = new DOMDocument('1.0', 'UTF-8');
$dom->formatOutput = TRUE;
$root = $dom
->createElement("content");
$dom
->appendChild($root);
$id = $dom
->createAttribute('bid');
$id->value = $term->tid;
$root
->appendChild($id);
if (!empty($path)) {
globallink_insert_child_element($dom, $root, "taxonomy", $path, array(
'name' => 'path',
'label' => 'Path',
));
}
$language = $term->language;
$fields = get_taxonomy_fields($term->vocabulary_machine_name);
$configured_fields = get_configured_fields_for_taxonomy($term->vocabulary_machine_name);
foreach ($fields as $field) {
if (array_key_exists($field, $configured_fields) && $configured_fields[$field]->translatable == 1) {
if (!empty($term->{$field})) {
$field_values = $term->{$field};
if (is_array($field_values) && !empty($field_values[$language])) {
foreach ($field_values[$language] as $delta => $values) {
globallink_insert_child_element($dom, $root, 'field', $values['value'], array(
'field' => $field,
'delta' => $delta,
'langcode' => $language,
'label' => $configured_fields[$field]->field_label,
));
}
}
elseif (!empty($field_values) && is_string($field_values)) {
// Test this without field translation
globallink_insert_child_element($dom, $root, 'field', $field_values, array(
'field' => $field,
'label' => $configured_fields[$field]->field_label,
));
}
}
}
}
if (array_key_exists('metatags', $configured_fields)) {
if (isset($term->metatags) && isset($term->metatags[$language])) {
$mt = $term->metatags[$language];
if (isset($mt['title']) && isset($mt['title']['value'])) {
globallink_insert_child_element($dom, $root, 'metatag', $mt['title']['value'], array(
'field' => 'title',
'delta' => '0',
'langcode' => $language,
'label' => 'MetaTag Title',
));
}
if (isset($mt['description']) && isset($mt['description']['value'])) {
globallink_insert_child_element($dom, $root, 'metatag', $mt['description']['value'], array(
'field' => 'description',
'delta' => '0',
'langcode' => $language,
'label' => 'MetaTag Description',
));
}
if (isset($mt['abstract']) && isset($mt['abstract']['value'])) {
globallink_insert_child_element($dom, $root, 'metatag', $mt['abstract']['value'], array(
'field' => 'abstract',
'delta' => '0',
'langcode' => $language,
'label' => 'MetaTag Abstract',
));
}
if (isset($mt['keywords']) && isset($mt['keywords']['value'])) {
globallink_insert_child_element($dom, $root, 'metatag', $mt['keywords']['value'], array(
'field' => 'keywords',
'delta' => '0',
'langcode' => $language,
'label' => 'MetaTag Keywords',
));
}
}
}
$xml = $dom
->saveXML();
return $xml;
}