ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilHtmlImageMapFileInputGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4require_once 'Services/Form/classes/class.ilFileInputGUI.php';
5require_once 'Modules/TestQuestionPool/classes/class.assAnswerImagemap.php';
6
11{
15 protected $shapes = array();
16
20 public function checkInput()
21 {
25 global $lng;
26
27 if (!parent::checkInput()) {
28 return false;
29 }
30
31 $tmp_file_name = $_FILES[$this->getPostVar()]['tmp_name'];
32 if (strlen($tmp_file_name) == 0) {
33 return true;
34 }
35
36 if (!is_readable($tmp_file_name)) {
37 $this->setAlert($lng->txt('ass_imap_map_file_not_readable'));
38 return false;
39 }
40
41 $contents = file_get_contents($tmp_file_name);
42 $matches = null;
43 if (
44 !preg_match_all('/<area(.+)>/siU', $contents, $matches) ||
45 !is_array($matches) ||
46 !isset($matches[1]) ||
47 count($matches[1]) == 0
48 ) {
49 $this->setAlert($lng->txt('ass_imap_no_map_found'));
50 return false;
51 }
52
53 for ($i = 0; $i< count($matches[1]); $i++) {
54 preg_match("/alt\s*=\s*\"(.+)\"\s*/siU", $matches[1][$i], $alt);
55 preg_match("/coords\s*=\s*\"(.+)\"\s*/siU", $matches[1][$i], $coords);
56 preg_match("/shape\s*=\s*\"(.+)\"\s*/siU", $matches[1][$i], $shape);
57
58 $this->shapes[] = new ASS_AnswerImagemap($alt[1], 0.0, $i, $coords[1], $shape[1]);
59 }
60
61 return true;
62 }
63
67 public function getShapes()
68 {
69 return $this->shapes;
70 }
71}
Class for true/false or yes/no answers.
An exception for terminatinating execution or to throw for unit testing.
This class represents a file property in a property form.
checkInput()
Check input, strip slashes etc.
getPostVar()
Get Post Variable.
setAlert($a_alert)
Set Alert Text.
Class ilHtmlImageMapFileInputGUI.
$i
Definition: disco.tpl.php:19
$coords
Definition: example_030.php:88