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)) {
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;
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 64 of file class.ilImagemapPreview.php.
References $index, and array.
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
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 94 of file class.ilImagemapPreview.php.
References $index, and array.
103 "coords" =>
"$coords",
104 "linecolor" =>
'"' . $linecolor .
'"',
105 "fillcolor" =>
'"' . $fillcolor .
'"',
106 "bordercolor" =>
'"' . $bordercolor .
'"',
107 "visible" => (
int) $visible
Create styles array
The data for the language used.
◆ createPreview()
ilImagemapPreview::createPreview |
( |
| ) |
|
Definition at line 127 of file class.ilImagemapPreview.php.
References $i, $r, $source, $target, $x, $y, ilUtil\escapeShellCmd(), and ilUtil\execConvert().
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 .=
"\" ";
static escapeShellCmd($a_arg)
escape shell cmd
static execConvert($args)
execute convert command
◆ getAreaCount()
ilImagemapPreview::getAreaCount |
( |
| ) |
|
◆ getAreaIdent()
ilImagemapPreview::getAreaIdent |
( |
| ) |
|
Definition at line 111 of file class.ilImagemapPreview.php.
Referenced by getPreviewFilename().
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 .
"_";
◆ getImagemap()
ilImagemapPreview::getImagemap |
( |
|
$title | ) |
|
get imagemap html code note: html code should be placed in template files
Definition at line 230 of file class.ilImagemapPreview.php.
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";
◆ getPointCount()
ilImagemapPreview::getPointCount |
( |
| ) |
|
◆ getPreviewFilename()
ilImagemapPreview::getPreviewFilename |
( |
|
$imagePath, |
|
|
|
$baseFileName |
|
) |
| |
Definition at line 200 of file class.ilImagemapPreview.php.
References $filename, $preview_filename, getAreaIdent(), and ilUtil\sendInfo().
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) {
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: