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 
4 require_once 'Services/Form/classes/class.ilFileInputGUI.php';
5 require_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.
getPostVar()
Get Post Variable.
This class represents a file property in a property form.
Class ilHtmlImageMapFileInputGUI.
$coords
Definition: example_030.php:88
setAlert($a_alert)
Set Alert Text.
checkInput()
Check input, strip slashes etc.
Create styles array
The data for the language used.
global $lng
Definition: privfeed.php:17