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
|
<?php
/***************************************
* Description: Prikaže vprašanje Heatmap
*
* Vprašanje je prisotno:
* tip 27
*
* Autor: Patrik Pucer
* Created date: 06.10.2016
*****************************************/
namespace App\Controllers\Vprasanja;
// Osnovni razredi
use App\Controllers\Controller;
use App\Controllers\HelperController as Helper;
use App\Controllers\LanguageController as Language;
use App\Models\Model;
use enkaParameters;
use SurveySetting;
use App\Controllers\Vprasanja\RadioCheckboxSelectController as RadioCheckboxSelect;
use App\Controllers\Vprasanja\MultigridController as Multigrid;
// Iz admin/survey
// Vprašanja
class HeatMapController extends Controller
{
public function __construct()
{
parent::getGlobalVariables();
}
/************************************************
* Get instance
************************************************/
private static $_instance;
public static function getInstance()
{
if (self::$_instance)
return self::$_instance;
return new HeatMapController();
}
/**
* @desc prikaze vnos za image hotspot za radio
*/
public function display($spremenljivka){
global $lang;
$row = Model::select_from_srv_spremenljivka($spremenljivka);
$loop_id = get('loop_id') == null ? " IS NULL" : " = '" . get('loop_id') . "'";
$spremenljivkaParams = new enkaParameters($row['params']);
$selected = Model::getOtherValue($spremenljivka);
$order = Model::generate_order_by_field($spremenljivka, get('usr_id'));
$spremenljivkaParams = new enkaParameters($row['params']);
$hotspot_image = ($spremenljivkaParams->get('hotspot_image') ? $spremenljivkaParams->get('hotspot_image') : "");
$hotspot_region_visibility_option = ($spremenljivkaParams->get('hotspot_region_visibility_option') ? $spremenljivkaParams->get('hotspot_region_visibility_option') : 0);
//$hotspot_tooltips_option = ($spremenljivkaParams->get('hotspot_tooltips_option') ? $spremenljivkaParams->get('hotspot_tooltips_option') : 1); //po default-u skrij namig
$hotspot_tooltips_option = 1; //naj bo 1 tako, da je skrito, saj trenutno tega v heatmap ne rabimo
$hotspot_region_color = ($spremenljivkaParams->get('hotspot_region_color') ? $spremenljivkaParams->get('hotspot_region_color') : "");
$heatmap_num_clicks = ($spremenljivkaParams->get('heatmap_num_clicks') ? $spremenljivkaParams->get('heatmap_num_clicks') : 1);
$heatmap_show_clicks = ($spremenljivkaParams->get('heatmap_show_clicks') ? $spremenljivkaParams->get('heatmap_show_clicks') : 0); //za checkbox
$disable_heatmap_show_clicks_hidden = ($heatmap_show_clicks == 1) ? 'disabled' : '';
$heatmap_click_color = ($spremenljivkaParams->get('heatmap_click_color') ? $spremenljivkaParams->get('heatmap_click_color') : "");
$heatmap_click_size = ($spremenljivkaParams->get('heatmap_click_size') ? $spremenljivkaParams->get('heatmap_click_size') : 5);
$heatmap_click_shape = ($spremenljivkaParams->get('heatmap_click_shape') ? $spremenljivkaParams->get('heatmap_click_shape') : 1);
$heatmap_show_counter_clicks = ($spremenljivkaParams->get('heatmap_show_counter_clicks') ? $spremenljivkaParams->get('heatmap_show_counter_clicks') : 0); //za prikazovanje/skrivanje stevca klikov
// Pri vpogledu moramo deaktivirati canvas in tipke (quick_edit & quick_view = 0)
$quick_view = json_encode(get('quick_view'));
echo '<div id="heatmap_'.$spremenljivka.'" class="hotspot" style="width: 40%; float: left;">';
//imena obmocij iz srv_vrednost
$sql1 = sisplet_query("SELECT id, naslov FROM srv_vrednost WHERE spr_id='$row[id]' ORDER BY vrstni_red");
$sqlR = sisplet_query("SELECT region_coords, vre_id FROM srv_hotspot_regions WHERE spr_id='$row[id]' ");
//ce so podatki ze v bazi (rec. uporabnik klikne 'Prejsnja stran')
//$sql1a = sisplet_query("SELECT lat, lng, address, text FROM srv_data_map WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
$sql1a = sisplet_query("SELECT lat, lng, address, text FROM srv_data_heatmap WHERE spr_id='$spremenljivka' AND usr_id='" . get('usr_id') . "' AND loop_id $loop_id");
$heatmap_data = array();
while ($row1a = mysqli_fetch_array($sql1a)) {
$heatmap_data[] = $row1a;
}
echo '<div id="hotspot_regions_hidden_menu_'.$row[id].'" style="display:none; ">';
//echo '<div id="hotspot_regions_hidden_menu_'.$row[id].'">';
//echo ' <div class="variabla" id="variabla_'.$row1['id'].'">';
if (mysqli_num_rows($sql1) == 0){
echo ' <div class="variabla">';
echo '</div>';
}else{
while ($row1 = mysqli_fetch_array($sql1)) {
echo ' <div class="variabla" id="variabla_'.$row1['id'].'">';
echo '<div id="vre_id_'.$row1['id'].'" class="vrednost_inline" contenteditable="'.(!$locked?'true':'false').'" tabindex="1" vre_id="'.$row1['id'].'" '.(strpos($row1['naslov'], $lang['srv_new_vrednost'])!==false || strpos($row1['naslov'], $lang1['srv_new_vrednost'])!==false || $this->lang_id!=null ? ' default="1"':'').'>' . $row1['naslov'].'</div>';
echo '</div>';
}
}
echo '</div>';
//prikaz slike
$findme = 'img';
$pos = strpos($hotspot_image, $findme);
if($pos === false) { //string NOT present
}
else { //string present
$usemap = 'id="hotspot_'.$row['id'].'_image" usemap="#hotspot_'.$row['id'].'_usemap"';
//v $hotspot_image je potrebno dodati usemap="#hotspot_image_'.$row['id'].'" za identificiranje mape
$hotspot_image = substr_replace($hotspot_image, $usemap, 5, 0); //dodaj zeleni string v $hotspot_image
}
echo '<div id="hotspot_image_'.$row['id'].'" class="vrednost_inline_hotspot" contenteditable="false" spr_id="'.$row['id'].'">'.$hotspot_image.'';
//prikaz slike - konec
//canvas
echo '<canvas id="heatmapCanvas_'.$row['id'].'">';
echo '</canvas>';
//Za obmocja
echo '<map id="hotspot_'.$row['id'].'_map" name="hotspot_'.$row['id'].'_usemap">';
while ($rowR = mysqli_fetch_array($sqlR)) {
echo '<area coords="'.$rowR['region_coords'].'" name="'.$rowR['vre_id'].'" shape="poly" href="#">';
}
echo '</map>';
//************************************************************************************************
//izris radio button in checkbox, ki bo skrita in beležila odgovore na sliki
echo '<div id="heatmapCheckbox_'.$row['id'].'">';
RadioCheckboxSelect::getInstance()->display($spremenljivka); //prikaze radio button in checkbox z odgovori
echo '</div>';
//izris radio button in checkbox, ki bo skrita in beležila odgovore na sliki - konec
//***********************************************************************************
//Za obmocja - konec
//GUMBA
echo '<div class="buttonsHeatmap">';
//gumb za resetiranje vseh tock
echo '<input id="resetHeatMapCanvas_'.$row['id'].'" type="button" value="'.$lang['srv_vprasanje_heatmap_reset_canvas'].'">';
echo ' ';
//gumb za resetiranje zadnje tocke
echo '<input id="resetHeatMapLastPoint_'.$row['id'].'" type="button" value="'.$lang['srv_vprasanje_heatmap_reset_last_point'].'">';
echo '</div>';
//GUMBA - konec
//canvas - konec
//div za stevec klikov
if($heatmap_show_counter_clicks){
echo '</br><div id="heatmapClickCounter_'.$spremenljivka.'">';
echo '<div>'.$lang['srv_vprasanje_heatmap_num_clicks'].':</div>';
echo '<div id="heatmapClickNumber_'.$spremenljivka.'" style="float:left">0</div>/'.$heatmap_num_clicks;
echo '</div>';
}
//div za stevec klikov - konec
//div za inpute tock
echo '<div id="heatmapInputs_'.$spremenljivka.'" style="display:none">';
echo '</div>';
//div za inpute tock - konec
?>
<script>
mousePos[<?=$spremenljivka?>] = new Array(2);
indeksMousePos[<?=$spremenljivka?>] = 0;
heatmap_num_clicksGlobal[<?=$spremenljivka?>] = <?=$heatmap_num_clicks?>;
var heatmapDataLength = [];
var refreshed = [];
for(i = 1; i <= <?=$heatmap_num_clicks?>; i++){
mousePos[<?=$spremenljivka?>][i] = 0;
//console.log("mousePos[<?=$spremenljivka?>]["+i+"]: "+mousePos[<?=$spremenljivka?>][i]);
}
$(document).ready(function () {
InitHeatMapCanvas(<?=$spremenljivka?>, <?=$quick_view?>);
//Ta spremenljivka ze vsebuje podatke? primer, ce gre uporabnik na prejsnjo stran ali refresh-a stran
var heatmap_data = JSON.parse('<?php echo json_encode($heatmap_data); ?>');
heatmapDataLength[<?=$spremenljivka?>] = heatmap_data.length; //belezi zacetno dolzino polja
//ce ze obstajajo tocke, jih dodaj na canvas
if (heatmap_data.length > 0){
heatmap_data_add(<?=$spremenljivka?>, heatmap_data, '<?=$heatmap_click_color?>', <?=$heatmap_click_size?>, <?=$heatmap_click_shape?>, <?=$heatmap_show_clicks?>, <?=$heatmap_num_clicks?>);
refreshed[<?=$spremenljivka?>] = 1;
}
});
$('#heatmapCanvas_<?=$spremenljivka?>').click(function (e) {
HeatMapCanvasDelovanje(e, <?=$spremenljivka?>, <?=$heatmap_show_clicks?>, <?=$heatmap_num_clicks?>, '<?=$heatmap_click_color?>', <?=$heatmap_click_size?>, <?=$heatmap_click_shape?>, <?=$quick_view?>);
});
$('#heatmapCanvas_<?=$spremenljivka?>').mouseover(function (e) {
if (heatmap_num_clicksGlobal[<?=$spremenljivka?>] != 0){ //ce je se mozno klikati
$(this).css( 'cursor', 'pointer' ); //ko je se miška nahaja na canvas-u, naj se spremeni v rokico
}
});
//klicanje funkcije za brisanje vseh tock na canvasu
$('#resetHeatMapCanvas_<?=$spremenljivka?>').click(function (e) {
resetHeatMapCanvas(<?=$spremenljivka?>, <?=$heatmap_num_clicks?>, <?=$quick_view?>);
});
//klicanje funkcije za brisanje zadnje izbrane tocke na canvasu
$('#resetHeatMapLastPoint_<?=$spremenljivka?>').click(function (e) {
var heatmap_data = JSON.parse('<?php echo json_encode($heatmap_data); ?>');
resetHeatMapLastPoint(<?=$spremenljivka?>, <?=$heatmap_num_clicks?>, <?=$heatmap_show_clicks?>, '<?=$heatmap_click_color?>', <?=$heatmap_click_size?>, <?=$heatmap_click_shape?>, heatmap_data, <?=$quick_view?>);
});
$('#heatmapCheckbox_<?=$spremenljivka?> .variabla').css("display", "none"); //skrij radio/checkbox button odgovore, kjer se bodo beležili odgovori
</script>
<?
echo '</div>';
echo ' </div>';
}
}
|