summaryrefslogtreecommitdiffstats
path: root/main/survey/app/Controllers/LanguageController.php
diff options
context:
space:
mode:
Diffstat (limited to 'main/survey/app/Controllers/LanguageController.php')
-rw-r--r--main/survey/app/Controllers/LanguageController.php44
1 files changed, 28 insertions, 16 deletions
diff --git a/main/survey/app/Controllers/LanguageController.php b/main/survey/app/Controllers/LanguageController.php
index ab47a41..255ef35 100644
--- a/main/survey/app/Controllers/LanguageController.php
+++ b/main/survey/app/Controllers/LanguageController.php
@@ -70,14 +70,17 @@ class LanguageController extends Controller
// mamo prebran cookie in user id, spremenimo language ce je treba -- multilanguage podpora je vezana na usr_id
$row = SurveyInfo::getInstance()->getSurveyRow();
- if ($row['multilang'] == 1) {
- if (isset($_GET['language'])) { // jezik podan preko GETa (podan je ze v linku ali spremenimo v previewu)
+ if ($row['multilang'] == 1 || isset($_GET['language'])) {
+
+ // jezik podan preko GETa (podan je ze v linku ali spremenimo v previewu)
+ if (isset($_GET['language'])) {
if (!empty(get('usr_id'))) { // (v bazo se shrani v displayintroduction - z ostalimi sistemskimi) (usr_id se ni postavljen)
$sqll = sisplet_query("SELECT lang_id FROM srv_language WHERE ank_id='" . get('anketa') . "' AND lang_id='$_GET[language]'");
$rowl = mysqli_fetch_array($sqll);
save('lang_id', $rowl['lang_id']);
- } else { // v GETu, ko lahko v previewu spreminjamo jezik na strani (usr_id je ze postavljen)
+ }
+ else { // v GETu, ko lahko v previewu spreminjamo jezik na strani (usr_id je ze postavljen)
$sql1 = sisplet_query("SELECT s.id FROM srv_spremenljivka s, srv_grupa g WHERE s.variable='language' AND s.gru_id=g.id AND g.ank_id='" . get('anketa') . "'");
$row1 = mysqli_fetch_array($sql1);
if ($row1['id'] > 0)
@@ -85,29 +88,37 @@ class LanguageController extends Controller
save('lang_id', $_GET['language']);
}
- } elseif (isset($_POST['language'])) { // jezik podan v POSTu (ce si ga user spremeni na prvi strani)
-
+ }
+ // jezik podan v POSTu (ce si ga user spremeni na prvi strani)
+ elseif (isset($_POST['language'])) {
$sql1 = sisplet_query("SELECT s.id FROM srv_spremenljivka s, srv_grupa g WHERE s.variable='language' AND s.gru_id=g.id AND g.ank_id='" . get('anketa') . "'");
$row1 = mysqli_fetch_array($sql1);
+
if ($row1['id'] > 0)
$sql1 = sisplet_query("UPDATE srv_data_text" . get('db_table') . " dt SET text='$_POST[language]' WHERE spr_id='$row1[id]' AND usr_id='" . get('usr_id') . "'");
+
save('lang_id', $_POST['language']);
-
- } else { // jezik je ze shranjen v bazi, ga preberemo (naslednje strani)
-
+ }
+ // jezik je ze shranjen v bazi, ga preberemo (naslednje strani)
+ else {
$sqll = sisplet_query("SELECT text FROM srv_data_text" . get('db_table') . " dt, srv_spremenljivka s WHERE dt.spr_id=s.id AND s.variable='language' AND dt.usr_id='" . get('usr_id') . "'");
$rowl = mysqli_fetch_array($sqll);
- $sqll = sisplet_query("SELECT lang_id FROM srv_language WHERE ank_id='" . get('anketa') . "' AND lang_id='$rowl[text]'");
- $rowl = mysqli_fetch_array($sqll);
- save('lang_id', $rowl['lang_id']);
-
+
+ if(mysqli_num_rows($sqll) > 0){
+ $sql2 = sisplet_query("SELECT lang_id FROM srv_language WHERE ank_id='" . get('anketa') . "' AND lang_id='$rowl[text]'");
+ $row2 = mysqli_fetch_array($sql2);
+
+ save('lang_id', $row2['lang_id']);
+ }
+
}
if (get('lang_id') == null) { // ni bil podan preko GETa in ni shranjen v bazi -- priredimo default jezik
$_GET['language'] = self::$lang['id']; // to damo samo zato, da se shrani ID default jezika v bazo, namesto -1 (ker pri default jeziku ne podamo nič preko URLja)
// get('lang_id') mora se vedno ostati null !
- } else { // zamenjamo jezik
+ }
+ else { // zamenjamo jezik
$file = lang_path(get('lang_id'));
if (@include($file))
$_SESSION['langX'] = lang_path(get('lang_id'), 1);
@@ -147,10 +158,10 @@ class LanguageController extends Controller
$rowl = mysqli_fetch_array($sqll);
if($naslov2){
- if ($rowl['naslov2'] != '')
+ if (isset($rowl['naslov2']) && $rowl['naslov2'] != '')
return $rowl['naslov2'];
}
- elseif ($rowl['naslov'] != ''){
+ elseif (isset($rowl['naslov']) && $rowl['naslov'] != ''){
return $rowl['naslov'];
}
}
@@ -170,7 +181,8 @@ class LanguageController extends Controller
$sqll = sisplet_query("SELECT naslov FROM srv_language_grid WHERE ank_id='" . get('anketa') . "' AND spr_id='$spremenljivka' AND grd_id='$grid' AND lang_id='" . get('lang_id') . "'");
$rowl = mysqli_fetch_array($sqll);
- if ($rowl['naslov'] != '') return $rowl['naslov'];
+ if (isset($rowl['naslov']) && $rowl['naslov'] != '')
+ return $rowl['naslov'];
}
return false;