sid = $sid; SurveyInfo::getInstance()->SurveyInit($sid); $this->surveyInfo = SurveyInfo::getInstance()->getSurveyRow(); $this->current_skin = $this->surveyInfo['skin']; $this->current_mobile_skin = $this->surveyInfo['mobile_skin']; # polovimo grupe skinov # dodamo sistemsko $this->groups['0'] = array('name'=>'Sistemske teme'); $this->groups['-1'] = array('name'=>'Lastne teme'); $this->groups['-2'] = array('name'=>'Safe teme'); $this->groups['-3'] = array('name'=>'Mobilne teme'); $skinsArray = array(); $skinsArrayPersonal = array(); # polovimo vse skine v direktoriju $dir = opendir($site_path . 'main/survey/skins/'); while ($file = readdir($dir)) { $ext = pathinfo($file, PATHINFO_EXTENSION); if ($ext == 'css' && $file[0] != '_' && $file[0] != '.') { // Lastne teme if (strpos($file, $global_user_id.'_') === true) { $this->groups[-1]['skins'][] = $file; if ($file == $this->current_skin.'.css') $this->current_group = -1; } // Ni uporabniska tema else { // Standardni skini $standard_skins = array( 1 => '1kaBlue.css', 2 => '1kaRed.css', 3 => '1kaOrange.css', 4 => '1kaGreen.css', 5 => '1kaPurple.css', 6 => '1kaBlack.css', 7 => '1kaOffice.css', 8 => '1kaNature.css', 9 => 'Otroci3.css', 10 => 'Otroci4.css', 11 => 'Embed.css', 12 => 'Embed2.css', 13 => 'Slideshow.css' ); //if((($admin_type == '0' || $admin_type == '1') && (strpos($site_url, 'www.1ka.si') || strpos($site_url, 'test.1ka.si'))) || $debug == '1'){ $standard_skins[14] = 'Uni.css'; $standard_skins[15] = 'Fdv.css'; $standard_skins[16] = 'Cdi.css'; $standard_skins[17] = 'WebSM.css'; //} // Novi safe skini so v loceni skupini $safe_skins = array( 'Center.css', 'Center2.css', 'Oko.css', 'Oko2.css', 'Otroci.css', 'Otroci2.css', 'Safe.css', 'Safe2.css', 'Safe3.css' ); // Mobile skini $mobile_skins = array( 1 => 'MobileBlue.css', 2 => 'MobileRed.css', 3 => 'MobileOrange.css', 4 => 'MobileGreen.css', 5 => 'MobilePurple.css', 6 => 'MobileBlack.css' ); //if((($admin_type == '0' || $admin_type == '1') && (strpos($site_url, 'www.1ka.si') || strpos($site_url, 'test.1ka.si'))) || $debug == '1'){ $mobile_skins[7] = 'MobileUni.css'; $mobile_skins[8] = 'MobileFdv.css'; $mobile_skins[9] = 'MobileCdi.css'; //} // Safe skini if(in_array($file, $safe_skins)){ $this->groups[-2]['skins'][] = $file; if ($file == $this->current_skin.'.css') $this->current_group = -2; } // Mobile skini elseif($key = array_search($file, $mobile_skins)){ $this->groups[-3]['skins'][$key] = $file; } // Navadni skini elseif($key = array_search($file, $standard_skins)){ $this->groups[0]['skins'][$key] = $file; if ($file == $this->current_skin.'.css') $this->current_group = 0; } } } } // Sortiramo skine ksort($this->groups[0]['skins']); // Sortiramo safe skine - po abecedi sort($this->groups[-2]['skins']); // Sortiramo mobilne skine ksort($this->groups[-3]['skins']); } function getGroups () { return $this->groups; } function Ajax() { switch ($_GET['a']) { case 'changeGroup': $this->displayGroupThemes($_POST['gid']); break; case 'changeTheme': $this->changeTheme($_POST['css'],$_POST['gid']); break; case 'changeProgressbar': $this->changeProgressbar(); break; case 'theme_rename': $this->themeRename($_POST['msg']); break; case 'theme_rename_confirm': $this->themeRenameConfirm(); break; case 'theme_delete': $this->themeDelete(); break; case 'add_theme': $this->ajax_add_theme(); break; case 'checboxThemeSave': $this->ajaxSaveChecboxTheme($_POST['anketa'],$_POST['checkbox']); breake; default: print_r("
");
			print_r($_POST);
			print_r($_GET);
			break;
		}
	}

	
	function displayGroup($groupId = null) {
		global $lang;
		
		if ($groupId == null)
			$groupId = 0;
		
		echo '
'; echo '
'; $this->displayGroupSelector($groupId); echo '
'; echo '
'; $this->displayGroupThemes($groupId); echo '
'; // tole sem premaknil izven onload.js da se ne klice vedno po nepotrebnem ?>'; } function handleEditing() { global $lang; global $global_user_id; // preusmeritev, ko kliknemo na prilagodi pri sistemski temi in naredimo nov profil if ( isset($_GET['profile_new']) ) { if ($_GET['name'] != '') $name = $_GET['name']; else $name = $_GET['profile_new'].''; $sql = sisplet_query("INSERT INTO srv_theme_profiles (id, usr_id, skin, name) VALUES ('', '$global_user_id', '".$_GET['profile_new']."', '".$name."')"); $profile = mysqli_insert_id($GLOBALS['connect_db']); $s = sisplet_query("UPDATE srv_anketa SET skin='".$_GET['profile_new']."', skin_profile='".$profile."' WHERE id = '".$this->sid."'"); if (!$s) echo mysqli_error($GLOBALS['connect_db']); header("Location: index.php?anketa=".$this->sid."&a=theme-editor&profile=".$profile.'&newalert=1'); die(); } // preusmeritev, ko kliknemo na prilagodi pri sistemski MOBILNI temi in naredimo nov profil if ( isset($_GET['profile_new_mobile']) ) { if ($_GET['name'] != '') $name = $_GET['name']; else $name = $_GET['profile_new_mobile'].''; $sql = sisplet_query("INSERT INTO srv_theme_profiles_mobile (id, usr_id, skin, name) VALUES ('', '$global_user_id', '".$_GET['profile_new_mobile']."', '".$name."')"); $profile = mysqli_insert_id($GLOBALS['connect_db']); $s = sisplet_query("UPDATE srv_anketa SET mobile_skin='".$_GET['profile_new_mobile']."', skin_profile_mobile='".$profile."' WHERE id = '".$this->sid."'"); if (!$s) echo mysqli_error($GLOBALS['connect_db']); header("Location: index.php?anketa=".$this->sid."&a=theme-editor&profile=".$profile.'&newalert=1&mobile=1'); die(); } $row = SurveyInfo::getInstance()->getSurveyRow(); // urejanje CSSa if ( $_GET['t'] == 'css' ) { // CSS za mobilen skin if($_GET['mobile'] == '1'){ $sqlp = sisplet_query("SELECT usr_id, skin FROM srv_theme_profiles_mobile WHERE id = '".$_GET['profile']."'"); $rowp = mysqli_fetch_array($sqlp); $skin = $rowp['skin']; // nastavljena je sistemska tema, moramo jo spremeniti v lastno if (strpos($skin, $rowp['usr_id'].'_') === false) { $skin_name = $rowp['usr_id'].'_'.$skin; $css_content = file_get_contents('../../main/survey/skins/'.$skin.'.css'); $name = $rowp['usr_id'].'_'.$skin; while ( file_exists('../../main/survey/skins/'.$name.'.css') ) { $name = $name.'1'; } $f = fopen('../../main/survey/skins/'.$name.'.css', 'w'); fwrite($f, $css_content); fclose($f); $skin = $name; sisplet_query("UPDATE srv_theme_profiles_mobile SET skin = '$skin' WHERE id = '".$_GET['profile']."'"); } } else{ $sqlp = sisplet_query("SELECT usr_id, skin FROM srv_theme_profiles WHERE id = '".$_GET['profile']."'"); $rowp = mysqli_fetch_array($sqlp); $skin = $rowp['skin']; // nastavljena je sistemska tema, moramo jo spremeniti v lastno if (strpos($skin, $rowp['usr_id'].'_') === false) { $skin_name = $rowp['usr_id'].'_'.$skin; $css_content = file_get_contents('../../main/survey/skins/'.$skin.'.css'); $name = $rowp['usr_id'].'_'.$skin; while ( file_exists('../../main/survey/skins/'.$name.'.css') ) { $name = $name.'1'; } $f = fopen('../../main/survey/skins/'.$name.'.css', 'w'); fwrite($f, $css_content); fclose($f); //header("Location: index.php?anketa=".$this->sid."&a=edit_css&skin=".$name."&newalert=1"); //die(); $skin = $name; sisplet_query("UPDATE srv_theme_profiles SET skin = '$skin' WHERE id = '".$_GET['profile']."'"); } } $_GET['skin'] = $skin; } } // urejanje teme function displayEditing () { global $lang; global $global_user_id; $mobile = (isset($_GET['mobile']) && $_GET['mobile'] == '1') ? '_mobile' : ''; // najprej se pohendla ce gre za nove profile itd... $this->handleEditing(); echo '
'; $sql = sisplet_query("SELECT name FROM srv_theme_profiles".$mobile." WHERE id = '".$_GET['profile']."'"); $row = mysqli_fetch_array($sql); echo '

'.$lang['srv_themes_mod'].': '.$row['name'].'

'; //self::displayTabs(); if ( !isset($_GET['t']) ) { $ste = new SurveyThemeEditor($this->sid); $ste->display(); } elseif ( $_GET['t'] == 'css' ) { $this->edit_css(); } elseif ( $_GET['t'] == 'upload' ) { $this->upload_css(); } echo '
'; } function displayGroupSelector ($groupId = null) { global $lang,$site_url; global $global_user_id; $row = SurveyInfo::getInstance()->getSurveyRow(); $simple_name = $this->current_skin; if ($row['skin_profile'] == 0) { $skin_name = $this->strip_name($simple_name); } else { $sqla = sisplet_query("SELECT name FROM srv_theme_profiles WHERE id = '".$row['skin_profile']."'"); $rowa = mysqli_fetch_array($sqla); $skin_name = $rowa['name']; } echo ''.$lang['srv_current_theme'].': '; if($row['skin_profile'] == 0){ echo '' . $skin_name . '' . ''; }else { echo '' . $skin_name . '' . ''; } echo '

'; } function displayAdvancedSettings ($groupId) { global $lang,$site_url; global $site_path, $global_user_id; global $admin_type; $row = $this->surveyInfo; $simple_name = $this->current_skin; echo '

'.$lang['srv_show_all_settings'].'

'; echo ''; } function ajaxSaveChecboxTheme($idAnkete, $value){ sisplet_query("UPDATE srv_anketa SET skin_checkbox='$value' WHERE id='$idAnkete'"); } function displayGroupThemes ($groupId) { global $lang; global $site_domain; // Custom skini $this->displayThemes(-1); // Ostali default skini $this->displayThemes($groupId); // Mobilni skini $this->displayThemes(-3); // Safe skini - samo na domeni safe.si in test.1ka.si (za testiranje) if(strpos($site_domain, "safe.si") || $site_domain == "test.1ka.si"){ $this->displayThemes(-2); } } function displayThemes ($groupId) { global $lang, $site_url; global $global_user_id; //if (count($this->groups[$groupId]['skins'])>0 || $groupId == -1) { $rowa = SurveyInfo::getSurveyRow(); if($groupId == -2) echo '

'.$lang['srv_safe_themes'].'

'; elseif ($groupId == -3) echo '

'.$lang['srv_mobile_themes'].'

'; elseif ($groupId != -1) echo '

'.$lang['srv_system_themes'].'

'; else{ echo '

'.$lang['srv_user_themes'].' '; echo ' '; echo '

'; } echo ''; } function changeTheme($css, $gid) { global $site_path; $_theme = urldecode($_POST['css']); $dir = $site_path . 'main/survey/skins/'; if (file_exists($dir.$_theme)) { $_theme = preg_replace("/\.css$/", '', $_theme); // Mobilna anketa if($gid == -3){ $strUpdate = "UPDATE srv_anketa SET mobile_skin = '$_theme', skin_profile_mobile='0' WHERE id=".$this->sid; $updated = sisplet_query($strUpdate); sisplet_query("COMMIT"); SurveyInfo::getInstance()->resetSurveyData(); $this->current_mobile_skin = $_theme; } else{ // Nastavimo se mobilni skin glede na osnovnega $mobile_skin_update = ''; if(in_array($_theme, array('1kaBlue', '1kaRed', '1kaOrange', '1kaGreen', '1kaPurple', '1kaBlack'))){ $mobile_skin = str_replace('1ka', 'Mobile', $_theme); $mobile_skin_update = ", mobile_skin='".$mobile_skin."', skin_profile_mobile='0'"; } elseif(in_array($_theme, array('Uni', 'Fdv', 'Cdi'))){ $mobile_skin = 'Mobile'.$_theme; $mobile_skin_update = ", mobile_skin='".$mobile_skin."', skin_profile_mobile='0'"; } $strUpdate = "UPDATE srv_anketa SET skin = '$_theme', skin_profile='0' ".$mobile_skin_update." WHERE id=".$this->sid; $updated = sisplet_query($strUpdate); sisplet_query("COMMIT"); SurveyInfo::getInstance()->resetSurveyData(); $this->current_skin = $_theme; // Popravimo se mobile skin ce smo ga slucajno preklopili if($mobile_skin_update != '') $this->current_mobile_skin = $mobile_skin; } } ob_start(); $this->displayGroupThemes(0); $data['group_themes'] = ob_get_clean(); ob_start(); $this->displayGroupSelector(); $data['theme_name'] = ob_get_clean(); echo json_encode($data); } function changeProgressbar() { $progressbar = $_POST['progressbar']; $strUpdate = "UPDATE srv_anketa SET progressbar = '$progressbar' WHERE id=".$this->sid; $updated = sisplet_query($strUpdate); sisplet_query("COMMIT"); SurveyInfo :: getInstance()->resetSurveyData(); } function themeRename($msg = array()) { global $lang, $global_user_id; echo '
'; echo '
'; print_r("
");
		print_r($msg);
		print_r($_POST);
		print_r("
"); $_theme_new = (isset($_POST['theme_new_name']) ? $_POST['theme_new_name'] : $_POST['theme']); $_theme_new = urldecode(preg_replace("/\.css$/", '', $_theme_new)); # Če gre za lastno temo odstranimo $global_user_id+_ if (is_numeric( substr($_theme_new, 0, strpos($_theme_new, '_')) )) { $owner = (int)substr($_theme_new, 0, strpos($_theme_new, '_')); if ($owner == $global_user_id) { # odstranimo $global_user_id_ $_theme_new = preg_replace("/^".$global_user_id."_/", '', $_theme_new); } } echo ''; echo ''; echo '
'; #inv_FS_content echo '
'; echo ''.$lang['srv_rename_profile_yes'].''; echo ''.$lang['srv_cancel'].''; echo '
'; echo '
'; echo '
'; } function themeRenameConfirm() { global $lang, $global_user_id, $site_path; $dir = $site_path . 'main/survey/skins/'; $return = array('msg'=>'', 'error'=>'1', 'theme'=>$_POST['theme'], 'theme_new_name'=>$_POST['theme_new_name']); $_theme_old = urldecode($_POST['theme']); $_theme_new = preg_replace("/\.css$/", '', urldecode($_POST['theme_new_name'])); # preverimo ali gre za lastno temo, na začetku dodamo $global_user_id+_ if (is_numeric( substr($_theme_old, 0, strpos($_theme_old, '_')) )) { $owner = (int)substr($_theme_old, 0, strpos($_theme_old, '_')); if ($owner == $global_user_id) { # gre za lastno temo, na začetku preventivno odstranimo $global_user_id_ in ga nato dodamo $_theme_new = $global_user_id.'_'.preg_replace("/^".$global_user_id."_/", '', $_theme_new); } } # novo ime ne sme biti prazno if (trim($_theme_new) == '' || $_theme_new == null) { $return['error'] = 1; $return['msg'] = 'Ime teme ne sme biti prazno!'; echo json_encode($return); exit; } $_theme_new = $_theme_new.'.css'; # preverimo obstoj stare datoteke if (!file_exists($dir.$_theme_old)) { $return['error'] = 2; $return['msg'] = 'Izvorna datoteka ne obstaja!'; echo json_encode($return); exit; } #preverimo ali je novo ime enako staremu if ($_theme_old == $_theme_new) { $return['error'] = 3; $return['msg'] = 'Novo ime je enako staremu!'; echo json_encode($return); exit; } # preverimo in preprečimo obstoj datoteke z novim imenom if (file_exists($dir.$_theme_new)) { $return['error'] = 4; $return['msg'] = 'Datoteka s tem imenom že obstaja!'; echo json_encode($return); exit; } #preimenujemo datoteko if ((int)rename($dir.$_theme_old,$dir.$_theme_new) == true) { #datoteka je bila uspešno preimenovana, popravimo še v bazi, če je potrebno $simple_name = preg_replace("/\.css$/", '', $_theme_new); $strUpdate = "UPDATE srv_anketa SET skin = '".$simple_name."' WHERE id=".$this->sid; $updated = sisplet_query($strUpdate); sisplet_query("COMMIT"); $return = array('msg'=>(int)$updated, 'error'=>'0', 'theme'=>urlencode($_theme_new), 'theme_new_name'=>$_theme_new); echo json_encode($return); exit; } else { $return['error'] = 5; $return['msg'] = 'Pri preimenovanju je prišlo do napake!'; echo json_encode($return); exit; } # vse je ok! echo json_encode($return); exit; } // izbrise temo function themeDelete() { global $site_path; global $global_user_id; $dir = $site_path . 'main/survey/skins/'; $skin = urldecode( $_POST['css'] ); // preverimo, da ima na zacetku user ID, da ne bo brisal kar vsega po vrsti XX_ ter .css na koncu if ( substr($skin, 0, strpos($skin, '_')+1 ) == $global_user_id.'_' && substr($skin, -4) == '.css' ) { unlink($dir.$skin); } $sql = sisplet_query("SELECT skin FROM srv_anketa WHERE id = '{$_POST['anketa']}'"); $row = mysqli_fetch_array($sql); if ($row['skin'] == substr($skin, 0, -4)) { sisplet_query("UPDATE srv_anketa SET skin='Default' WHERE id = '{$_POST['anketa']}'"); } } // iz imena skina odstrani uid stevilko userja in _ function strip_name ($simple_name) { // Popravimo se default skine - vstavimo presledek da lepse izgleda $skins = array( '1kaBlue (Privzeto)', '1kaRed', '1kaOrange', '1kaGreen', '1kaPurple', '1kaBlack', '1kaOffice', '1kaNature', 'MobileBlue (Privzeto)', 'MobileRed', 'MobileOrange', 'MobileGreen', 'MobilePurple', 'MobileBlack', 'MobileUni', 'MobileFdv', 'MobileCdi' ); if(in_array($simple_name, $skins)){ $simple_name = preg_replace('/(?'.$lang['srv_add_theme_upload'].''; echo '
'; echo '

'; echo ''; echo ' (' . $lang['srv_skintmpl1'] . ' ' . $lang['srv_skintmpl'] . ')'; echo '

'; echo '

'.$lang['srv_skin_disclamer'].'

'; echo ''.$lang['srv_zapri'].''; } function edit_css () { global $lang; global $site_url; global $site_path; global $admin_type; global $global_user_id; $row = SurveyInfo::getInstance()->getSurveyRow(); $skin = $_GET['skin']; echo '
'; echo '
'.$lang['srv_themes_edit_warning'].'
'; echo '
'; $profile = $_GET['profile']; $mobile = (isset($_GET['mobile']) && $_GET['mobile'] == '1') ? true : false; $sqlp = sisplet_query("SELECT usr_id FROM srv_theme_profiles".($mobile ? '_mobile' : '')." WHERE id = '$profile'"); $rowp = mysqli_fetch_array($sqlp); $skin_name = str_replace($rowp['usr_id'].'_', '', $skin); //echo '

'.$lang['srv_skinname'].':

'; echo ''; echo ''; echo ''; echo '
'; echo ''.$lang['srv_themes_edit'].''; echo '

'; echo '

'; echo '

'; echo '
'; echo '

'.$lang['srv_upload_pic'].'

'; echo '
'; echo '
'.$lang['srv_upload_pic'].':'; /*echo '
'; echo '

'; echo ''; echo '

'; */ echo '
'; echo '

'; echo ''; echo '

'; echo '

'.$lang['srv_upload_pic_disclaimer'].'


'; // prikazemo uploadane slike $dir = opendir($site_path . 'main/survey/uploads/'); $skinsArray = array(); $skinsArrayPersonal = array(); while ($file = readdir($dir)) { if ( $file!='.' && $file!='..') { $allowed = false; if (is_numeric( substr($file, 0, strpos($file, '_')) )) { $owner = (int)substr($file, 0, strpos($file, '_')); if ($owner == $global_user_id) $allowed = true; } if ($allowed) { echo ' '; } } } echo '
'; echo '
'; echo '
'; $sql = sisplet_query("SELECT id FROM srv_grupa WHERE ank_id='$this->sid' ORDER BY vrstni_red ASC LIMIT 1"); $row = mysqli_fetch_array($sql); $grupa = $row['id']; //echo '
'; echo '
'; //echo '
'; //echo '
'; //echo '
'; SurveyThemeEditor::new_theme_alert($skin_name, true); } function ajax_add_theme () { global $lang; global $site_url; $row = SurveyInfo::getSurveyRow(); $default = 'Default'; echo '

'.$lang['srv_add_theme_css'].'

'; echo '

'.$lang['srv_select_base_theme'].': '.$lang['srv_select_base_theme_2'].'

'; echo '

'.$lang['srv_skinname'].':

'; echo '

'; echo '

'.$lang['srv_add_theme_upload'].'

'; echo '
'; echo '

'; echo ''; echo ' (' . $lang['srv_skintmpl1'] . ' ' . $lang['srv_skintmpl'] . ')'; echo '

'; echo '

'.$lang['srv_skin_disclamer'].'

'; echo ''.$lang['srv_zapri'].''; } } ?>