57 $this->glyph_factory = $DIC->ui()->factory()->symbol()->glyph();
58 $this->
renderer = $DIC->ui()->renderer();
73 $this->areas = $a_areas;
83 $this->line_color = $a_color;
93 $this->image_path = $a_path;
103 $this->image_path_web = $a_path_web;
108 if (is_array($a_areas[
'name'])) {
110 foreach ($a_areas[
'name'] as $idx => $name) {
112 $pointsUnchecked = $a_areas[
'points_unchecked'][$idx];
114 $pointsUnchecked = 0.0;
119 $a_areas[
'points'][$idx],
121 $a_areas[
'coords'][$idx],
122 $a_areas[
'shape'][$idx],
128 $imagemap->setCoords($a_areas[
'coords'][$idx]);
129 $imagemap->setArea($a_areas[
'shape'][$idx]);
130 $imagemap->setPointsUnchecked($pointsUnchecked);
131 array_push($this->areas, $imagemap);
148 if (isset($a_value[$this->
getPostVar() .
'_name'])) {
151 if (isset($a_value[$this->
getPostVar()][
'coords'])) {
158 parent::setValue($a_value);
163 return parent::getInput();
185 $filename_arr = pathinfo($_FILES[$this->
getPostVar()][
"name"]);
186 $suffix = $filename_arr[
"extension"] ??
'';
187 $mimetype = $_FILES[$this->
getPostVar()][
"type"];
188 $size_bytes = $_FILES[$this->
getPostVar()][
"size"];
189 $temp_name = $_FILES[$this->
getPostVar()][
"tmp_name"];
190 $error = $_FILES[$this->
getPostVar()][
"error"];
195 case UPLOAD_ERR_FORM_SIZE:
196 case UPLOAD_ERR_INI_SIZE:
201 case UPLOAD_ERR_PARTIAL:
206 case UPLOAD_ERR_NO_FILE:
215 case UPLOAD_ERR_NO_TMP_DIR:
220 case UPLOAD_ERR_CANT_WRITE:
225 case UPLOAD_ERR_EXTENSION:
233 if ($_FILES[$this->
getPostVar()][
"tmp_name"] !=
"" &&
235 if (!in_array(strtolower($suffix), $this->
getSuffixes())) {
242 if ($_FILES[$this->
getPostVar()][
"tmp_name"] !=
"") {
244 if ($vir[0] ==
false) {
245 $this->
setAlert(
$lng->
txt(
"form_msg_file_virus_found") .
"<br />" . $vir[1]);
253 if (isset($post_body[
'coords']) && is_array($post_body[
'coords'][
'name'])) {
254 foreach ($post_body[
'coords'][
'name'] as $idx => $name) {
256 !isset($post_body[
'coords'][
'points'][$idx]) ||
257 $post_body[
'coords'][
'points'][$idx] ==
'' 263 if ((!is_numeric($post_body[
'coords'][
'points'][$idx]))) {
268 if ($post_body[
'coords'][
'points'][$idx] > 0) {
269 $max = $post_body[
'coords'][
'points'][$idx];
274 if ($max == 0 && (!
$filename) && !$_FILES[
'imagemapfile'][
'tmp_name']) {
288 $template =
new ilTemplate(
"tpl.prop_imagemap_file.html",
true,
true,
"components/ILIAS/TestQuestionPool");
294 $template->setCurrentBlock(
"has_value");
295 $template->setVariable(
"TEXT_IMAGE_NAME", $this->
getValue());
296 $template->setVariable(
"POST_VAR_D", $this->
getPostVar());
297 $template->parseCurrentBlock();
299 $template->setCurrentBlock(
"image");
302 foreach ($this->
getAreas() as $index => $area) {
303 $preview->addArea($index, $area->getArea(), $area->getCoords(), $area->getAnswertext(),
"",
"",
true, $this->
getLineColor());
305 $preview->createPreview();
307 $template->setVariable(
"SRC_IMAGE", $imagepath);
309 $template->setVariable(
"SRC_IMAGE", $this->
getImage());
311 $template->setVariable(
"ALT_IMAGE", $this->
getAlt());
312 $template->setVariable(
"POST_VAR_D", $this->
getPostVar());
313 $template->setVariable(
314 "TXT_DELETE_EXISTING",
315 $lng->
txt(
"delete_existing_file")
317 $template->setVariable(
"TEXT_ADD_RECT",
$lng->
txt(
'add_rect'));
318 $template->setVariable(
"TEXT_ADD_CIRCLE",
$lng->
txt(
'add_circle'));
319 $template->setVariable(
"TEXT_ADD_POLY",
$lng->
txt(
'add_poly'));
320 $template->parseCurrentBlock();
325 foreach ($this->
getAreas() as $area) {
326 if (strlen($area->getPoints())) {
327 $template->setCurrentBlock(
'area_points_value');
328 $template->setVariable(
'VALUE_POINTS', $area->getPoints());
329 $template->parseCurrentBlock();
332 if (strlen($area->getPointsUnchecked())) {
333 $template->setCurrentBlock(
'area_points_unchecked_value');
334 $template->setVariable(
'VALUE_POINTS_UNCHECKED', $area->getPointsUnchecked());
335 $template->parseCurrentBlock();
338 $template->setCurrentBlock(
'area_points_unchecked_field');
339 $template->parseCurrentBlock();
341 if (strlen($area->getAnswertext())) {
342 $template->setCurrentBlock(
'area_name_value');
343 $template->setVariable(
'VALUE_NAME', htmlspecialchars($area->getAnswertext()));
344 $template->parseCurrentBlock();
346 $template->setCurrentBlock(
'row');
347 $template->setVariable(
'POST_VAR_R', $this->
getPostVar());
348 $template->setVariable(
'TEXT_SHAPE', strtoupper($area->getArea()));
349 $template->setVariable(
'VALUE_SHAPE', $area->getArea());
350 $coords = preg_replace(
"/(\d+,\d+,)/",
"\$1 ", $area->getCoords());
351 $template->setVariable(
'VALUE_COORDINATES', $area->getCoords());
352 $template->setVariable(
'TEXT_COORDINATES', $coords);
353 $template->setVariable(
"REMOVE_BUTTON", $this->
renderer->render(
354 $this->glyph_factory->remove()->withAction(
'#')
356 $template->parseCurrentBlock();
359 $template->setCurrentBlock(
"areas");
360 $template->setVariable(
"TEXT_NAME",
$lng->
txt(
"ass_imap_hint"));
362 $template->setVariable(
"TEXT_POINTS",
$lng->
txt(
"points_checked"));
364 $template->setCurrentBlock(
'area_points_unchecked_head');
365 $template->setVariable(
"TEXT_POINTS_UNCHECKED",
$lng->
txt(
"points_unchecked"));
366 $template->parseCurrentBlock();
368 $template->setVariable(
"TEXT_POINTS",
$lng->
txt(
"points"));
370 $template->setVariable(
"TEXT_SHAPE",
$lng->
txt(
"shape"));
371 $template->setVariable(
"TEXT_COORDINATES",
$lng->
txt(
"coordinates"));
372 $template->setVariable(
"TEXT_COMMANDS",
$lng->
txt(
"actions"));
373 $template->parseCurrentBlock();
376 $template->setVariable(
"POST_VAR", $this->
getPostVar());
377 $template->setVariable(
"ID", $this->
getFieldId());
378 $template->setVariable(
"TXT_BROWSE",
$lng->
txt(
"select_file"));
379 $template->setVariable(
'MAX_SIZE_WARNING', $this->
lng->txt(
'form_msg_file_size_exceeds'));
380 $template->setVariable(
'MAX_SIZE', $this->upload_limit->getPhpUploadLimitInBytes());
381 $template->setVariable(
"TXT_MAX_SIZE",
$lng->
txt(
"file_notice") .
" " .
385 $a_tpl->
setVariable(
"PROP_GENERIC", $template->get());
388 $this->tpl->addJavascript(
"assets/js/answerwizardinput.js");
389 $this->tpl->addJavascript(
"assets/js/imagemap.js");
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
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)
__construct(Container $dic, ilPlugin $plugin)