4include_once 
"./Modules/Test/classes/inc.AssessmentConstants.php";
 
   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;
 
   58                return count($this->areas);
 
   63                return count($this->points);
 
   75                $bordercolor = 
"white",
 
   76                $fillcolor = 
"#FFFFFFA0" 
   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
 
  104                $bordercolor = 
"white",
 
  105                $fillcolor = 
"#FFFFFFA0" 
  108                $this->points[$index] = array(
 
  109                        "coords" => 
"$coords",
 
  110                        "linecolor" => 
'"' . $linecolor . 
'"',
 
  111                        "fillcolor" => 
'"' . $fillcolor . 
'"',
 
  112                        "bordercolor" => 
'"' . $bordercolor . 
'"',
 
  113                        "visible" => (
int)$visible
 
  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 . 
"_";
 
  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;
 
  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)
 
  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";
 
An exception for terminatinating execution or to throw for unit testing.
Image map image preview creator.
getPreviewFilename($imagePath, $baseFileName)
addPoint( $index, $coords, $visible=true, $linecolor="red", $bordercolor="white", $fillcolor="#FFFFFFA0")
getImagemap($title)
get imagemap html code note: html code should be placed in template files
__construct($imagemap_filename="")
ilImagemapPreview constructor
addArea( $index, $shape, $coords, $title="", $href="", $target="", $visible=true, $linecolor="red", $bordercolor="white", $fillcolor="#FFFFFFA0")
static execConvert($args)
execute convert command
static escapeShellCmd($a_arg)
escape shell cmd
static ilTempnam($a_temp_path=null)
Create a temporary file in an ILIAS writable directory.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.