function lingotek_process_menu_link_xml in Lingotek Translation 7.7
Inserts newly downloaded menu link data into the menu_links table
1 call to lingotek_process_menu_link_xml()
File
- ./
lingotek.remote.inc, line 336
Code
function lingotek_process_menu_link_xml($xml, &$entity, $entity_type, $langcode, $translation_set) {
$old_hidden = $entity->hidden;
$new_hidden = '0';
if (module_exists('entity_translation')) {
$published_preference = variable_get('lingotek_target_download_status', 'published');
if ($published_preference === 'published') {
$new_hidden = '0';
}
elseif ($published_preference === 'unpublished') {
$new_hidden = '1';
}
elseif ($published_preference === 'same-as-source') {
$new_hidden = $old_hidden;
}
}
$item = array(
'link_title' => '',
'mlid' => 0,
'plid' => 0,
'menu_name' => $entity->menu_name,
'weight' => $entity->weight,
'link_path' => $entity->link_path,
'options' => array(),
'customized' => 1,
'module' => 'menu',
'expanded' => 0,
'hidden' => $new_hidden,
'has_children' => 0,
'language' => $langcode,
);
foreach ($xml as $field_name => $content) {
foreach ($content as $column_name => $text) {
$value = lingotek_unfilter_placeholders(decode_entities((string) $text->element));
if ($field_name == 'title') {
$item['link_title'] = $value;
}
elseif ($field_name == 'description') {
$item['options']['attributes']['title'] = $value;
}
}
}
$translations = array(
$langcode => $item,
);
$translation_set
->add_translations($translations);
$item['translation_set'] = $translation_set;
menu_link_save($item);
}