From 0f1c86f210f22a0306268459fbaa664171f0094a Mon Sep 17 00:00:00 2001 From: Roman Hergenreder Date: Mon, 22 Jun 2020 01:06:54 +0200 Subject: [PATCH] Language Flags --- core/Views/LanguageFlags.class.php | 23 +++++++++++------------ css/admin.css | 7 +++++++ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/core/Views/LanguageFlags.class.php b/core/Views/LanguageFlags.class.php index 555857d..5a76854 100644 --- a/core/Views/LanguageFlags.class.php +++ b/core/Views/LanguageFlags.class.php @@ -13,33 +13,34 @@ class LanguageFlags extends View { $this->languageFlags = array(); } - public function loadView() { - parent::loadView(); + public function getCode() { $request = new \Api\Language\Get($this->getDocument()->getUser()); - if($request->execute()) { + if ($request->execute()) { $requestUri = $_SERVER["REQUEST_URI"]; $queryString = $_SERVER['QUERY_STRING']; $params = explode("&", $queryString); $query = array(); - foreach($params as $param) { + foreach ($params as $param) { $aParam = explode("=", $param); $key = $aParam[0]; - if($key == "s" && startsWith($requestUri, "/s/")) + if ($key === "site" && + (!startsWith($_SERVER["REQUEST_URI"], "/index.php") || $_SERVER["REQUEST_URI"] === "/")) { continue; + } $val = (isset($aParam[1]) ? $aParam[1] : ""); - if(!empty($key)) { + if (!empty($key)) { $query[$key] = $val; } } $url = parse_url($requestUri, PHP_URL_PATH) . "?"; - foreach($request->getResult()['languages'] as $lang) { + foreach ($request->getResult()['languages'] as $lang) { $langCode = $lang['code']; $langName = $lang['name']; $query['lang'] = $langCode; @@ -47,13 +48,11 @@ class LanguageFlags extends View { $this->languageFlags[] = $this->createLink( "$url$queryString", - "\"$langName\"" + "\"$langName\"" ); } + + return implode('', $this->languageFlags); } } - - public function getCode() { - return implode('', $this->languageFlags); - } } \ No newline at end of file diff --git a/css/admin.css b/css/admin.css index 404b2cd..aed3902 100644 --- a/css/admin.css +++ b/css/admin.css @@ -20,4 +20,11 @@ padding: 0; margin-bottom: 0; vertical-align: bottom; +} + +.flags { + right: 3px; + bottom: -22px; + background-color: darkgray; + border-radius: 5px; } \ No newline at end of file