function translation_node_view

cis7 translation.module translation_node_view($node, $view_mode)
cle7 translation.module translation_node_view($node, $view_mode)
elmsmedia7 translation.module translation_node_view($node, $view_mode)
icor7 translation.module translation_node_view($node, $view_mode)
meedjum_blog7 translation.module translation_node_view($node, $view_mode)
mooc7 translation.module translation_node_view($node, $view_mode)

Implements hook_node_view().

Displays translation links with language names if this node is part of a translation set. If no language provider is enabled, "fall back" to simple links built through the result of translation_node_get_translations().

File

modules/translation/translation.module, line 216
Manages content translations.

Code

function translation_node_view($node, $view_mode) {
  // If the site has no translations or is not multilingual we have no content
  // translation links to display.
  if (isset($node->tnid) && drupal_multilingual() && $translations = translation_node_get_translations($node->tnid)) {
    $languages = language_list('enabled');
    $languages = $languages[1];

    // There might be a language provider enabled defining custom language
    // switch links which need to be taken into account while generating the
    // content translation links. As custom language switch links are available
    // only for configurable language types and interface language is the only
    // configurable language type in core, we use it as default. Contributed
    // modules can change this behavior by setting the system variable below.
    $type = variable_get('translation_language_type', LANGUAGE_TYPE_INTERFACE);
    $custom_links = language_negotiation_get_switch_links($type, "node/$node->nid");
    $links = array();

    foreach ($translations as $langcode => $translation) {
      // Do not show links to the same node, to unpublished translations or to
      // translations in disabled languages.
      if ($translation->status && isset($languages[$langcode]) && $langcode != entity_language('node', $node)) {
        $language = $languages[$langcode];
        $key = "translation_$langcode";

        if (isset($custom_links->links[$langcode])) {
          $links[$key] = $custom_links->links[$langcode];
        }
        else {
          $links[$key] = array(
            'href' => "node/{$translation->nid}",
            'title' => $language->native,
            'language' => $language,
          );
        }

        // Custom switch links are more generic than content translation links,
        // hence we override existing attributes with the ones below.
        $links[$key] += array('attributes' => array());
        $attributes = array(
          'title' => $translation->title,
          'class' => array('translation-link'),
        );
        $links[$key]['attributes'] = $attributes + $links[$key]['attributes'];
      }
    }

    $node->content['links']['translation'] = array(
      '#theme' => 'links__node__translation',
      '#links' => $links,
      '#attributes' => array('class' => array('links', 'inline')),
    );
  }
}
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.