4include_once 
"./Modules/Test/classes/inc.AssessmentConstants.php";
 
   41        if (!@is_file($this->preview_filename)) {
 
   43            if (preg_match(
"/.*\.(png|jpg|gif|jpeg)$/", $this->imagemap_filename, $matches)) {
 
   44                $extension = 
"." . $matches[1];
 
   46            include_once 
"./Services/Utilities/classes/class.ilUtil.php";
 
   49        $this->areas = array();
 
   50        $this->points = array();
 
   51        $this->linewidth_outer = 4;
 
   52        $this->linewidth_inner = 2;
 
   57        return count($this->areas);
 
   62        return count($this->points);
 
   74        $bordercolor = 
"white",
 
   75        $fillcolor = 
"#FFFFFFA0" 
   77        if (ini_get(
"safe_mode")) {
 
   78            if ((strpos($fillcolor, 
"#") !== 
false) ||  (strpos($fillcolor, 
"rgb") !== 
false)) {
 
   79                $fillcolor = str_replace(
"\"", 
"", $fillcolor);
 
   82        $this->areas[
$index] = array(
 
   84            "coords" => 
"$coords",
 
   87            "target" => 
"$target",
 
   88            "linecolor" => 
'"' . $linecolor . 
'"',
 
   89            "fillcolor" => 
'"' . $fillcolor . 
'"',
 
   90            "bordercolor" => 
'"' . $bordercolor . 
'"',
 
   91            "visible" => (
int) $visible
 
  100        $bordercolor = 
"white",
 
  101        $fillcolor = 
"#FFFFFFA0" 
  103        $this->points[
$index] = array(
 
  104            "coords" => 
"$coords",
 
  105            "linecolor" => 
'"' . $linecolor . 
'"',
 
  106            "fillcolor" => 
'"' . $fillcolor . 
'"',
 
  107            "bordercolor" => 
'"' . $bordercolor . 
'"',
 
  108            "visible" => (
int) $visible
 
  114        if (count($this->areas) + count($this->points) > 0) {
 
  115            $arr = array_merge(array_keys($this->areas), array_keys($this->points));
 
  116            sort($arr, SORT_NUMERIC);
 
  118            $inner = join(
"_", $arr);
 
  119            if (strlen($inner) > 32) {
 
  120                $inner = md5($inner);
 
  122            return "preview_" . $inner . 
"_";
 
  130        if (count($this->areas) + count($this->points) == 0) {
 
  133        include_once 
"./Services/Utilities/classes/class.ilUtil.php";
 
  134        $convert_cmd = 
"-quality 100 ";
 
  135        foreach ($this->points as $point) {
 
  136            if ($point[
"visible"]) {
 
  137                preg_match(
"/(\d+)\s*,\s*(\d+)/", $point[
"coords"], $matches);
 
  142                $convert_cmd .= 
"-stroke " . $point[
"bordercolor"] . 
" -fill " . $point[
"fillcolor"] . 
" -strokewidth $this->linewidth_outer -draw \"line " .
 
  144                "-stroke " . $point[
"bordercolor"] . 
" -fill " . $point[
"fillcolor"] . 
" -strokewidth $this->linewidth_outer -draw \"line " .
 
  146                "-stroke " . $point[
"linecolor"] . 
" -fill " . $point[
"fillcolor"] . 
" -strokewidth $this->linewidth_inner -draw \"line " .
 
  148                "-stroke " . $point[
"linecolor"] . 
" -fill " . $point[
"fillcolor"] . 
" -strokewidth $this->linewidth_inner -draw \"line " .
 
  152        foreach ($this->areas as $area) {
 
  153            if ($area[
"visible"] and strcmp(strtolower($area[
"shape"]), 
"rect") == 0) {
 
  154                preg_match(
"/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/", $area[
"coords"], $matches);
 
  160                $convert_cmd .= 
"-stroke " . $area[
"bordercolor"] . 
" -fill " . $area[
"fillcolor"] . 
" -strokewidth $this->linewidth_outer -draw \"rectangle " .
 
  161                $x0 . 
"," . $y0 . 
" " . ($x1) . 
"," . $y1 . 
"\" " .
 
  162                "-stroke " . $area[
"linecolor"] . 
" -fill " . $area[
"fillcolor"] . 
" -strokewidth $this->linewidth_inner -draw \"rectangle " .
 
  163                $x0 . 
"," . $y0 . 
" " . ($x1) . 
"," . $y1 . 
"\" ";
 
  164            } elseif ($area[
"visible"] and strcmp(strtolower($area[
"shape"]), 
"circle") == 0) {
 
  165                preg_match(
"/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/", $area[
"coords"], $matches);
 
  170                $convert_cmd .= 
"-stroke " . $area[
"bordercolor"] . 
" -fill " . $area[
"fillcolor"] . 
" -strokewidth $this->linewidth_outer -draw \"circle " .
 
  171                $x . 
"," . 
$y . 
" " . (
$x + 
$r) . 
"," . 
$y . 
"\" " .
 
  172                "-stroke " . $area[
"linecolor"] . 
" -fill " . $area[
"fillcolor"] . 
" -strokewidth $this->linewidth_inner -draw \"circle " .
 
  173                $x . 
"," . 
$y . 
" " . (
$x + 
$r) . 
"," . 
$y . 
"\" ";
 
  174            } elseif ($area[
"visible"] and strcmp(strtolower($area[
"shape"]), 
"poly") == 0) {
 
  177                preg_match_all(
"/(\d+)\s*,\s*(\d+)/", $area[
"coords"], $matches, PREG_PATTERN_ORDER);
 
  178                if (count($matches[0]) == 2) {
 
  181                $convert_cmd .= 
"-stroke " . $area[
"bordercolor"] . 
" -fill " . $area[
"fillcolor"] . 
" -strokewidth $this->linewidth_outer -draw \"$obj ";
 
  182                for (
$i = 0; 
$i < count($matches[0]); 
$i++) {
 
  183                    $convert_cmd .= $matches[1][
$i] . 
"," . $matches[2][
$i] . 
" ";
 
  185                $convert_cmd .= 
"\" ";
 
  186                $convert_cmd .= 
"-stroke " . $area[
"linecolor"] . 
" -fill " . $area[
"fillcolor"] . 
" -strokewidth $this->linewidth_inner -draw \"$obj ";
 
  187                preg_match_all(
"/(\d+)\s*,\s*(\d+)/", $area[
"coords"], $matches, PREG_PATTERN_ORDER);
 
  188                for (
$i = 0; 
$i < count($matches[0]); 
$i++) {
 
  189                    $convert_cmd .= $matches[1][
$i] . 
"," . $matches[2][
$i] . 
" ";
 
  191                $convert_cmd .= 
"\" ";
 
  204        if (count($this->areas) + count($this->points) > 0) {
 
  206            if (is_file($pfile)) {
 
  208                $previewfile = $imagePath . $ident . $baseFileName;
 
  209                if (@md5_file($previewfile) != @md5_file($pfile)) {
 
  210                    if (strlen($ident) > 0) {
 
  211                        @copy($pfile, $previewfile);
 
  215                if (strlen($pfile) == 0) {
 
  233        $map = 
"<map name=\"$title\"> ";
 
  234        foreach ($this->areas as $area) {
 
  235            $map .= 
"<area alt=\"" . $area[
"title"] . 
"\"  title=\"" . $area[
"title"] . 
"\" ";
 
  236            $map .= 
"shape=\"" . $area[
"shape"] . 
"\" ";
 
  237            $map .= 
"coords=\"" . $area[
"coords"] . 
"\" ";
 
  239                $map .= 
"href=\"" . $area[
"href"] . 
"\" ";
 
  240                if ($area[
"target"]) {
 
  241                    $map .= 
"target=\"" . $area[
"target"] . 
"\" ";
 
  245                $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)
Returns a unique and non existing Path for e temporary file or directory.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.