Exemplo n.º 1
0
 /**
  * Get an object with the amount of words per state
  *
  * @return stdClass
  */
 public function getWordCount()
 {
     if ($this->wordCount === null) {
         $this->wordCount = new stdClass();
         $this->wordCount->total = 0;
         $this->wordCount->untranslated = 0;
         $this->wordCount->translated = 0;
         $this->wordCount->queued = 0;
         $this->wordCount->changed = 0;
         $db = JFactory::getDbo();
         $query = $db->getQuery(true);
         $workingLanguage = NenoHelper::getWorkingLanguage();
         $query->select(array('SUM(word_counter) AS counter', 'tr.state'))->from($db->quoteName(NenoContentElementField::getDbTable(), 'f'))->innerJoin($db->quoteName(NenoContentElementTranslation::getDbTable(), 'tr') . ' ON tr.content_id = f.id AND tr.content_type = ' . $db->quote('db_string') . ' AND tr.language LIKE ' . $db->quote($workingLanguage))->where(array('f.table_id = ' . $this->getId(), 'f.translate = 1'))->group('tr.state');
         $db->setQuery($query);
         $statistics = $db->loadAssocList('state');
         // Assign the statistics
         foreach ($statistics as $state => $data) {
             switch ($state) {
                 case NenoContentElementTranslation::NOT_TRANSLATED_STATE:
                     $this->wordCount->untranslated = (int) $data['counter'];
                     break;
                 case NenoContentElementTranslation::QUEUED_FOR_BEING_TRANSLATED_STATE:
                     $this->wordCount->queued = (int) $data['counter'];
                     break;
                 case NenoContentElementTranslation::SOURCE_CHANGED_STATE:
                     $this->wordCount->changed = (int) $data['counter'];
                     break;
                 case NenoContentElementTranslation::TRANSLATED_STATE:
                     $this->wordCount->translated = (int) $data['counter'];
                     break;
             }
         }
         $this->wordCount->total = $this->wordCount->untranslated + $this->wordCount->queued + $this->wordCount->changed + $this->wordCount->translated;
     }
     return $this->wordCount;
 }