24 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
60 if (!@is_file($this->preview_filename))
63 if (preg_match(
"/.*\.(png|jpg|gif|jpeg)$/", $this->imagemap_filename, $matches))
65 $extension =
"." . $matches[1];
67 include_once
"./Services/Utilities/classes/class.ilUtil.php";
70 $this->areas = array();
71 $this->points = array();
72 $this->linewidth_outer = 4;
73 $this->linewidth_inner = 2;
78 return count($this->areas);
83 return count($this->points);
95 $bordercolor =
"white",
96 $fillcolor =
"#FFFFFFA0"
99 if (ini_get(
"safe_mode"))
101 if ((strpos($fillcolor,
"#") !==
false) || (strpos($fillcolor,
"rgb") !==
false))
103 $fillcolor = str_replace(
"\"",
"", $fillcolor);
106 $this->areas[$index] = array(
108 "coords" =>
"$coords",
111 "target" =>
"$target",
112 "linecolor" =>
'"' . $linecolor .
'"',
113 "fillcolor" =>
'"' . $fillcolor .
'"',
114 "bordercolor" =>
'"' . $bordercolor .
'"',
115 "visible" => (
int)$visible
124 $bordercolor =
"white",
125 $fillcolor =
"#FFFFFFA0"
128 $this->points[$index] = array(
129 "coords" =>
"$coords",
130 "linecolor" =>
'"' . $linecolor .
'"',
131 "fillcolor" =>
'"' . $fillcolor .
'"',
132 "bordercolor" =>
'"' . $bordercolor .
'"',
133 "visible" => (
int)$visible
139 if (count($this->areas)+count($this->points) > 0)
141 $arr = array_merge(array_keys($this->areas), array_keys($this->points));
142 sort($arr, SORT_NUMERIC);
143 return "preview_" . join(
"_", $arr) .
"_";
153 if (count($this->areas)+count($this->points)==0)
return;
154 include_once
"./Services/Utilities/classes/class.ilUtil.php";
156 foreach ($this->points as $point)
158 if ($point[
"visible"])
160 preg_match(
"/(\d+)\s*,\s*(\d+)/", $point[
"coords"], $matches);
165 $convert_cmd .=
"-stroke " . $point[
"bordercolor"] .
" -fill " . $point[
"fillcolor"] .
" -strokewidth $this->linewidth_outer -draw \"line " .
166 (
$x-$r) .
"," . (
$y-$r) .
" " . (
$x+$r) .
"," . (
$y+$r) .
"\" " .
167 "-stroke " . $point[
"bordercolor"] .
" -fill " . $point[
"fillcolor"] .
" -strokewidth $this->linewidth_outer -draw \"line " .
168 (
$x+$r) .
"," . (
$y-$r) .
" " . (
$x-$r) .
"," . (
$y+$r) .
"\" " .
169 "-stroke " . $point[
"linecolor"] .
" -fill " . $point[
"fillcolor"] .
" -strokewidth $this->linewidth_inner -draw \"line " .
170 (
$x-$r) .
"," . (
$y-$r) .
" " . (
$x+$r) .
"," . (
$y+$r) .
"\" " .
171 "-stroke " . $point[
"linecolor"] .
" -fill " . $point[
"fillcolor"] .
" -strokewidth $this->linewidth_inner -draw \"line " .
172 (
$x+$r) .
"," . (
$y-$r) .
" " . (
$x-$r) .
"," . (
$y+$r) .
"\" ";
175 foreach ($this->areas as $area)
177 if ($area[
"visible"] and strcmp(strtolower($area[
"shape"]),
"rect") == 0)
179 preg_match(
"/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/", $area[
"coords"], $matches);
185 $convert_cmd .=
"-stroke " . $area[
"bordercolor"] .
" -fill " . $area[
"fillcolor"] .
" -strokewidth $this->linewidth_outer -draw \"rectangle " .
186 $x0 .
"," . $y0 .
" " . ($x1) .
"," . $y1 .
"\" " .
187 "-stroke " . $area[
"linecolor"] .
" -fill " . $area[
"fillcolor"] .
" -strokewidth $this->linewidth_inner -draw \"rectangle " .
188 $x0 .
"," . $y0 .
" " . ($x1) .
"," . $y1 .
"\" ";
190 else if ($area[
"visible"] and strcmp(strtolower($area[
"shape"]),
"circle") == 0)
192 preg_match(
"/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/", $area[
"coords"], $matches);
197 $convert_cmd .=
"-stroke " . $area[
"bordercolor"] .
" -fill " . $area[
"fillcolor"] .
" -strokewidth $this->linewidth_outer -draw \"circle " .
198 $x .
"," .
$y .
" " . (
$x+$r) .
"," .
$y .
"\" " .
199 "-stroke " . $area[
"linecolor"] .
" -fill " . $area[
"fillcolor"] .
" -strokewidth $this->linewidth_inner -draw \"circle " .
200 $x .
"," .
$y .
" " . (
$x+$r) .
"," .
$y .
"\" ";
202 else if ($area[
"visible"] and strcmp(strtolower($area[
"shape"]),
"poly") == 0)
206 preg_match_all(
"/(\d+)\s*,\s*(\d+)/", $area[
"coords"], $matches, PREG_PATTERN_ORDER);
207 if (count($matches[0]) == 2) $obj =
"line";
208 $convert_cmd .=
"-stroke " . $area[
"bordercolor"] .
" -fill " . $area[
"fillcolor"] .
" -strokewidth $this->linewidth_outer -draw \"$obj ";
209 for ($i = 0; $i < count($matches[0]); $i++)
211 $convert_cmd .= $matches[1][$i] .
"," . $matches[2][$i] .
" ";
213 $convert_cmd .=
"\" ";
214 $convert_cmd .=
"-stroke " . $area[
"linecolor"] .
" -fill " . $area[
"fillcolor"] .
" -strokewidth $this->linewidth_inner -draw \"$obj ";
215 preg_match_all(
"/(\d+)\s*,\s*(\d+)/", $area[
"coords"], $matches, PREG_PATTERN_ORDER);
216 for ($i = 0; $i < count($matches[0]); $i++)
218 $convert_cmd .= $matches[1][$i] .
"," . $matches[2][$i] .
" ";
220 $convert_cmd .=
"\" ";
226 $convert_cmd = $convert_prefix . $convert_cmd . $source .
" " . $target;
227 system($convert_cmd);
233 if (count($this->areas)+count($this->points)>0)
239 $previewfile = $imagePath . $ident . $baseFileName;
240 if (@md5_file($previewfile) != @md5_file($pfile))
242 if (strlen($ident) > 0)
244 @copy($pfile, $previewfile);
248 if (strlen($pfile) == 0)
271 $map =
"<map name=\"$title\"> ";
272 foreach ($this->areas as $area)
274 $map .=
"<area alt=\"" . $area[
"title"] .
"\" title=\"" . $area[
"title"] .
"\" ";
275 $map .=
"shape=\"" . $area[
"shape"] .
"\" ";
276 $map .=
"coords=\"" . $area[
"coords"] .
"\" ";
279 $map .=
"href=\"" . $area[
"href"] .
"\" ";
282 $map .=
"target=\"" . $area[
"target"] .
"\" ";
288 $map .=
"nohref />\n";