4require_once(
"./Services/Link/classes/class.ilInternalLink.php");
 
    6define(
"IL_AREA_RECT", 
"Rect");
 
    7define(
"IL_AREA_CIRCLE", 
"Circle");
 
    8define(
"IL_AREA_POLY", 
"Poly");
 
    9define(
"IL_AREA_WHOLE_PICTURE", 
"WholePicture");
 
   11define(
"IL_INT_LINK", 
"int");
 
   12define(
"IL_EXT_LINK", 
"ext");
 
   13define(
"IL_NO_LINK", 
"no");
 
   15define(
"IL_LT_STRUCTURE", 
"StructureObject");
 
   16define(
"IL_LT_PAGE", 
"PageObject");
 
   17define(
"IL_LT_MEDIA", 
"MediaObject");
 
   18define(
"IL_LT_GLITEM", 
"GlossaryItem");
 
   20define(
"IL_TF_MEDIA", 
"Media");
 
   21define(
"IL_TF_FAQ", 
"FAQ");
 
   22define(
"IL_TF_GLOSSARY", 
"Glossary");
 
   23define(
"IL_TF_NEW", 
"New");
 
   73        $this->db = 
$DIC->database();
 
   75        if ($a_item_id != 0 && $a_nr != 0) {
 
   89        $q = 
"INSERT INTO map_area (item_id, nr, shape, " .
 
   90            "coords, link_type, title, href, target, type, highlight_mode, highlight_class, target_frame) " .
 
   93            $ilDB->quote($this->
getNr(), 
"integer") . 
"," .
 
  104        $ilDB->manipulate($q);
 
  120        $q = 
"SELECT max(nr) AS max_nr FROM map_area WHERE item_id = " .
 
  121            $ilDB->quote($a_item_id, 
"integer");
 
  122        $max_set = 
$ilDB->query($q);
 
  123        $max_rec = 
$ilDB->fetchAssoc($max_set);
 
  125        return $max_rec[
"max_nr"];
 
  135        $q = 
"SELECT * FROM map_area WHERE item_id = " .
 
  137            " AND nr = " . 
$ilDB->quote($this->
getNr(), 
"integer");
 
  138        $area_set = 
$ilDB->query($q);
 
  139        $area_rec = 
$ilDB->fetchAssoc($area_set);
 
  141        $this->
setShape($area_rec[
"shape"]);
 
  143        $this->
setNr($area_rec[
"nr"]);
 
  146        $this->
setTitle($area_rec[
"title"]);
 
  147        $this->
setHref($area_rec[
"href"]);
 
  149        $this->
setType($area_rec[
"type"]);
 
  162        $q = 
"UPDATE map_area SET shape = " . 
$ilDB->quote($this->
getShape(), 
"text") .
 
  172            " WHERE item_id = " . 
$ilDB->quote($this->
getItemId(), 
"integer") .
 
  173            " AND nr = " . 
$ilDB->quote($this->
getNr(), 
"integer");
 
  174        $ilDB->manipulate($q);
 
  187        $q = 
"SELECT * FROM map_area WHERE item_id = " .
 
  188            $ilDB->quote($a_item_id, 
"integer");
 
  189        $area_set = 
$ilDB->query($q);
 
  190        while ($area_rec = 
$ilDB->fetchAssoc($area_set)) {
 
  191            $target = $area_rec[
"target"];
 
  192            $type = $area_rec[
"type"];
 
  194            $nr = $area_rec[
"nr"];
 
  196            if (($area_rec[
"link_type"] == 
IL_INT_LINK) && (!is_int(strpos($target, 
"__")))) {
 
  198                if ($new_target !== 
false) {
 
  199                    $query = 
"UPDATE map_area SET " .
 
  200                        "target = " . 
$ilDB->quote($new_target, 
"text") . 
" " .
 
  202                        " AND nr = " . 
$ilDB->quote(
$nr, 
"integer");
 
  220        $q = 
"SELECT * FROM map_area WHERE item_id = " .
 
  221            $ilDB->quote($a_item_id, 
"integer");
 
  222        $area_set = 
$ilDB->query($q);
 
  226        while ($area_rec = 
$ilDB->fetchAssoc($area_set)) {
 
  227            $target = $area_rec[
"target"];
 
  228            $type = $area_rec[
"type"];
 
  229            $targetframe = $area_rec[
"target_frame"];
 
  231            if (($area_rec[
"link_type"] == 
IL_INT_LINK) && (is_int(strpos($target, 
"__")))) {
 
  232                $links[$target . 
":" . 
$type . 
":" . $targetframe] =
 
  233                    array(
"Target" => $target, 
"Type" => 
$type,
 
  234                        "TargetFrame" => $targetframe);
 
  249        $q = 
"SELECT * FROM map_area WHERE " .
 
  251            " AND target = " . 
$ilDB->quote($a_target, 
"text");
 
  252        $set = 
$ilDB->query($q);
 
  255        while ($rec = 
$ilDB->fetchAssoc($set)) {
 
  257            $mobs[$mob_id] = $mob_id;
 
  276            self::HL_NONE => 
$lng->txt(
"cont_none"),
 
  277            self::HL_HOVER => 
$lng->txt(
"cont_hover"),
 
  278            self::HL_ALWAYS => 
$lng->txt(
"cont_always")
 
  290        $this->highlight_mode = $a_val;
 
  300        return $this->highlight_mode;
 
  315            self::HLCL_ACCENTED => 
$lng->txt(
"cont_accented"),
 
  316            self::HLCL_LIGHT => 
$lng->txt(
"cont_light"),
 
  317            self::HLCL_DARK => 
$lng->txt(
"cont_dark"),
 
  328        $this->highlight_class = $a_val;
 
  338        return $this->highlight_class;
 
  348        $this->item_id = $a_item_id;
 
  388        $this->shape = $a_shape;
 
  408        $this->coords = $a_coords;
 
  428        $this->title = $a_title;
 
  438        $this->title .= $a_title_str;
 
  458        $this->linktype = $a_link_type;
 
  478        $this->xl_href = $a_href;
 
  498        $this->xl_title = $a_title;
 
  518        $this->il_target = $a_target;
 
  530        if ((substr($target, 0, 4) == 
"il__") && $a_insert_inst) {
 
  531            $target = 
"il_" . IL_INST_ID . 
"_" . substr($target, 4, strlen($target) - 4);
 
  566        $this->il_target_frame = $a_target_frame;
 
  589        $a_close_poly = 
true,
 
  641    public function drawLine(&$im, $x1, $y1, $x2, $y2, $c1, $c2)
 
  643        imageline($im, $x1 + 1, $y1, $x2 + 1, $y2, $c1);
 
  644        imageline($im, $x1 - 1, $y1, $x2 - 1, $y2, $c1);
 
  645        imageline($im, $x1, $y1 + 1, $x2, $y2 + 1, $c1);
 
  646        imageline($im, $x1, $y1 - 1, $x2, $y2 - 1, $c1);
 
  647        imageline($im, $x1, $y1, $x2, $y2, $c2);
 
  661        $coord = explode(
",", 
$coords);
 
  665            $coord[0] / $a_x_ratio,
 
  666            $coord[1] / $a_y_ratio,
 
  667            $coord[0] / $a_x_ratio,
 
  668            $coord[3] / $a_y_ratio,
 
  674            $coord[0] / $a_x_ratio,
 
  675            $coord[3] / $a_y_ratio,
 
  676            $coord[2] / $a_x_ratio,
 
  677            $coord[3] / $a_y_ratio,
 
  683            $coord[2] / $a_x_ratio,
 
  684            $coord[3] / $a_y_ratio,
 
  685            $coord[2] / $a_x_ratio,
 
  686            $coord[1] / $a_y_ratio,
 
  692            $coord[2] / $a_x_ratio,
 
  693            $coord[1] / $a_y_ratio,
 
  694            $coord[0] / $a_x_ratio,
 
  695            $coord[1] / $a_y_ratio,
 
  712    public function drawPoly(&$im, 
$coords, $c1, $c2, $closed, $a_x_ratio = 1, $a_y_ratio = 1)
 
  722        if ($anz < (3 - $p)) {
 
  728        for (
$i = 0; 
$i < $anz - $p; 
$i++) {
 
  731                $c[
$i * 2] / $a_x_ratio,
 
  732                $c[
$i * 2 + 1] / $a_y_ratio,
 
  733                $c[(
$i * 2 + 2) % (2 * $anz)] / $a_x_ratio,
 
  734                $c[(
$i * 2 + 3) % (2 * $anz)] / $a_y_ratio,
 
  758            (
$c[2] + 1) * 2 / $a_x_ratio,
 
  759            (
$c[2] + 1) * 2 / $a_y_ratio,
 
  768            (
$c[2] - 1) * 2 / $a_x_ratio,
 
  769            (
$c[2] - 1) * 2 / $a_y_ratio,
 
  778            $c[2] * 2 / $a_x_ratio,
 
  779            $c[2] * 2 / $a_y_ratio,
 
  797            $coord_array = explode(
",", 
$c);
 
  798            return (count($coord_array) / 2);
 
An exception for terminatinating execution or to throw for unit testing.
static _getIdForImportId($a_type, $a_target)
Get current id for an import id.
static getAllHighlightClasses()
Get all highlight classes.
setHighlightClass($a_val)
Set highlight class.
setTarget($a_target)
set link target (internal link only)
draw(&$a_image, $a_col1, $a_col2, $a_close_poly=true, $a_x_ratio=1, $a_y_ratio=1)
draw image to
getTitle()
get (tooltip) title
static _resolveIntLinks($a_item_id)
resolve internal links of an item id
static _getIntLinks($a_item_id)
get all internal links of a media items map areas
setExtTitle($a_title)
set link text (external link only)
__construct($a_item_id=0, $a_nr=0)
map area
setTargetFrame($a_target_frame)
set link target frame (internal link only)
static _getMaxNr($a_item_id)
get maximum nr of media item (static)
setHighlightMode($a_val)
Set highlight mode.
getTarget($a_insert_inst=false)
get link target (internal link only)
getHref()
get hyper reference url (external link only)
getHighlightMode()
Get highlight mode.
drawRect(&$im, $coords, $c1, $c2, $a_x_ratio=1, $a_y_ratio=1)
draws an outlined two color rectangle
getLinkType()
get link type
setTitle($a_title)
set (tooltip)title of area
setHref($a_href)
set hyper reference (external link only)
getTargetFrame()
get link target frame (internal link only)
create()
create persistent map area object in db
setNr($a_nr)
set area number
static countCoords($c)
count the number of coordinates (x,y) in a coordinate string (format: "x1,y1,x2,y2,...
static _getMobsForTarget($a_type, $a_target)
Get areas for a certain target.
appendTitle($a_title_str)
append string to (tooltip) title of area
drawLine(&$im, $x1, $y1, $x2, $y2, $c1, $c2)
draws an outlined two color line in an image
setShape($a_shape)
set shape (IL_AREA_RECT, IL_AREA_CIRCLE, IL_AREA_POLY, IL_AREA_WHOLE_PICTURE)
setItemId($a_item_id)
set media item id
read()
read map area data into object (item id and nr must be set)
setType($a_type)
set link type (internal link only)
drawCircle(&$im, $coords, $c1, $c2, $a_x_ratio=1, $a_y_ratio=1)
draws an outlined two colored circle
getType()
get link type (internal link only)
setLinkType($a_link_type)
set link type
static getAllHighlightModes()
Get all highlight modes.
setCoords($a_coords)
set coords of area
getExtTitle()
get link text (external link only)
drawPoly(&$im, $coords, $c1, $c2, $closed, $a_x_ratio=1, $a_y_ratio=1)
draws an outlined two color polygon
getHighlightClass()
Get highlight class.