You are here

public function TMGMTJob::cleanSuggestionsList in Translation Management Tool 7

Removes all suggestions from the given list which should not be processed.

This function removes all suggestions from the given list which are already assigned to a translation job or which should not be processed because there are no words, no translation is needed, ...

Parameters

array &$suggestions: Associative array of translation suggestions. It must contain at least:

File

entity/tmgmt.entity.job.inc, line 855

Class

TMGMTJob
Entity class for the tmgmt_job entity.

Code

public function cleanSuggestionsList(array &$suggestions) {
  foreach ($suggestions as $k => $suggestion) {
    if (is_array($suggestion) && isset($suggestion['job_item']) && $suggestion['job_item'] instanceof TMGMTJobItem) {
      $jobItem = $suggestion['job_item'];

      // Items with no words to translate should not be presented.
      if ($jobItem
        ->getWordCount() <= 0) {
        unset($suggestions[$k]);
        continue;
      }

      // Check if there already exists a translation job for this item in the
      // current language.
      $items = tmgmt_job_item_load_all_latest($jobItem->plugin, $jobItem->item_type, $jobItem->item_id, $this->source_language);
      if ($items && isset($items[$this->target_language])) {
        unset($suggestions[$k]);
        continue;
      }
    }
    else {
      unset($suggestions[$k]);
      continue;
    }
  }
}