wefra/scripts/changeLang.php

37 lines
1.2 KiB
PHP

<?php
session_start();
require_once('modules/InterfaceTranslation.php');
require_once('modules/InterfacePostgreSQL.php');
require_once('modules/InterfaceEmail.php');
require_once('modules/ClassConfig.php');
// require_once('modules/ClassContent.php');
require_once('modules/ClassFeature.php');
require_once('modules/ClassFeatureTranslation.php');
require_once('modules/ClassUser.php');
require_once('modules/ClassTranslation.php');
$oFeat = new ClassFeature();
$oFeatTrans = new ClassFeatureTranslation();
$oUser = new ClassUser();
$oTrans = new ClassTranslation();
$oldLang = $_SESSION['config']['default_lang_code'];
$newLang = $_REQUEST['lang'];
$oldPage = $_SERVER['HTTP_REFERER'];
if(isset($_SESSION['user'])){
$oUser->setLangForUser($_SESSION['user']['id'], $newLang);
$_SESSION['user']['lang_code'] = $newLang;
$_SESSION['features'] = $oFeat->getFeaturesOfUser($_SESSION['user']['id'], $newLang);
} else {
$_SESSION['features'] = $oFeat->getFeatures($newLang);
//$_SESSION['config']['default_lang_code'] = $newLang;
}
$_SESSION['config']['default_lang_code'] = $newLang;
$_SESSION['translations'] = $oTrans->listTranslations($newLang);
$newPage = $oFeatTrans->getURLTranslation($oldLang, $newLang, $oldPage);
header("Location: ".$newPage);