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'
);
$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'
);
$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']);
break;
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
?>
echo '
';
}
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 (isset($_GET['name']) && $_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 (isset($_GET['t']) && $_GET['t'] == 'css') {
// CSS za mobilen skin
if(isset($_GET['mobile']) && $_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 '';
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 = self::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'].' ';
//AKTIVNA SPLOŠNA TEMA
echo '';
echo '
';
echo ''.$skin_name.' ';
echo '('.$lang['srv_current_theme_general'].') ';
echo '
';
if($row['skin_profile'] == 0){
$preview_link = SurveyInfo::getSurveyLink().'&no_preview=1&preview=on&theme='.$simple_name.'';
$modify_link = '\'index.php?anketa=' . $this->sid . '&a=theme-editor&profile_new=' . $simple_name . '\'';
}
else {
$preview_link = SurveyInfo::getSurveyLink().'&no_preview=1&preview=on&theme_profile='.$row['skin_profile'];
$modify_link = '\'index.php?anketa=' . $this->sid . '&a=theme-editor&profile=' . $row['skin_profile'] . '\'';
}
//Gumbi
echo '
';
echo '
';
// echo '
';
echo '
';
echo ' ';
echo '
';
echo '
';
echo '
';
//AKTIVNA MOBILNA TEMA
$simple_name = $this->current_mobile_skin;
if ($row['skin_profile_mobile'] == 0) {
$skin_name = self::strip_name($simple_name);
} else {
$sqla = sisplet_query("SELECT name FROM srv_theme_profiles_mobile WHERE id = '".$row['skin_profile_mobile']."'");
$rowa = mysqli_fetch_array($sqla);
$skin_name = $rowa['name'];
}
echo '';
echo '
';
echo ''.$skin_name.' ';
echo '('.$lang['srv_current_theme_mobile'].') ';
echo '
';
if($row['skin_profile_mobile'] == 0){
$preview_link_mobile = SurveyInfo::getSurveyLink().'&no_preview=1&preview=on&theme='.$simple_name.'&mobile=1';
$modify_link_mobile = '\'index.php?anketa=' . $this->sid . '&a=theme-editor&mobile=1&profile_new_mobile=' . $simple_name . '\'';
}
else {
$preview_link_mobile = SurveyInfo::getSurveyLink().'&no_preview=1&preview=on&theme_profile='.$row['skin_profile_mobile'].'&mobile=1';
$modify_link_mobile = '\'index.php?anketa=' . $this->sid . '&a=theme-editor&mobile=1&profile=' . $row['skin_profile_mobile'] . '\'';
}
//Gumbi
echo '
';
echo '
';
echo '
';
echo '
';
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 '';
echo ' ';
echo ''.$lang['srv_offline_edit'].': ';
echo '';
echo '' . $lang['srv_uploadtheme'] . ': ';
echo ' ';
echo ' (' . $lang['srv_skintmpl1'] . ' ' . $lang['srv_skintmpl'] . ' )';
echo '
';
echo ''.$lang['srv_skin_disclamer'].'
';
echo ''.$lang['srv_upload_pic'].': ';
echo '';
echo '' . $lang['srv_upload_pic2'] . ': ';
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 ' ';
}
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;
$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 ' ';
}
if ( isset($this->groups[$groupId]['skins']) && count($this->groups[$groupId]['skins']) > 0 ) {
echo '';
}
echo '
';
$sqlg = sisplet_query("SELECT id FROM srv_grupa WHERE ank_id='$this->sid' ORDER BY vrstni_red ASC LIMIT 1");
$rowg = mysqli_fetch_array($sqlg);
$grupa = $rowg['id'];
$profiles = 0;
// Profili lastnih tem
if ($groupId == -1) {
// preverimo se, ce trenutno izbran skin pripada drugemu userju (v tem primeru ga vseeno prikazemo)
$is_current = false;
if ( isset($this->groups[$groupId]['skins']) && count($this->groups[$groupId]['skins']) > 0 ) {
foreach ($this->groups[$groupId]['skins'] AS $skinid => $skin) {
$simple_name = preg_replace("/\.css$/", '', $skin);
$is_current = ($this->current_skin == $simple_name && $rowa['skin_profile'] == 0) ? true : false;
}
}
$sql = sisplet_query("SELECT id FROM srv_theme_profiles WHERE usr_id = '$global_user_id' ORDER BY name ASC");
while ($row = mysqli_fetch_array($sql)) {
$is_current = ($rowa['skin_profile'] == $row['id']) ? true : false;
}
if (!$is_current) {
$append_skin = " OR id = '".$rowa['skin_profile']."' ";
} else {
$append_skin = "";
}
// Custom navadni skini
$sql = sisplet_query("SELECT id, name, skin FROM srv_theme_profiles WHERE usr_id = '$global_user_id' $append_skin ORDER BY name ASC");
while ($row = mysqli_fetch_array($sql)) {
$skin = $row['skin'];
$src = ''.SurveyInfo::getSurveyLink().'&grupa='.$grupa.'&no_preview=1&preview=on&theme_profile='.$row['id'].'';
$is_current_skin = ($rowa['skin_profile'] == $row['id']) ? true : false;
echo '
';
echo '
';
echo ' '.$skin_name.' ';
echo ' '.substr($row['name'], 0, 30).(strlen($row['name']) > 30 ? '...' : '').' ';
echo ' ('.$lang['srv_current_theme_general'].') ';
echo '
';
echo '
';
echo '
';
echo '
'; // additional_settings
echo '
'; //div.options
echo '
'; //div.theme_list
$profiles++;
}
// Custom mobile skini
$sql = sisplet_query("SELECT id, name, skin FROM srv_theme_profiles_mobile WHERE usr_id = '$global_user_id' ORDER BY name ASC");
while ($row = mysqli_fetch_array($sql)) {
$skin = $row['skin'];
$src = ''.SurveyInfo::getSurveyLink().'&grupa='.$grupa.'&no_preview=1&preview=on&theme_profile='.$row['id'].'&mobile=1';
$is_current_skin = ($rowa['skin_profile_mobile'] == $row['id']) ? true : false;
echo '
';
echo '
';
echo ''.$skin_name.' ';
echo ''.substr($row['name'], 0, 30).(strlen($row['name']) > 30 ? '...' : '').' ';
echo '('.$lang['srv_mobile_theme'].') ';
echo '
';
//Gumbi
echo '
';
echo '
';
echo '
'; //additional settings
echo '
'; //div.options
echo '
'; //div.theme_list
$profiles++;
}
}
// Klik izven - zapremo okno
echo '';
// Splošne teme - GRID
if ( isset($this->groups[$groupId]['skins']) && count($this->groups[$groupId]['skins']) > 0 ) {
foreach ($this->groups[$groupId]['skins'] AS $skinid => $skin) {
$simple_name = preg_replace("/\.css$/", '', $skin);
$is_current_skin = ($this->current_skin == $simple_name && $rowa['skin_profile'] == 0) ? true : false;
$is_current_mobile_skin = ($this->current_mobile_skin == $simple_name && $rowa['skin_profile_mobile'] == 0) ? true : false;
$src = ''.SurveyInfo::getSurveyLink().'&grupa='.$grupa.'&no_preview=1&preview=on&theme='.$skin.'';
if(substr($skin, 0, 6) == 'Mobile')
$src .= '&mobile=1';
// Preview slika
$css = urlencode($skin);
$gid = $groupId;
echo '
';
echo '
';
if ($groupId == -1)
echo '
'.$lang['srv_anketadelete_txt'].' ';
if ($groupId == -1) {
echo '
';
}
else
echo '
';
echo '
';
//Gumbi
echo '
';
// Ime teme
echo "
";
echo '
';
echo self::strip_name($simple_name.($simple_name=='1kaBlue' || $simple_name=='MobileBlue' ? ' ('.$lang['default'].')
' : ''));
// Vprasajcki
if( in_array($simple_name, array('Fdv', 'Cdi', 'Uni', 'MobileFdv', 'MobileCdi', 'MobileUni')) ){
echo ' '.Help::display('srv_skins_Fdv');
}
elseif($simple_name == 'Embed' || $simple_name == 'Embed2' || $simple_name == 'Slideshow'){
echo ' '.Help::display('srv_skins_'.$simple_name);
}
if($groupId == -1)
echo ' (CSS)';
echo ' ';
echo '
';
// Prilagodi - samo ce je tema aktivna
if($is_current_skin || $is_current_mobile_skin){
if ($groupId == -3)
$link = 'index.php?anketa='.$this->sid.'&a=theme-editor&profile_new_mobile='.$rowa['mobile_skin'];
else
$link = 'index.php?anketa='.$this->sid.'&a=theme-editor&profile_new='.$rowa['skin'];
echo ' ';
}
// Predogled
echo ' ';
echo '
'; // div.buttons_flex
echo '
';
echo '
'; //div.theme_label
}
}
elseif ($profiles == 0) {
echo '
'.$lang['srv_te_no_profiles'].'
';
echo '
';
}
echo '
';
if ( isset($this->groups[$groupId]['skins']) && count($this->groups[$groupId]['skins']) > 0 ) { // div#theme_grid_holder
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'];
$updated = sisplet_query("UPDATE srv_anketa SET progressbar = '$progressbar' WHERE id=".$this->sid);
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 '
Novo ime: ';
echo '
'; #inv_FS_content
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 _
static function strip_name ($simple_name) {
global $lang;
// Popravimo se default skine - vstavimo presledek da lepse izgleda
$skins = array(
'1kaBlue ('.$lang['default'].')', '1kaBlue', '1kaRed', '1kaOrange', '1kaGreen', '1kaPurple', '1kaBlack', '1kaOffice', '1kaNature',
'MobileBlue ('.$lang['default'].')', 'MobileBlue', 'MobileRed', 'MobileOrange', 'MobileGreen', 'MobilePurple', 'MobileBlack',
'MobileUni', 'MobileFdv', 'MobileCdi'
);
if(in_array($simple_name, $skins)){
$name_array = explode(' ', $simple_name);
$name_array[0] = preg_replace('/(?'.$lang['srv_themes_upload_css'].' ';
$sql = sisplet_query("SELECT name FROM srv_theme_profiles".$mobile." WHERE id = '".$profile."'");
$row = mysqli_fetch_array($sql);
echo ''.$lang['srv_themes_mod2'].': '.$row['name'].' ';
echo ''.$lang['srv_add_theme_upload'].':
';
echo '';
echo ''.$lang['srv_skintmpl1'] . ' ' . $lang['srv_skintmpl'] . ' .
';
echo ''.$lang['srv_skin_disclamer'].'
';
echo ''.$lang['srv_skin_warning'].'
';
echo ''.$lang['srv_zapri'].' ';
echo '';
}
function edit_css () {
global $lang;
global $site_url;
global $site_path;
global $admin_type;
global $global_user_id;
$row = SurveyInfo::getInstance()->getSurveyRow();
$skin = isset($_GET['skin']) ? $_GET['skin'] : '';
$profile = isset($_GET['profile']) ? $_GET['profile'] : '';
$mobile = (isset($_GET['mobile']) && $_GET['mobile'] == '1') ? true : false;
echo '';
echo '
';
$sql = sisplet_query("SELECT name FROM srv_theme_profiles".$mobile." WHERE id = '".$profile."'");
$row = mysqli_fetch_array($sql);
echo '
'.$lang['srv_themes_mod2'].': '.$row['name'].' ';
echo '
';
// 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 '
'.$lang['srv_skin_warning_edit'].'
';
echo '
';
readfile('../../main/survey/skins/'.$skin.'.css');
echo '
';
echo '
';
echo '
';
echo ''.$lang['edit1338'].' ';
echo ''. $lang['edit1337'].' ';
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 '
';
SurveyThemeEditor::new_theme_alert($skin_name, true);
echo '
';
}
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'].': ';
foreach ($this->groups[0]['skins'] AS $key => $val) {
$skin = str_replace('.css', '', $val);
echo ''.$skin.' ';
}
echo ' '.$lang['srv_select_base_theme_2'].'
';
echo ''.$lang['srv_skinname'].':
';
echo '
';
echo ''.$lang['srv_add_theme_upload'].' ';
echo '';
echo '' . $lang['srv_uploadtheme'] . ': ';
echo ' ';
echo ' (' . $lang['srv_skintmpl1'] . ' ' . $lang['srv_skintmpl'] . ' )';
echo '
';
echo ''.$lang['srv_skin_disclamer'].'
';
echo ''.$lang['srv_zapri'].' ';
}
}
?>