24 include_once 
"./Modules/Test/classes/inc.AssessmentConstants.php";
 
   60                 if (!@is_file($this->preview_filename))
 
   63                         if (preg_match(
"/.*\.(png|jpg|gif|jpeg)$/", $this->imagemap_filename, $matches))
 
   65                                 $extension = 
"." . $matches[1];
 
   67                         include_once 
"./Services/Utilities/classes/class.ilUtil.php";
 
   70                 $this->areas = array();
 
   71                 $this->points = array();
 
   72                 $this->linewidth_outer = 4;
 
   73                 $this->linewidth_inner = 2;
 
   78                 return count($this->areas);
 
   83                 return count($this->points);
 
   95                 $bordercolor = 
"white",
 
   96                 $fillcolor = 
"#FFFFFFA0" 
   99                 if (ini_get(
"safe_mode"))
 
  101                         if ((strpos($fillcolor, 
"#") !== 
false) || (strpos($fillcolor, 
"rgb") !== 
false))
 
  103                                 $fillcolor = str_replace(
"\"", 
"", $fillcolor);
 
  106                 $this->areas[$index] = array(
 
  108                         "coords" => 
"$coords",
 
  111                         "target" => 
"$target",
 
  112                         "linecolor" => 
'"' . $linecolor . 
'"',
 
  113                         "fillcolor" => 
'"' . $fillcolor . 
'"',
 
  114                         "bordercolor" => 
'"' . $bordercolor . 
'"',
 
  115                         "visible" => (
int)$visible
 
  124                 $bordercolor = 
"white",
 
  125                 $fillcolor = 
"#FFFFFFA0" 
  128                 $this->points[$index] = array(
 
  129                         "coords" => 
"$coords",
 
  130                         "linecolor" => 
'"' . $linecolor . 
'"',
 
  131                         "fillcolor" => 
'"' . $fillcolor . 
'"',
 
  132                         "bordercolor" => 
'"' . $bordercolor . 
'"',
 
  133                         "visible" => (
int)$visible
 
  139                 if (count($this->areas)+count($this->points) > 0)
 
  141                         $arr = array_merge(array_keys($this->areas), array_keys($this->points));
 
  142                         sort($arr, SORT_NUMERIC);
 
  144                         $inner = join(
"_", $arr);
 
  145                         if (strlen($inner) > 32) {
 
  146                                 $inner = md5($inner);
 
  148                         return "preview_" . $inner . 
"_";
 
  158                 if (count($this->areas)+count($this->points)==0) 
return;
 
  159                 include_once 
"./Services/Utilities/classes/class.ilUtil.php";
 
  160                 $convert_cmd = 
"-quality 100 ";
 
  161                 foreach ($this->points as $point)
 
  163                         if ($point[
"visible"])
 
  165                                 preg_match(
"/(\d+)\s*,\s*(\d+)/", $point[
"coords"], $matches);
 
  170                                 $convert_cmd .= 
"-stroke " . $point[
"bordercolor"] . 
" -fill " . $point[
"fillcolor"] . 
" -strokewidth $this->linewidth_outer -draw \"line " .
 
  171                                 ($x-$r) . 
"," . ($y-$r) .       
" " . ($x+$r) . 
"," . ($y+$r) . 
"\" " .
 
  172                                 "-stroke " . $point[
"bordercolor"] . 
" -fill " . $point[
"fillcolor"] . 
" -strokewidth $this->linewidth_outer -draw \"line " .
 
  173                                 ($x+$r) . 
"," . ($y-$r) .       
" " . ($x-$r) . 
"," . ($y+$r) . 
"\" " .
 
  174                                 "-stroke " . $point[
"linecolor"] . 
" -fill " . $point[
"fillcolor"] . 
" -strokewidth $this->linewidth_inner -draw \"line " .
 
  175                                 ($x-$r) . 
"," . ($y-$r) .       
" " . ($x+$r) . 
"," . ($y+$r) . 
"\" " .
 
  176                                 "-stroke " . $point[
"linecolor"] . 
" -fill " . $point[
"fillcolor"] . 
" -strokewidth $this->linewidth_inner -draw \"line " .
 
  177                                 ($x+$r) . 
"," . ($y-$r) .       
" " . ($x-$r) . 
"," . ($y+$r) . 
"\" ";
 
  180                 foreach ($this->areas as $area)
 
  182                         if ($area[
"visible"] and strcmp(strtolower($area[
"shape"]), 
"rect") == 0)
 
  184                                 preg_match(
"/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/", $area[
"coords"], $matches);
 
  190                                 $convert_cmd .= 
"-stroke " . $area[
"bordercolor"] . 
" -fill " . $area[
"fillcolor"] . 
" -strokewidth $this->linewidth_outer -draw \"rectangle " .
 
  191                                 $x0 . 
"," . $y0 .       
" " . ($x1) . 
"," . $y1 . 
"\" " .
 
  192                                 "-stroke " . $area[
"linecolor"] . 
" -fill " . $area[
"fillcolor"] . 
" -strokewidth $this->linewidth_inner -draw \"rectangle " .
 
  193                                 $x0 . 
"," . $y0 .       
" " . ($x1) . 
"," . $y1 . 
"\" ";
 
  195                         else if ($area[
"visible"] and strcmp(strtolower($area[
"shape"]), 
"circle") == 0)
 
  197                                 preg_match(
"/(\d+)\s*,\s*(\d+)\s*,\s*(\d+)/", $area[
"coords"], $matches);
 
  202                                 $convert_cmd .= 
"-stroke " . $area[
"bordercolor"] . 
" -fill " . $area[
"fillcolor"] . 
" -strokewidth $this->linewidth_outer -draw \"circle " .
 
  203                                 $x . 
"," . $y . 
" " . ($x+$r) . 
"," . $y . 
"\" " .
 
  204                                 "-stroke " . $area[
"linecolor"] . 
" -fill " . $area[
"fillcolor"] . 
" -strokewidth $this->linewidth_inner -draw \"circle " .
 
  205                                 $x . 
"," . $y . 
" " . ($x+$r) . 
"," . $y . 
"\" ";
 
  207                         else if ($area[
"visible"] and strcmp(strtolower($area[
"shape"]), 
"poly") == 0)
 
  211                                 preg_match_all(
"/(\d+)\s*,\s*(\d+)/", $area[
"coords"], $matches, PREG_PATTERN_ORDER);
 
  212                                 if (count($matches[0]) == 2) $obj = 
"line";
 
  213                                 $convert_cmd .= 
"-stroke " . $area[
"bordercolor"] . 
" -fill " . $area[
"fillcolor"] . 
" -strokewidth $this->linewidth_outer -draw \"$obj ";
 
  214                                 for ($i = 0; $i < count($matches[0]); $i++)
 
  216                                         $convert_cmd .= $matches[1][$i] . 
"," . $matches[2][$i] .       
" ";
 
  218                                 $convert_cmd .= 
"\" ";
 
  219                                 $convert_cmd .= 
"-stroke " . $area[
"linecolor"] . 
" -fill " . $area[
"fillcolor"] . 
" -strokewidth $this->linewidth_inner -draw \"$obj ";
 
  220                                 preg_match_all(
"/(\d+)\s*,\s*(\d+)/", $area[
"coords"], $matches, PREG_PATTERN_ORDER);
 
  221                                 for ($i = 0; $i < count($matches[0]); $i++)
 
  223                                         $convert_cmd .= $matches[1][$i] . 
"," . $matches[2][$i] .       
" ";
 
  225                                 $convert_cmd .= 
"\" ";
 
  231                 $convert_cmd = $source . 
"[0] " . $convert_cmd.
" ".$target;
 
  238                 if (count($this->areas)+count($this->points)>0)
 
  244                                 $previewfile = $imagePath . $ident . $baseFileName;
 
  245                                 if (@md5_file($previewfile) != @md5_file($pfile))
 
  247                                         if (strlen($ident) > 0)
 
  249                                                 @copy($pfile, $previewfile);
 
  253                                 if (strlen($pfile) == 0)
 
  276                 $map = 
"<map name=\"$title\"> ";
 
  277                 foreach ($this->areas as $area)
 
  279                         $map .= 
"<area alt=\"" . $area[
"title"] . 
"\"  title=\"" . $area[
"title"] . 
"\" ";
 
  280                         $map .= 
"shape=\"" . $area[
"shape"] . 
"\" ";
 
  281                         $map .= 
"coords=\"" .  $area[
"coords"] . 
"\" ";
 
  284                                 $map .= 
"href=\"" . $area[
"href"] . 
"\" ";
 
  287                                         $map .= 
"target=\"" . $area[
"target"] . 
"\" ";
 
  293                                 $map .= 
"nohref />\n";