mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
Move SUPPORTED_LANGS out of config.inc.php
This has no real business being here, and is a pain to update when new languages are shipped. Move it and the set_lang() function to translator.inc.php instead so it doesn't overwhelm the user-configurable settings file with static stuff. Signed-off-by: Dan McGee <dan@archlinux.org> Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
This commit is contained in:
parent
795971bc80
commit
bd361242f9
3 changed files with 84 additions and 84 deletions
|
@ -261,62 +261,6 @@ function db_query($query="", $db_handle="") {
|
|||
return $result;
|
||||
}
|
||||
|
||||
# set up the visitor's language
|
||||
#
|
||||
function set_lang($dbh=NULL) {
|
||||
global $LANG;
|
||||
global $SUPPORTED_LANGS;
|
||||
global $PERSISTENT_COOKIE_TIMEOUT;
|
||||
global $streamer, $l10n;
|
||||
|
||||
$update_cookie = 0;
|
||||
if (isset($_REQUEST['setlang'])) {
|
||||
# visitor is requesting a language change
|
||||
#
|
||||
$LANG = $_REQUEST['setlang'];
|
||||
$update_cookie = 1;
|
||||
|
||||
} elseif (isset($_COOKIE['AURLANG'])) {
|
||||
# If a cookie is set, use that
|
||||
#
|
||||
$LANG = $_COOKIE['AURLANG'];
|
||||
|
||||
} elseif (isset($_COOKIE["AURSID"])) {
|
||||
# No language but a session; use default lang preference
|
||||
#
|
||||
if(!$dbh) {
|
||||
$dbh = db_connect();
|
||||
}
|
||||
$q = "SELECT LangPreference FROM Users, Sessions ";
|
||||
$q.= "WHERE Users.ID = Sessions.UsersID ";
|
||||
$q.= "AND Sessions.SessionID = '";
|
||||
$q.= mysql_real_escape_string($_COOKIE["AURSID"])."'";
|
||||
$result = db_query($q, $dbh);
|
||||
|
||||
if ($result) {
|
||||
$row = mysql_fetch_array($result);
|
||||
$LANG = $row[0];
|
||||
}
|
||||
$update_cookie = 1;
|
||||
}
|
||||
|
||||
# Set $LANG to default if nothing is valid.
|
||||
if (!array_key_exists($LANG, $SUPPORTED_LANGS)) {
|
||||
$LANG = DEFAULT_LANG;
|
||||
}
|
||||
|
||||
if ($update_cookie) {
|
||||
$cookie_time = time() + $PERSISTENT_COOKIE_TIMEOUT;
|
||||
setcookie("AURLANG", $LANG, $cookie_time, "/");
|
||||
}
|
||||
|
||||
$streamer = new FileReader('../locale/' . $LANG .
|
||||
'/LC_MESSAGES/aur.mo');
|
||||
$l10n = new gettext_reader($streamer, true);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
# common header
|
||||
#
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue