/**
  * Returns the translation state for an extension
  *
  * @param string $extensionKey The extension key
  * @param string $locale Locale to return
  * @return integer Translation state
  */
 protected function getTranslationStateForExtension($extensionKey, $locale)
 {
     if (empty($extensionKey) || empty($locale)) {
         return static::TRANSLATION_INVALID;
     }
     $identifier = $extensionKey . '-' . $locale;
     if (isset($this->translationStates[$identifier])) {
         return $this->translationStates[$identifier];
     }
     $selectedLanguages = $this->languageRepository->findSelected();
     if (empty($selectedLanguages) || !is_array($selectedLanguages)) {
         return static::TRANSLATION_INVALID;
     }
     $mirrorUrl = $this->getMirrorUrl($extensionKey);
     $status = $this->terConnection->fetchTranslationStatus($extensionKey, $mirrorUrl);
     foreach ($selectedLanguages as $language) {
         $stateLocale = $language->getLocale();
         $stateIdentifier = $extensionKey . '-' . $stateLocale;
         $this->translationStates[$stateIdentifier] = static::TRANSLATION_INVALID;
         if (empty($status[$stateLocale]) || !is_array($status[$stateLocale])) {
             $this->translationStates[$stateIdentifier] = static::TRANSLATION_NOT_AVAILABLE;
             continue;
         }
         $md5 = $this->getTranslationFileMd5($extensionKey, $stateLocale);
         if ($md5 !== $status[$stateLocale]['md5']) {
             $this->translationStates[$stateIdentifier] = static::TRANSLATION_AVAILABLE;
             continue;
         }
         $this->translationStates[$stateIdentifier] = static::TRANSLATION_OK;
     }
     return $this->translationStates[$identifier];
 }
Пример #2
0
 /**
  * Update the language selection form
  *
  * @param \TYPO3\CMS\Lang\Domain\Model\LanguageSelectionForm $languageSelectionForm
  * @return void
  * @ignorevalidation $languageSelectionForm
  */
 public function updateLanguageSelectionAction(\TYPO3\CMS\Lang\Domain\Model\LanguageSelectionForm $languageSelectionForm)
 {
     if ($languageSelectionForm !== NULL) {
         $this->languageRepository->updateSelectedLanguages($languageSelectionForm->getSelectedLanguages());
     }
     $this->redirect('index');
 }
Пример #3
0
 /**
  * Deactivate a language
  *
  * @param array $data The request data
  * @return void
  */
 public function deactivateLanguageAction(array $data)
 {
     $response = array('success' => false);
     if (!empty($data['locale'])) {
         $response = $this->languageRepository->deactivateByLocale($data['locale']);
     }
     $this->view->assign('response', $response);
 }
Пример #4
0
 /**
  * Save selected locale(s)
  *
  * @param \TYPO3\CMS\Lang\Domain\Model\LanguageSelectionForm $form
  * @return void
  */
 public function saveSelectedLocaleAction(\TYPO3\CMS\Lang\Domain\Model\LanguageSelectionForm $form)
 {
     $selectedLanguages = array();
     foreach ($form->getLocale() as $locale => $value) {
         if ($value) {
             $selectedLanguages[] = $locale;
         }
     }
     $this->languageRepository->updateSelectedLanguages($selectedLanguages);
     $this->forward('index');
 }