You are here

function lingotek_get_workbench_url in Lingotek Translation 7.3

Same name and namespace in other branches
  1. 7.7 lingotek.remote.inc \lingotek_get_workbench_url()
  2. 7.2 lingotek.api.inc \lingotek_get_workbench_url()
  3. 7.4 lingotek.api.inc \lingotek_get_workbench_url()
  4. 7.5 lingotek.remote.inc \lingotek_get_workbench_url()
  5. 7.6 lingotek.remote.inc \lingotek_get_workbench_url()

Get the url to open the Lingotek Workbench.

This fetches a link.

Parameters

object $node: A Drupal node.

$lingotek_locale: A target language.

mixed $label: The label to use as text for the link. Possible values are TRUE, FALSE, or a string to use as a the custom label for the link.

bool $force: Force the link to use the label of the first returned workflow phase for the target Document.

Return value

string Either a link pointing the the url, or the url itself if $label is FALSE

2 calls to lingotek_get_workbench_url()
lingotek_form_node_form_alter in ./lingotek.module
Implements hook_form_BASE_FORM_ID_alter().
lingotek_node_view in ./lingotek.module
Implements hook_node_view().

File

./lingotek.api.inc, line 522

Code

function lingotek_get_workbench_url($node, $lingotek_locale, $label = FALSE, $force = FALSE) {
  if ($lingotek_locale === FALSE) {
    return "";
  }
  $api = LingotekApi::instance();
  $document_id = lingotek_lingonode($node->nid, 'document_id');
  $targets = lingotek_get_document_targets($document_id, TRUE);

  //Make sure we get the current phases for the links and not out of date ones (so caches don't combine)
  if (count($targets) == 0) {
    return '';
  }
  foreach ($targets as $lang => $translation_target) {
    if ($lang != $lingotek_locale) {
      continue;
    }
    $target = $api
      ->getTranslationTarget($translation_target->id);
    $phases = $target ? $target->phases : array();
    return lingotek_get_workbench_url_by_phases($node, $phases, $label, $force);
  }
  LingotekLog::error('lingotek_get_workbench_url - Specified language target not found');
  return '';
}