59 $this->glyph_factory =
$DIC->ui()->factory()->symbol()->glyph();
60 $this->button_factory =
$DIC->ui()->factory()->button();
61 $this->
renderer = $DIC->ui()->renderer();
76 $this->areas = $a_areas;
86 $this->line_color = $a_color;
96 $this->image_path = $a_path;
106 $this->image_path_web = $a_path_web;
111 if (is_array($a_areas[
'name'])) {
113 foreach ($a_areas[
'name'] as $idx => $name) {
115 $pointsUnchecked = $a_areas[
'points_unchecked'][$idx];
117 $pointsUnchecked = 0.0;
122 $a_areas[
'points'][$idx],
124 $a_areas[
'coords'][$idx],
125 $a_areas[
'shape'][$idx],
131 $imagemap->setCoords($a_areas[
'coords'][$idx]);
132 $imagemap->setArea($a_areas[
'shape'][$idx]);
133 $imagemap->setPointsUnchecked($pointsUnchecked);
134 array_push($this->areas, $imagemap);
151 if (isset($a_value[$this->
getPostVar() .
'_name'])) {
154 if (isset($a_value[$this->
getPostVar()][
'coords'])) {
161 parent::setValue($a_value);
166 return parent::getInput();
188 $filename_arr = pathinfo($_FILES[$this->
getPostVar()][
"name"]);
189 $suffix = $filename_arr[
"extension"] ??
'';
190 $mimetype = $_FILES[$this->
getPostVar()][
"type"];
191 $size_bytes = $_FILES[$this->
getPostVar()][
"size"];
192 $temp_name = $_FILES[$this->
getPostVar()][
"tmp_name"];
193 $error = $_FILES[$this->
getPostVar()][
"error"];
198 case UPLOAD_ERR_FORM_SIZE:
199 case UPLOAD_ERR_INI_SIZE:
204 case UPLOAD_ERR_PARTIAL:
209 case UPLOAD_ERR_NO_FILE:
218 case UPLOAD_ERR_NO_TMP_DIR:
223 case UPLOAD_ERR_CANT_WRITE:
228 case UPLOAD_ERR_EXTENSION:
236 if ($_FILES[$this->
getPostVar()][
"tmp_name"] !=
"" &&
238 if (!in_array(strtolower($suffix), $this->
getSuffixes())) {
245 if ($_FILES[$this->
getPostVar()][
"tmp_name"] !=
"") {
247 if ($vir[0] ==
false) {
248 $this->
setAlert(
$lng->
txt(
"form_msg_file_virus_found") .
"<br />" . $vir[1]);
256 if (isset($post_body[
'coords']) && is_array($post_body[
'coords'][
'name'])) {
257 foreach ($post_body[
'coords'][
'name'] as $idx => $name) {
259 !isset($post_body[
'coords'][
'points'][$idx]) ||
260 $post_body[
'coords'][
'points'][$idx] ==
''
266 if ((!is_numeric($post_body[
'coords'][
'points'][$idx]))) {
271 if ($post_body[
'coords'][
'points'][$idx] > 0) {
272 $max = $post_body[
'coords'][
'points'][$idx];
277 if ($max == 0 && (!
$filename) && !$_FILES[
'imagemapfile'][
'tmp_name']) {
291 $template =
new ilTemplate(
"tpl.prop_imagemap_file.html",
true,
true,
"components/ILIAS/TestQuestionPool");
297 $template->setCurrentBlock(
"has_value");
298 $template->setVariable(
"TEXT_IMAGE_NAME", $this->
getValue());
299 $template->setVariable(
"POST_VAR_D", $this->
getPostVar());
300 $template->parseCurrentBlock();
302 $template->setCurrentBlock(
"image");
305 foreach ($this->
getAreas() as $index => $area) {
306 $preview->addArea($index, $area->getArea(), $area->getCoords(), $area->getAnswertext(),
"",
"",
true, $this->getLineColor());
308 $preview->createPreview();
310 $template->setVariable(
"SRC_IMAGE", $imagepath);
312 $template->setVariable(
"SRC_IMAGE", $this->
getImage());
314 $template->setVariable(
"ALT_IMAGE", $this->
getAlt());
315 $template->setVariable(
"POST_VAR_D", $this->
getPostVar());
316 $template->setVariable(
317 "TXT_DELETE_EXISTING",
318 $lng->
txt(
"delete_existing_file")
320 $template->setVariable(
"TEXT_ADD_RECT",
$lng->
txt(
'add_rect'));
321 $template->setVariable(
"TEXT_ADD_CIRCLE",
$lng->
txt(
'add_circle'));
322 $template->setVariable(
"TEXT_ADD_POLY",
$lng->
txt(
'add_poly'));
323 $template->parseCurrentBlock();
328 foreach ($this->
getAreas() as $area) {
329 if (strlen($area->getPoints())) {
330 $template->setCurrentBlock(
'area_points_value');
331 $template->setVariable(
'VALUE_POINTS', $area->getPoints());
332 $template->parseCurrentBlock();
335 if (strlen($area->getPointsUnchecked())) {
336 $template->setCurrentBlock(
'area_points_unchecked_value');
337 $template->setVariable(
'VALUE_POINTS_UNCHECKED', $area->getPointsUnchecked());
338 $template->parseCurrentBlock();
341 $template->setCurrentBlock(
'area_points_unchecked_field');
342 $template->parseCurrentBlock();
344 if (strlen($area->getAnswertext())) {
345 $template->setCurrentBlock(
'area_name_value');
346 $template->setVariable(
'VALUE_NAME', htmlspecialchars($area->getAnswertext()));
347 $template->parseCurrentBlock();
349 $template->setCurrentBlock(
'row');
350 $template->setVariable(
'POST_VAR_R', $this->
getPostVar());
351 $template->setVariable(
'TEXT_SHAPE', strtoupper($area->getArea()));
352 $template->setVariable(
'VALUE_SHAPE', $area->getArea());
353 $coords = preg_replace(
"/(\d+,\d+,)/",
"\$1 ", $area->getCoords());
354 $template->setVariable(
'VALUE_COORDINATES', $area->getCoords());
355 $template->setVariable(
'TEXT_COORDINATES', $coords);
356 $template->setVariable(
"REMOVE_BUTTON", $this->
renderer->render(
357 $this->button_factory->shy(
'',
'')->withSymbol($this->glyph_factory->remove())
359 $template->parseCurrentBlock();
362 $template->setCurrentBlock(
"areas");
363 $template->setVariable(
"TEXT_NAME",
$lng->
txt(
"ass_imap_hint"));
365 $template->setVariable(
"TEXT_POINTS",
$lng->
txt(
"points_checked"));
367 $template->setCurrentBlock(
'area_points_unchecked_head');
368 $template->setVariable(
"TEXT_POINTS_UNCHECKED",
$lng->
txt(
"points_unchecked"));
369 $template->parseCurrentBlock();
371 $template->setVariable(
"TEXT_POINTS",
$lng->
txt(
"points"));
373 $template->setVariable(
"TEXT_SHAPE",
$lng->
txt(
"shape"));
374 $template->setVariable(
"TEXT_COORDINATES",
$lng->
txt(
"coordinates"));
375 $template->setVariable(
"TEXT_COMMANDS",
$lng->
txt(
"actions"));
376 $template->parseCurrentBlock();
379 $template->setVariable(
"POST_VAR", $this->
getPostVar());
380 $template->setVariable(
"ID", $this->
getFieldId());
381 $template->setVariable(
"TXT_BROWSE",
$lng->
txt(
"select_file"));
382 $template->setVariable(
'MAX_SIZE_WARNING', $this->
lng->txt(
'form_msg_file_size_exceeds'));
383 $template->setVariable(
'MAX_SIZE', $this->upload_limit->getPhpUploadLimitInBytes());
384 $template->setVariable(
"TXT_MAX_SIZE",
$lng->
txt(
"file_notice") .
" " .
385 $this->getMaxFileSizeString());
388 $a_tpl->
setVariable(
"PROP_GENERIC", $template->get());
391 $this->tpl->addJavascript(
"assets/js/answerwizardinput.js");
392 $this->tpl->addJavascript(
"assets/js/imagemap.js");
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.
Builds a Color from either hex- or rgb values.
static stripSlashesRecursive($a_data, bool $a_strip_html=true, string $a_allow="")
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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...
special template class to simplify handling of ITX/PEAR
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
static virusHandling(string $a_file, string $a_orig_name='', bool $a_clean=true)
This is how a factory for glyphs looks like.
An entity that renders components to a string output.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc