function _noderelationships_parent_node_form_build_translation_settings in Node Relationships 6
Build translation settings for the current node edit form.
1 call to _noderelationships_parent_node_form_build_translation_settings()
- _noderelationships_parent_node_form_alter in ./
noderelationships.pages.inc - Alter parent node form to attach extra buttons to node reference fields.
File
- ./
noderelationships.translation.inc, line 153 - Translation support for Node Relationships module.
Code
function _noderelationships_parent_node_form_build_translation_settings(&$node, &$field_settings, $noderef_settings) {
foreach ($field_settings as $field_name => $field_options) {
// Skip if "Translate and reference" feature has not been enabled for this field.
if (!isset($noderef_settings['translate_and_reference'][$field_name])) {
continue;
}
// Skip if this field does not exist in current node.
if (!isset($node->{$field_name}) || !is_array($node->{$field_name})) {
continue;
}
// Scan all items in this nodereference field.
foreach ($node->{$field_name} as $delta => $reference) {
// Skip if manual translation for this reference if not required.
if (!isset($reference['translate_and_reference']) || empty($reference['translate_and_reference']['translation_source'])) {
continue;
}
$reference_source = $reference['translate_and_reference']['translation_source'];
// Generate a warning message for the user to note a translation for this
// reference is missing.
// Also, allow them to review the source reference on new window.
$field_settings[$field_name]['missingTranslations'][$delta] = t('Missing translation for !title.', array(
'!title' => l($reference_source->title . ' [nid: ' . $reference_source->nid . ']', 'node/' . $reference_source->nid, array(
'attributes' => array(
'target' => '_blank',
'title' => t('View @title [nid: @nid] in new window...', array(
'@title' => $reference_source->title,
'@nid' => $reference_source->nid,
)),
),
)),
));
// Provide a link to "Translate and reference" when possible.
if ($reference['translate_and_reference']['translation_supported']) {
$language_list = language_list();
$language = isset($_GET['language']) && isset($language_list[$_GET['language']]) ? $_GET['language'] : $GLOBALS['language']->language;
$field_settings[$field_name]['missingTranslations'][$delta] .= ' ' . t('You can !translate now.', array(
'!translate' => l(t('translate and reference'), 'noderelationships/create/' . $node->type . '/' . $field_name, array(
'query' => 'translation=' . $reference_source->nid . '&language=' . $language,
'attributes' => array(
'class' => 'noderelationships-translate',
'title' => t('Click here to translate and reference @title [nid: @nid] now.', array(
'@title' => $reference_source->title,
'@nid' => $reference_source->nid,
)),
),
)),
));
}
else {
$field_settings[$field_name]['missingTranslations'][$delta] .= ' ' . t('Translation of this reference is not supported.');
}
}
}
}