This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.
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...
|
|
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.
ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.
If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning 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 31 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 50 of file class.ilImagemapPreview.php.
References $DIC, $imagemap_filename, $lng, ilFileUtils\ilTempnam(), and ILIAS\Repository\lng().
53 $this->main_tpl = $DIC->ui()->mainTemplate();
58 if (!@is_file($this->preview_filename)) {
60 if (preg_match(
"/.*\.(png|jpg|gif|jpeg)$/", $this->imagemap_filename, $matches)) {
61 $extension =
"." . $matches[1];
63 include_once
"./Services/Utilities/classes/class.ilUtil.php";
66 $this->areas = array();
67 $this->points = array();
68 $this->linewidth_outer = 4;
69 $this->linewidth_inner = 2;
static ilTempnam(?string $a_temp_path=null)
Returns a unique and non existing Path for e temporary file or directory.
◆ addArea()
ilImagemapPreview::addArea |
( |
|
$index, |
|
|
|
$shape, |
|
|
|
$coords, |
|
|
|
$title = "" , |
|
|
|
$href = "" , |
|
|
|
$target = "" , |
|
|
|
$visible = true , |
|
|
|
$linecolor = "red" , |
|
|
|
$bordercolor = "white" , |
|
|
|
$fillcolor = "#FFFFFFA0" |
|
) |
| |
Definition at line 82 of file class.ilImagemapPreview.php.
References $index.
94 if (ini_get(
"safe_mode")) {
95 if ((strpos($fillcolor,
"#") !==
false) || (strpos($fillcolor,
"rgb") !==
false)) {
96 $fillcolor = str_replace(
"\"",
"", $fillcolor);
99 $this->areas[
$index] = array(
101 "coords" =>
"$coords",
102 "title" => htmlspecialchars($title),
104 "target" =>
"$target",
105 "linecolor" =>
'"' . $linecolor .
'"',
106 "fillcolor" =>
'"' . $fillcolor .
'"',
107 "bordercolor" =>
'"' . $bordercolor .
'"',
108 "visible" => (
int) $visible
◆ addPoint()
ilImagemapPreview::addPoint |
( |
|
$index, |
|
|
|
$coords, |
|
|
|
$visible = true , |
|
|
|
$linecolor = "red" , |
|
|
|
$bordercolor = "white" , |
|
|
|
$fillcolor = "#FFFFFFA0" |
|
) |
| |
Definition at line 112 of file class.ilImagemapPreview.php.
References $index.
120 $this->points[
$index] = array(
121 "coords" =>
"$coords",
122 "linecolor" =>
'"' . $linecolor .
'"',
123 "fillcolor" =>
'"' . $fillcolor .
'"',
124 "bordercolor" =>
'"' . $bordercolor .
'"',
125 "visible" => (
int) $visible
◆ createPreview()
ilImagemapPreview::createPreview |
( |
| ) |
|
Definition at line 145 of file class.ilImagemapPreview.php.
References $i, $source, escapeShellCmd(), and execQuoted().
147 if (count($this->areas) + count($this->points) == 0) {
150 include_once
"./Services/Utilities/classes/class.ilUtil.php";
151 $convert_cmd =
"-quality 100 ";
152 foreach ($this->points as $point) {
153 if ($point[
"visible"]) {
154 preg_match(
"/(\d+)\s*,\s*(\d+)/", $point[
"coords"], $matches);
159 $convert_cmd .=
"-stroke " . $point[
"bordercolor"] .
" -fill " . $point[
"fillcolor"] .
" -strokewidth $this->linewidth_outer -draw \"line " .
160 ($x - $r) .
"," . ($y - $r) .
" " . ($x + $r) .
"," . ($y + $r) .
"\" " .
161 "-stroke " . $point[
"bordercolor"] .
" -fill " . $point[
"fillcolor"] .
" -strokewidth $this->linewidth_outer -draw \"line " .
162 ($x + $r) .
"," . ($y - $r) .
" " . ($x - $r) .
"," . ($y + $r) .
"\" " .
163 "-stroke " . $point[
"linecolor"] .
" -fill " . $point[
"fillcolor"] .
" -strokewidth $this->linewidth_inner -draw \"line " .
164 ($x - $r) .
"," . ($y - $r) .
" " . ($x + $r) .
"," . ($y + $r) .
"\" " .
165 "-stroke " . $point[
"linecolor"] .
" -fill " . $point[
"fillcolor"] .
" -strokewidth $this->linewidth_inner -draw \"line " .
166 ($x + $r) .
"," . ($y - $r) .
" " . ($x - $r) .
"," . ($y + $r) .
"\" ";
169 foreach ($this->areas as $area) {
170 if ($area[
"visible"] and strcmp(strtolower($area[
"shape"]),
"rect") == 0) {
171 preg_match(
"/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/", $area[
"coords"], $matches);
177 $convert_cmd .=
"-stroke " . $area[
"bordercolor"] .
" -fill " . $area[
"fillcolor"] .
" -strokewidth $this->linewidth_outer -draw \"rectangle " .
178 $x0 .
"," . $y0 .
" " . ($x1) .
"," . $y1 .
"\" " .
179 "-stroke " . $area[
"linecolor"] .
" -fill " . $area[
"fillcolor"] .
" -strokewidth $this->linewidth_inner -draw \"rectangle " .
180 $x0 .
"," . $y0 .
" " . ($x1) .
"," . $y1 .
"\" ";
181 } elseif ($area[
"visible"] and strcmp(strtolower($area[
"shape"]),
"circle") == 0) {
182 preg_match(
"/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/", $area[
"coords"], $matches);
187 $convert_cmd .=
"-stroke " . $area[
"bordercolor"] .
" -fill " . $area[
"fillcolor"] .
" -strokewidth $this->linewidth_outer -draw \"circle " .
188 $x .
"," . $y .
" " . ($x + $r) .
"," . $y .
"\" " .
189 "-stroke " . $area[
"linecolor"] .
" -fill " . $area[
"fillcolor"] .
" -strokewidth $this->linewidth_inner -draw \"circle " .
190 $x .
"," . $y .
" " . ($x + $r) .
"," . $y .
"\" ";
191 } elseif ($area[
"visible"] and strcmp(strtolower($area[
"shape"]),
"poly") == 0) {
194 preg_match_all(
"/(\d+)\s*,\s*(\d+)/", $area[
"coords"], $matches, PREG_PATTERN_ORDER);
195 if (count($matches[0]) == 2) {
198 $convert_cmd .=
"-stroke " . $area[
"bordercolor"] .
" -fill " . $area[
"fillcolor"] .
" -strokewidth $this->linewidth_outer -draw \"$obj ";
199 for (
$i = 0;
$i < count($matches[0]);
$i++) {
200 $convert_cmd .= $matches[1][
$i] .
"," . $matches[2][
$i] .
" ";
202 $convert_cmd .=
"\" ";
203 $convert_cmd .=
"-stroke " . $area[
"linecolor"] .
" -fill " . $area[
"fillcolor"] .
" -strokewidth $this->linewidth_inner -draw \"$obj ";
204 preg_match_all(
"/(\d+)\s*,\s*(\d+)/", $area[
"coords"], $matches, PREG_PATTERN_ORDER);
205 for (
$i = 0;
$i < count($matches[0]);
$i++) {
206 $convert_cmd .= $matches[1][
$i] .
"," . $matches[2][
$i] .
" ";
208 $convert_cmd .=
"\" ";
215 $convert_cmd = preg_replace(
'/\\\\(#([a-fA-F0-9]{3}|[a-fA-F0-9]{6}|[a-fA-F0-9]{8}))/',
'${1}', $convert_cmd);
216 $convert_cmd =
$source .
"[0] " . $convert_cmd .
" " . $target;
217 $this->
execQuoted(PATH_TO_CONVERT, $convert_cmd);
static execQuoted($cmd, $args=null)
static escapeShellCmd($a_arg)
◆ escapeShellCmd()
static ilImagemapPreview::escapeShellCmd |
( |
|
$a_arg | ) |
|
|
static |
◆ execQuoted()
static ilImagemapPreview::execQuoted |
( |
|
$cmd, |
|
|
|
$args = null |
|
) |
| |
|
static |
◆ getAreaCount()
ilImagemapPreview::getAreaCount |
( |
| ) |
|
◆ getAreaIdent()
ilImagemapPreview::getAreaIdent |
( |
| ) |
|
Definition at line 129 of file class.ilImagemapPreview.php.
Referenced by getPreviewFilename().
131 if (count($this->areas) + count($this->points) > 0) {
132 $arr = array_merge(array_keys($this->areas), array_keys($this->points));
133 sort($arr, SORT_NUMERIC);
135 $inner = join(
"_", $arr);
136 if (strlen($inner) > 32) {
137 $inner = md5($inner);
139 return "preview_" . $inner .
"_";
◆ getImagemap()
ilImagemapPreview::getImagemap |
( |
|
$title | ) |
|
get imagemap html code note: html code should be placed in template files
Definition at line 278 of file class.ilImagemapPreview.php.
280 $map =
"<map name=\"$title\"> ";
281 foreach ($this->areas as $area) {
282 $map .=
"<area alt=\"" . $area[
"title"] .
"\" title=\"" . $area[
"title"] .
"\" ";
283 $map .=
"shape=\"" . $area[
"shape"] .
"\" ";
284 $map .=
"coords=\"" . $area[
"coords"] .
"\" ";
286 $map .=
"href=\"" . $area[
"href"] .
"\" ";
287 if ($area[
"target"]) {
288 $map .=
"target=\"" . $area[
"target"] .
"\" ";
292 $map .=
"nohref />\n";
◆ getPointCount()
ilImagemapPreview::getPointCount |
( |
| ) |
|
◆ getPreviewFilename()
ilImagemapPreview::getPreviewFilename |
( |
|
$imagePath, |
|
|
|
$baseFileName |
|
) |
| |
Definition at line 248 of file class.ilImagemapPreview.php.
References $filename, $preview_filename, getAreaIdent(), and ILIAS\Repository\lng().
251 if (count($this->areas) + count($this->points) > 0) {
253 if (is_file($pfile)) {
255 $previewfile = $imagePath . $ident . $baseFileName;
256 if (@md5_file($previewfile) != @md5_file($pfile)) {
257 if (strlen($ident) > 0) {
258 @copy($pfile, $previewfile);
262 if (strlen($pfile) == 0) {
263 $this->main_tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"qpl_imagemap_preview_missing"));
268 $this->main_tpl->setOnScreenMessage(
'info', $this->
lng->txt(
"qpl_imagemap_preview_missing"));
◆ $areas
ilImagemapPreview::$areas |
◆ $imagemap_filename
ilImagemapPreview::$imagemap_filename |
◆ $linewidth_inner
ilImagemapPreview::$linewidth_inner |
◆ $linewidth_outer
ilImagemapPreview::$linewidth_outer |
◆ $lng
◆ $main_tpl
◆ $points
ilImagemapPreview::$points |
◆ $preview_filename
ilImagemapPreview::$preview_filename |
The documentation for this class was generated from the following file: