You are here

public function TMGMTJobItem::recalculateStatistics in Translation Management Tool 7

Recalculate statistical word-data: pending, translated, reviewed, accepted.

File

entity/tmgmt.entity.job_item.inc, line 930

Class

TMGMTJobItem
Entity class for the tmgmt_job entity.

Code

public function recalculateStatistics() {

  // Set translatable data from the current entity to calculate words.
  if (empty($this->data)) {
    $this->data = $this
      ->getSourceData();
  }

  // Consider everything accepted when the job item is accepted.
  if ($this
    ->isAccepted()) {
    $this->count_pending = 0;
    $this->count_translated = 0;
    $this->count_reviewed = 0;
    $this->count_accepted = count(array_filter(tmgmt_flatten_data($this->data), '_tmgmt_filter_data'));
  }
  else {

    // Reset counter values.
    $this->count_pending = 0;
    $this->count_translated = 0;
    $this->count_reviewed = 0;
    $this->count_accepted = 0;
    $this->word_count = 0;
    $this
      ->count($this->data);
  }
}