19define(
"IL_AREA_RECT",
"Rect");
20define(
"IL_AREA_CIRCLE",
"Circle");
21define(
"IL_AREA_POLY",
"Poly");
22define(
"IL_AREA_WHOLE_PICTURE",
"WholePicture");
24define(
"IL_INT_LINK",
"int");
25define(
"IL_EXT_LINK",
"ext");
26define(
"IL_NO_LINK",
"no");
28define(
"IL_LT_STRUCTURE",
"StructureObject");
29define(
"IL_LT_PAGE",
"PageObject");
30define(
"IL_LT_MEDIA",
"MediaObject");
31define(
"IL_LT_GLITEM",
"GlossaryItem");
33define(
"IL_TF_MEDIA",
"Media");
34define(
"IL_TF_FAQ",
"FAQ");
35define(
"IL_TF_GLOSSARY",
"Glossary");
36define(
"IL_TF_NEW",
"New");
80 $this->db =
$DIC->database();
82 if ($a_item_id != 0 && $a_nr != 0) {
96 $q =
"INSERT INTO map_area (item_id, nr, shape, " .
97 "coords, link_type, title, href, target, type, highlight_mode, highlight_class, target_frame) " .
100 $ilDB->quote($this->
getNr(),
"integer") .
"," .
124 $q =
"SELECT max(nr) AS max_nr FROM map_area WHERE item_id = " .
125 $ilDB->quote($a_item_id,
"integer");
127 $max_rec =
$ilDB->fetchAssoc($max_set);
129 return (
int) $max_rec[
"max_nr"];
136 $q =
"SELECT * FROM map_area WHERE item_id = " .
137 $ilDB->quote($this->getItemId(),
"integer") .
138 " AND nr = " .
$ilDB->quote($this->getNr(),
"integer");
140 $area_rec =
$ilDB->fetchAssoc($area_set);
141 $this->setShape((
string) $area_rec[
"shape"]);
143 $this->setNr((
int) $area_rec[
"nr"]);
144 $this->setCoords((
string) $area_rec[
"coords"]);
145 $this->setLinkType((
string) $area_rec[
"link_type"]);
146 $this->setTitle((
string) $area_rec[
"title"]);
147 $this->setHref((
string) $area_rec[
"href"]);
148 $this->setTarget((
string) $area_rec[
"target"]);
149 $this->setType((
string) $area_rec[
"type"]);
150 $this->setTargetFrame((
string) $area_rec[
"target_frame"]);
151 $this->setHighlightMode((
string) $area_rec[
"highlight_mode"]);
152 $this->setHighlightClass((
string) $area_rec[
"highlight_class"]);
159 $q =
"UPDATE map_area SET shape = " .
$ilDB->quote($this->getShape(),
"text") .
160 ", coords = " .
$ilDB->quote($this->getCoords(),
"text") .
161 ", link_type = " .
$ilDB->quote($this->getLinkType(),
"text") .
163 ", href = " .
$ilDB->quote($this->getHref(),
"text") .
164 ", target = " .
$ilDB->quote($this->getTarget(),
"text") .
165 ", type = " .
$ilDB->quote($this->getType(),
"text") .
166 ", highlight_mode = " .
$ilDB->quote($this->getHighlightMode(),
"text") .
167 ", highlight_class = " .
$ilDB->quote($this->getHighlightClass(),
"text") .
168 ", target_frame = " .
$ilDB->quote($this->getTargetFrame(),
"text") .
169 " WHERE item_id = " .
$ilDB->quote($this->getItemId(),
"integer") .
170 " AND nr = " .
$ilDB->quote($this->getNr(),
"integer");
185 $q =
"SELECT * FROM map_area WHERE item_id = " .
186 $ilDB->quote($a_item_id,
"integer");
188 while ($area_rec =
$ilDB->fetchAssoc($area_set)) {
189 $target = (string) $area_rec[
"target"];
190 $type = $area_rec[
"type"];
191 $item_id = $area_rec[
"item_id"];
192 $nr = $area_rec[
"nr"];
194 if (($area_rec[
"link_type"] ==
IL_INT_LINK) && (!is_int(strpos($target,
"__")))) {
196 if ($new_target !==
false) {
197 $query =
"UPDATE map_area SET " .
198 "target = " .
$ilDB->quote($new_target,
"text") .
" " .
199 "WHERE item_id = " .
$ilDB->quote($item_id,
"integer") .
200 " AND nr = " .
$ilDB->quote($nr,
"integer");
201 $ilDB->manipulate($query);
219 $q =
"SELECT * FROM map_area WHERE item_id = " .
220 $ilDB->quote($a_item_id,
"integer");
225 while ($area_rec =
$ilDB->fetchAssoc($area_set)) {
226 $target = $area_rec[
"target"];
227 $type = $area_rec[
"type"];
228 $targetframe = $area_rec[
"target_frame"];
230 if (($area_rec[
"link_type"] ==
IL_INT_LINK) && (is_int(strpos($target,
"__")))) {
231 $links[$target .
":" . $type .
":" . $targetframe] =
232 array(
"Target" => $target,
"Type" => $type,
233 "TargetFrame" => $targetframe);
250 $q =
"SELECT * FROM map_area WHERE " .
251 " link_type = " .
$ilDB->quote($a_type,
"text") .
252 " AND target = " .
$ilDB->quote($a_target,
"text");
256 while ($rec =
$ilDB->fetchAssoc($set)) {
258 $mobs[$mob_id] = $mob_id;
271 self::HL_NONE =>
$lng->txt(
"cont_none"),
272 self::HL_HOVER =>
$lng->txt(
"cont_hover"),
273 self::HL_ALWAYS =>
$lng->txt(
"cont_always")
280 $this->highlight_mode = $a_val;
285 return $this->highlight_mode;
295 self::HLCL_ACCENTED =>
$lng->txt(
"cont_accented"),
296 self::HLCL_LIGHT =>
$lng->txt(
"cont_light"),
297 self::HLCL_DARK =>
$lng->txt(
"cont_dark"),
303 $this->highlight_class = $a_val;
308 return $this->highlight_class;
313 $this->item_id = $a_item_id;
318 return $this->item_id;
321 public function setNr(
int $a_nr): void
336 $this->shape = $a_shape;
350 $this->coords = $a_coords;
355 return $this->coords;
363 $this->title = $a_title;
368 $this->title .= $a_title_str;
382 $this->linktype = $a_link_type;
387 return $this->linktype;
395 $this->xl_href = $a_href;
400 return $this->xl_href;
409 $this->xl_title = $a_title;
414 return $this->xl_title;
423 $this->il_target = $a_target;
429 public function getTarget(
bool $a_insert_inst =
false): string
431 $target = $this->il_target;
433 if ((substr($target, 0, 4) ==
"il__") && $a_insert_inst) {
434 $target =
"il_" .
IL_INST_ID .
"_" . substr($target, 4, strlen($target) - 4);
447 $this->il_type = $a_type;
452 return $this->il_type;
463 $this->il_target_frame = $a_target_frame;
468 return $this->il_target_frame;
478 bool $a_close_poly =
true,
479 float $a_x_ratio = 1,
482 switch ($this->getShape()) {
538 imageline($im, $x1 + 1, $y1, $x2 + 1, $y2, $c1);
539 imageline($im, $x1 - 1, $y1, $x2 - 1, $y2, $c1);
540 imageline($im, $x1, $y1 + 1, $x2, $y2 + 1, $c1);
541 imageline($im, $x1, $y1 - 1, $x2, $y2 - 1, $c1);
542 imageline($im, $x1, $y1, $x2, $y2, $c2);
558 float $a_x_ratio = 1,
561 $coord = explode(
",", $coords);
565 $coord[0] / $a_x_ratio,
566 $coord[1] / $a_y_ratio,
567 $coord[0] / $a_x_ratio,
568 $coord[3] / $a_y_ratio,
574 $coord[0] / $a_x_ratio,
575 $coord[3] / $a_y_ratio,
576 $coord[2] / $a_x_ratio,
577 $coord[3] / $a_y_ratio,
583 $coord[2] / $a_x_ratio,
584 $coord[3] / $a_y_ratio,
585 $coord[2] / $a_x_ratio,
586 $coord[1] / $a_y_ratio,
592 $coord[2] / $a_x_ratio,
593 $coord[1] / $a_y_ratio,
594 $coord[0] / $a_x_ratio,
595 $coord[1] / $a_y_ratio,
617 float $a_x_ratio = 1,
628 if ($anz < (3 - $p)) {
632 $c = explode(
",", $coords);
634 for ($i = 0; $i < $anz - $p; $i++) {
637 $c[$i * 2] / $a_x_ratio,
638 $c[$i * 2 + 1] / $a_y_ratio,
639 $c[($i * 2 + 2) % (2 * $anz)] / $a_x_ratio,
640 $c[($i * 2 + 3) % (2 * $anz)] / $a_y_ratio,
661 float $a_x_ratio = 1,
664 $c = explode(
",", $coords);
669 (
$c[2] + 1) * 2 / $a_x_ratio,
670 (
$c[2] + 1) * 2 / $a_y_ratio,
679 (
$c[2] - 1) * 2 / $a_x_ratio,
680 (
$c[2] - 1) * 2 / $a_y_ratio,
689 $c[2] * 2 / $a_x_ratio,
690 $c[2] * 2 / $a_y_ratio,
707 $coord_array = explode(
",",
$c);
708 return (count($coord_array) / 2);
static _getIdForImportId(string $a_type, string $a_target)
Get current id for an import id.
setItemId(int $a_item_id)
drawPoly( $im, string $coords, int $c1, int $c2, bool $closed, float $a_x_ratio=1, float $a_y_ratio=1)
draws an outlined two color polygon
static getAllHighlightClasses()
setHref(string $a_href)
set hyper reference (external link only)
drawCircle( $im, string $coords, int $c1, int $c2, float $a_x_ratio=1, float $a_y_ratio=1)
draws an outlined two colored circle
draw( $a_image, int $a_col1, int $a_col2, bool $a_close_poly=true, float $a_x_ratio=1, float $a_y_ratio=1)
setShape(string $a_shape)
set shape (IL_AREA_RECT, IL_AREA_CIRCLE, IL_AREA_POLY, IL_AREA_WHOLE_PICTURE)
static _resolveIntLinks(int $a_item_id)
resolve internal links of an item id
static _getMaxNr(int $a_item_id)
get maximum nr of media item (static)
setCoords(string $a_coords)
set coords of area
create()
create persistent map area object in db
__construct(int $a_item_id=0, int $a_nr=0)
setTitle(string $a_title)
set (tooltip)title of area
getTarget(bool $a_insert_inst=false)
get link target (internal link only)
drawRect( $im, string $coords, int $c1, int $c2, float $a_x_ratio=1, float $a_y_ratio=1)
draws an outlined two color rectangle
static _getIntLinks(int $a_item_id)
get all internal links of a media items map areas
setExtTitle(string $a_title)
set link text (external link only)
static _getMobsForTarget(string $a_type, string $a_target)
Get areas for a certain target.
appendTitle(string $a_title_str)
setType(string $a_type)
set link type (internal link only)
static getAllHighlightModes()
drawLine( $im, int $x1, int $y1, int $x2, int $y2, int $c1, int $c2)
draws an outlined two color line in an image
setTarget(string $a_target)
set link target (internal link only)
setHighlightClass(string $a_val)
setHighlightMode(string $a_val)
setTargetFrame(string $a_target_frame)
set link target frame (internal link only)
static countCoords(string $c)
count the number of coordinates (x,y) in a coordinate string (format: "x1,y1,x2,y2,...
setLinkType(string $a_link_type)
set link type
if(!file_exists('../ilias.ini.php'))