4 include_once
"./Modules/Test/classes/inc.AssessmentConstants.php";
40 if (!@is_file($this->preview_filename)) {
42 if (preg_match(
"/.*\.(png|jpg|gif|jpeg)$/", $this->imagemap_filename, $matches)) {
43 $extension =
"." . $matches[1];
45 include_once
"./Services/Utilities/classes/class.ilUtil.php";
48 $this->areas =
array();
49 $this->points =
array();
50 $this->linewidth_outer = 4;
51 $this->linewidth_inner = 2;
56 return count($this->areas);
61 return count($this->points);
73 $bordercolor =
"white",
74 $fillcolor =
"#FFFFFFA0" 76 if (ini_get(
"safe_mode")) {
77 if ((strpos($fillcolor,
"#") !==
false) || (strpos($fillcolor,
"rgb") !==
false)) {
78 $fillcolor = str_replace(
"\"",
"", $fillcolor);
83 "coords" =>
"$coords",
86 "target" =>
"$target",
87 "linecolor" =>
'"' . $linecolor .
'"',
88 "fillcolor" =>
'"' . $fillcolor .
'"',
89 "bordercolor" =>
'"' . $bordercolor .
'"',
90 "visible" => (
int) $visible
99 $bordercolor =
"white",
100 $fillcolor =
"#FFFFFFA0" 103 "coords" =>
"$coords",
104 "linecolor" =>
'"' . $linecolor .
'"',
105 "fillcolor" =>
'"' . $fillcolor .
'"',
106 "bordercolor" =>
'"' . $bordercolor .
'"',
107 "visible" => (
int) $visible
113 if (count($this->areas)+count($this->points) > 0) {
114 $arr = array_merge(array_keys($this->areas), array_keys($this->points));
115 sort($arr, SORT_NUMERIC);
117 $inner = join(
"_", $arr);
118 if (strlen($inner) > 32) {
119 $inner = md5($inner);
121 return "preview_" . $inner .
"_";
129 if (count($this->areas)+count($this->points)==0) {
132 include_once
"./Services/Utilities/classes/class.ilUtil.php";
133 $convert_cmd =
"-quality 100 ";
134 foreach ($this->points as $point) {
135 if ($point[
"visible"]) {
136 preg_match(
"/(\d+)\s*,\s*(\d+)/", $point[
"coords"], $matches);
141 $convert_cmd .=
"-stroke " . $point[
"bordercolor"] .
" -fill " . $point[
"fillcolor"] .
" -strokewidth $this->linewidth_outer -draw \"line " .
143 "-stroke " . $point[
"bordercolor"] .
" -fill " . $point[
"fillcolor"] .
" -strokewidth $this->linewidth_outer -draw \"line " .
145 "-stroke " . $point[
"linecolor"] .
" -fill " . $point[
"fillcolor"] .
" -strokewidth $this->linewidth_inner -draw \"line " .
147 "-stroke " . $point[
"linecolor"] .
" -fill " . $point[
"fillcolor"] .
" -strokewidth $this->linewidth_inner -draw \"line " .
151 foreach ($this->areas as $area) {
152 if ($area[
"visible"] and strcmp(strtolower($area[
"shape"]),
"rect") == 0) {
153 preg_match(
"/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/", $area[
"coords"], $matches);
159 $convert_cmd .=
"-stroke " . $area[
"bordercolor"] .
" -fill " . $area[
"fillcolor"] .
" -strokewidth $this->linewidth_outer -draw \"rectangle " .
160 $x0 .
"," . $y0 .
" " . ($x1) .
"," . $y1 .
"\" " .
161 "-stroke " . $area[
"linecolor"] .
" -fill " . $area[
"fillcolor"] .
" -strokewidth $this->linewidth_inner -draw \"rectangle " .
162 $x0 .
"," . $y0 .
" " . ($x1) .
"," . $y1 .
"\" ";
163 } elseif ($area[
"visible"] and strcmp(strtolower($area[
"shape"]),
"circle") == 0) {
164 preg_match(
"/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/", $area[
"coords"], $matches);
169 $convert_cmd .=
"-stroke " . $area[
"bordercolor"] .
" -fill " . $area[
"fillcolor"] .
" -strokewidth $this->linewidth_outer -draw \"circle " .
170 $x .
"," .
$y .
" " . (
$x+
$r) .
"," .
$y .
"\" " .
171 "-stroke " . $area[
"linecolor"] .
" -fill " . $area[
"fillcolor"] .
" -strokewidth $this->linewidth_inner -draw \"circle " .
172 $x .
"," .
$y .
" " . (
$x+
$r) .
"," .
$y .
"\" ";
173 } elseif ($area[
"visible"] and strcmp(strtolower($area[
"shape"]),
"poly") == 0) {
176 preg_match_all(
"/(\d+)\s*,\s*(\d+)/", $area[
"coords"], $matches, PREG_PATTERN_ORDER);
177 if (count($matches[0]) == 2) {
180 $convert_cmd .=
"-stroke " . $area[
"bordercolor"] .
" -fill " . $area[
"fillcolor"] .
" -strokewidth $this->linewidth_outer -draw \"$obj ";
181 for (
$i = 0;
$i < count($matches[0]);
$i++) {
182 $convert_cmd .= $matches[1][
$i] .
"," . $matches[2][
$i] .
" ";
184 $convert_cmd .=
"\" ";
185 $convert_cmd .=
"-stroke " . $area[
"linecolor"] .
" -fill " . $area[
"fillcolor"] .
" -strokewidth $this->linewidth_inner -draw \"$obj ";
186 preg_match_all(
"/(\d+)\s*,\s*(\d+)/", $area[
"coords"], $matches, PREG_PATTERN_ORDER);
187 for (
$i = 0;
$i < count($matches[0]);
$i++) {
188 $convert_cmd .= $matches[1][
$i] .
"," . $matches[2][
$i] .
" ";
190 $convert_cmd .=
"\" ";
203 if (count($this->areas)+count($this->points)>0) {
205 if (is_file($pfile)) {
207 $previewfile = $imagePath . $ident . $baseFileName;
208 if (@md5_file($previewfile) != @md5_file($pfile)) {
209 if (strlen($ident) > 0) {
210 @copy($pfile, $previewfile);
214 if (strlen($pfile) == 0) {
232 $map =
"<map name=\"$title\"> ";
233 foreach ($this->areas as $area) {
234 $map .=
"<area alt=\"" . $area[
"title"] .
"\" title=\"" . $area[
"title"] .
"\" ";
235 $map .=
"shape=\"" . $area[
"shape"] .
"\" ";
236 $map .=
"coords=\"" . $area[
"coords"] .
"\" ";
238 $map .=
"href=\"" . $area[
"href"] .
"\" ";
239 if ($area[
"target"]) {
240 $map .=
"target=\"" . $area[
"target"] .
"\" ";
244 $map .=
"nohref />\n";
getPreviewFilename($imagePath, $baseFileName)
Image map image preview creator.
static escapeShellCmd($a_arg)
escape shell cmd
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
getImagemap($title)
get imagemap html code note: html code should be placed in template files
__construct($imagemap_filename="")
ilImagemapPreview constructor
static execConvert($args)
execute convert command
addPoint( $index, $coords, $visible=true, $linecolor="red", $bordercolor="white", $fillcolor="#FFFFFFA0")
Create styles array
The data for the language used.
static ilTempnam($a_temp_path=null)
Create a temporary file in an ILIAS writable directory.
addArea( $index, $shape, $coords, $title="", $href="", $target="", $visible=true, $linecolor="red", $bordercolor="white", $fillcolor="#FFFFFFA0")