anketa = $_GET['anketa']; elseif (isset ($_POST['anketa'])) $this->anketa = $_POST['anketa']; if ($anketa != 0) $this->anketa = $anketa; SurveyInfo::getInstance()->SurveyInit($this->anketa); $rowa = SurveyInfo::getInstance()->getSurveyRow(); SurveySetting::getInstance()->Init($this->anketa); $this->db_table = SurveyInfo::getInstance()->getSurveyArchiveDBString(); $row = SurveyInfo::getInstance()->getSurveyRow(); $this->lang_admin = $row['lang_admin']; $this->lang_resp = $row['lang_resp']; if (isset($_REQUEST['lang_id'])) $this->lang_id = $_REQUEST['lang_id']; $this->include_lang($this->lang_resp); $lang1 = $lang; if ($this->lang_id > 0) { $this->include_second_lang(); $lang2 = $lang; } $this->include_base_lang(); } function dostop () { global $admin_type; global $global_user_id; SurveyInfo::getInstance()->SurveyInit($this->anketa); $rowa = SurveyInfo::getInstance()->getSurveyRow(); $manage = ''; if ($admin_type <= 1) $manage = " OR uid IN (SELECT user FROM srv_dostop_manage WHERE manager = '$global_user_id')"; $sql = sisplet_query("SELECT ank_id, uid FROM srv_dostop WHERE ank_id = '$this->anketa' AND dostop LIKE '%edit%' AND (uid='$global_user_id' $manage )"); if (mysqli_num_rows($sql) > 0) $this->user_dostop_edit = 1; else $this->user_dostop_edit = 0; if ($this->user_dostop_edit == 1 || $admin_type <= $rowa['dostop']) { // vse ok $this->user_dostop_edit = 1; // ce je admin in ima dostop, potem je aktiven (ni pa vpisan v srv_dostop) } else { if (count($this->get_all_translation_langs())==0) // ce pasivni uporabnik nima dodeljenega nobenega jezika die('No access language'); $this->user_dostop_edit = 0; // to niti ni treba, ampak zarad lepsga, ce je ze zgoraj :) } } /** * starting point za prevajanje * */ function prevajaj () { global $lang; // admin-default lang global $lang1; // respondent lang global $lang2; // lang ki ga prevajamo $this->dostop(); $rowa = SurveyInfo::getInstance()->getSurveyRow(); if ($rowa['multilang'] == 1) { // default je pač prvi jezik v seznamu... if ($this->lang_id==0) { $lang_array = $this->get_all_translation_langs(); if (count($lang_array) > 0) { //list($this->lang_id) = each($lang_array); reset($lang_array); $this->lang_id = key($lang_array); // redirectamo, da je nastavljen tudi v urlju header("Location: index.php?anketa=".$this->anketa."&a=prevajanje&lang_id=".$this->lang_id); $this->include_lang($this->lang_resp); $lang1 = $lang; $this->include_second_lang(); $lang2 = $lang; $this->include_base_lang(); } } } echo '
'; // Segment z zgornjimi nastavitvami echo '
'; $this->top_settings(); echo '
'; $sql = sisplet_query("SELECT * FROM srv_language WHERE ank_id = '$this->anketa'"); if (mysqli_num_rows($sql) == 0) { //$this->dodaj_jezik(1); } elseif ($rowa['multilang'] == 1) { $this->urejanje(); ?>'; } /** * Zgornje nastavitve in opcije pri prevajanju. * */ function top_settings () { global $lang; global $site_url; global $site_path; global $admin_type; global $global_user_id; SurveySetting::getInstance()->Init($this->anketa); $row = SurveyInfo::getInstance()->getSurveyRow(); $lang_admin = $row['lang_admin']; $lang_resp = $row['lang_resp']; $lang_array = array(); // Preberemo razpoložljive jezikovne datoteke if ($dir = opendir($site_path . 'lang')) { while (($file = readdir($dir)) !== false) { if ($file != '.' AND $file != '..') { if (is_numeric(substr($file, 0, strpos($file, '.')))) { $i = substr($file, 0, strpos($file, '.')); if ($i > 0) { $file = '../../lang/'.$i.'.php'; @include($file); $lang_array[$i] = $lang['language']; } } } } } // nastavimo jezik nazaj if ($lang_admin > 0) { $file = '../../lang/'.$lang_admin.'.php'; @include($file); } echo '
'; // Leva stran nastavitev echo '
'; if ($this->user_dostop_edit == 1) { echo '' . $lang['srv_language_settings'] . ''; echo '
'; echo ' '; asort($lang_array); echo '
'; echo ''.$lang['srv_language_respons_1'].':'; echo ''; echo '
'; $resp_change_lang = SurveySetting::getInstance()->getSurveyMiscSetting('resp_change_lang'); $resp_change_lang = ($resp_change_lang == '') ? 0 : $resp_change_lang; if ($this->lang_id != 0) { echo '
'; echo ''.$lang['srv_resp_change_lang'].':'; echo '
'; echo ''; echo ' '; echo '
'; echo '
'; echo ''; echo ''; echo '
'; echo '
'; if($resp_change_lang==1){ $resp_change_lang_type = SurveySetting::getInstance()->getSurveyMiscSetting('resp_change_lang_type'); $resp_change_lang_type = ($resp_change_lang_type == '') ? 0 : $resp_change_lang_type; echo '
'; echo ''.$lang['srv_resp_change_lang_type'].':'; echo '
'; echo ''; echo ''; echo '
'; echo '
'; echo ''; echo ''; echo '
'; echo '
'; } } else { //echo ''.$lang['srv_back_edit'].''; } //Standardne besede echo '

'.$lang['srv_language_std_bes1'].''.$lang['srv_language_std_bes2'].'.

'; echo '
'; } echo '
'; // Desna stran echo '
'.$lang['srv_multilang'].''; if ($this->lang_id != 0) { $lang_array = $this->get_all_translation_langs(); foreach ($lang_array AS $key => $l) { $bold = ''; $display = 'displayNone'; $active_urejanje = ''; if ($this->lang_id == $key) { $bold = 'semi-bold'; $display = ''; $active_urejanje = '
'.$lang['edit2'].'
'; } echo '

'; echo '

'; echo ''.$l.' '; echo $active_urejanje; echo '
'; echo '
'; echo '
'; echo ''; echo ''; echo ''; echo '
'; $d = new Dostop(); if ($d->checkDostopSub('edit')) { $title = ''; $sqlu = sisplet_query("SELECT uid FROM srv_dostop_language WHERE ank_id='$this->anketa' AND lang_id='$key'"); while ($rowu = mysqli_fetch_array($sqlu)) { $sql1 = sisplet_query("SELECT name, surname, email FROM users WHERE id = '$rowu[uid]'"); $row1 = mysqli_fetch_array($sql1); if ($title != '') $title .= ', '; $title .= $row1['name'].' '.$row1['surname'].' ('.$row1['email'].')'; } echo '
'; echo ''; echo ''; echo '
'; } echo '
'; echo '
'; echo ' '.$lang['srv_lang_pdf'].''; echo '
'; echo '
'; echo ' '.$lang['srv_lang_rtf'].''; echo '
'; if ($this->user_dostop_edit == 1) { echo '
'; echo ' '.$lang['srv_lang_rem'].''; echo '
'; } echo '
'; echo '
'; } } // Dodajanje novega jezika $this->dodaj_jezik(); echo '
'; echo '
'; } /** * opcija za dodajanje novega jezika -- ima svoj
zato ne more biti znotraj drugega forma * */ function dodaj_jezik ($first_page=0) { global $lang; global $lang1; if ($this->user_dostop_edit == 1) { // ok } else return; $row = SurveyInfo::getInstance()->getSurveyRow(); $lang_array = $this->get_all_available_langs(); asort($lang_array); echo ''; echo '
'; echo '
'; echo '
'; echo ''.$lang['srv_prevajanje_dodaj'].':'; echo ' '; echo '
'; echo ''; echo '
'; //button_holder echo '
'; //dodaj_prevod echo '
'; } /** * spremeni jezik, ki ga trenutno prevajamo * */ function spremeni_jezik () { global $lang; global $site_url; //echo ''; echo ''; echo ''; if ($spremenljivka < 0) $row['tip'] = -1; else $row = Cache::srv_spremenljivka($spremenljivka); // spremenljivka - to majo vse spremenljivka $this->vprasanje_spremenljivka($spremenljivka); // grid - vse tabele if ( in_array( $row['tip'], array(6, 16, 19, 20) ) ) { $this->vprasanje_grid($spremenljivka); } // vrednost - vsa vprasanja, ki uporabljajo srv_vrednost if ( in_array( $row['tip'], array(1, 2, 21, 7, 17, 18, 6, 16, 19, 20) ) ) { $this->vprasanje_vrednost($spremenljivka); } // vsota - ma se svoje polje if ( $row['tip'] == 18 ) { $this->vprasanje_vsota($spremenljivka); } echo '

'; echo ''; } /** * prevod spremenljivka - naslov in info * * @param mixed $spremenljivka */ function vprasanje_spremenljivka ($spremenljivka) { global $lang; global $lang2; $row = Cache::srv_spremenljivka($spremenljivka); $rowa = SurveyInfo::getInstance()->getSurveyRow(); $sql1 = sisplet_query("SELECT naslov, info FROM srv_language_spremenljivka WHERE ank_id='$this->anketa' AND spr_id='$spremenljivka' AND lang_id='$this->lang_id'"); $row1 = mysqli_fetch_array($sql1); if (strtolower(substr($row1['naslov'], 0, 3)) == '

' && strtolower(substr($row1['naslov'], -4)) == '

' && strrpos($row1['naslov'], '

') == 0) { $row1['naslov'] = substr($row1['naslov'], 3); $row1['naslov'] = substr($row1['naslov'], 0, -4); } if ($spremenljivka == -1) { // uvod echo '

'.$lang2['srv_intro'].'

'; } elseif ($spremenljivka == -2) { // zakljucek echo '

'.$lang2['srv_end'].'

'; } else { // obicna spremenljivka echo '

'.$row['naslov'].'

'; echo '

'.$row['info'].'

'; } } /** * prevod vrednosti * * @param mixed $spremenljivka */ function vprasanje_vrednost ($spremenljivka) { global $lang; global $lang2; $row = Cache::srv_spremenljivka($spremenljivka); $sql1 = sisplet_query("SELECT id, naslov FROM srv_vrednost WHERE spr_id = '$spremenljivka' ORDER BY vrstni_red"); while ($row1 = mysqli_fetch_array($sql1)) { $sql2 = sisplet_query("SELECT naslov FROM srv_language_vrednost WHERE ank_id='$this->anketa' AND vre_id='$row1[id]' AND lang_id='$this->lang_id'"); $row2 = mysqli_fetch_array($sql2); echo '

'.$row1['naslov'].'

'; } } /** * prevod za gride * * @param mixed $spremenljivka */ function vprasanje_grid ($spremenljivka) { global $lang; global $lang2; $row = Cache::srv_spremenljivka($spremenljivka); echo ''; $sql1 = sisplet_query("SELECT id, naslov FROM srv_grid WHERE spr_id = '$spremenljivka' ORDER BY vrstni_red"); while ($row1 = mysqli_fetch_array($sql1)) { $sql2 = sisplet_query("SELECT naslov FROM srv_language_grid WHERE ank_id='$this->anketa' AND spr_id='$spremenljivka' AND grd_id='$row1[id]' AND lang_id='$this->lang_id'"); $row2 = mysqli_fetch_array($sql2); echo ''; } echo '
'.$row1['naslov'].'
'; } /** * prevod za polje vsota * * @param mixed $spremenljivka */ function vprasanje_vsota ($spremenljivka) { global $lang; global $lang2; $row = Cache::srv_spremenljivka($spremenljivka); $sql1 = sisplet_query("SELECT vsota FROM srv_language_spremenljivka WHERE ank_id='$this->anketa' AND spr_id='$spremenljivka' AND lang_id='$this->lang_id'"); $row1 = mysqli_fetch_array($sql1); echo '

'.$row['vsota'].'

'; } /** * vrne vse jezikovne datoteke, ki so nam se na voljo * */ function get_all_available_langs () { global $lang; global $site_path; $row = SurveyInfo::getInstance()->getSurveyRow(); // Dobimo vse jezike za katere obstaja jezikovna datoteka include_once($site_path.'lang/jeziki.php'); $lang_array = $lang_all_global['ime']; // pobrisemo jezike, ki so ze dodani, tudi default jezik $sql1 = sisplet_query("SELECT lang_id FROM srv_language WHERE ank_id = '$this->anketa'"); while ($row1 = mysqli_fetch_array($sql1)) { unset($lang_array[$row1['lang_id']]); } unset($lang_array[$row['lang_resp']]); return $lang_array; } /** * vrne vse jezike, ki so ze dodani * */ function get_all_translation_langs () { global $lang; global $global_user_id; global $admin_type; $lang_array = array(); if ($this->user_dostop_edit == 1) $sql = sisplet_query("SELECT lang_id, language FROM srv_language WHERE ank_id = '$this->anketa'"); else $sql = sisplet_query("SELECT * FROM srv_language l, srv_dostop_language d WHERE l.ank_id='$this->anketa' AND d.ank_id=l.ank_id AND d.lang_id=l.lang_id AND d.uid='$global_user_id'"); while ($row = mysqli_fetch_array($sql)) { $lang_array[$row['lang_id']] = $row['language']; } return $lang_array; } /** * nastavi jezik nazaj na osnovnega takrat, ko kaj delamo z includi ostalih jezikov * */ function include_base_lang() { global $lang; $this->include_lang($this->lang_admin); } /** * includa jezik, ki ga prevajamo * */ function include_second_lang () { global $lang; $this->include_lang($this->lang_id); } /** * includa podan jezik * * @param mixed $id */ function include_lang ($id) { global $lang; if ($id > 0) { $file = '../../lang/'.$id.'.php'; @include($file); } } /** * pohendla razne nastavitve, ki se postnejo * ne gre nujno vse prek ajaxa, ene so tud navadne post * */ function ajax() { global $lang; if ($_GET['a'] == 'dodaj_jezik') { $this->ajax_dodaj_jezik(); } elseif ($_GET['a'] == 'brisi_jezik') { $this->ajax_brisi_jezik(); } elseif ($_GET['a'] == 'extra_translation') { $this->ajax_extra_translation(); } elseif ($_GET['a'] == 'extra_translation_save') { $this->ajax_extra_translation_save(); } elseif ($_GET['a'] == 'vprasanje_prevod') { $this->ajax_vprasanje_prevod(); } elseif ($_GET['a'] == 'vprasanje_prevod_save') { $this->ajax_vprasanje_prevod_save(); } } function ajax_dodaj_jezik () { global $lang; $lang_id = $_POST['lang_id']; if (!$lang_id > 0) { header("Location: index.php?anketa=".$this->anketa."&a=prevajanje"); return; } // "Jezik" v originalnem jeziku (preden prklopimo na novega z include) $lang_string = $lang['lang']; // Originalni jezik za respondente $this->include_lang($this->lang_resp); $base_lang_resp = $lang['language']; $this->include_lang($lang_id); $added_lang = $lang['language']; $s = sisplet_query("UPDATE srv_anketa SET multilang='1' WHERE id='$this->anketa'"); $sql = sisplet_query("INSERT INTO srv_language (ank_id, lang_id, language) VALUES ('$this->anketa', '$lang_id', '$lang[language]')"); // Po novem dodamo tudi spremenljivko za jezik (najlazje za upostevanje if-ov in validacij) // Na zacetku moramo ustvarit najprej vprasanje (ce ga se nimamo) $sqlS = sisplet_query("SELECT s.id AS spr_id FROM srv_spremenljivka s, srv_grupa g WHERE g.ank_id='$this->anketa' AND s.gru_id=g.id AND s.skupine='3'"); if(mysqli_num_rows($sqlS) == 0){ $sqlG = sisplet_query("SELECT id FROM srv_grupa WHERE ank_id='$this->anketa' AND vrstni_red='1'"); $rowG = mysqli_fetch_array($sqlG); $gru_id = $rowG['id']; $b = new Branching($this->anketa); $spr_id = $b->nova_spremenljivka($grupa=$gru_id, $grupa_vrstni_red=1, $vrstni_red=0); $sql = sisplet_query("UPDATE srv_spremenljivka SET naslov='".$lang_string."', variable='language', variable_custom='1', skupine='3', sistem='1', visible='0', size='0' WHERE id='$spr_id'"); Vprasanje::change_tip($spr_id, 1); // Dodamo se variablo za originalni jezik $v = new Vprasanje($this->anketa); $v->spremenljivka = $spr_id; $vre_id = $v->vrednost_new($base_lang_resp); } else{ $rowS = mysqli_fetch_array($sqlS); $spr_id = $rowS['spr_id']; } // Dodamo se variablo za dodajani jezik $v = new Vprasanje($this->anketa); $v->spremenljivka = $spr_id; $vre_id = $v->vrednost_new($added_lang); // Prestevilcimo in popravimo vrstni red Common::repareVrednost($spr_id); Common::prestevilci($spr_id); header("Location: index.php?anketa=".$this->anketa."&a=prevajanje&lang_id=".$lang_id); $this->include_base_lang(); } function ajax_brisi_jezik () { global $lang; $lang_id = $_REQUEST['lang_id']; sisplet_query("DELETE FROM srv_language WHERE ank_id='$this->anketa' AND lang_id='$lang_id'"); // Pobrisemo variablo iz vprasanja $sqlS = sisplet_query("SELECT s.id AS spr_id FROM srv_spremenljivka s, srv_grupa g WHERE g.ank_id='$this->anketa' AND s.gru_id=g.id AND s.skupine='3'"); $spr_id = 0; if(mysqli_num_rows($sqlS) > 0){ $rowS = mysqli_fetch_array($sqlS); $spr_id = $rowS['spr_id']; $this->include_lang($lang_id); $naslov = $lang['language']; $this->include_base_lang(); $sqlV = sisplet_query("DELETE FROM srv_vrednost WHERE naslov='".$naslov."' AND spr_id='$spr_id'"); } // Ce nimamo vec nobenega dodanega jezika $sql = sisplet_query("SELECT * FROM srv_language WHERE ank_id='$this->anketa'"); if (mysqli_num_rows($sql) == 0){ sisplet_query("UPDATE srv_anketa SET multilang='0' WHERE id='$this->anketa'"); // Pobrisemo vse vrednosti (za vsak slucaj ce kaksna ostane) in potem se spremenljivko if($spr_id > 0){ $sqlVDelete = sisplet_query("DELETE FROM srv_vrednost WHERE spr_id='$spr_id'"); $sqlSDelete = sisplet_query("DELETE FROM srv_spremenljivka WHERE id='$spr_id'"); } } // Drugace prestevilcimo in popravimo vrstni red elseif($spr_id > 0){ Common::repareVrednost($spr_id); Common::prestevilci($spr_id); } header("Location: index.php?anketa=".$this->anketa."&a=prevajanje"); } function ajax_extra_translation () { $text = $_POST['text']; $this->edit_extra_translation($text); } function ajax_extra_translation_save () { global $lang2; $value = $_POST['value']; $text = $_POST['text']; if ($value != '') { $value = strip_tags($value); SurveySetting::getInstance()->setSurveyMiscSetting('srvlang_'.$text.'_'.$this->lang_id, $value); echo '

'.$value.'

'; } else { SurveySetting::getInstance()->removeSurveyMiscSetting('srvlang_'.$text.'_'.$this->lang_id); echo '

'.$lang2[$text].'

'; } } function ajax_vprasanje_prevod () { $spremenljivka = $_POST['spremenljivka']; $this->vprasanje_prevod($spremenljivka); } function ajax_vprasanje_prevod_save () { global $lang; global $lang2; $spremenljivka = $_POST['spremenljivka']; $naslov = $_POST['naslov']; $info = $_POST['info']; $vsota = $_POST['vsota']; if (strtolower(substr($naslov, 0, 3)) != '

' && strtolower(substr($naslov, -4)) != '

' && strrpos($naslov, '

') === false) { $naslov = '

' . str_replace("\n", "

\n

", $naslov) . '

'; } // spremenljivka if ($naslov!='' || $info!='' || $vsota!='') sisplet_query("REPLACE INTO srv_language_spremenljivka (ank_id, spr_id, lang_id, naslov, info, vsota) VALUES ('$this->anketa', '$spremenljivka', '$this->lang_id', '$naslov', '$info', '$vsota')"); else sisplet_query("DELETE FROM srv_language_spremenljivka WHERE ank_id='$this->anketa' AND spr_id='$spremenljivka' AND lang_id='$this->lang_id'"); // vrednost $sql1 = sisplet_query("SELECT * FROM srv_vrednost WHERE spr_id = '$spremenljivka'"); while ($row1 = mysqli_fetch_array($sql1)) { $naslov = $_POST['naslov_vrednost_'.$row1['id']]; if ($naslov != '') $s = sisplet_query("REPLACE INTO srv_language_vrednost (ank_id, vre_id, lang_id, naslov) VALUES ('$this->anketa', '$row1[id]', '$this->lang_id', '$naslov')"); else $s = sisplet_query("DELETE FROM srv_language_vrednost WHERE ank_id='$this->anketa' AND vre_id='$row1[id]' AND lang_id='$this->lang_id'"); } // grid $sql1 = sisplet_query("SELECT * FROM srv_grid WHERE spr_id = '$spremenljivka'"); while ($row1 = mysqli_fetch_array($sql1)) { $naslov = $_POST['naslov_grid_'.$row1['id']]; if ($naslov != '') $s = sisplet_query("REPLACE INTO srv_language_grid (ank_id, spr_id, grd_id, lang_id, naslov) VALUES ('$this->anketa', '$spremenljivka', '$row1[id]', '$this->lang_id', '$naslov')"); else $s = sisplet_query("DELETE FROM srv_language_grid WHERE ank_id='$this->anketa' AND spr_id='$spremenljivka' AND grd_id='$row1[id]' AND lang_id='$this->lang_id'"); } echo ''; include_once('../../main/survey/app/global_function.php'); $this->Survey = new \App\Controllers\SurveyController(true); save('forceShowSpremenljivka', true); save('lang_id', $this->lang_id); $lang = $lang2; if ($spremenljivka == -1) \App\Controllers\BodyController::getInstance()->displayIntroduction(); elseif ($spremenljivka == -2) \App\Controllers\BodyController::getInstance()->displayKonec(); else \App\Controllers\Vprasanja\VprasanjaController::getInstance()->displaySpremenljivka($spremenljivka); } } ?>