You are here

function lingotek_node_view in Lingotek Translation 7.6

Same name and namespace in other branches
  1. 6 lingotek.module \lingotek_node_view()
  2. 7.7 lingotek.module \lingotek_node_view()
  3. 7.2 lingotek.module \lingotek_node_view()
  4. 7.3 lingotek.module \lingotek_node_view()
  5. 7.4 lingotek.module \lingotek_node_view()
  6. 7.5 lingotek.module \lingotek_node_view()

Implements hook_node_view().

File

./lingotek.module, line 1306

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;
  }
  $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']);
  $community_translation_allowed = !empty($source_node->lingotek['allow_community_translation']);
  if ($community_translation_allowed && $lingotek_has_doc_id && lingotek_supported_type($source_node->type) && Lingotek::isSupportedLanguage($node->language)) {
    if ($language->language != $source_node->language) {
      $link = lingotek_get_workbench_url($source_node->lingotek['document_id'], $language->lingotek_locale, t('Help make it better.'));
      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 = $node->lingotek['upload_status'] == 'TARGET';
  if ($can_translate && $uploaded_to_lingotek || $is_target) {
    global $language;
    $node->content['lingotek_link']['#markup'] = lingotek_workbench_icon('node', $source_node->nid, Lingotek::convertDrupal2Lingotek($language->language));
  }
}