You are here

function lingotek_current_phase in Lingotek Translation 7.5

Same name and namespace in other branches
  1. 7.7 lingotek.util.inc \lingotek_current_phase()
  2. 7.2 lingotek.util.inc \lingotek_current_phase()
  3. 7.3 lingotek.util.inc \lingotek_current_phase()
  4. 7.4 lingotek.util.inc \lingotek_current_phase()
  5. 7.6 lingotek.util.inc \lingotek_current_phase()

Gets the phase ID of the "current" phase for a translation target.

Parameters

array $phases: An array of phase data from the result of a getTranslationTarget Lingotek API call.

Return value

int The Phase ID of the current phase. Note that if all phases are marked as complete, the ID of the last phase will be returned.

1 call to lingotek_current_phase()
lingotek_page_mark_phases_complete in includes/lingotek.ajax.inc
Page handler for completing the current phases of remote Lingotek documents.

File

./lingotek.util.inc, line 582
Utility functions.

Code

function lingotek_current_phase($phases) {
  $phase_id = -1;
  $current_phase = 0;
  foreach ($phases as $phase) {
    if (!$phase->isMarkedComplete) {
      $phase_id = $phase->id;
      break;
    }
    $current_phase++;
  }

  // All phases are complete, use last phase as current.
  if (!empty($phases) && $phase_id == -1) {
    $last_phase = end($phases);
    $phase_id = $last_phase->id;
  }
  return $phase_id;
}