function lingotek_summary in Lingotek Translation 6        
                          
                  
                        
1 string reference to 'lingotek_summary'
  - lingotek_menu in ./lingotek.module
 
  
 
File
 
   - ./lingotek.page.inc, line 17
 
  - Displays progress of the community translation
 
Code
function lingotek_summary($source) {
  global $_lingotek_client, $_lingotek_locale;
  drupal_add_js(drupal_get_path('module', 'lingotek') . '/js/lingotek.pm.js');
  if (!$_lingotek_client
    ->canLogIn()) {
    $msg = 'Lingotek Login Failed';
    lingotek_error($msg);
    return t($msg);
  }
  $current_nid = $source->nid;
  
  if ($source->tnid) {
    $tnid = $source->tnid;
    $source = node_load(array(
      'nid' => $source->tnid,
    ));
  }
  else {
    $tnid = $source->nid;
  }
  
  if (!$source) {
    return t("The source language document has been deleted.  Translation has been disabled.");
  }
  
  lingotek_update_nodes($source);
  $doc_id = lingotek_lingonode($source->nid, 'document_id');
  
  $output = $_lingotek_client
    ->request('listTranslationTargets', array(
    'documentId' => $doc_id,
  ));
  $phases = array();
  if ($output->results == "success") {
    foreach ($output->translationTargets as $target) {
      $language = lingotek_language_matching($target->language);
      $list_phases = $_lingotek_client
        ->request('listPhases', array(
        'translationTargetId' => $target->id,
      ));
      if ($list_phases->results == "success") {
        foreach ($list_phases->phases as $phase) {
          $phases[$language][$phase->order] = $phase;
        }
      }
      foreach ($target->phases as $phase) {
        $phases[$language][$phase->order]->percentComplete = $phase->percentComplete;
      }
    }
  }
  
  $list = language_list();
  $header = array(
    t('Language'),
    t('Title'),
    t('Phase'),
    t('Status'),
    t('Published'),
  );
  
  $translations = lingotek_node_get_translations($tnid);
  foreach ($translations as $node) {
    if ($list[lingotek_language_matching($node->language)]->enabled != "1") {
      continue;
    }
    $node = node_load(array(
      'nid' => $node->nid,
    ));
    $operation = "";
    $current_phase = 0;
    $progress = 0;
    $order = 0;
    $native = $list[lingotek_language_matching($node->language)]->native;
    $check = "";
    
    $language_phases = $phases[$node->language];
    if ($language_phases) {
      
      foreach ($language_phases as $key => $value) {
        if ($value->percentComplete < 100) {
          $progress = $value->percentComplete;
          $order = $value->order;
          break;
        }
        $current_phase++;
      }
      $num_phases = count($language_phases);
      $label = "";
      $phase_id = -1;
      if ($current_phase != $num_phases) {
        $this_phase = $language_phases[$order];
        $label = t($this_phase->name);
        $phase_id = $this_phase->id;
      }
      $percent = lingotek_lingonode($node->nid, 'percent_complete');
      if ($percent == "") {
        $percent = 0;
      }
      $total_percent = $percent . "%";
      $operation = $label;
      
      if ($percent == 100) {
        $operation = t('Completed');
      }
      else {
        
        if ($current_phase == 0) {
          if (user_access('translate content')) {
            $operation = lingotek_workbench_phase_link($doc_id, $phase_id, $label);
          }
        }
        else {
          if (user_access('review translations')) {
            $operation = lingotek_workbench_phase_link($doc_id, $phase_id, $label);
          }
        }
      }
    }
    else {
      
      
      
      node_delete($node->nid);
      continue;
    }
    if (user_access('run machine translation') || user_access('flush translations from lingotek')) {
      $check = '<input tag="lingotek_pm_row" type="checkbox" language="' . $node->language . '" />';
    }
    $title = check_plain($node->title);
    
    if ($node->nid != $current_nid) {
      
      $title = "<a href=\"" . url('node/' . $node->nid, array(
        'language' => $list[$node->language],
      )) . "\">" . check_plain($node->title) . "</a>";
    }
    $published = $node->status ? "Yes" : "No";
    $row = array(
      $native,
      $title,
      $operation,
      $total_percent,
      $published,
    );
    if ($check != "") {
      array_unshift($row, $check);
    }
    $rows[] = $row;
  }
  
  sort($rows);
  $title = "<a href=\"" . url('node/' . $source->nid, array(
    'language' => $list[$source->language],
  )) . "\">" . check_plain($source->title) . "</a>";
  drupal_set_title(t('Collaborative Translations of') . ' ' . $title, PASS_THROUGH);
  $download = "";
  if (user_access('flush translations from lingotek')) {
    $download = '<input type="button" value="Sync" onclick="lingotek.pm.update();" />';
  }
  $mt = "";
  if (user_access('run machine translation')) {
    $available_engines = lingotek_get_machine_translation_engines();
    $enabled_engines = variable_get('lingotek_available_mt_options', array_keys($available_engines));
    $engines = array();
    $select = "";
    foreach ($enabled_engines as $engine) {
      $engines[$engine] = $available_engines[$engine];
    }
    unset($engines[0]);
    if (count($engines) == 0) {
      $mt = "";
    }
    else {
      if (count($engines) == 1) {
        $keys = array_keys($engines);
        $mt .= '<input id="lingotek-mt-engine" tag="lingotek-engine" type="hidden" value="' . $keys[0] . '" />';
      }
      else {
        foreach ($engines as $value => $label) {
          $select .= '<option tag="lingotek-engine" value="' . $value . '">' . t($label) . '</option>';
        }
        $mt .= "<select id=\"lingotek-mt-engine\">{$select}</select>";
      }
      $mt .= '<input id="lingotek-mt-button" type="button" onclick="lingotek.pm.mt();" value="' . t('Machine Translate') . '" />';
    }
  }
  if (user_access('flush translations from lingotek') || user_access('run machine translation')) {
    array_unshift($header, '<input type="checkbox" onclick="lingotek.pm.toggle_checkboxes(this);" />');
  }
  $table = theme('table', $header, $rows);
  return $table . $mt . '<br />' . $download . '<input id="lingotek_nid" type="hidden" value="' . $tnid . '" />';
}