ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ImageMapRetrieval.php
Go to the documentation of this file.
1<?php
2
14declare(strict_types=1);
15
17
20use ILIAS\Repository\RetrievalBase;
22
24{
25 use RetrievalBase;
26
27 protected ?array $data = null;
28
29 public function __construct(
30 protected \ilPCInteractiveImage|\ilPCMediaObject $content_obj,
31 protected string $parent_node_name
32 ) {
33 }
34
35 public function getData(
36 array $fields,
37 ?Range $range = null,
38 ?Order $order = null,
39 array $filter = [],
40 array $parameters = []
41 ): \Generator {
42 $data = $this->applyOrder($this->collectData(), $order);
43 $data = $this->applyRange($data, $range);
44
45 foreach ($data as $row) {
46 yield $row;
47 }
48 }
49
50 public function count(array $filter = [], array $parameters = []): int
51 {
52 return count($this->collectData());
53 }
54
55 public function isFieldNumeric(string $field): bool
56 {
57 return $field === "id";
58 }
59
60 protected function collectData(): array
61 {
62 if ($this->data !== null) {
63 return $this->data;
64 }
65
66 $alias_item = new \ilMediaAliasItem(
67 $this->content_obj->getDomDoc(),
68 $this->content_obj->hier_id,
69 "Standard",
70 $this->content_obj->getPCId(),
71 $this->parent_node_name
72 );
73 $data = [];
74 foreach ($alias_item->getMapAreas() as $area) {
75 $link = $area["Link"] ?? [];
76 $link_type = strtolower($link["LinkType"] ?? "");
77 $link_type = match ($link_type) {
78 "extlink" => "ext",
79 "intlink" => "int",
80 default => $link_type
81 };
82 $data[] = [
83 "id" => (int) $area["Nr"],
84 "title" => $link["Title"] ?? "",
85 "shape" => $area["Shape"],
86 "coords" => implode(", ", explode(",", $area["Coords"])),
87 "highlight_mode" => $area["HighlightMode"],
88 "highlight_class" => $area["HighlightClass"],
89 "link_type" => $link_type,
90 "href" => $link["Href"] ?? "",
91 "target" => $link["Target"] ?? "",
92 "type" => $link["Type"] ?? "",
93 "target_frame" => $link["TargetFrame"] ?? ""
94 ];
95 }
96
97 usort(
98 $data,
99 static fn(array $left, array $right): int => strcasecmp($left["title"], $right["title"])
100 );
101
102 return $this->data = $data;
103 }
104}
count(array $filter=[], array $parameters=[])
__construct(protected \ilPCInteractiveImage|\ilPCMediaObject $content_obj, protected string $parent_node_name)
getData(array $fields, ?Range $range=null, ?Order $order=null, array $filter=[], array $parameters=[])
Both the subject and the direction need to be specified when expressing an order.
Definition: Order.php:29
A simple class to express a naive range of whole positive numbers.
Definition: Range.php:29
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilPCMediaObject Media content object (see ILIAS DTD)
$data
Definition: storeScorm.php:45