52 $this->glyph_factory = $DIC->ui()->factory()->symbol()->glyph();
53 $this->renderer = $DIC->ui()->renderer();
68 $this->areas = $a_areas;
78 $this->line_color = $a_color;
88 $this->image_path = $a_path;
98 $this->image_path_web = $a_path_web;
103 if (is_array($a_areas[
'name'])) {
104 $this->areas = array();
105 foreach ($a_areas[
'name'] as $idx => $name) {
107 $pointsUnchecked = $a_areas[
'points_unchecked'][$idx];
109 $pointsUnchecked = 0.0;
114 $a_areas[
'points'][$idx],
116 $a_areas[
'coords'][$idx],
117 $a_areas[
'shape'][$idx],
123 $imagemap->setCoords($a_areas[
'coords'][$idx]);
124 $imagemap->setArea($a_areas[
'shape'][$idx]);
125 $imagemap->setPointsUnchecked($pointsUnchecked);
126 array_push($this->areas, $imagemap);
143 if (isset($a_value[$this->
getPostVar() .
'_name'])) {
146 if (isset($a_value[$this->
getPostVar()][
'coords'])) {
153 parent::setValue($a_value);
158 return parent::getInput();
180 $filename_arr = pathinfo($_FILES[$this->
getPostVar()][
"name"]);
181 $suffix = $filename_arr[
"extension"] ??
'';
182 $mimetype = $_FILES[$this->
getPostVar()][
"type"];
183 $size_bytes = $_FILES[$this->
getPostVar()][
"size"];
184 $temp_name = $_FILES[$this->
getPostVar()][
"tmp_name"];
185 $error = $_FILES[$this->
getPostVar()][
"error"];
190 case UPLOAD_ERR_FORM_SIZE:
191 case UPLOAD_ERR_INI_SIZE:
196 case UPLOAD_ERR_PARTIAL:
201 case UPLOAD_ERR_NO_FILE:
210 case UPLOAD_ERR_NO_TMP_DIR:
215 case UPLOAD_ERR_CANT_WRITE:
220 case UPLOAD_ERR_EXTENSION:
228 if ($_FILES[$this->
getPostVar()][
"tmp_name"] !=
"" &&
230 if (!in_array(strtolower($suffix), $this->
getSuffixes())) {
237 if ($_FILES[$this->
getPostVar()][
"tmp_name"] !=
"") {
239 if ($vir[0] ==
false) {
240 $this->
setAlert(
$lng->
txt(
"form_msg_file_virus_found") .
"<br />" . $vir[1]);
248 if (isset($post_body[
'coords']) && is_array($post_body[
'coords'][
'name'])) {
249 foreach ($post_body[
'coords'][
'name'] as $idx => $name) {
251 !isset($post_body[
'coords'][
'points'][$idx]) ||
252 $post_body[
'coords'][
'points'][$idx] ==
'' 258 if ((!is_numeric($post_body[
'coords'][
'points'][$idx]))) {
263 if ($post_body[
'coords'][
'points'][$idx] > 0) {
264 $max = $post_body[
'coords'][
'points'][$idx];
269 if ($max == 0 && (!
$filename) && !$_FILES[
'imagemapfile'][
'tmp_name']) {
283 $template =
new ilTemplate(
"tpl.prop_imagemap_file.html",
true,
true,
"Modules/TestQuestionPool");
289 $template->setCurrentBlock(
"has_value");
290 $template->setVariable(
"TEXT_IMAGE_NAME", $this->
getValue());
291 $template->setVariable(
"POST_VAR_D", $this->
getPostVar());
292 $template->parseCurrentBlock();
294 $template->setCurrentBlock(
"image");
297 foreach ($this->
getAreas() as $index => $area) {
298 $preview->addArea($index, $area->getArea(), $area->getCoords(), $area->getAnswertext(),
"",
"",
true, $this->
getLineColor());
300 $preview->createPreview();
302 $template->setVariable(
"SRC_IMAGE", $imagepath);
304 $template->setVariable(
"SRC_IMAGE", $this->
getImage());
306 $template->setVariable(
"ALT_IMAGE", $this->
getAlt());
307 $template->setVariable(
"POST_VAR_D", $this->
getPostVar());
308 $template->setVariable(
309 "TXT_DELETE_EXISTING",
310 $lng->
txt(
"delete_existing_file")
312 $template->setVariable(
"TEXT_ADD_RECT",
$lng->
txt(
'add_rect'));
313 $template->setVariable(
"TEXT_ADD_CIRCLE",
$lng->
txt(
'add_circle'));
314 $template->setVariable(
"TEXT_ADD_POLY",
$lng->
txt(
'add_poly'));
315 $template->parseCurrentBlock();
320 foreach ($this->
getAreas() as $area) {
321 if (strlen($area->getPoints())) {
322 $template->setCurrentBlock(
'area_points_value');
323 $template->setVariable(
'VALUE_POINTS', $area->getPoints());
324 $template->parseCurrentBlock();
327 if (strlen($area->getPointsUnchecked())) {
328 $template->setCurrentBlock(
'area_points_unchecked_value');
329 $template->setVariable(
'VALUE_POINTS_UNCHECKED', $area->getPointsUnchecked());
330 $template->parseCurrentBlock();
333 $template->setCurrentBlock(
'area_points_unchecked_field');
334 $template->parseCurrentBlock();
336 if (strlen($area->getAnswertext())) {
337 $template->setCurrentBlock(
'area_name_value');
338 $template->setVariable(
'VALUE_NAME', htmlspecialchars($area->getAnswertext()));
339 $template->parseCurrentBlock();
341 $template->setCurrentBlock(
'row');
342 $template->setVariable(
'POST_VAR_R', $this->
getPostVar());
343 $template->setVariable(
'TEXT_SHAPE', strtoupper($area->getArea()));
344 $template->setVariable(
'VALUE_SHAPE', $area->getArea());
345 $coords = preg_replace(
"/(\d+,\d+,)/",
"\$1 ", $area->getCoords());
346 $template->setVariable(
'VALUE_COORDINATES', $area->getCoords());
347 $template->setVariable(
'TEXT_COORDINATES', $coords);
348 $template->setVariable(
"REMOVE_BUTTON", $this->renderer->render(
349 $this->glyph_factory->remove()->withAction(
'#')
351 $template->parseCurrentBlock();
354 $template->setCurrentBlock(
"areas");
355 $template->setVariable(
"TEXT_NAME",
$lng->
txt(
"ass_imap_hint"));
357 $template->setVariable(
"TEXT_POINTS",
$lng->
txt(
"points_checked"));
359 $template->setCurrentBlock(
'area_points_unchecked_head');
360 $template->setVariable(
"TEXT_POINTS_UNCHECKED",
$lng->
txt(
"points_unchecked"));
361 $template->parseCurrentBlock();
363 $template->setVariable(
"TEXT_POINTS",
$lng->
txt(
"points"));
365 $template->setVariable(
"TEXT_SHAPE",
$lng->
txt(
"shape"));
366 $template->setVariable(
"TEXT_COORDINATES",
$lng->
txt(
"coordinates"));
367 $template->setVariable(
"TEXT_COMMANDS",
$lng->
txt(
"actions"));
368 $template->parseCurrentBlock();
371 $template->setVariable(
"POST_VAR", $this->
getPostVar());
372 $template->setVariable(
"ID", $this->
getFieldId());
373 $template->setVariable(
"TXT_BROWSE",
$lng->
txt(
"select_file"));
374 $template->setVariable(
'MAX_SIZE_WARNING', $this->
lng->txt(
'form_msg_file_size_exceeds'));
375 $template->setVariable(
'MAX_SIZE', $this->upload_limit->getPhpUploadLimitInBytes());
376 $template->setVariable(
"TXT_MAX_SIZE",
$lng->
txt(
"file_notice") .
" " .
380 $a_tpl->
setVariable(
"PROP_GENERIC", $template->get());
383 $this->tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/answerwizardinput.js");
384 $this->tpl->addJavascript(
"./Modules/TestQuestionPool/templates/default/imagemap.js");
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
An entity that renders components to a string output.
static stripSlashesRecursive($a_data, bool $a_strip_html=true, string $a_allow="")
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static virusHandling(string $a_file, string $a_orig_name='', bool $a_clean=true)
This is how a factory for glyphs looks like.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setVariable($variable, $value='')
Sets a variable value.
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)