Image map image preview creator.
More...
|
| __construct ($imagemap_filename="") |
| ilImagemapPreview constructor More...
|
|
| getAreaCount () |
|
| getPointCount () |
|
| addArea ( $index, $shape, $coords, $title="", $href="", $target="", $visible=true, $linecolor="red", $bordercolor="white", $fillcolor="#FFFFFFA0") |
|
| addPoint ( $index, $coords, $visible=true, $linecolor="red", $bordercolor="white", $fillcolor="#FFFFFFA0") |
|
| getAreaIdent () |
|
| createPreview () |
|
| getPreviewFilename ($imagePath, $baseFileName) |
|
| getImagemap ($title) |
| get imagemap html code note: html code should be placed in template files More...
|
|
Image map image preview creator.
Takes an image and imagemap areas and creates a preview image containing the imagemap areas.
- Author
- Helmut Schottmüller helmu.nosp@m.t.sc.nosp@m.hottm.nosp@m.uell.nosp@m.er@ma.nosp@m.c.co.nosp@m.m
- Version
- $Id$
Definition at line 16 of file class.ilImagemapPreview.php.
◆ __construct()
ilImagemapPreview::__construct |
( |
|
$imagemap_filename = "" | ) |
|
ilImagemapPreview constructor
Creates an instance of the ilImagemapPreview class
- Parameters
-
integer | $id | The database id of a image map question object public |
Definition at line 34 of file class.ilImagemapPreview.php.
References $imagemap_filename, $lng, $preview_filename, array, and ilUtil\ilTempnam().
40 if (!@is_file($this->preview_filename))
43 if (preg_match(
"/.*\.(png|jpg|gif|jpeg)$/", $this->imagemap_filename, $matches))
45 $extension =
"." . $matches[1];
47 include_once
"./Services/Utilities/classes/class.ilUtil.php";
50 $this->areas =
array();
51 $this->points =
array();
52 $this->linewidth_outer = 4;
53 $this->linewidth_inner = 2;
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()
ilImagemapPreview::addArea |
( |
|
$index, |
|
|
|
$shape, |
|
|
|
$coords, |
|
|
|
$title = "" , |
|
|
|
$href = "" , |
|
|
|
$target = "" , |
|
|
|
$visible = true , |
|
|
|
$linecolor = "red" , |
|
|
|
$bordercolor = "white" , |
|
|
|
$fillcolor = "#FFFFFFA0" |
|
) |
| |
Definition at line 66 of file class.ilImagemapPreview.php.
References array.
79 if (ini_get(
"safe_mode"))
81 if ((strpos($fillcolor,
"#") !==
false) ||Â (strpos($fillcolor,
"rgb") !==
false))
83 $fillcolor = str_replace(
"\"",
"", $fillcolor);
86 $this->areas[$index] =
array(
88 "coords" =>
"$coords",
91 "target" =>
"$target",
92 "linecolor" =>
'"' . $linecolor .
'"',
93 "fillcolor" =>
'"' . $fillcolor .
'"',
94 "bordercolor" =>
'"' . $bordercolor .
'"',
95 "visible" => (
int)$visible
Create styles array
The data for the language used.
◆ addPoint()
ilImagemapPreview::addPoint |
( |
|
$index, |
|
|
|
$coords, |
|
|
|
$visible = true , |
|
|
|
$linecolor = "red" , |
|
|
|
$bordercolor = "white" , |
|
|
|
$fillcolor = "#FFFFFFA0" |
|
) |
| |
Definition at line 99 of file class.ilImagemapPreview.php.
References array.
108 $this->points[$index] =
array(
109 "coords" =>
"$coords",
110 "linecolor" =>
'"' . $linecolor .
'"',
111 "fillcolor" =>
'"' . $fillcolor .
'"',
112 "bordercolor" =>
'"' . $bordercolor .
'"',
113 "visible" => (
int)$visible
Create styles array
The data for the language used.
◆ createPreview()
ilImagemapPreview::createPreview |
( |
| ) |
|
Definition at line 136 of file class.ilImagemapPreview.php.
References $r, $target, $x, $y, ilUtil\escapeShellCmd(), and ilUtil\execConvert().
138 if (count($this->areas)+count($this->points)==0)
return;
139 include_once
"./Services/Utilities/classes/class.ilUtil.php";
140 $convert_cmd =
"-quality 100 ";
141 foreach ($this->points as $point)
143 if ($point[
"visible"])
145 preg_match(
"/(\d+)\s*,\s*(\d+)/", $point[
"coords"], $matches);
150 $convert_cmd .=
"-stroke " . $point[
"bordercolor"] .
" -fill " . $point[
"fillcolor"] .
" -strokewidth $this->linewidth_outer -draw \"line " .
152 "-stroke " . $point[
"bordercolor"] .
" -fill " . $point[
"fillcolor"] .
" -strokewidth $this->linewidth_outer -draw \"line " .
154 "-stroke " . $point[
"linecolor"] .
" -fill " . $point[
"fillcolor"] .
" -strokewidth $this->linewidth_inner -draw \"line " .
156 "-stroke " . $point[
"linecolor"] .
" -fill " . $point[
"fillcolor"] .
" -strokewidth $this->linewidth_inner -draw \"line " .
160 foreach ($this->areas as $area)
162 if ($area[
"visible"]
and strcmp(strtolower($area[
"shape"]),
"rect") == 0)
164 preg_match(
"/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/", $area[
"coords"], $matches);
170 $convert_cmd .=
"-stroke " . $area[
"bordercolor"] .
" -fill " . $area[
"fillcolor"] .
" -strokewidth $this->linewidth_outer -draw \"rectangle " .
171 $x0 .
"," . $y0 .
" " . ($x1) .
"," . $y1 .
"\" " .
172 "-stroke " . $area[
"linecolor"] .
" -fill " . $area[
"fillcolor"] .
" -strokewidth $this->linewidth_inner -draw \"rectangle " .
173 $x0 .
"," . $y0 .
" " . ($x1) .
"," . $y1 .
"\" ";
175 else if ($area[
"visible"]
and strcmp(strtolower($area[
"shape"]),
"circle") == 0)
177 preg_match(
"/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/", $area[
"coords"], $matches);
182 $convert_cmd .=
"-stroke " . $area[
"bordercolor"] .
" -fill " . $area[
"fillcolor"] .
" -strokewidth $this->linewidth_outer -draw \"circle " .
183 $x .
"," .
$y .
" " . (
$x+
$r) .
"," .
$y .
"\" " .
184 "-stroke " . $area[
"linecolor"] .
" -fill " . $area[
"fillcolor"] .
" -strokewidth $this->linewidth_inner -draw \"circle " .
185 $x .
"," .
$y .
" " . (
$x+
$r) .
"," .
$y .
"\" ";
187 else if ($area[
"visible"]
and strcmp(strtolower($area[
"shape"]),
"poly") == 0)
191 preg_match_all(
"/(\d+)\s*,\s*(\d+)/", $area[
"coords"], $matches, PREG_PATTERN_ORDER);
192 if (count($matches[0]) == 2) $obj =
"line";
193 $convert_cmd .=
"-stroke " . $area[
"bordercolor"] .
" -fill " . $area[
"fillcolor"] .
" -strokewidth $this->linewidth_outer -draw \"$obj ";
194 for ($i = 0; $i < count($matches[0]); $i++)
196 $convert_cmd .= $matches[1][$i] .
"," . $matches[2][$i] .
" ";
198 $convert_cmd .=
"\" ";
199 $convert_cmd .=
"-stroke " . $area[
"linecolor"] .
" -fill " . $area[
"fillcolor"] .
" -strokewidth $this->linewidth_inner -draw \"$obj ";
200 preg_match_all(
"/(\d+)\s*,\s*(\d+)/", $area[
"coords"], $matches, PREG_PATTERN_ORDER);
201 for ($i = 0; $i < count($matches[0]); $i++)
203 $convert_cmd .= $matches[1][$i] .
"," . $matches[2][$i] .
" ";
205 $convert_cmd .=
"\" ";
211 $convert_cmd = $source .
"[0] " . $convert_cmd.
" ".
$target;
static escapeShellCmd($a_arg)
escape shell cmd
static execConvert($args)
execute convert command
◆ getAreaCount()
ilImagemapPreview::getAreaCount |
( |
| ) |
|
◆ getAreaIdent()
ilImagemapPreview::getAreaIdent |
( |
| ) |
|
Definition at line 117 of file class.ilImagemapPreview.php.
Referenced by getPreviewFilename().
119 if (count($this->areas)+count($this->points) > 0)
121 $arr = array_merge(array_keys($this->areas), array_keys($this->points));
122 sort($arr, SORT_NUMERIC);
124 $inner = join(
"_", $arr);
125 if (strlen($inner) > 32) {
126 $inner = md5($inner);
128 return "preview_" . $inner .
"_";
◆ getImagemap()
ilImagemapPreview::getImagemap |
( |
|
$title | ) |
|
get imagemap html code note: html code should be placed in template files
Definition at line 254 of file class.ilImagemapPreview.php.
256 $map =
"<map name=\"$title\"> ";
257 foreach ($this->areas as $area)
259 $map .=
"<area alt=\"" . $area[
"title"] .
"\" title=\"" . $area[
"title"] .
"\" ";
260 $map .=
"shape=\"" . $area[
"shape"] .
"\" ";
261 $map .=
"coords=\"" . $area[
"coords"] .
"\" ";
264 $map .=
"href=\"" . $area[
"href"] .
"\" ";
267 $map .=
"target=\"" . $area[
"target"] .
"\" ";
273 $map .=
"nohref />\n";
◆ getPointCount()
ilImagemapPreview::getPointCount |
( |
| ) |
|
◆ getPreviewFilename()
ilImagemapPreview::getPreviewFilename |
( |
|
$imagePath, |
|
|
|
$baseFileName |
|
) |
| |
Definition at line 215 of file class.ilImagemapPreview.php.
References $filename, $preview_filename, getAreaIdent(), and ilUtil\sendInfo().
218 if (count($this->areas)+count($this->points)>0)
224 $previewfile = $imagePath . $ident . $baseFileName;
225 if (@md5_file($previewfile) != @md5_file($pfile))
227 if (strlen($ident) > 0)
229 @copy($pfile, $previewfile);
233 if (strlen($pfile) == 0)
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
◆ $areas
ilImagemapPreview::$areas |
◆ $imagemap_filename
ilImagemapPreview::$imagemap_filename |
◆ $linewidth_inner
ilImagemapPreview::$linewidth_inner |
◆ $linewidth_outer
ilImagemapPreview::$linewidth_outer |
◆ $lng
◆ $points
ilImagemapPreview::$points |
◆ $preview_filename
ilImagemapPreview::$preview_filename |
The documentation for this class was generated from the following file: