Image map image preview creator. More...
Public Member Functions | |
| ilImagemapPreview ($imagemap_filename="", $preview_filename="") | |
| ilImagemapPreview constructor | |
| addArea ($shape, $coords, $title="", $href="", $target="", $visible=true, $linecolor="red", $bordercolor="white", $fillcolor="\"#FFFFFFC0\"") | |
| deleteArea ($key, $value) | |
| createPreview () | |
| getPreviewFilename () | |
| getImagemap ($title) | |
| get imagemap html code note: html code should be placed in template files | |
Data Fields | |
| $imagemap_filename | |
| $preview_filename | |
| $areas | |
| $linewidth_outer | |
| $linewidth_inner | |
Image map image preview creator.
Takes an image and imagemap areas and creates a preview image containing the imagemap areas.
class.ilImagemapPreview.php Assessment
Definition at line 37 of file class.ilImagemapPreview.php.
| ilImagemapPreview::addArea | ( | $ | shape, | |
| $ | coords, | |||
| $ | title = "", |
|||
| $ | href = "", |
|||
| $ | target = "", |
|||
| $ | visible = true, |
|||
| $ | linecolor = "red", |
|||
| $ | bordercolor = "white", |
|||
| $ | fillcolor = "\"#FFFFFFC0\"" | |||
| ) |
Definition at line 74 of file class.ilImagemapPreview.php.
{
array_push($this->areas, array(
"shape" => "$shape",
"coords" => "$coords",
"title" => "$title",
"href" => "$href",
"target" => "$target",
"linecolor" => "$linecolor",
"fillcolor" => "$fillcolor",
"bordercolor" => "$bordercolor",
"visible" => (int)$visible
));
}
| ilImagemapPreview::createPreview | ( | ) |
Definition at line 111 of file class.ilImagemapPreview.php.
References $x, and ilUtil::getConvertCmd().
{
if (!count($this->areas)) return;
$convert_prefix = ilUtil::getConvertCmd() . " -quality 100 ";
foreach ($this->areas as $area)
{
if ($area["visible"] and strcmp(strtolower($area["shape"]), "rect") == 0)
{
preg_match("/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/", $area["coords"], $matches);
$x0 = $matches[1];
$y0 = $matches[2];
$x1 = $matches[3];
$y1 = $matches[4];
// draw a rect around the selection
$convert_cmd .= "-stroke " . $area["bordercolor"] . " -fill " . $area["fillcolor"] . " -strokewidth $this->linewidth_outer -draw \"rectangle " .
$x0 . "," . $y0 . " " . ($x1) . "," . $y1 . "\" " .
"-stroke " . $area["linecolor"] . " -fill " . $area["fillcolor"] . " -strokewidth $this->linewidth_inner -draw \"rectangle " .
$x0 . "," . $y0 . " " . ($x1) . "," . $y1 . "\" ";
}
else if ($area["visible"] and strcmp(strtolower($area["shape"]), "circle") == 0)
{
preg_match("/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/", $area["coords"], $matches);
$x = $matches[1];
$y = $matches[2];
$r = $matches[3];
// draw a circle around the selection
$convert_cmd .= "-stroke " . $area["bordercolor"] . " -fill " . $area["fillcolor"] . " -strokewidth $this->linewidth_outer -draw \"circle " .
$x . "," . $y . " " . ($x+$r) . "," . $y . "\" " .
"-stroke " . $area["linecolor"] . " -fill " . $area["fillcolor"] . " -strokewidth $this->linewidth_inner -draw \"circle " .
$x . "," . $y . " " . ($x+$r) . "," . $y . "\" ";
}
else if ($area["visible"] and strcmp(strtolower($area["shape"]), "poly") == 0)
{
// draw a polygon around the selection
$convert_cmd .= "-stroke " . $area["bordercolor"] . " -fill " . $area["fillcolor"] . " -strokewidth $this->linewidth_outer -draw \"polygon ";
preg_match_all("/(\d+)\s*,\s*(\d+)/", $area["coords"], $matches, PREG_PATTERN_ORDER);
for ($i = 0; $i < count($matches[0]); $i++)
{
$convert_cmd .= $matches[1][$i] . "," . $matches[2][$i] . " ";
}
$convert_cmd .= "\" ";
$convert_cmd .= "-stroke " . $area["linecolor"] . " -fill " . $area["fillcolor"] . " -strokewidth $this->linewidth_inner -draw \"polygon ";
preg_match_all("/(\d+)\s*,\s*(\d+)/", $area["coords"], $matches, PREG_PATTERN_ORDER);
for ($i = 0; $i < count($matches[0]); $i++)
{
$convert_cmd .= $matches[1][$i] . "," . $matches[2][$i] . " ";
}
$convert_cmd .= "\" ";
}
}
$convert_cmd = $convert_prefix . $convert_cmd . escapeshellcmd(str_replace(" ", "\ ", $this->imagemap_filename)) ." " . escapeshellcmd($this->preview_filename);
system($convert_cmd);
}
Here is the call graph for this function:| ilImagemapPreview::deleteArea | ( | $ | key, | |
| $ | value | |||
| ) |
Definition at line 99 of file class.ilImagemapPreview.php.
{
foreach ($this->areas as $areakey => $areavalue)
{
if (strcmp($value, $areavalue[$key]) == 0)
{
unset($this->areas[$areakey]);
}
}
$this->areas = array_values($this->areas);
}
| ilImagemapPreview::getImagemap | ( | $ | title | ) |
get imagemap html code note: html code should be placed in template files
Definition at line 181 of file class.ilImagemapPreview.php.
{
$map = "<map name=\"$title\"> ";
foreach ($this->areas as $area)
{
$map .= "<area alt=\"" . $area["title"] . "\" title=\"" . $area["title"] . "\" ";
$map .= "shape=\"" . $area["shape"] . "\" ";
$map .= "coords=\"" . $area["coords"] . "\" ";
if ($area["href"])
{
$map .= "href=\"" . $area["href"] . "\" ";
if ($area["target"])
{
$map .= "target=\"" . $area["target"] . "\" ";
}
$map .= "/>\n";
}
else
{
$map .= "nohref />\n";
}
}
$map .= "</map>";
return $map;
}
| ilImagemapPreview::getPreviewFilename | ( | ) |
Definition at line 165 of file class.ilImagemapPreview.php.
{
if (is_file($this->preview_filename))
{
return basename($this->preview_filename);
}
else
{
return "";
}
}
| ilImagemapPreview::ilImagemapPreview | ( | $ | imagemap_filename = "", |
|
| $ | preview_filename = "" | |||
| ) |
ilImagemapPreview constructor
Creates an instance of the ilImagemapPreview class
| integer | $id The database id of a image map question object public |
Definition at line 53 of file class.ilImagemapPreview.php.
References $imagemap_filename, $preview_filename, and ilUtil::ilTempnam().
{
$this->imagemap_filename = $imagemap_filename;
$this->preview_filename = $preview_filename;
if (!@is_file($this->preview_filename))
{
$extension = ".jpg";
if (preg_match("/.*\.(png|jpg|gif|jpeg)$/", $this->imagemap_filename, $matches))
{
$extension = "." . $matches[1];
}
$this->preview_filename = ilUtil::ilTempnam() . $extension;
}
$this->areas = array();
$this->linewidth_outer = 4;
$this->linewidth_inner = 2;
}
Here is the call graph for this function:| ilImagemapPreview::$areas |
Definition at line 41 of file class.ilImagemapPreview.php.
| ilImagemapPreview::$imagemap_filename |
Definition at line 39 of file class.ilImagemapPreview.php.
Referenced by ilImagemapPreview().
| ilImagemapPreview::$linewidth_inner |
Definition at line 43 of file class.ilImagemapPreview.php.
| ilImagemapPreview::$linewidth_outer |
Definition at line 42 of file class.ilImagemapPreview.php.
| ilImagemapPreview::$preview_filename |
Definition at line 40 of file class.ilImagemapPreview.php.
Referenced by ilImagemapPreview().
1.7.1