Beispiel #1
0
 /**
  * {@inheritdoc}
  *
  *
  * @return array
  */
 public function getItems()
 {
     /* @var $db NenoDatabaseDriverMysqlx */
     $db = JFactory::getDbo();
     $db->setQuery($this->getListQuery());
     $languages = $db->loadObjectListMultiIndex('lang_code');
     $items = array();
     foreach ($languages as $language) {
         $translated = 0;
         $queued = 0;
         $changed = 0;
         $untranslated = 0;
         $item = new stdClass();
         $item->lang_code = $language[0]->lang_code;
         $item->comment = $language[0]->comment;
         $item->published = $language[0]->published;
         $item->title = $language[0]->title;
         $item->image = $language[0]->image;
         $item->errors = NenoHelper::getLanguageErrors((array) $language[0]);
         $item->isInstalled = NenoHelper::isCompletelyInstall($item->lang_code);
         foreach ($language as $internalItem) {
             switch ($internalItem->state) {
                 case NenoContentElementTranslation::TRANSLATED_STATE:
                     $translated = (int) $internalItem->word_count;
                     break;
                 case NenoContentElementTranslation::QUEUED_FOR_BEING_TRANSLATED_STATE:
                     $queued = (int) $internalItem->word_count;
                     break;
                 case NenoContentElementTranslation::SOURCE_CHANGED_STATE:
                     $changed = (int) $internalItem->word_count;
                     break;
                 case NenoContentElementTranslation::NOT_TRANSLATED_STATE:
                     $untranslated = (int) $internalItem->word_count;
                     break;
             }
         }
         $item->wordCount = new stdClass();
         $item->wordCount->translated = $translated;
         $item->wordCount->queued = $queued;
         $item->wordCount->changed = $changed;
         $item->wordCount->untranslated = $untranslated;
         $item->wordCount->total = $translated + $queued + $changed + $untranslated;
         $item->translationMethods = NenoHelper::getLanguageDefault($item->lang_code);
         $items[] = $item;
     }
     return $items;
 }
Beispiel #2
0
 /**
  * Check if a particular language has been installed
  *
  * @return void
  */
 public function isLanguageInstalled()
 {
     $input = $this->input;
     $language = $input->post->getString('language');
     if (!empty($language)) {
         if (NenoHelper::isCompletelyInstall($language)) {
             echo 'ok';
         } else {
             echo 'err';
         }
     }
     JFactory::getApplication()->close();
 }
Beispiel #3
0
 /**
  * Get language configuration data
  *
  * @return array
  */
 public static function getLanguageConfigurationData()
 {
     /* @var $db NenoDatabaseDriverMysqlx */
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $default = NenoSettings::get('source_language');
     $subquery1 = $db->getQuery(true);
     $subquery2 = $db->getQuery(true);
     $subquery2->select('tr2.*')->from('#__neno_content_element_translations AS tr2')->where('content_type = ' . $db->quote('lang_string'));
     $subquery1->select('tr.*')->from('#__neno_content_element_translations AS tr')->innerJoin('#__neno_content_element_fields AS f ON tr.content_id = f.id')->innerJoin('#__neno_content_element_tables AS t ON t.id = f.table_id')->where(array('content_type = ' . $db->quote('db_string'), 'f.translate = 1', 't.translate = 1'))->union($subquery2);
     $query->select(array('l.lang_code', 'l.published', 'l.title', 'l.image', 'tr.state', 'SUM(tr.word_counter) AS word_count', 'lc.comment'))->from('#__languages AS l')->leftJoin('#__neno_language_external_translators_comments AS lc ON l.lang_code = lc.language')->leftJoin('(' . (string) $subquery1 . ') AS tr ON tr.language = l.lang_code')->where('l.lang_code <> ' . $db->quote($default))->group(array('l.lang_code', 'tr.state'))->order('lang_code');
     $db->setQuery($query);
     $languages = $db->loadObjectListMultiIndex('lang_code');
     $items = array();
     if (!empty($languages)) {
         foreach ($languages as $language) {
             $translated = 0;
             $queued = 0;
             $changed = 0;
             $untranslated = 0;
             $item = new stdClass();
             $item->lang_code = $language[0]->lang_code;
             $item->comment = $language[0]->comment;
             $item->published = $language[0]->published;
             $item->title = $language[0]->title;
             $item->image = $language[0]->image;
             $item->errors = NenoHelper::getLanguageErrors((array) $language[0]);
             $item->isInstalled = NenoHelper::isCompletelyInstall($item->lang_code);
             foreach ($language as $internalItem) {
                 switch ($internalItem->state) {
                     case NenoContentElementTranslation::TRANSLATED_STATE:
                         $translated = (int) $internalItem->word_count;
                         break;
                     case NenoContentElementTranslation::QUEUED_FOR_BEING_TRANSLATED_STATE:
                         $queued = (int) $internalItem->word_count;
                         break;
                     case NenoContentElementTranslation::SOURCE_CHANGED_STATE:
                         $changed = (int) $internalItem->word_count;
                         break;
                     case NenoContentElementTranslation::NOT_TRANSLATED_STATE:
                         $untranslated = (int) $internalItem->word_count;
                         break;
                 }
             }
             $item->wordCount = new stdClass();
             $item->wordCount->translated = $translated;
             $item->wordCount->queued = $queued;
             $item->wordCount->changed = $changed;
             $item->wordCount->untranslated = $untranslated;
             $item->wordCount->total = $translated + $queued + $changed + $untranslated;
             $item->translationMethods = NenoHelper::getLanguageDefault($item->lang_code);
             $items[] = $item;
         }
     }
     $languagesOnLanguageTable = array_keys($languages);
     $knownLanguages = JFactory::getLanguage()->getKnownLanguages();
     $defaultTranslationsMethods = NenoHelper::getDefaultTranslationMethods();
     foreach ($knownLanguages as $languageTag => $languageInfo) {
         if ($languageTag != $default && !in_array($languageTag, $languagesOnLanguageTable)) {
             $languagesData = new stdClass();
             $languagesData->lang_code = $languageInfo['tag'];
             $languagesData->title = $languageInfo['name'];
             $languagesData->translationMethods = $defaultTranslationsMethods;
             $languagesData->errors = NenoHelper::getLanguageErrors((array) $languagesData);
             $languagesData->placement = 'dashboard';
             $languagesData->image = NenoHelper::getLanguageImage($languageInfo['tag']);
             $languagesData->published = NenoHelper::isLanguagePublished($languageInfo['tag']);
             $languagesData->comment = NenoHelper::getLanguageTranslatorComment($languageInfo['tag']);
             $items[] = $languagesData;
         }
     }
     return $items;
 }