Language Flags
This commit is contained in:
parent
92a5ec867a
commit
0f1c86f210
@ -13,33 +13,34 @@ class LanguageFlags extends View {
|
|||||||
$this->languageFlags = array();
|
$this->languageFlags = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function loadView() {
|
public function getCode() {
|
||||||
parent::loadView();
|
|
||||||
|
|
||||||
$request = new \Api\Language\Get($this->getDocument()->getUser());
|
$request = new \Api\Language\Get($this->getDocument()->getUser());
|
||||||
if($request->execute()) {
|
if ($request->execute()) {
|
||||||
|
|
||||||
$requestUri = $_SERVER["REQUEST_URI"];
|
$requestUri = $_SERVER["REQUEST_URI"];
|
||||||
$queryString = $_SERVER['QUERY_STRING'];
|
$queryString = $_SERVER['QUERY_STRING'];
|
||||||
|
|
||||||
$params = explode("&", $queryString);
|
$params = explode("&", $queryString);
|
||||||
$query = array();
|
$query = array();
|
||||||
foreach($params as $param) {
|
foreach ($params as $param) {
|
||||||
$aParam = explode("=", $param);
|
$aParam = explode("=", $param);
|
||||||
$key = $aParam[0];
|
$key = $aParam[0];
|
||||||
|
|
||||||
if($key == "s" && startsWith($requestUri, "/s/"))
|
if ($key === "site" &&
|
||||||
|
(!startsWith($_SERVER["REQUEST_URI"], "/index.php") || $_SERVER["REQUEST_URI"] === "/")) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$val = (isset($aParam[1]) ? $aParam[1] : "");
|
$val = (isset($aParam[1]) ? $aParam[1] : "");
|
||||||
if(!empty($key)) {
|
if (!empty($key)) {
|
||||||
$query[$key] = $val;
|
$query[$key] = $val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$url = parse_url($requestUri, PHP_URL_PATH) . "?";
|
$url = parse_url($requestUri, PHP_URL_PATH) . "?";
|
||||||
|
|
||||||
foreach($request->getResult()['languages'] as $lang) {
|
foreach ($request->getResult()['languages'] as $lang) {
|
||||||
$langCode = $lang['code'];
|
$langCode = $lang['code'];
|
||||||
$langName = $lang['name'];
|
$langName = $lang['name'];
|
||||||
$query['lang'] = $langCode;
|
$query['lang'] = $langCode;
|
||||||
@ -47,13 +48,11 @@ class LanguageFlags extends View {
|
|||||||
|
|
||||||
$this->languageFlags[] = $this->createLink(
|
$this->languageFlags[] = $this->createLink(
|
||||||
"$url$queryString",
|
"$url$queryString",
|
||||||
"<img class=\"p-1\" src=\"/img/icons/lang/$langCode.gif\" alt=\"$langName\" title=\"$langName\">"
|
"<img class=\"p-1 clickable\" src=\"/img/icons/lang/$langCode.gif\" alt=\"$langName\" title=\"$langName\">"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getCode() {
|
|
||||||
return implode('', $this->languageFlags);
|
return implode('', $this->languageFlags);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -21,3 +21,10 @@
|
|||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
vertical-align: bottom;
|
vertical-align: bottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.flags {
|
||||||
|
right: 3px;
|
||||||
|
bottom: -22px;
|
||||||
|
background-color: darkgray;
|
||||||
|
border-radius: 5px;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user