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 \ilObjMediaObject $media_object
31 ) {
32 }
33
34 public function getData(
35 array $fields,
36 ?Range $range = null,
37 ?Order $order = null,
38 array $filter = [],
39 array $parameters = []
40 ): \Generator {
41 $data = $this->collectData();
42 $data = $this->applyOrder($data, $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 $item = $this->media_object->getMediaItem("Standard");
67 $data = [];
68 $highlight_modes = \ilMapArea::getAllHighlightModes();
69 $highlight_classes = \ilMapArea::getAllHighlightClasses();
70
71 for ($id = 1, $max = \ilMapArea::_getMaxNr($item->getId()); $id <= $max; $id++) {
72 $area = new \ilMapArea($item->getId(), $id);
73 $data[] = [
74 "id" => $id,
75 "title" => $area->getTitle(),
76 "shape" => $area->getShape(),
77 "coords" => implode(", ", explode(",", $area->getCoords())),
78 "highlight_mode" => $highlight_modes[$area->getHighlightMode()] ?? $area->getHighlightMode(),
79 "highlight_class" => $highlight_classes[$area->getHighlightClass()] ?? $area->getHighlightClass(),
80 "link_type" => $area->getLinkType(),
81 "href" => $area->getHref(),
82 "target" => $area->getTarget(),
83 "type" => $area->getType(),
84 "target_frame" => $area->getTargetFrame()
85 ];
86 }
87
88 return $this->data = $data;
89 }
90}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
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
__construct(protected \ilObjMediaObject $media_object)
getData(array $fields, ?Range $range=null, ?Order $order=null, array $filter=[], array $parameters=[])
count(array $filter=[], array $parameters=[])
static getAllHighlightClasses()
static _getMaxNr(int $a_item_id)
get maximum nr of media item (static)
static getAllHighlightModes()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$data
Definition: storeScorm.php:45