11 include_once
"./Services/Form/classes/class.ilImageFileInputGUI.php";
47 $this->areas = $a_areas;
57 $this->line_color = $a_color;
67 $this->image_path = $a_path;
77 $this->image_path_web = $a_path_web;
82 if (is_array($a_areas[
'name']))
84 $this->areas = array();
85 include_once
"./Modules/TestQuestionPool/classes/class.assAnswerImagemap.php";
86 foreach ($a_areas[
'name'] as $idx => $name)
90 $pointsUnchecked = $a_areas[
'points_unchecked'][$idx];
94 $pointsUnchecked = 0.0;
99 $a_areas[
'points'][$idx],
101 $a_areas[
'coords'][$idx], $a_areas[
'shape'][$idx],
141 while (substr($_FILES[$this->
getPostVar()][
"name"],-1) ==
'/')
147 $filename_arr = pathinfo($_FILES[$this->
getPostVar()][
"name"]);
148 $suffix = $filename_arr[
"extension"];
149 $mimetype = $_FILES[$this->
getPostVar()][
"type"];
150 $size_bytes = $_FILES[$this->
getPostVar()][
"size"];
151 $temp_name = $_FILES[$this->
getPostVar()][
"tmp_name"];
152 $error = $_FILES[$this->
getPostVar()][
"error"];
159 case UPLOAD_ERR_INI_SIZE:
160 $this->
setAlert($lng->txt(
"form_msg_file_size_exceeds"));
164 case UPLOAD_ERR_FORM_SIZE:
165 $this->
setAlert($lng->txt(
"form_msg_file_size_exceeds"));
169 case UPLOAD_ERR_PARTIAL:
170 $this->
setAlert($lng->txt(
"form_msg_file_partially_uploaded"));
174 case UPLOAD_ERR_NO_FILE:
179 $this->
setAlert($lng->txt(
"form_msg_file_no_upload"));
185 case UPLOAD_ERR_NO_TMP_DIR:
186 $this->
setAlert($lng->txt(
"form_msg_file_missing_tmp_dir"));
190 case UPLOAD_ERR_CANT_WRITE:
191 $this->
setAlert($lng->txt(
"form_msg_file_cannot_write_to_disk"));
195 case UPLOAD_ERR_EXTENSION:
196 $this->
setAlert($lng->txt(
"form_msg_file_upload_stopped_ext"));
203 if ($_FILES[$this->
getPostVar()][
"tmp_name"] !=
"" &&
206 if (!in_array(strtolower($suffix), $this->
getSuffixes()))
208 $this->
setAlert($lng->txt(
"form_msg_file_wrong_file_type"));
214 if ($_FILES[$this->
getPostVar()][
"tmp_name"] !=
"")
217 if ($vir[0] ==
false)
219 $this->
setAlert($lng->txt(
"form_msg_file_virus_found").
"<br />".$vir[1]);
229 if ((!strlen(
$_POST[$this->
getPostVar()][
'coords'][
'points'][$idx])) && ($this->getRequired))
231 $this->
setAlert($lng->txt(
'form_msg_area_missing_points'));
236 $this->
setAlert($lng->txt(
'form_msg_numeric_value_required'));
245 $this->
setAlert($lng->txt(
"enter_enough_positive_points"));
258 $template =
new ilTemplate(
"tpl.prop_imagemap_file.html",
true,
true,
"Modules/TestQuestionPool");
266 $template->setCurrentBlock(
"has_value");
267 $template->setVariable(
"TEXT_IMAGE_NAME", $this->
getValue());
268 $template->setVariable(
"POST_VAR_D", $this->
getPostVar());
269 $template->parseCurrentBlock();
271 $template->setCurrentBlock(
"image");
274 include_once
"./Modules/TestQuestionPool/classes/class.ilImagemapPreview.php";
276 foreach ($this->
getAreas() as $index => $area)
278 $preview->addArea($index, $area->getArea(), $area->getCoords(), $area->getAnswertext(),
"",
"",
true, $this->
getLineColor());
282 $template->setVariable(
"SRC_IMAGE", $imagepath);
286 $template->setVariable(
"SRC_IMAGE", $this->
getImage());
288 $template->setVariable(
"ALT_IMAGE", $this->
getAlt());
289 $template->setVariable(
"POST_VAR_D", $this->
getPostVar());
290 $template->setVariable(
"TXT_DELETE_EXISTING",
291 $lng->txt(
"delete_existing_file"));
292 $template->setVariable(
"TEXT_ADD_RECT", $lng->txt(
'add_rect'));
293 $template->setVariable(
"TEXT_ADD_CIRCLE", $lng->txt(
'add_circle'));
294 $template->setVariable(
"TEXT_ADD_POLY", $lng->txt(
'add_poly'));
295 $template->parseCurrentBlock();
301 foreach ($this->
getAreas() as $area)
303 if (strlen($area->getPoints()))
305 $template->setCurrentBlock(
'area_points_value');
306 $template->setVariable(
'VALUE_POINTS', $area->getPoints());
307 $template->parseCurrentBlock();
311 if (strlen($area->getPointsUnchecked()))
313 $template->setCurrentBlock(
'area_points_unchecked_value');
314 $template->setVariable(
'VALUE_POINTS_UNCHECKED', $area->getPointsUnchecked());
315 $template->parseCurrentBlock();
318 $template->setCurrentBlock(
'area_points_unchecked_field');
319 $template->parseCurrentBlock();
321 if (strlen($area->getAnswertext()))
323 $template->setCurrentBlock(
'area_name_value');
324 $template->setVariable(
'VALUE_NAME', $area->getAnswertext());
325 $template->parseCurrentBlock();
327 $template->setCurrentBlock(
'row');
328 $class = ($counter % 2 == 0) ?
"tblrow1" :
"tblrow2";
329 if ($counter == 0) $class .=
" first";
330 if ($counter == count($this->
getAreas())-1) $class .=
" last";
331 $template->setVariable(
"ROW_CLASS", $class);
332 $template->setVariable(
'POST_VAR_R', $this->
getPostVar());
333 $template->setVariable(
'TEXT_SHAPE', strtoupper($area->getArea()));
334 $template->setVariable(
'VALUE_SHAPE', $area->getArea());
335 $coords = preg_replace(
"/(\d+,\d+,)/",
"\$1 ", $area->getCoords());
336 $template->setVariable(
'VALUE_COORDINATES', $area->getCoords());
337 $template->setVariable(
'TEXT_COORDINATES', $coords);
338 $template->setVariable(
'COUNTER', $counter);
340 $template->parseCurrentBlock();
343 $template->setCurrentBlock(
"areas");
344 $template->setVariable(
"TEXT_NAME", $lng->txt(
"hint"));
347 $template->setVariable(
"TEXT_POINTS", $lng->txt(
"points_checked"));
349 $template->setCurrentBlock(
'area_points_unchecked_head');
350 $template->setVariable(
"TEXT_POINTS_UNCHECKED", $lng->txt(
"points_unchecked"));
351 $template->parseCurrentBlock();
355 $template->setVariable(
"TEXT_POINTS", $lng->txt(
"points"));
357 $template->setVariable(
"TEXT_SHAPE", $lng->txt(
"shape"));
358 $template->setVariable(
"TEXT_COORDINATES", $lng->txt(
"coordinates"));
359 $template->setVariable(
"TEXT_COMMANDS", $lng->txt(
"actions"));
360 $template->parseCurrentBlock();
363 $template->setVariable(
"POST_VAR", $this->
getPostVar());
364 $template->setVariable(
"ID", $this->
getFieldId());
365 $template->setVariable(
"TXT_MAX_SIZE", $lng->txt(
"file_notice").
" ".
368 $a_tpl->setCurrentBlock(
"prop_generic");
369 $a_tpl->setVariable(
"PROP_GENERIC", $template->get());
370 $a_tpl->parseCurrentBlock();
373 include_once
"./Services/YUI/classes/class.ilYuiUtil.php";
375 $tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/imagemap.js");