*/ /** * Template that will be rendered on the login page */ $appId = $_['appId']; //Gets the current user's language $userLang = \OCA\AgreeDisclaimer\Utils::getUserLang(); 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
/** * Get the file information for the txt and pdf files * * @param bool $isAdminForm Whether or not is called from the admin * form. This is used because the method can be also called from * the login page. Here the differences: * - When called from the admin form, no fall back languages will * be used * - When called from the login form, fall back languages will be * used * @param string $defaultLang Default language for which the file will * be recovered in case that it doesn't exist for the current * language. In case that it is null, then the default language of * the application will be used. * * @return array Array with the file information for the txt and pdf * files. It has this format: * [ * '<appId>TxtFile' => [ * 'value' => <true_or_false>, * 'basePath' => <absolute_path_of_txt_file>, * 'file' => [ * 'exists' => <does_the_file_exist>, * 'lang' => <file_language_code>, * 'name' => <file_name>, * 'path' => <file_location_in_the_file_system>, * 'url' => <url_to_file_in_web_browser>, * 'content' => <contents_txt_file>, * 'error' => <error_message>, * ], * ], * '<appId>PdfFile' => [ * 'value' => <true_or_false>, * 'basePath' => <absolute_path_of_pdf_file>, * 'file' => [ * 'exists' => <does_the_file_exist>, * 'lang' => <file_language_code>, * 'name' => <file_name>, * 'path' => <file_location_in_the_file_system>, * 'url' => <url_to_file_in_web_browser>, * 'error' => <error_message>, * ], * ] * ] */ function getFiles($isAdminForm = false, $defaultLang = null) { $data = array(); $appId = Application::APP_ID; $appConfig = \OC::$server->getAppConfig(); if ($defaultLang === null) { $defaultLangProp = $appId . 'DefaultLang'; $defaultLang = self::getSetting($defaultLangProp, 'en', $appConfig); } if (!$isAdminForm) { $userLang = Utils::getUserLang(); $getFallbackLang = true; } else { $userLang = $defaultLang; $getFallbackLang = false; } $maxTxtFileSizeProp = $appId . 'MaxTxtFileSize'; $maxTxtFileSize = self::getSetting($maxTxtFileSizeProp, '1', $appConfig); $txtFileBasePath = Application::getTxtFilesPath(); $pdfFileBasePath = Application::getPdfFilesPath(); $fileInfo = self::getFile($userLang, $defaultLang, $txtFileBasePath, 'txt', true, $maxTxtFileSize, $getFallbackLang); $data['txtFile'] = $fileInfo; $fileInfo = self::getFile($userLang, $defaultLang, $pdfFileBasePath, 'pdf', false, 2, $getFallbackLang); $data['pdfFile'] = $fileInfo; return $data; }