예제 #1
0
 /**
  * Install language
  *
  * @return void
  */
 public function installLanguage()
 {
     $input = $this->input;
     $updateId = $input->post->getInt('update');
     $language = $input->post->getString('language');
     $placement = $input->post->getCmd('placement');
     if (NenoHelper::installLanguage($updateId, $placement != 'dashboard')) {
         /* @var $db NenoDatabaseDriverMysqlx */
         $db = JFactory::getDbo();
         $query = $db->getQuery(true);
         $query->select(array('l.lang_code', 'l.published', 'l.title', 'l.image', 'tr.state', 'SUM(tr.word_counter) AS word_count'))->from('#__languages AS l')->leftJoin('#__neno_content_element_translations AS tr ON tr.language = l.lang_code')->where('l.lang_code = ' . $db->quote($language))->group(array('l.lang_code', 'tr.state'))->order('lang_code');
         $db->setQuery($query);
         $languages = $db->loadObjectListMultiIndex('lang_code');
         $item = new stdClass();
         foreach ($languages as $language) {
             $translated = 0;
             $queued = 0;
             $changed = 0;
             $untranslated = 0;
             $item->lang_code = $language[0]->lang_code;
             $item->published = $language[0]->published;
             $item->title = $language[0]->title;
             $item->image = $language[0]->image;
             $item->errors = NenoHelper::getLanguageErrors((array) $language[0]);
             $item->translationMethods = NenoHelper::getLanguageDefault($item->lang_code);
             // If the language was installed from the dashboard, let's add a task to set all the shadow tables structure
             if ($placement == 'dashboard') {
                 // Add task to
                 NenoTaskMonitor::addTask('language', array('language' => $item->lang_code));
                 // Create menu structure for this language
                 NenoHelper::createMenuStructureForLanguage($item->lang_code);
             }
             $item->isInstalled = NenoHelper::isCompletelyInstall($language[0]->lang_code);
             foreach ($language as $internalItem) {
                 switch ($internalItem->state) {
                     case NenoContentElementTranslation::TRANSLATED_STATE:
                         $untranslated = (int) $internalItem->word_count;
                         break;
                     case NenoContentElementTranslation::QUEUED_FOR_BEING_TRANSLATED_STATE:
                         $untranslated = (int) $internalItem->word_count;
                         break;
                     case NenoContentElementTranslation::SOURCE_CHANGED_STATE:
                         $untranslated = (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->placement = $placement;
         }
         echo JLayoutHelper::render('languageconfiguration', get_object_vars($item), JPATH_NENO_LAYOUTS);
     } else {
         echo 'err';
     }
     JFactory::getApplication()->close();
 }