You are here

function lingotek_download_translations_form in Lingotek Translation 7.3

Same name and namespace in other branches
  1. 7.7 lingotek.page.inc \lingotek_download_translations_form()
  2. 7.4 lingotek.page.inc \lingotek_download_translations_form()
  3. 7.5 lingotek.page.inc \lingotek_download_translations_form()
  4. 7.6 lingotek.page.inc \lingotek_download_translations_form()

Download Translations Form.

1 string reference to 'lingotek_download_translations_form'
lingotek_pm in ./lingotek.page.inc
Page callback for the Lingotek local task on node detail pages.

File

./lingotek.page.inc, line 11
Lingotek Tab for Nodes

Code

function lingotek_download_translations_form($form, $form_state, $node, $document = NULL) {
  $form = array();
  $document_progress = LingotekApi::instance()
    ->getDocumentProgress($document->document_id);
  $icon_green_check = base_path() . drupal_get_path('module', 'lingotek') . '/images/ico_tick_17x.png';
  $rows = array();
  foreach ($document_progress->translationTargets as $target) {
    $current_phase = $document
      ->currentPhase($target->id);
    $phase_complete_percent = is_object($current_phase) ? $current_phase->percentComplete : 0;
    if (empty($phase_complete_percent)) {
      $phase_complete_percent = 0;
    }
    $language_link = l(lingotek_language_field_lookup('native', $target->language), '', array(
      'attributes' => array(
        'onclick' => 'window.open(\'' . lingotek_get_workbench_url_by_phases($node, $target->phases) . '\'); return false;',
      ),
    ));
    $language_link .= ' (' . lingotek_language_field_lookup('name', $target->language) . ')';
    $row = array(
      'language' => $language_link,
      'document_progress' => $target->percentComplete . '%',
      'phase' => $current_phase->name,
      'phase_progress' => $phase_complete_percent . '%',
      'phase_complete' => $current_phase->isMarkedComplete ? '<img src="' . $icon_green_check . '" />' : '',
    );
    LingotekLog::trace("lingotek_pm table row [@locale]", array(
      '@locale' => $target->language,
    ));
    $rows[$target->language] = $row;
  }
  $form['fieldset'] = array(
    '#type' => 'fieldset',
    '#title' => t('Download Translations'),
    '#description' => t('Download the latest translations from Lingotek in the selected languages.'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  $header = array(
    'language' => t('Language'),
    'document_progress' => t('Document Progress'),
    'phase' => t('Phase'),
    'phase_progress' => t('Phase Progress'),
    'phase_complete' => t('Phase Complete'),
  );
  $form['fieldset']['documents'] = array(
    '#type' => 'tableselect',
    '#header' => $header,
    '#options' => $rows,
    '#empty' => t('No content available.'),
  );
  $form['fieldset']['submit'] = array(
    '#type' => 'submit',
    '#value' => 'Download',
  );
  $form['fieldset']['nid'] = array(
    '#type' => 'value',
    '#value' => $node->nid,
  );
  return $form;
}