Exemplo n.º 1
0
 /**
  * Renders the template for the login page
  *
  * @return TemplateResponse   The response for the login template
  */
 public function getDisclaimerForm()
 {
     $container = $this->getContainer();
     $session = $container->query('OCP\\IUserSession');
     $templateResponse = null;
     if (!$session->isLoggedIn()) {
         $userLang = $this->l10n->getLanguageCode();
         //Fix it: No way of getting rid of this static call. There is no
         //class method on OwnCloud that does this
         if (!\OC_L10N::languageExists($this->appName, $userLang)) {
             //It can be that some language dialects hasn't being translated,
             //so, a suitable language will be searched. ie: if 'de_CH' isn't
             //available, then 'de_DE' (formal german) will be used. In case
             //that 'de_DE' isn't available, then 'de' (informal german will
             //be used). If no fallback language is found, then the defined
             //default language will be used. In case nothing is found, then
             //ownCloud will decide which language to use, which in most
             //cases is 'en'.
             $langFallbacks = $this->utils->getFallbackLang($userLang);
             $defaultLang = $this->config->getDefaultLang();
             if ($defaultLang !== $userLang) {
                 $langFallbacks[] = $defaultLang;
             }
             foreach ($langFallbacks as $langCode) {
                 //Fix it: again, no way of getting rid of this static calls;
                 //the ownCloud library doesn't have any other way
                 if (\OC_L10N::languageExists($this->appName, $langCode)) {
                     $userLang = $langCode;
                     \OC_L10N::forceLanguage($userLang);
                     break;
                 }
             }
         }
         $data = ['appName' => $this->appName];
         $templateResponse = new TemplateResponse($this->appName, 'login', $data, 'blank');
     }
     return $templateResponse;
 }
Exemplo n.º 2
0
if (!\OC_L10N::languageExists($appId, $userLang)) {
    #It can be that some language dialects hasn't being translated, so, a
    #suitable language will be searched. ie: if 'de_CH' isn't available, then
    #'de_DE' (formal german) will be used. In case that 'de_DE' isn't available,
    #then 'de' (informal german will be used). If no fallback language is found,
    #then the defined default language will be used. In case nothing is found,
    #then ownCloud will decide which language to use, which in most cases is
    #'en'.
    $langFallbacks = \OCA\AgreeDisclaimer\Utils::getFallbackLang($userLang);
    $defaultLangProp = $appId . 'DefaultLang';
    $defLang = \OCA\AgreeDisclaimer\Controller\SettingsController::getSetting($defaultLangProp, 'en');
    if ($defLang !== $userLang) {
        $langFallbacks[] = $defLang;
    }
    foreach ($langFallbacks as $langCode) {
        if (\OC_L10N::languageExists($appId, $langCode)) {
            \OC_L10N::forceLanguage($langCode);
            \OCP\Util::writeLog($appId, "The language: {$userLang} hasn't been " . "yet translated, falling back to: {$langCode}", \OCP\Util::WARN);
            break;
        }
    }
}
/**
 * Adds the javascript utilities to the login page
 */
script($appId, 'utils');
/**
 * Adds the javascript to the login page
 */
script($appId, 'login');
/**