You are here

function lingotek_render_source_current_icon_link in Lingotek Translation 7.7

1 call to lingotek_render_source_current_icon_link()
lingotek_render_source in ./lingotek.bulk_grid.inc

File

./lingotek.bulk_grid.inc, line 2513

Code

function lingotek_render_source_current_icon_link($row, $entity_properties, $profile) {
  $language = $GLOBALS['language'];
  $info = $entity_properties['info'];
  $language_col = $entity_properties['language_col'];
  $entity_type = $entity_properties['type'];
  $no_localized_title = language_default()->language != $language->language && (!isset($row->localized_title) or $row->localized_title == '');
  $icon_class = $profile === LingotekSync::PROFILE_DISABLED ? 'ltk-source-icon source-disabled' : 'ltk-source-icon source-current';
  $tip = $profile === LingotekSync::PROFILE_DISABLED ? 'Disabled, cannot request translation' : 'Source Uploaded';

  // 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') {

      // Paragraphs url callback doesn't work currently, so we build the link here
      $paragraphs_item = lingotek_entity_load_single($entity_type, $row->item_id);
      $bundle = $paragraphs_item->bundle;
      $real_path = $entity_properties['info']['bundles'][$bundle]['admin']['real path'];
      $edit_link = $real_path . '/edit';
      $paragraphs_language = $language_col ? $row->language : '';
      $paragraphs_icon = l($paragraphs_language, $edit_link, array(
        'attributes' => array(
          'target' => '_blank',
          'title' => $tip,
          'class' => $icon_class,
        ),
      ));
      return $paragraphs_icon;
    }
    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',
    'class' => $icon_class,
    'title' => $tip,
  );
  $title = '';
  $title_to_show = isset($row->localized_title) ? $row->localized_title : $row->title;
  $source_str = $language_col ? $row->language : '';
  if (isset($uri['path'])) {
    $title .= l($source_str, $uri['path'], $uri['options']);
  }
  else {
    $title .= $title_to_show;
  }
  return $title;
}