function lingotek_node_view in Lingotek Translation 7.7
Same name and namespace in other branches
- 6 lingotek.module \lingotek_node_view()
- 7.2 lingotek.module \lingotek_node_view()
- 7.3 lingotek.module \lingotek_node_view()
- 7.4 lingotek.module \lingotek_node_view()
- 7.5 lingotek.module \lingotek_node_view()
- 7.6 lingotek.module \lingotek_node_view()
Implements hook_node_view().
File
- ./
lingotek.module, line 1375
Code
function lingotek_node_view($node, $view_mode) {
global $language, $first_load, $user;
// add to the node view only in full view mode.
if ($view_mode != 'full') {
return;
}
// If anonymous users don't have permission, don't deliver the crowd-sourced workbench link
$has_permissions = user_access('manage projects') || user_access('translation') ? TRUE : FALSE;
if (!$has_permissions) {
return;
}
$source_node = lingotek_get_source_node($node);
if (!lingotek_managed_entity('node', $source_node) || !lingotek_enabled_langcode($language->language)) {
return;
}
$lingotek_has_doc_id = !empty($source_node->lingotek['document_id']);
$document_id = $lingotek_has_doc_id ? $source_node->lingotek['document_id'] : '';
$community_translation_allowed = !empty($source_node->lingotek['allow_community_translation']);
if ($community_translation_allowed && $lingotek_has_doc_id && isset($source_node->lingotek['profile']) && $source_node->lingotek['profile'] != LingotekSync::PROFILE_DISABLED) {
if ($language->language != $source_node->language) {
$link = lingotek_get_workbench_url($document_id, $language->lingotek_locale, t('Edit in Lingotek Workbench'));
if ($link != '') {
$message = t('The translation of this page is still being worked on.') . " ";
$message .= $link . ' ';
if (lingotek_access($node, 'manage projects')) {
$message .= '<span style="font-size: 80%">[' . l(t('progress'), 'node/' . $source_node->nid . '/lingotek_pm', array(
'html' => TRUE,
)) . ']</span>';
}
drupal_set_message($message, 'warning', FALSE);
}
}
}
$can_translate = user_access('translation') && $source_node->lingotek['profile'] != LingotekSync::PROFILE_DISABLED;
$uploaded_to_lingotek = !empty($source_node->lingotek['document_id']);
$is_target = !empty($node->lingotek['upload_status']) && $node->lingotek['upload_status'] == 'TARGET';
if ($can_translate && ($uploaded_to_lingotek || $is_target)) {
global $language;
$node->content['lingotek_link']['#markup'] = lingotek_workbench_icon($document_id, Lingotek::convertDrupal2Lingotek($language->language));
}
}