Compare commits
No commits in common. "translations" and "master" have entirely different histories.
translatio
...
master
@ -3,9 +3,9 @@ class ClassTranslation extends ClassConfig implements InterfaceTranslation {
|
||||
public function __construct(){}
|
||||
public function __destruct(){}
|
||||
|
||||
public function getTranslationV2($message_code, $lang_code, $set_data = array(), $db_table="core_translation"){
|
||||
$this->_code = $message_code;
|
||||
$this->_lang = $lang_code;
|
||||
public function getTranslationV2($message_code, $lang_code, $set_data, $db_table="core_translation"){
|
||||
$this->_code = $code;
|
||||
$this->_lang = $lang;
|
||||
$this->_setData = $set_data;
|
||||
$this->_dbTable = $db_table;
|
||||
$oPDOLink = ClassConfig::databaseConnect();
|
||||
@ -104,26 +104,22 @@ class ClassTranslation extends ClassConfig implements InterfaceTranslation {
|
||||
}
|
||||
|
||||
|
||||
public function getTranslation($code, $lang = null, $set_data = array()){
|
||||
public function getTranslation($code, $lang, $set_data = array()){
|
||||
$this->_code = $code;
|
||||
$this->_lang = $lang ?? $_SESSION['config']['default_lang_code'];
|
||||
$this->_lang = $lang;
|
||||
$this->_setData = $set_data;
|
||||
|
||||
//if translation not in SESSION, then go get it from DB
|
||||
if(!isset($_SESSION['translations'][$this->_code]) or $_SESSION['translations'][$this->_code]['source']==''){
|
||||
$row = $this->getTranslationInDatabase($this->_code, $this->_lang);
|
||||
$_SESSION['translations'][$this->_code][$this->_lang] = $row[$this->_lang];
|
||||
$_SESSION['translations'][$this->_code]['source'] = $row['source'];
|
||||
}
|
||||
|
||||
//if translation in current language, display it. Else, display source
|
||||
if($_SESSION['translations'][$this->_code][$this->_lang] != ''){
|
||||
$translation = $_SESSION['translations'][$this->_code][$this->_lang];
|
||||
} else {
|
||||
$translation = $_SESSION['translations'][$this->_code]['source'];
|
||||
}
|
||||
|
||||
//if [data] in content, get values set in array $set_data
|
||||
$replacement_regex = '/\[data\]/';
|
||||
foreach($this->_setData as $k=>$v){
|
||||
$translation = preg_replace($replacement_regex, $this->_setData[$k], $translation, 1);
|
||||
|
@ -8,7 +8,6 @@ require_once './modules/ClassConfig.php';
|
||||
$oConf = new ClassConfig();
|
||||
|
||||
$file_path = substr_replace($_SERVER['REQUEST_URI'], '/', 0, strlen($oConf->getURLRoot()));
|
||||
$file_path = explode('?', $file_path)[0];
|
||||
|
||||
$custom_file = $oConf->getPathCustom($file_path);
|
||||
$native_file = $oConf->getPathRoot($file_path);
|
||||
|
@ -1,19 +1,20 @@
|
||||
<?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');
|
||||
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();
|
||||
$oContent = new ClassContent();
|
||||
$oTrans = new ClassTranslation();
|
||||
|
||||
$oldLang = $_SESSION['config']['default_lang_code'];
|
||||
@ -30,6 +31,7 @@ if(isset($_SESSION['user'])){
|
||||
}
|
||||
|
||||
$_SESSION['config']['default_lang_code'] = $newLang;
|
||||
$_SESSION['content'] = $oContent->listContent($newLang);
|
||||
$_SESSION['translations'] = $oTrans->listTranslations($newLang);
|
||||
|
||||
$newPage = $oFeatTrans->getURLTranslation($oldLang, $newLang, $oldPage);
|
||||
|
Loading…
Reference in New Issue
Block a user