4 require_once(
"./Services/Link/classes/class.ilInternalLink.php");
6 define(
"IL_AREA_RECT",
"Rect");
7 define(
"IL_AREA_CIRCLE",
"Circle");
8 define(
"IL_AREA_POLY",
"Poly");
9 define(
"IL_AREA_WHOLE_PICTURE",
"WholePicture");
11 define(
"IL_INT_LINK",
"int");
12 define(
"IL_EXT_LINK",
"ext");
13 define(
"IL_NO_LINK",
"no");
15 define(
"IL_LT_STRUCTURE",
"StructureObject");
16 define(
"IL_LT_PAGE",
"PageObject");
17 define(
"IL_LT_MEDIA",
"MediaObject");
18 define(
"IL_LT_GLITEM",
"GlossaryItem");
20 define(
"IL_TF_MEDIA",
"Media");
21 define(
"IL_TF_FAQ",
"FAQ");
22 define(
"IL_TF_GLOSSARY",
"Glossary");
23 define(
"IL_TF_NEW",
"New");
67 if ($a_item_id !=0 && $a_nr != 0)
82 $q =
"INSERT INTO map_area (item_id, nr, shape, ".
83 "coords, link_type, title, href, target, type, highlight_mode, highlight_class, target_frame) ".
85 $ilDB->quote($this->
getItemId(),
"integer").
",".
86 $ilDB->quote($this->
getNr(),
"integer").
",".
87 $ilDB->quote($this->
getShape(),
"text").
",".
88 $ilDB->quote($this->
getCoords(),
"text").
",".
90 $ilDB->quote($this->
getTitle(),
"text").
",".
91 $ilDB->quote($this->
getHref(),
"text").
",".
92 $ilDB->quote($this->
getTarget(),
"text").
",".
93 $ilDB->quote($this->
getType(),
"text").
",".
97 $ilDB->manipulate($q);
111 $q =
"SELECT max(nr) AS max_nr FROM map_area WHERE item_id = ".
112 $ilDB->quote($a_item_id,
"integer");
113 $max_set = $ilDB->query($q);
114 $max_rec = $ilDB->fetchAssoc($max_set);
116 return $max_rec[
"max_nr"];
126 $q =
"SELECT * FROM map_area WHERE item_id = ".
127 $ilDB->quote($this->
getItemId(),
"integer").
128 " AND nr = ".$ilDB->quote($this->
getNr(),
"integer");
129 $area_set = $ilDB->query($q);
130 $area_rec = $ilDB->fetchAssoc($area_set);
132 $this->
setShape($area_rec[
"shape"]);
134 $this->
setNr($area_rec[
"nr"]);
137 $this->
setTitle($area_rec[
"title"]);
138 $this->
setHref($area_rec[
"href"]);
140 $this->
setType($area_rec[
"type"]);
154 $q =
"UPDATE map_area SET shape = ".$ilDB->quote($this->
getShape(),
"text").
155 ", coords = ".$ilDB->quote($this->
getCoords(),
"text").
156 ", link_type = ".$ilDB->quote($this->
getLinkType(),
"text").
157 ", title = ".$ilDB->quote($this->
getTitle(),
"text").
158 ", href = ".$ilDB->quote($this->
getHref(),
"text").
159 ", target = ".$ilDB->quote($this->
getTarget(),
"text").
160 ", type = ".$ilDB->quote($this->
getType(),
"text").
163 ", target_frame = ".$ilDB->quote($this->
getTargetFrame(),
"text").
164 " WHERE item_id = ".$ilDB->quote($this->
getItemId(),
"integer").
165 " AND nr = ".$ilDB->quote($this->
getNr(),
"integer");
166 $ilDB->manipulate($q);
177 $q =
"SELECT * FROM map_area WHERE item_id = ".
178 $ilDB->quote($a_item_id,
"integer");
179 $area_set = $ilDB->query($q);
180 while ($area_rec = $ilDB->fetchAssoc($area_set))
183 $type = $area_rec[
"type"];
184 $item_id = $area_rec[
"item_id"];
185 $nr = $area_rec[
"nr"];
190 if ($new_target !==
false)
192 $query =
"UPDATE map_area SET ".
193 "target = ".$ilDB->quote($new_target,
"text").
" ".
194 "WHERE item_id = ".$ilDB->quote($item_id,
"integer").
195 " AND nr = ".$ilDB->quote($nr,
"integer");
196 $ilDB->manipulate(
$query);
211 $q =
"SELECT * FROM map_area WHERE item_id = ".
212 $ilDB->quote($a_item_id,
"integer");
213 $area_set = $ilDB->query($q);
217 while ($area_rec = $ilDB->fetchAssoc($area_set))
220 $type = $area_rec[
"type"];
221 $targetframe = $area_rec[
"target_frame"];
225 $links[
$target.
":".$type.
":".$targetframe] =
227 "TargetFrame" => $targetframe);
240 $q =
"SELECT * FROM map_area WHERE ".
241 " link_type = ".$ilDB->quote(
$a_type,
"text").
242 " AND target = ".$ilDB->quote($a_target,
"text");
243 $set = $ilDB->query($q);
246 while($rec = $ilDB->fetchAssoc($set))
249 $mobs[$mob_id] = $mob_id;
266 self::HL_NONE => $lng->txt(
"cont_none"),
267 self::HL_HOVER => $lng->txt(
"cont_hover"),
268 self::HL_ALWAYS => $lng->txt(
"cont_always")
281 $this->highlight_mode = $a_val;
291 return $this->highlight_mode;
304 self::HLCL_ACCENTED => $lng->txt(
"cont_accented"),
305 self::HLCL_LIGHT => $lng->txt(
"cont_light"),
306 self::HLCL_DARK => $lng->txt(
"cont_dark"),
317 $this->highlight_class = $a_val;
327 return $this->highlight_class;
337 $this->item_id = $a_item_id;
377 $this->shape = $a_shape;
397 $this->coords = $a_coords;
417 $this->title = $a_title;
427 $this->title.= $a_title_str;
447 $this->linktype = $a_link_type;
467 $this->xl_href = $a_href;
487 $this->xl_title = $a_title;
507 $this->il_target = $a_target;
519 if ((substr(
$target, 0, 4) ==
"il__") && $a_insert_inst)
556 $this->il_target_frame = $a_target_frame;
575 function draw(&$a_image, $a_col1, $a_col2, $a_close_poly =
true,
576 $a_x_ratio = 1, $a_y_ratio = 1)
582 $a_x_ratio, $a_y_ratio);
587 $a_x_ratio, $a_y_ratio);
592 $a_x_ratio, $a_y_ratio);
608 function drawLine(&$im, $x1, $y1, $x2, $y2, $c1, $c2)
610 imageline($im, $x1+1, $y1, $x2+1, $y2, $c1);
611 imageline($im, $x1-1, $y1, $x2-1, $y2, $c1);
612 imageline($im, $x1, $y1+1, $x2, $y2+1, $c1);
613 imageline($im, $x1, $y1-1, $x2, $y2-1, $c1);
614 imageline($im, $x1, $y1, $x2, $y2, $c2);
626 function drawRect(&$im,$coords,$c1,$c2,$a_x_ratio = 1, $a_y_ratio = 1)
628 $coord=explode(
",", $coords);
630 $this->
drawLine($im, $coord[0] / $a_x_ratio, $coord[1] / $a_y_ratio,
631 $coord[0] / $a_x_ratio, $coord[3] / $a_y_ratio, $c1, $c2);
632 $this->
drawLine($im, $coord[0] / $a_x_ratio, $coord[3] / $a_y_ratio,
633 $coord[2] / $a_x_ratio, $coord[3] / $a_y_ratio, $c1, $c2);
634 $this->
drawLine($im, $coord[2] / $a_x_ratio, $coord[3] / $a_y_ratio,
635 $coord[2] / $a_x_ratio, $coord[1] / $a_y_ratio, $c1, $c2);
636 $this->
drawLine($im, $coord[2] / $a_x_ratio, $coord[1] / $a_y_ratio,
637 $coord[0] / $a_x_ratio, $coord[1] / $a_y_ratio, $c1, $c2);
651 function drawPoly(&$im, $coords, $c1, $c2, $closed,$a_x_ratio = 1, $a_y_ratio = 1)
669 $c = explode(
",", $coords);
671 for($i=0; $i<$anz-$p; $i++)
673 $this->
drawLine($im, $c[$i*2] / $a_x_ratio, $c[$i*2+1] / $a_y_ratio,
674 $c[($i*2+2)%(2*$anz)] / $a_x_ratio,
675 $c[($i*2+3)%(2*$anz)] / $a_y_ratio, $c1, $c2);
689 function drawCircle(&$im, $coords, $c1, $c2,$a_x_ratio = 1, $a_y_ratio = 1)
691 $c = explode(
",", $coords);
692 imagearc($im, $c[0] / $a_x_ratio, $c[1] / $a_y_ratio,
693 ($c[2]+1)*2 / $a_x_ratio, ($c[2]+1)*2 / $a_y_ratio, 1, 360, $c1);
694 imagearc($im, $c[0] / $a_x_ratio, $c[1] / $a_y_ratio,
695 ($c[2]-1)*2 / $a_x_ratio, ($c[2]-1)*2 / $a_y_ratio, 1, 360, $c1);
696 imagearc($im, $c[0] / $a_x_ratio, $c[1] / $a_y_ratio,
697 $c[2]*2 / $a_x_ratio, $c[2]*2 / $a_y_ratio, 1, 360, $c2);
714 $coord_array = explode(
",", $c);
715 return (count($coord_array) / 2);
getTargetFrame()
get link target frame (internal link only)
appendTitle($a_title_str)
append string to (tooltip) title of area
setHighlightClass($a_val)
Set highlight class.
setTarget($a_target)
set link target (internal link only)
setTargetFrame($a_target_frame)
set link target frame (internal link only)
drawCircle(&$im, $coords, $c1, $c2, $a_x_ratio=1, $a_y_ratio=1)
draws an outlined two colored circle
static getAllHighlightClasses()
Get all highlight classes.
setHref($a_href)
set hyper reference (external link only)
setCoords($a_coords)
set coords of area
getTitle()
get (tooltip) title
read()
read map area data into object (item id and nr must be set)
getHref()
get hyper reference url (external link only)
static _getIdForImportId($a_type, $a_target)
Get current id for an import id.
drawRect(&$im, $coords, $c1, $c2, $a_x_ratio=1, $a_y_ratio=1)
draws an outlined two color rectangle
setHighlightMode($a_val)
Set highlight mode.
__construct($a_item_id=0, $a_nr=0)
map area
static getAllHighlightModes()
Get all highlight modes.
static _getIntLinks($a_item_id)
get all internal links of a media items map areas
getHighlightMode()
Get highlight mode.
setType($a_type)
set link type (internal link only)
static _resolveIntLinks($a_item_id)
resolve internal links of an item id
create()
create persistent map area object in db
draw(&$a_image, $a_col1, $a_col2, $a_close_poly=true, $a_x_ratio=1, $a_y_ratio=1)
draw image to
setTitle($a_title)
set (tooltip)title of area
getExtTitle()
get link text (external link only)
getLinkType()
get link type
static _getMobsForTarget($a_type, $a_target)
Get areas for a certain target.
Create styles array
The data for the language used.
drawPoly(&$im, $coords, $c1, $c2, $closed, $a_x_ratio=1, $a_y_ratio=1)
draws an outlined two color polygon
setShape($a_shape)
set shape (IL_AREA_RECT, IL_AREA_CIRCLE, IL_AREA_POLY, IL_AREA_WHOLE_PICTURE)
static _getMaxNr($a_item_id)
get maximum nr of media item (static)
getHighlightClass()
Get highlight class.
setNr($a_nr)
set area number
getTarget($a_insert_inst=false)
get link target (internal link only)
setItemId($a_item_id)
set media item id
setLinkType($a_link_type)
set link type
static countCoords($c)
count the number of coordinates (x,y) in a coordinate string (format: "x1,y1,x2,y2,x3,y3,...")
setExtTitle($a_title)
set link text (external link only)
getType()
get link type (internal link only)
drawLine(&$im, $x1, $y1, $x2, $y2, $c1, $c2)
draws an outlined two color line in an image