ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 function checkInput()
21 {
25 global $lng;
26
27 if(!parent::checkInput())
28 {
29 return false;
30 }
31
32 $tmp_file_name = $_FILES[$this->getPostVar()]['tmp_name'];
33 if(strlen($tmp_file_name) == 0)
34 {
35 return true;
36 }
37
38 if(!is_readable($tmp_file_name))
39 {
40 $this->setAlert($lng->txt('ass_imap_map_file_not_readable'));
41 return false;
42 }
43
44 $contents = file_get_contents($tmp_file_name);
45 $matches = null;
46 if(
47 !preg_match_all('/<area(.+)>/siU', $contents, $matches) ||
48 !is_array($matches) ||
49 !isset($matches[1]) ||
50 count($matches[1]) == 0
51 )
52 {
53 $this->setAlert($lng->txt('ass_imap_no_map_found'));
54 return false;
55 }
56
57 for($i = 0; $i< count($matches[1]); $i++)
58 {
59 preg_match("/alt\s*=\s*\"(.+)\"\s*/siU", $matches[1][$i], $alt);
60 preg_match("/coords\s*=\s*\"(.+)\"\s*/siU", $matches[1][$i], $coords);
61 preg_match("/shape\s*=\s*\"(.+)\"\s*/siU", $matches[1][$i], $shape);
62
63 $this->shapes[] = new ASS_AnswerImagemap($alt[1], 0.0, $i, $coords[1], $shape[1]);
64 }
65
66 return true;
67 }
68
72 public function getShapes()
73 {
74 return $this->shapes;
75 }
76}
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.
$coords
Definition: example_030.php:88
global $lng
Definition: privfeed.php:17