From 0eab8391ddf4a31ffddec09ab6f106f0e2b99d40 Mon Sep 17 00:00:00 2001 From: Joshua Ramon Enslin Date: Mon, 18 Jun 2018 17:18:06 +0200 Subject: [PATCH] Made input interface multilingual. Set proper default for CSS file in password_protect.php. --- edit/editHTMLPage.php | 8 ++++---- edit/inc/functions.php | 6 ++++-- edit/inc/standardHTML.php | 2 +- edit/index.php | 8 ++++---- edit/page.php | 8 ++++---- edit/pages.php | 8 ++++---- edit/password_protect.php | 2 +- edit/settings.php | 8 ++++---- edit/users.php | 8 ++++---- 9 files changed, 30 insertions(+), 28 deletions(-) diff --git a/edit/editHTMLPage.php b/edit/editHTMLPage.php index c161fad..0190546 100644 --- a/edit/editHTMLPage.php +++ b/edit/editHTMLPage.php @@ -9,10 +9,10 @@ require_once __DIR__ . "/inc/functions.php"; -ensureEnvironment(); // Ensure existence of system files. -$translations = loadLanguage(); // Load translations. -ensureBackendEnv(); // Ensure session is started etc. -$pages = loadPages(); // Load overview of pages. +ensureEnvironment(); // Ensure existence of system files. +$translations = loadLanguage($settings['defaultLang']); // Load translations. +ensureBackendEnv(); // Ensure session is started etc. +$pages = loadPages(); // Load overview of pages. /* * Load contents diff --git a/edit/inc/functions.php b/edit/inc/functions.php index c3c36ee..6b680ed 100644 --- a/edit/inc/functions.php +++ b/edit/inc/functions.php @@ -55,16 +55,18 @@ function loadHttpToGlobals(array $vars) { /** * Function for loading the language. * + * @param string $default The default language to use. + * * @return string[] */ -function loadLanguage():array { +function loadLanguage($default):array { if (isset($_GET['lan'])) $_SESSION['lan'] = $lan = $_GET['lan']; else if (isset($_SESSION['lan'])) $lan = $_SESSION['lan']; // Default to English if (!isset($lan) or !file_exists(__DIR__ . "/translations/$lan.php")) { - $lan = "en"; + $lan = $default; } include __DIR__ . "/../translations/$lan.php"; diff --git a/edit/inc/standardHTML.php b/edit/inc/standardHTML.php index 23568c0..d32123f 100644 --- a/edit/inc/standardHTML.php +++ b/edit/inc/standardHTML.php @@ -21,7 +21,7 @@ function printBackendHead(array $settings, string $page = "home", string $title = "Home", string $icon = ""):string { $output = ' - + diff --git a/edit/index.php b/edit/index.php index 326b458..bbaca15 100644 --- a/edit/index.php +++ b/edit/index.php @@ -12,10 +12,10 @@ require_once __DIR__ . "/inc/functions.php"; -ensureEnvironment(); // Ensure existence of system files. -$translations = loadLanguage(); // Load translations. -ensureBackendEnv(); // Ensure session is started etc. -$pages = loadPages(); // Load overview of pages. +ensureEnvironment(); // Ensure existence of system files. +$translations = loadLanguage($settings['defaultLang']); // Load translations. +ensureBackendEnv(); // Ensure session is started etc. +$pages = loadPages(); // Load overview of pages. /* * Load data. diff --git a/edit/page.php b/edit/page.php index 2950034..c1416ad 100644 --- a/edit/page.php +++ b/edit/page.php @@ -9,10 +9,10 @@ require_once __DIR__ . "/inc/functions.php"; -ensureEnvironment(); // Ensure existence of system files. -$translations = loadLanguage(); // Load translations. -ensureBackendEnv(); // Ensure session is started etc. -$pages = loadPages(); // Load overview of pages. +ensureEnvironment(); // Ensure existence of system files. +$translations = loadLanguage($settings['defaultLang']); // Load translations. +ensureBackendEnv(); // Ensure session is started etc. +$pages = loadPages(); // Load overview of pages. /* * Load contents diff --git a/edit/pages.php b/edit/pages.php index 29dc819..1650005 100644 --- a/edit/pages.php +++ b/edit/pages.php @@ -12,10 +12,10 @@ require_once __DIR__ . "/inc/functions.php"; -ensureEnvironment(); // Ensure existence of system files. -$translations = loadLanguage(); // Load translations. -ensureBackendEnv(); // Ensure session is started etc. -$pages = loadPages(); // Load overview of pages. +ensureEnvironment(); // Ensure existence of system files. +$translations = loadLanguage($settings['defaultLang']); // Load translations. +ensureBackendEnv(); // Ensure session is started etc. +$pages = loadPages(); // Load overview of pages. /* * Load data. diff --git a/edit/password_protect.php b/edit/password_protect.php index b85f153..9653035 100644 --- a/edit/password_protect.php +++ b/edit/password_protect.php @@ -23,7 +23,7 @@ define("loginLogFile", __DIR__ . "/../data/logins.csv"); * * @return void */ -function showLoginPasswordProtect($error_msg = "", $cssFile = "themes/default/default.css") { +function showLoginPasswordProtect($error_msg = "", $cssFile = "themes/default/theme.css") { echo ' diff --git a/edit/settings.php b/edit/settings.php index 657ff37..292fb0d 100644 --- a/edit/settings.php +++ b/edit/settings.php @@ -12,10 +12,10 @@ require_once __DIR__ . "/inc/functions.php"; -ensureEnvironment(); // Ensure existence of system files. -$translations = loadLanguage(); // Load translations. -ensureBackendEnv(); // Ensure session is started etc. -$pages = loadPages(); // Load overview of pages. +ensureEnvironment(); // Ensure existence of system files. +$translations = loadLanguage($settings['defaultLang']); // Load translations. +ensureBackendEnv(); // Ensure session is started etc. +$pages = loadPages(); // Load overview of pages. if (!$_SESSION['admin']) { echo printErrorPage($translations['accessDenied']); return; diff --git a/edit/users.php b/edit/users.php index d6a1f82..6ea823a 100644 --- a/edit/users.php +++ b/edit/users.php @@ -12,10 +12,10 @@ require_once __DIR__ . "/inc/functions.php"; -ensureEnvironment(); // Ensure existence of system files. -$translations = loadLanguage(); // Load translations. -ensureBackendEnv(); // Ensure session is started etc. -$pages = loadPages(); // Load overview of pages. +ensureEnvironment(); // Ensure existence of system files. +$translations = loadLanguage($settings['defaultLang']); // Load translations. +ensureBackendEnv(); // Ensure session is started etc. +$pages = loadPages(); // Load overview of pages. if (!$_SESSION['admin']) { echo printErrorPage($translations['accessDenied']); return;