You are here

protected function TMGMTJobItem::count in Translation Management Tool 7

Parse all data items recursively and sums up the counters for accepted, translated and pending items.

Parameters

$item: The current data item.

1 call to TMGMTJobItem::count()
TMGMTJobItem::recalculateStatistics in entity/tmgmt.entity.job_item.inc
Recalculate statistical word-data: pending, translated, reviewed, accepted.

File

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

Class

TMGMTJobItem
Entity class for the tmgmt_job entity.

Code

protected function count(&$item) {
  if (!empty($item['#text'])) {
    if (_tmgmt_filter_data($item)) {

      // Count words of the data item.
      $this->word_count += tmgmt_word_count($item['#text']);

      // Set default states if no state is set.
      if (!isset($item['#status'])) {

        // Translation is present.
        if (!empty($item['#translation'])) {
          $item['#status'] = TMGMT_DATA_ITEM_STATE_TRANSLATED;
        }
        else {
          $item['#status'] = TMGMT_DATA_ITEM_STATE_PENDING;
        }
      }
      switch ($item['#status']) {
        case TMGMT_DATA_ITEM_STATE_REVIEWED:
          $this->count_reviewed++;
          break;
        case TMGMT_DATA_ITEM_STATE_TRANSLATED:
          $this->count_translated++;
          break;
        default:
          $this->count_pending++;
          break;
      }
    }
  }
  elseif (is_array($item)) {
    foreach (element_children($item) as $key) {
      $this
        ->count($item[$key]);
    }
  }
}