You are here

function lingotek_views_handler_workbench_link::render in Lingotek Translation 7.6

Same name and namespace in other branches
  1. 7.4 lingotek_views_handler_workbench_link.inc \lingotek_views_handler_workbench_link::render()
  2. 7.5 lingotek_views_handler_workbench_link.inc \lingotek_views_handler_workbench_link::render()

Render the field.

Parameters

array $values: The values retrieved from the database.

Overrides views_handler_field::render

File

./lingotek_views_handler_workbench_link.inc, line 36
A handler to link to the Lingotek Workbench.

Class

lingotek_views_handler_workbench_link
@file A handler to link to the Lingotek Workbench.

Code

function render($values) {
  global $language;
  $entity_type = $this->view->base_table;
  if ($entity_type == 'node') {
    $entity = node_load($values->nid);
  }
  elseif ($entity_type == 'comment') {
    $entity = comment_load($values->cid);
  }
  if (!user_access('manage projects') && !user_access('translation')) {
    return;

    //do not show if the user does not have correct permissions
  }
  if ($language->language == $entity->language) {
    return;
  }
  drupal_add_css(drupal_get_path('module', 'lingotek') . '/style/workbench-link.css', array(
    'group' => CSS_DEFAULT,
  ));
  $text = '<img src="' . base_path() . drupal_get_path('module', 'lingotek') . '/images/ico_chevs_dd.png" >';
  $url = 'node/' . $values->nid . '/lingotekworkbench/' . Lingotek::convertDrupal2Lingotek($language->language);
  return l($text, $url, array(
    'attributes' => array(
      'target' => '_blank',
      'title' => 'Edit this translation',
      'class' => 'lingotek-translation-link',
    ),
    'html' => TRUE,
  ));
}