You are here

function lingotek_mark_phases_complete in Lingotek Translation 7.3

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

Form constructor for the lingotek_mark_phases_complete form.

Parameters

array $form: A FAPI form array.

array $form_state: A FAPI form state array.

object $node: The Drupal node whose complete-eligible phases should be displayed.

Return value

array A FAPI form data array.

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

File

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

Code

function lingotek_mark_phases_complete($form, $form_state, $node, $document = NULL) {
  $form = array();
  $document = is_null($document) ? LingotekDocument::load(lingotek_lingonode($node->nid, 'document_id')) : $document;
  $document_id = $document->document_id;

  //lingotek_lingonode($node->nid, 'document_id');
  if (class_exists('LingotekPhase') && $document_id) {
    $api = LingotekApi::instance();

    //$document = LingotekDocument::load($document_id);
    if ($progress = $document
      ->translationProgress()) {
      $targets = $progress->translationTargets;
      foreach ($targets as $target) {
        $language = Lingotek::convertLingotek2Drupal($target->language);
        $current_phase = $document
          ->currentPhase($target->id);
        $phase_complete_percent = $current_phase->percentComplete;
        if (empty($phase_complete_percent)) {
          $phase_complete_percent = 0;
        }
        if ($current_phase && $current_phase
          ->canBeMarkedComplete()) {
          $phase_link = l($current_phase->name, '', array(
            'attributes' => array(
              'onclick' => 'window.open(\'' . $api
                ->getWorkbenchLink($document_id, $current_phase->id) . '\'); return false;',
            ),
          ));
          $row = array(
            lingotek_language_native($language) . ' (' . lingotek_language_name($language) . ')',
            $phase_link,
            $phase_complete_percent . '%',
          );
          $options[$current_phase->id] = $row;
        }
      }
      $form['mark_complete'] = array(
        '#type' => 'fieldset',
        '#title' => t('Mark Workflow Phases complete'),
        '#description' => t('The following Translation Targets have Phases that can be marked as complete.'),
        '#collapsible' => TRUE,
        '#collapsed' => TRUE,
      );
      $form['mark_complete']['phases'] = array(
        '#type' => 'tableselect',
        '#header' => array(
          t('Language'),
          t('Phase'),
          t('Phase Progress'),
        ),
        '#options' => $options,
      );
      $form['mark_complete']['submit'] = array(
        '#type' => 'submit',
        '#value' => t('Mark Selected Phases as Complete'),
      );
    }
    else {
      LingotekLog::error('Unable to build mark as complete form: could not get progress data from API.');
    }
  }
  return $form;
}