1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
|
<?php
/**
*
* Inline nacin urejanja vprasanja
*
*/
class VprasanjeInline {
var $anketa; // trenutna anketa
var $spremenljivka; // spremenljivka ki jo urejamo
var $db_table = '';
var $expanded = 0;
/**
* konstruktor
*
* @param mixed $anketa
* @return Vprasanje
*/
function __construct ($anketa = 0) {
if (isset ($_GET['anketa']))
$this->anketa = $_GET['anketa'];
elseif (isset ($_POST['anketa']))
$this->anketa = $_POST['anketa'];
elseif ($anketa != 0)
$this->anketa = $anketa;
SurveyInfo::getInstance()->SurveyInit($this->anketa);
$this->db_table = SurveyInfo::getInstance()->getSurveyArchiveDBString();
if (SurveyInfo::getInstance()->getSurveyColumn('expanded') == 1)
$this->expanded = 1;
}
/**
* pohendla ajax klice za vprasanje
*
*/
function ajax () {
if (isset($_POST['spremenljivka'])) $this->spremenljivka = $_POST['spremenljivka'];
// genericna resitev za vse nadaljne
$ajax = 'ajax_' . $_GET['a'];
if ( method_exists('VprasanjeInline', $ajax) )
$this->$ajax();
else
echo 'method '.$ajax.' does not exist';
}
function ajax_inline_vrednost_naslov_save () {
Common::updateEditStamp();
$row = Cache::srv_spremenljivka($this->spremenljivka);
$naslov = $_POST['naslov'];
$lang_id = $_POST['lang_id'];
// firefox na koncu vsakega contenteditable doda <br>, ki ga tukaj odstranimo
if (substr($naslov, -4) == '<br>') {
$naslov = substr($naslov, 0, -4);
}
$vrednost = $_POST['vrednost'];
$v = explode('_', $vrednost);
$vrednost = isset($v[0]) ? $v[0] : '';
$vrednost2 = isset($v[1]) ? $v[1] : ''; // naslov2 za diferencial
$purifier = New Purifier();
$naslov = $purifier->purify_DB($naslov);
if ( ! $vrednost > 0 ) return;
if ($vrednost2 == '2')
$_naslov = 'naslov2';
else
$_naslov = 'naslov';
// Navadno popravljanje (ne prevajanje)
if ($lang_id == 0) {
$s = sisplet_query("UPDATE srv_vrednost SET $_naslov='$naslov' WHERE id = '$vrednost'");
if (!$s) echo mysqli_error($GLOBALS['connect_db']);
}
// Prevajamo za drug jezik
else {
// Semanticni diferencial posebej obravnavamo (naslov ali naslov2)
//if($row['tip'] == 6 && $row['enota'] == 1){
if($row['tip'] == 6 && ($row['enota'] == 1 || $row['enota'] == 4)){ //diferencial, one against another
// Ce popravljamo naslov2
if($vrednost2 == '2'){
$s = sisplet_query("INSERT INTO srv_language_vrednost
(ank_id, vre_id, lang_id, naslov2) VALUES ('$this->anketa', '$vrednost', '$lang_id', '$naslov')
ON DUPLICATE KEY UPDATE naslov2='$naslov'");
}
else{
$s = sisplet_query("INSERT INTO srv_language_vrednost
(ank_id, vre_id, lang_id, naslov) VALUES ('$this->anketa', '$vrednost', '$lang_id', '$naslov')
ON DUPLICATE KEY UPDATE naslov='$naslov'");
}
}
else{
if ($naslov != '')
$s = sisplet_query("REPLACE INTO srv_language_vrednost (ank_id, vre_id, lang_id, naslov) VALUES ('$this->anketa', '$vrednost', '$lang_id', '$naslov')");
else
$s = sisplet_query("DELETE FROM srv_language_vrednost WHERE ank_id='$this->anketa' AND vre_id='$vrednost' AND lang_id='$lang_id'");
}
}
if ($row['tip'] == 24) {
$v = new Vprasanje($this->anketa);
$v->repare_grid_multiple($this->spremenljivka);
}
echo mysql_real_unescape_string($naslov);
Vprasanje::vprasanje_tracking();
}
function ajax_inline_hotspot_vrednost_save () {
Common::updateEditStamp();
$naslov = $_POST['naslov'];
$lang_id = $_POST['lang_id'];
// firefox na koncu vsakega contenteditable doda <br>, ki ga tukaj odstranimo
if (substr($naslov, -4) == '<br>') {
$naslov = substr($naslov, 0, -4);
}
$vrednost = $_POST['vrednost'];
$v = explode('_', $vrednost);
$vrednost = $v[0];
$vrednost2 = $v[1]; // naslov2 za diferencial
$purifier = New Purifier();
$naslov = $purifier->purify_DB($naslov);
if ( ! $vrednost > 0 ) return;
if ($vrednost2 == '2')
$_naslov = 'naslov2';
else
$_naslov = 'naslov';
if ($lang_id == 0) {
//$s = sisplet_query("UPDATE srv_vrednost SET $_naslov='$naslov' WHERE id = '$vrednost'");
$s = sisplet_query("UPDATE srv_vrednost SET naslov='$naslov' WHERE id = '$vrednost'");
$sR = sisplet_query("UPDATE srv_hotspot_regions SET region_name='$naslov' WHERE vre_id = '$vrednost'");
if (!$s) echo mysqli_error($GLOBALS['connect_db']);
} else {
if ($naslov != '')
$s = sisplet_query("REPLACE INTO srv_language_vrednost (ank_id, vre_id, lang_id, naslov) VALUES ('$this->anketa', '$vrednost', '$lang_id', '$naslov')");
else
$s = sisplet_query("DELETE FROM srv_language_vrednost WHERE ank_id='$this->anketa' AND vre_id='$vrednost' AND lang_id='$lang_id'");
}
$row = Cache::srv_spremenljivka($this->spremenljivka);
if ($row['tip'] == 24) {
$v = new Vprasanje($this->anketa);
$v->repare_grid_multiple($this->spremenljivka);
}
echo mysql_real_unescape_string($naslov);
Vprasanje::vprasanje_tracking();
}
function ajax_inline_grid_naslov_save () {
Common::updateEditStamp();
$naslov = $_POST['naslov'];
$lang_id = $_POST['lang_id'];
$purifier = New Purifier();
$naslov = $purifier->purify_DB($naslov);
$grid = $_POST['grid'];
if ($lang_id == 0) {
$s = sisplet_query("UPDATE srv_grid SET naslov='$naslov' WHERE id='$grid' AND spr_id='$this->spremenljivka'");
if (!$s) echo mysqli_error($GLOBALS['connect_db']);
// dvojni gridi
$row = Cache::srv_spremenljivka($this->spremenljivka);
if ($row['enota'] == 3) {
$sql = sisplet_query("SELECT id, spr_id FROM srv_grid WHERE spr_id='$this->spremenljivka' AND other!=0 AND part=1");
$s = sisplet_query("UPDATE srv_grid SET naslov='$naslov' WHERE id='".($grid + $row['grids'] + mysqli_num_rows($sql))."' AND spr_id='$this->spremenljivka'");
if (!$s) echo mysqli_error($GLOBALS['connect_db']);
}
}
else {
//if ($naslov != '')
$s = sisplet_query("INSERT INTO srv_language_grid
(ank_id, spr_id, grd_id, lang_id, naslov)
VALUES
('$this->anketa', '$this->spremenljivka', '$grid', '$lang_id', '$naslov')
ON DUPLICATE KEY UPDATE naslov='$naslov'");
//else
// $s = sisplet_query("DELETE FROM srv_language_grid WHERE ank_id='$this->anketa' AND spr_id='$this->spremenljivka' AND grd_id='$grid' AND lang_id='$lang_id'");*/
}
Vprasanje::vprasanje_tracking();
}
function ajax_inline_grid_variable_save () {
Common::updateEditStamp();
$variable = strip_tags($_POST['variable']);
$grid = $_POST['grid'];
$s = sisplet_query("UPDATE srv_grid SET variable='$variable' WHERE id='$grid' AND spr_id='$this->spremenljivka'");
if (!$s) echo mysqli_error($GLOBALS['connect_db']);
/*// dvojni gridi
$row = Cache::srv_spremenljivka($this->spremenljivka);
if ($row['enota'] == 3) {
$s = sisplet_query("UPDATE srv_grid SET naslov='$naslov' WHERE id='".($grid + $row['grids'])."' AND spr_id='$this->spremenljivka'");
if (!$s) echo mysqli_error($GLOBALS['connect_db']);
}*/
Vprasanje::vprasanje_tracking();
}
function ajax_inline_grid_subtitle_save () {
Common::updateEditStamp();
$subtitle = $_POST['subtitle'];
$value = $_POST['value'];
$lang_id = $_POST['lang_id'];
$grid_id = $_POST['grid_id'];
$purifier = New Purifier();
$subtitle = $purifier->purify_DB($subtitle);
// Navadno popravljanje (ne prevajanje)
if ($lang_id == 0) {
$s = sisplet_query("UPDATE srv_spremenljivka SET $subtitle='$value' WHERE id='$this->spremenljivka'");
if (!$s) echo mysqli_error($GLOBALS['connect_db']);
}
// Prevajamo podnaslove za drug jezik
else{
//if ($value != '')
$s = sisplet_query("INSERT INTO srv_language_grid
(ank_id, spr_id, grd_id, lang_id, podnaslov)
VALUES
('$this->anketa', '$this->spremenljivka', '$grid_id', '$lang_id', '$value')
ON DUPLICATE KEY UPDATE podnaslov='$value'");
/*else
$s = sisplet_query("DELETE FROM srv_language_grid WHERE ank_id='$this->anketa' AND spr_id='$this->spremenljivka' AND grd_id='$grid_id' AND lang_id='$lang_id'");*/
}
Vprasanje::vprasanje_tracking();
}
function ajax_inline_vrednost_new () {
Common::getInstance()->Init($this->anketa);
Common::getInstance()->updateEditStamp();
global $lang;
$naslov = '';
//$other = $_POST['other'];
//$mv = $_POST['mv'];
$v = new Vprasanje($this->anketa);
$v->spremenljivka = $this->spremenljivka;
$vrednost = $v->vrednost_new($naslov /*, $other, $mv*/);
Common::prestevilci($this->spremenljivka);
//$b = new Branching($this->anketa);
//$b->vprasanje($this->spremenljivka);
echo $vrednost;
Vprasanje::vprasanje_tracking();
}
function ajax_inline_vrednost_vrstni_red () {
Common::updateEditStamp();
$sortable = $_POST['sortable'];
print_r($sortable);
$exploded = explode('&', $sortable);
$i = 1;
foreach ($exploded AS $key) {
$key = str_replace('variabla_', '', $key);
$explode = explode('[]=', $key);
$sql = sisplet_query("UPDATE srv_vrednost SET vrstni_red = '$i' WHERE id = '$explode[1]'");
if (!$sql) echo mysqli_error($GLOBALS['connect_db']);
$i++;
}
Common::prestevilci($this->spremenljivka);
Vprasanje::vprasanje_tracking();
}
function ajax_inline_info_save() {
Common::updateEditStamp();
$info = $_POST['info'];
$lang_id = $_POST['lang_id'];
// Po�istimo opombo
$info = trim(strip_tags($info));
if ($lang_id == 0) {
sisplet_query("UPDATE srv_spremenljivka SET info='$info' WHERE id = '$this->spremenljivka'");
}
else {
//if ($info != '')
sisplet_query("INSERT INTO srv_language_spremenljivka (ank_id, spr_id, lang_id, info) VALUES ('$this->anketa', '$this->spremenljivka', '$lang_id', '$info') ON DUPLICATE KEY UPDATE info='$info'");
//else
// sisplet_query("DELETE FROM srv_language_spremenljivka WHERE ank_id='$this->anketa' AND spr_id='$this->spremenljivka' AND lang_id='$lang_id'");
}
Vprasanje::vprasanje_tracking();
}
function ajax_inline_variable_save() {
Common::updateEditStamp();
$variable = $_POST['variable'];
$row = SurveyInfo::getInstance()->getSurveyRow();
if ( in_array($row['variable'], array('email','telefon','ime','priimek','naziv','drugo')) && $row['sistem']==1 ) {
// tukaj ne pustimo spremeniti
} else {
if ($variable != $row['variable'])
sisplet_query("UPDATE srv_spremenljivka SET variable='$variable', variable_custom='1' WHERE id = '$this->spremenljivka'");
}
Vprasanje::vprasanje_tracking();
}
function ajax_inline_vrednost_variable_save () {
Common::updateEditStamp();
$variable = $_POST['variable'];
$vre_id = $_POST['vre_id'];
$sql = sisplet_query("SELECT variable, spr_id FROM srv_vrednost WHERE id = '".$vre_id."'");
$row = mysqli_fetch_array($sql);
if ($row['variable'] != $variable) {
// Preverimo, ce ze obstaja kaksna variabla z istim imenom - pri kvizu pa ima lahko isto ime
if(!SurveyInfo::getInstance()->checkSurveyModule('quiz')){
$sql2 = sisplet_query("SELECT id FROM srv_vrednost WHERE variable='".$variable."' AND spr_id='".$row['spr_id']."'");
if(mysqli_num_rows($sql2) > 0)
return false;
}
sisplet_query("UPDATE srv_vrednost SET variable='".$variable."', variable_custom='1' WHERE id='".$vre_id."'");
}
}
function ajax_inline_label_save () {
Common::updateEditStamp();
$row = Cache::srv_spremenljivka($this->spremenljivka);
$spremenljivkaParams = new enkaParameters($row['params']);
$purifier = New Purifier();
$Label = $purifier->purify_DB($_POST['label']);
//$Label = $_POST['label'];
$TipLabele = $_POST['tiplabele'];
//error_log("TipLabele: ".$TipLabele);
$lang_id = $_POST['lang_id'];
$TrenutnaLabela = ($spremenljivkaParams->get($TipLabele) ? $spremenljivkaParams->get($TipLabele) : '');
//error_log("TrenutnaLabela: ".$TrenutnaLabela);
// firefox na koncu vsakega contenteditable doda <br>, ki ga tukaj odstranimo
if (substr($Label, -4) == '<br>') {
$Label = substr($Label, 0, -4);
}
if ($lang_id == 0) {
$sql = sisplet_query("SELECT params FROM srv_spremenljivka WHERE id = '$this->spremenljivka'"); //poberi trenutne params iz baze
$row = mysqli_fetch_array($sql);
if($TrenutnaLabela != ''){
$TipLabelepart1 = strchr($row['params'], $TipLabele."="); //iz stringa, kjer so vsi params izlusci le string od TipLabele dalje
//print_r (explode("\n",$row['params'])); //explode(separator,string,limit)
$newTipLabele = $TipLabele.'='.$Label; //formiraj nov tip labele z labelo
$explodedparams = explode("\n",$row['params']); //spremeni string v array
for($i=0; $i<=sizeof($explodedparams); $i++){ //za vse elemente array-a
//echo 'Sem v for zanki';
if((strstr($explodedparams[$i], $TipLabele.'=') != '')){ //ce element array-a vsebuje besedilo z ustreznim tipom labele //strstr(string,search,before_search)
//echo 'Smo dobili string na indeksu: '.$i;
$indeks = $i; //zabele�i indeks
//echo 'Indeks1: '.$indeks;
//$explodedparams[$i] = $newTipLabele; //povozi ustrezen element array-a z novim tipom labele
//echo 'Exploded: '.$explodedparams[$i];
}
}
//echo 'Indeks2: '.$indeks;
$explodedparams[$indeks] = $newTipLabele; //povozi ustrezen element array-a z novim tipom labele
//print_r ($explodedparams);
$newparams = implode("\n",$explodedparams); //zdruzi array ponovno v string
//echo 'New params: '.$newparams;
$s = sisplet_query("UPDATE srv_spremenljivka SET params = '$newparams' WHERE id='$this->spremenljivka'"); //posodobi params
}
elseif ($TrenutnaLabela == ''){
$s = sisplet_query("UPDATE srv_spremenljivka SET params = CONCAT( srv_spremenljivka.params , '\n$TipLabele=$Label ') WHERE id='$this->spremenljivka'"); //k obstoje�im params dodaj �e naslednje
//echo $Label;
//print_r (explode("\n",$row['params'])); //explode(separator,string,limit)
}
}else{
if($TipLabele == 'MinLabel'){
$grid = 1;
}elseif($TipLabele =='MaxLabel'){
$grid = 2;
}else{
$grid = 0;
}
if ($TrenutnaLabela != ''){
$sString = "REPLACE INTO srv_language_slider (ank_id, spr_id, label_id, lang_id, label) VALUES ('$this->anketa', '$this->spremenljivka', '$grid', '$lang_id', '$Label')";
}else{
$sString = "DELETE FROM srv_language_slider WHERE ank_id='$this->anketa' AND spr_id='$this->spremenljivka' AND label_id='$grid' AND lang_id='$lang_id'";
}
if($grid == 0){ //ce je prevod custom opisnih label
$sString = "REPLACE INTO srv_language_slider (ank_id, spr_id, label_id, lang_id, label) VALUES ('$this->anketa', '$this->spremenljivka', '$grid', '$lang_id', '$Label')";
}
//error_log($sString);
$s = sisplet_query($sString);
}
if (!$s) echo mysqli_error($GLOBALS['connect_db']);
Vprasanje::vprasanje_tracking();
}
function ajax_inline_nadnaslov_save () {
Common::updateEditStamp();
$anketa = $_POST['anketa'];
$naslov = $_POST['label'];
$lang_id = $_POST['lang_id'];
$purifier = New Purifier();
$naslov = $purifier->purify_DB($naslov);
$grid = $_POST['grid'];
if ($lang_id != 0) {
if ($naslov != ''){
$s = sisplet_query("REPLACE INTO srv_language_grid (ank_id, spr_id, grd_id, lang_id, naslov) VALUES ('$anketa', '$this->spremenljivka', '$grid', '$lang_id', '$naslov')");
}
else{
$s = sisplet_query("DELETE FROM srv_language_grid WHERE ank_id='$anketa' AND spr_id='$this->spremenljivka' AND grd_id='$grid' AND lang_id='$lang_id'");
}
}elseif($lang_id == 0){
$row = Cache::srv_spremenljivka($this->spremenljivka);
$spremenljivkaParams = new enkaParameters($row['params']);
$Label = $_POST['label'];
$TipLabele = $_POST['tiplabele'];
$TrenutnaLabela = ($spremenljivkaParams->get($TipLabele) ? $spremenljivkaParams->get($TipLabele) : '');
// firefox na koncu vsakega contenteditable doda <br>, ki ga tukaj odstranimo
if (substr($Label, -4) == '<br>') {
$Label = substr($Label, 0, -4);
}
$sql = sisplet_query("SELECT params FROM srv_spremenljivka WHERE id = '$this->spremenljivka'"); //poberi trenutne params iz baze
$row = mysqli_fetch_array($sql);
if($TrenutnaLabela != ''){
$TipLabelepart1 = strchr($row['params'], $TipLabele."="); //iz stringa, kjer so vsi params izlusci le string od TipLabele dalje
$newTipLabele = $TipLabele.'='.$Label; //formiraj nov tip labele z labelo
$explodedparams = explode("\n",$row['params']); //spremeni string v array
for($i=0; $i<=sizeof($explodedparams); $i++){ //za vse elemente array-a
if((strstr($explodedparams[$i], $TipLabele.'=') != '')){ //ce element array-a vsebuje besedilo z ustreznim tipom labele //strstr(string,search,before_search)
$indeks = $i; //zabelezi indeks
}
}
$explodedparams[$indeks] = $newTipLabele; //povozi ustrezen element array-a z novim tipom labele
$newparams = implode("\n",$explodedparams); //zdruzi array ponovno v string
$s = sisplet_query("UPDATE srv_spremenljivka SET params = '$newparams' WHERE id='$this->spremenljivka'"); //posodobi params
}
elseif ($TrenutnaLabela == ''){
$s = sisplet_query("UPDATE srv_spremenljivka SET params = CONCAT( srv_spremenljivka.params , '\n$TipLabele=$Label ') WHERE id='$this->spremenljivka'"); //k obstoje�im params dodaj �e naslednje
}
}
if (!$s) echo mysqli_error($GLOBALS['connect_db']);
Vprasanje::vprasanje_tracking();
}
function ajax_inline_labele_podrocij_save () {
Common::updateEditStamp();
#############################
$anketa = $_POST['anketa'];
$naslov = $_POST['naslov'];
$lang_id = $_POST['lang_id'];
$purifier = New Purifier();
$naslov = $purifier->purify_DB($naslov);
$grid = $_POST['grid'];
############################
$row = Cache::srv_spremenljivka($this->spremenljivka);
$spremenljivkaParams = new enkaParameters($row['params']);
$Label = $_POST['label'];
$TipLabele = $_POST['tiplabele'];
$TrenutnaLabela = ($spremenljivkaParams->get($TipLabele) ? $spremenljivkaParams->get($TipLabele) : '');
// firefox na koncu vsakega contenteditable doda <br>, ki ga tukaj odstranimo
if (substr($Label, -4) == '<br>') {
$Label = substr($Label, 0, -4);
}
$sql = sisplet_query("SELECT params FROM srv_spremenljivka WHERE id = '$this->spremenljivka'"); //poberi trenutne params iz baze
$row = mysqli_fetch_array($sql);
if($TrenutnaLabela != ''){
//echo "Update labele";
$TipLabelepart1 = strchr($row['params'], $TipLabele."="); //iz stringa, kjer so vsi params izlusci le string od TipLabele dalje
//print_r (explode("\n",$row['params'])); //explode(separator,string,limit)
$newTipLabele = $TipLabele.'='.$Label; //formiraj nov tip labele z labelo
$explodedparams = explode("\n",$row['params']); //spremeni string v array
for($i=0; $i<=sizeof($explodedparams); $i++){ //za vse elemente array-a
//echo 'Sem v for zanki';
if((strstr($explodedparams[$i], $TipLabele.'=') != '')){ //ce element array-a vsebuje besedilo z ustreznim tipom labele //strstr(string,search,before_search)
//echo 'Smo dobili string na indeksu: '.$i;
$indeks = $i; //zabele�i indeks
//echo 'Indeks1: '.$indeks;
//$explodedparams[$i] = $newTipLabele; //povozi ustrezen element array-a z novim tipom labele
//echo 'Exploded: '.$explodedparams[$i];
}
}
//echo 'Indeks2: '.$indeks;
$explodedparams[$indeks] = $newTipLabele; //povozi ustrezen element array-a z novim tipom labele
//print_r ($explodedparams);
$newparams = implode("\n",$explodedparams); //zdruzi array ponovno v string
//echo 'New params: '.$newparams;
$s = sisplet_query("UPDATE srv_spremenljivka SET params = '$newparams' WHERE id='$this->spremenljivka'"); //posodobi params
}
elseif ($TrenutnaLabela == ''){
$s = sisplet_query("UPDATE srv_spremenljivka SET params = CONCAT( srv_spremenljivka.params , '\n$TipLabele=$Label ') WHERE id='$this->spremenljivka'"); //k obstoje�im params dodaj �e naslednje
//echo $Label;
//print_r (explode("\n",$row['params'])); //explode(separator,string,limit)
//echo "Trenutna labela je prazna";
}
if (!$s) echo mysqli_error($GLOBALS['connect_db']);
Vprasanje::vprasanje_tracking();
}
function ajax_inline_opisne_labele_save () {
Common::updateEditStamp();
$row = Cache::srv_spremenljivka($this->spremenljivka);
$spremenljivkaParams = new enkaParameters($row['params']);
$Label = $_POST['label'];
$TipLabele = $_POST['tiplabele'];
$TrenutnaLabela = ($spremenljivkaParams->get($TipLabele) ? $spremenljivkaParams->get($TipLabele) : '');
// firefox na koncu vsakega contenteditable doda <br>, ki ga tukaj odstranimo
if (substr($Label, -4) == '<br>') {
$Label = substr($Label, 0, -4);
}
$spremenljivkaParams->set($TipLabele, $Label);
$params = $spremenljivkaParams->getString();
$update .= " params = '$params' ";
$sqlString = "UPDATE srv_spremenljivka SET $update WHERE id = '$this->spremenljivka'";
//error_log($sqlString);
sisplet_query($sqlString);
if (!$s) echo mysqli_error($GLOBALS['connect_db']);
Vprasanje::vprasanje_tracking();
}
function ajax_inline_variabla_vsota_save () {
Common::updateEditStamp();
$vsota = $_POST['inline_variabla_vsota'];
// firefox na koncu vsakega contenteditable doda <br>, ki ga tukaj odstranimo
if (substr($vsota, -4) == '<br>') {
$vsota = substr($vsota, 0, -4);
}
$s = sisplet_query("UPDATE srv_spremenljivka SET vsota='$vsota' WHERE id='$this->spremenljivka'");
if (!$s) echo mysqli_error($GLOBALS['connect_db']);
Vprasanje::vprasanje_tracking();
}
function ajax_inline_hotspot_delete_region () {
Common::updateEditStamp();
$spr_id = $_POST['spr_id'];
$vre_id = $_POST['vre_id'];
$region_index = $_POST['region_index'];
//zbrisi podatke o obstojecem obmocju
$s = sisplet_query("DELETE FROM srv_hotspot_regions WHERE spr_id='$spr_id' AND region_index='$region_index'");
$v = sisplet_query("DELETE FROM srv_vrednost WHERE spr_id='$spr_id' AND id='$vre_id'");
Common::repareVrednost($spr_id);
}
function ajax_inline_hotspot_update_region () {
Common::updateEditStamp();
$spr_id = $_POST['spr_id'];
//$vre_id = $_POST['vre_id'];
//posodobi podatke o obstojecih obmocjih po brisanju obmocja
$sqlv = sisplet_query("SELECT id, variable, vrstni_red FROM srv_vrednost WHERE spr_id = $spr_id");
while($rowv = mysqli_fetch_array($sqlv)){
$vre_id_V = $rowv['id'];
$variable = $rowv['variable'];
$vrstni_red = $rowv['vrstni_red'];
//echo $variable;
$sqlR = sisplet_query("UPDATE srv_hotspot_regions SET variable = '$variable', vrstni_red = '$vrstni_red' WHERE spr_id='$spr_id' AND vre_id = $vre_id_V");
}
//$s = sisplet_query("DELETE FROM srv_hotspot_regions WHERE spr_id='$spr_id' AND region_index='$region_index'");
//$v = sisplet_query("DELETE FROM srv_vrednost WHERE spr_id='$spr_id' AND id='$vre_id'");
}
}
?>
|