languageFlags = array(); } public function getCode() { $request = new \Api\Language\Get($this->getDocument()->getUser()); if ($request->execute()) { $requestUri = $_SERVER["REQUEST_URI"]; $queryString = $_SERVER['QUERY_STRING']; $params = explode("&", $queryString); $query = array(); foreach ($params as $param) { $aParam = explode("=", $param); $key = $aParam[0]; if ($key === "site" && (!startsWith($_SERVER["REQUEST_URI"], "/index.php") || $_SERVER["REQUEST_URI"] === "/")) { continue; } $val = (isset($aParam[1]) ? $aParam[1] : ""); if (!empty($key)) { $query[$key] = $val; } } $url = parse_url($requestUri, PHP_URL_PATH) . "?"; foreach ($request->getResult()['languages'] as $lang) { $langCode = $lang['code']; $langName = $lang['name']; $query['lang'] = $langCode; $queryString = http_build_query($query); $this->languageFlags[] = $this->createLink( "$url$queryString", "\"$langName\"" ); } return implode('', $this->languageFlags); } } }