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