function lingotek_entity_xml_body in Lingotek Translation 7.5
Same name and namespace in other branches
- 7.7 lingotek.util.inc \lingotek_entity_xml_body()
- 7.6 lingotek.util.inc \lingotek_entity_xml_body()
Return the xml representation of the source content for a node.
Parameters
object $node: A Drupal node.
Return value
string The XML representation of the node in Lingotek format.
2 calls to lingotek_entity_xml_body()
- LingotekEntity::documentLingotekXML in lib/
Drupal/ lingotek/ LingotekEntity.php - Gets the contents of this item formatted as XML that can be sent to Lingotek.
- lingotek_entity_changed in ./
lingotek.util.inc
File
- ./
lingotek.util.inc, line 288 - Utility functions.
Code
function lingotek_entity_xml_body($entity_type, $entity) {
$translatable = array();
$translate = variable_get('lingotek_enabled_fields', array());
list($id, $vid, $bundle) = lingotek_entity_extract_ids($entity_type, $entity);
$fields_desired = isset($translate[$entity_type][$bundle]) ? $translate[$entity_type][$bundle] : array();
if (empty($fields_desired) && lingotek_oneoff_translate($entity)) {
$fields_desired = lingotek_get_translatable_fields_by_content_type($entity_type, $bundle);
}
foreach ($fields_desired as $value) {
$field = field_info_field($value);
if (isset($field)) {
array_push($translatable, $value);
}
}
$content = lingotek_xml_fields($entity, $translatable, $entity->language);
/* deprecated with config translation
//Menus related to the page:
// Do we still want this? Config translation translates these items
$menu = menu_link_get_preferred('node/' . $entity->nid);
$txt = $menu['link_title'];
if ($txt != "") {
$content = $content . "<menu_title><![CDATA[$txt]]></menu_title>\n";
} */
if ($entity_type == 'node') {
//URL Alias related to the page:
$url_alias_translation = isset($entity->lingotek['url_alias_translation']) ? $entity->lingotek['url_alias_translation'] : 0;
if ($url_alias_translation == 1) {
$conditions = array(
'source' => 'node/' . $entity->nid,
);
if ($entity->language != LANGUAGE_NONE) {
$conditions['language'] = $entity->language;
}
$path = path_load($conditions);
if ($path !== FALSE) {
$url = $path['alias'];
$content = $content . "<url_alias><![CDATA[{$url}]]></url_alias>\n";
}
}
}
return "<?xml version=\"1.0\" encoding=\"UTF-8\"?><contents>{$content}</contents>";
}