';
}
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 '
';
}
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 '
';
}
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('/(?';
$sql = sisplet_query("SELECT name FROM srv_theme_profiles".$mobile." WHERE id = '".$_GET['profile']."'");
$row = mysqli_fetch_array($sql);
echo '
';
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 = $_GET['skin'];
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 '