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");
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);
118 $ilDB = $DIC->database();
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);
184 $ilDB = $DIC->database();
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)) {
192 $type = $area_rec[
"type"];
194 $nr = $area_rec[
"nr"];
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");
218 $ilDB = $DIC->database();
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)) {
228 $type = $area_rec[
"type"];
229 $targetframe = $area_rec[
"target_frame"];
234 "TargetFrame" => $targetframe);
247 $ilDB = $DIC->database();
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;
273 $lng = $DIC->language();
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;
312 $lng = $DIC->language();
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) {
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);
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.
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