You are here

function lingotek_render_title in Lingotek Translation 7.7

Same name and namespace in other branches
  1. 7.6 lingotek.bulk_grid.inc \lingotek_render_title()
1 call to lingotek_render_title()
lingotek_bulk_grid_parse_table_data in ./lingotek.bulk_grid.inc

File

./lingotek.bulk_grid.inc, line 2463

Code

function lingotek_render_title($row, $entity_properties) {
  $language = $GLOBALS['language'];
  $info = $entity_properties['info'];
  $entity_type = $entity_properties['type'];
  $no_localized_title = language_default()->language != $language->language && (!isset($row->localized_title) or $row->localized_title == '');

  // special handling of taxonomy terms for URI generation
  if ($entity_type == 'taxonomy_term') {
    $term_obj = lingotek_entity_load_single($entity_type, $row->tid);
    $uri = isset($info['uri callback']) ? call_user_func($info['uri callback'], $term_obj) : '';
  }
  else {
    if ($entity_type == 'bean') {
      $row = lingotek_entity_load_single($entity_type, $row->bid);
    }
    elseif ($entity_type == 'group') {
      $row = lingotek_entity_load_single($entity_type, $row->gid);
    }
    elseif ($entity_type == 'paragraphs_item') {
      $row = lingotek_entity_load_single($entity_type, $row->item_id);
    }
    elseif ($entity_type == 'file') {
      $row = lingotek_entity_load_single($entity_type, $row->fid);
    }
    $uri = isset($info['uri callback']) ? call_user_func($info['uri callback'], $row) : '';
  }
  $uri['options']['attributes'] = array(
    'target' => '_blank',
  );
  if ($entity_type == 'paragraphs_item') {
    list($parent_id, $parent_title) = lingotek_get_paragraph_parent_info($entity_type, $row->item_id);
    $title_to_show = $parent_title;
  }
  elseif ($entity_type == 'file') {
    $title_to_show = $row->filename;
  }
  else {
    $title_to_show = isset($row->localized_title) ? $row->localized_title : $row->title;
  }
  $title = $no_localized_title ? '<span class="no-localized-title">' : '';
  if (isset($uri['path'])) {
    $title .= l($title_to_show, $uri['path'], $uri['options']);
  }
  else {
    $title .= $title_to_show;
  }
  $title .= $no_localized_title ? '</span>' : '';
  return $title;
}