You are here

function lingotek_render_source in Lingotek Translation 7.7

Same name and namespace in other branches
  1. 7.6 lingotek.bulk_grid.inc \lingotek_render_source()
2 calls to lingotek_render_source()
lingotek_bulk_grid_parse_config_data in ./lingotek.config.inc
lingotek_bulk_grid_parse_table_data in ./lingotek.bulk_grid.inc

File

./lingotek.bulk_grid.inc, line 2572

Code

function lingotek_render_source($entity_type, $row, $languages, $language_col, $entity_properties = array()) {
  $profile = $row->lingotek['name'];
  if ($entity_type == 'node') {
    $id = $row->nid;
  }
  elseif ($entity_type == 'comment') {
    $id = $row->cid;
  }
  elseif ($entity_type == 'config') {
    $id = $row->lid;
  }
  elseif ($entity_type == 'fieldable_panels_pane') {
    $id = $row->fpid;
  }
  elseif ($entity_type == 'taxonomy_term') {
    $id = $row->tid;
    $row->language = isset($row->translation_mode) && $row->translation_mode == '1' ? 'en' : $row->language;
  }
  elseif ($entity_type == 'bean') {
    $id = $row->bid;
    $language = lingotek_get_bean_source($id);
    $row->language = $language;
  }
  elseif ($entity_type == 'group') {
    $id = $row->gid;
    $language = lingotek_get_group_source($row->gid);
    $row->language = $language;
  }
  elseif ($entity_type == 'menu_link') {
    $id = $row->mlid;
  }
  elseif ($entity_type == 'paragraphs_item') {
    $id = $row->item_id;
  }
  elseif ($entity_type == 'file') {
    $id = $row->fid;
    $row->language = lingotek_get_file_source($row->fid);
  }
  elseif ($entity_type === 'commerce_product') {
    $id = $row->product_id;
  }
  elseif (!empty($row->id)) {
    $id = $row->id;
  }
  $source_str = $language_col ? $row->language : '';
  if ($row->upload_status === LingotekSync::STATUS_NONE) {
    $source_html = '<a href="#" onclick="lingotek_perform_action(' . $id . ',\'upload\')" class="ltk-source-icon source-none" title="Upload">' . $source_str . '</a>';
  }
  elseif ($row->upload_status === LingotekSync::STATUS_EDITED) {
    $source_html = '<a href="#" onclick="lingotek_perform_action(' . $id . ',\'upload\')" class="ltk-source-icon source-edited" title="Re-upload (content has changed since last upload)">' . $source_str . '</a>';
  }
  elseif ($row->upload_status === LingotekSync::STATUS_ARCHIVED) {
    $source_html = '<a href="#" onclick="lingotek_perform_action(' . $id . ',\'upload\')" class="ltk-source-icon source-gone" title="This document has been archived. Re-upload the source for translation.">' . $source_str . '</a>';
  }
  elseif ($row->upload_status === LingotekSync::STATUS_GONE) {
    $source_html = '<a href="#" onclick="lingotek_perform_action(' . $id . ',\'upload\')" class="ltk-source-icon source-gone" title="This document has been deleted. Re-upload the source for translation.">' . $source_str . '</a>';
  }
  elseif ($row->upload_status === LingotekSync::STATUS_CURRENT) {
    if ($entity_type === 'config') {
      $source_html = '<span class="ltk-source-icon-config-current" title="Source Uploaded">' . $source_str . '</span>';
    }
    else {
      $source_html = lingotek_render_source_current_icon_link($row, $entity_properties, $profile);
    }
  }
  elseif ($row->upload_status === LingotekSync::STATUS_ERROR) {
    if ($entity_type === 'config') {
      $error_message = isset($row->upload_error) ? $row->upload_error : '';
    }
    else {
      $error_message = isset($row->last_sync_error) ? $row->last_sync_error : '';
    }
    $source_html = '<a href="#" onclick="lingotek_perform_action(' . $id . ',\'upload\')" class="ltk-source-icon source-error" title="Error: ' . $error_message . '">' . $source_str . '</a>';
  }
  elseif ($row->upload_status === LingotekSync::STATUS_PENDING) {
    $source_html = '<a href="#" class="ltk-source-icon source-pending" title="Source Uploaded">' . $source_str . '</a>';
  }
  else {
    $source_html = '<a href="#" onclick="lingotek_perform_action(' . $id . ',\'upload\')" class="ltk-source-icon source-none" title="Upload">' . $source_str . '</a>';
  }

  // Config items aren't added to the lingotek_config_metadata table until uploaded.
  if ($entity_type === 'config' && $row->upload_status === NULL) {
    $source_html = '<a href="#" onclick="lingotek_perform_action(' . $id . ',\'upload\')" class="ltk-source-icon source-none" title="Upload">' . $source_str . '</a>';
  }
  if ($profile == LingotekSync::PROFILE_DISABLED && $entity_type != 'config') {
    $source_html = '<span class="ltk-target-disabled" title="Disabled, cannot request translation">' . $source_str . '</span>';
  }
  return $source_html;
}