11 include_once
"./Services/Form/classes/class.ilImageFileInputGUI.php";
35 $this->areas = $a_areas;
55 $this->image_path = $a_path;
65 $this->image_path_web = $a_path_web;
70 if (is_array($a_areas[
'name']))
72 $this->areas = array();
73 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerImagemap.php";
74 foreach ($a_areas[
'name'] as $idx => $name)
76 array_push($this->areas,
new ASS_AnswerImagemap($name, $a_areas[
'points'][$idx], $idx, $a_areas[
'coords'][$idx], $a_areas[
'shape'][$idx]));
113 while (substr($_FILES[$this->
getPostVar()][
"name"],-1) ==
'/')
119 $filename_arr = pathinfo($_FILES[$this->
getPostVar()][
"name"]);
120 $suffix = $filename_arr[
"extension"];
121 $mimetype = $_FILES[$this->
getPostVar()][
"type"];
122 $size_bytes = $_FILES[$this->
getPostVar()][
"size"];
123 $temp_name = $_FILES[$this->
getPostVar()][
"tmp_name"];
124 $error = $_FILES[$this->
getPostVar()][
"error"];
131 case UPLOAD_ERR_INI_SIZE:
132 $this->
setAlert($lng->txt(
"form_msg_file_size_exceeds"));
136 case UPLOAD_ERR_FORM_SIZE:
137 $this->
setAlert($lng->txt(
"form_msg_file_size_exceeds"));
141 case UPLOAD_ERR_PARTIAL:
142 $this->
setAlert($lng->txt(
"form_msg_file_partially_uploaded"));
146 case UPLOAD_ERR_NO_FILE:
151 $this->
setAlert($lng->txt(
"form_msg_file_no_upload"));
157 case UPLOAD_ERR_NO_TMP_DIR:
158 $this->
setAlert($lng->txt(
"form_msg_file_missing_tmp_dir"));
162 case UPLOAD_ERR_CANT_WRITE:
163 $this->
setAlert($lng->txt(
"form_msg_file_cannot_write_to_disk"));
167 case UPLOAD_ERR_EXTENSION:
168 $this->
setAlert($lng->txt(
"form_msg_file_upload_stopped_ext"));
175 if ($_FILES[$this->
getPostVar()][
"tmp_name"] !=
"" &&
178 if (!in_array(strtolower($suffix), $this->
getSuffixes()))
180 $this->
setAlert($lng->txt(
"form_msg_file_wrong_file_type"));
186 if ($_FILES[$this->
getPostVar()][
"tmp_name"] !=
"")
189 if ($vir[0] ==
false)
191 $this->
setAlert($lng->txt(
"form_msg_file_virus_found").
"<br />".$vir[1]);
201 if ((!strlen(
$_POST[$this->
getPostVar()][
'coords'][
'points'][$idx])) && ($this->getRequired))
203 $this->
setAlert($lng->txt(
'form_msg_area_missing_points'));
208 $this->
setAlert($lng->txt(
'form_msg_numeric_value_required'));
217 $this->
setAlert($lng->txt(
"enter_enough_positive_points"));
230 $template =
new ilTemplate(
"tpl.prop_imagemap_file.html",
true,
true,
"Modules/TestQuestionPool");
238 $template->setCurrentBlock(
"has_value");
239 $template->setVariable(
"TEXT_IMAGE_NAME", $this->
getValue());
240 $template->setVariable(
"POST_VAR_D", $this->
getPostVar());
241 $template->parseCurrentBlock();
243 $template->setCurrentBlock(
"image");
246 include_once
"./Modules/TestQuestionPool/classes/class.ilImagemapPreview.php";
248 foreach ($this->
getAreas() as $index => $area)
250 $preview->addArea($index, $area->getArea(), $area->getCoords(), $area->getAnswertext(),
"",
"",
true, $this->
getLineColor());
254 $template->setVariable(
"SRC_IMAGE", $imagepath);
258 $template->setVariable(
"SRC_IMAGE", $this->
getImage());
260 $template->setVariable(
"ALT_IMAGE", $this->
getAlt());
261 $template->setVariable(
"POST_VAR_D", $this->
getPostVar());
262 $template->setVariable(
"TXT_DELETE_EXISTING",
263 $lng->txt(
"delete_existing_file"));
264 $template->setVariable(
"TEXT_ADD_RECT", $lng->txt(
'add_rect'));
265 $template->setVariable(
"TEXT_ADD_CIRCLE", $lng->txt(
'add_circle'));
266 $template->setVariable(
"TEXT_ADD_POLY", $lng->txt(
'add_poly'));
267 $template->parseCurrentBlock();
273 foreach ($this->
getAreas() as $area)
275 if (strlen($area->getPoints()))
277 $template->setCurrentBlock(
'area_points_value');
278 $template->setVariable(
'VALUE_POINTS', $area->getPoints());
279 $template->parseCurrentBlock();
281 if (strlen($area->getAnswertext()))
283 $template->setCurrentBlock(
'area_name_value');
284 $template->setVariable(
'VALUE_NAME', $area->getAnswertext());
285 $template->parseCurrentBlock();
287 $template->setCurrentBlock(
'row');
288 $class = ($counter % 2 == 0) ?
"even" :
"odd";
289 if ($counter == 0) $class .=
" first";
290 if ($counter == count($this->
getAreas())-1) $class .=
" last";
291 $template->setVariable(
"ROW_CLASS", $class);
292 $template->setVariable(
'POST_VAR_R', $this->
getPostVar());
293 $template->setVariable(
'TEXT_SHAPE', strtoupper($area->getArea()));
294 $template->setVariable(
'VALUE_SHAPE', $area->getArea());
295 $coords = preg_replace(
"/(\d+,\d+,)/",
"\$1 ", $area->getCoords());
296 $template->setVariable(
'VALUE_COORDINATES', $area->getCoords());
297 $template->setVariable(
'TEXT_COORDINATES', $coords);
298 $template->setVariable(
'COUNTER', $counter);
300 $template->parseCurrentBlock();
303 $template->setCurrentBlock(
"areas");
304 $template->setVariable(
"TEXT_NAME", $lng->txt(
"hint"));
305 $template->setVariable(
"TEXT_POINTS", $lng->txt(
"points"));
306 $template->setVariable(
"TEXT_SHAPE", $lng->txt(
"shape"));
307 $template->setVariable(
"TEXT_COORDINATES", $lng->txt(
"coordinates"));
308 $template->setVariable(
"TEXT_COMMANDS", $lng->txt(
"actions"));
309 $template->parseCurrentBlock();
312 $template->setVariable(
"POST_VAR", $this->
getPostVar());
313 $template->setVariable(
"ID", $this->
getFieldId());
314 $template->setVariable(
"TXT_MAX_SIZE", $lng->txt(
"file_notice").
" ".
317 $a_tpl->setCurrentBlock(
"prop_generic");
318 $a_tpl->setVariable(
"PROP_GENERIC", $template->get());
319 $a_tpl->parseCurrentBlock();
322 include_once
"./Services/YUI/classes/class.ilYuiUtil.php";
324 $tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/imagemap.js");