ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ILIAS\MediaPool\PageUsage\Retrieval Class Reference
+ Inheritance diagram for ILIAS\MediaPool\PageUsage\Retrieval:
+ Collaboration diagram for ILIAS\MediaPool\PageUsage\Retrieval:

Public Member Functions

 __construct (protected \ilMediaPoolPage $page, protected bool $include_hist, protected InternalDomainService $domain)
 
 getData (array $fields, ?Range $range=null, ?Order $order=null, array $filter=[], array $parameters=[])
 
 count (array $filter=[], array $parameters=[])
 
 isFieldNumeric (string $field)
 
 getData (array $fields, ?Range $range=null, ?Order $order=null, array $filter=[], array $parameters=[])
 
 count (array $filter, array $parameters)
 
 isFieldNumeric (string $field)
 

Protected Member Functions

 collectData ()
 
 buildRow (string $id, array $usage)
 
 buildVersions (array $usage)
 
 getFirstWritableRefId (int $object_id)
 

Protected Attributes

array $data = null
 

Detailed Description

Definition at line 29 of file Retrieval.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\MediaPool\PageUsage\Retrieval::__construct ( protected \ilMediaPoolPage  $page,
protected bool  $include_hist,
protected InternalDomainService  $domain 
)

Definition at line 35 of file Retrieval.php.

39 {
40 }

Member Function Documentation

◆ buildRow()

ILIAS\MediaPool\PageUsage\Retrieval::buildRow ( string  $id,
array  $usage 
)
protected

Definition at line 135 of file Retrieval.php.

135 : array
136 {
137 $usage_type = (string) ($usage["type"] ?? "");
138 $container_type = "";
139 if (str_contains($usage_type, ":")) {
140 [$container_type, $usage_type] = explode(":", $usage_type, 2);
141 }
142
143 $item = [
144 "type" => "",
145 "title" => "",
146 "sub_txt" => "",
147 "sub_title" => "",
148 "link" => ""
149 ];
150
151 switch ($usage_type) {
152 case "pg":
153 $page = $usage["page"] ?? null;
154 if (!$page instanceof \ilPageObject) {
155 break;
156 }
157
158 switch ($container_type) {
159 case "lm":
160 $lm_obj = new \ilObjLearningModule($page->getParentId(), false);
161 $item["type"] = $this->domain->lng()->txt("obj_" . $container_type);
162 $item["title"] = $lm_obj->getTitle();
163 $item["sub_txt"] = $this->domain->lng()->txt("pg");
164 $item["sub_title"] = \ilLMObject::_lookupTitle($page->getId());
165 $ref_id = $this->getFirstWritableRefId($lm_obj->getId());
166 if ($ref_id > 0) {
167 $item["link"] = \ilLink::_getLink(
168 null,
169 "pg",
170 [],
171 $page->getId() . "_" . $ref_id
172 );
173 }
174 break;
175
176 case "wpg":
177 $item["type"] = $this->domain->lng()->txt("obj_wiki");
178 $item["title"] = \ilObject::_lookupTitle($page->getParentId());
179 $item["sub_txt"] = $this->domain->lng()->txt("pg");
180 $item["sub_title"] = \ilWikiPage::lookupTitle($page->getId());
181 $ref_id = $this->getFirstWritableRefId($page->getParentId());
182 if ($ref_id > 0) {
183 $item["link"] = \ilLink::_getStaticLink($ref_id, "wiki");
184 }
185 break;
186
187 case "term":
188 $term_id = $page->getId();
189 $glossary_id = \ilGlossaryTerm::_lookGlossaryID($term_id);
190 $item["type"] = $this->domain->lng()->txt("obj_glo");
191 $item["title"] = \ilObject::_lookupTitle($glossary_id);
192 $item["sub_txt"] = $this->domain->lng()->txt("cont_term");
193 $item["sub_title"] = \ilGlossaryTerm::_lookGlossaryTerm($term_id);
194 $ref_id = $this->getFirstWritableRefId($page->getParentId());
195 if ($ref_id > 0) {
196 $item["link"] = \ilLink::_getStaticLink($ref_id, "glo");
197 }
198 break;
199
200 case "cont":
201 $object_type = \ilObject::_lookupType($page->getId());
202 $item["type"] = $this->domain->lng()->txt("obj_" . $object_type);
203 $item["title"] = \ilObject::_lookupTitle($page->getId());
204 $ref_id = $this->getFirstWritableRefId($page->getId());
205 if ($ref_id > 0) {
206 $item["link"] = \ilLink::_getStaticLink($ref_id, $object_type);
207 }
208 break;
209
210 case "copa":
211 $item["type"] = $this->domain->lng()->txt("obj_" . $container_type);
212 $item["title"] = \ilObject::_lookupTitle($page->getId());
213 $ref_id = $this->getFirstWritableRefId($page->getId());
214 if ($ref_id > 0) {
215 $item["link"] = \ilLink::_getStaticLink($ref_id, $container_type);
216 }
217 break;
218 }
219
220 if (($usage["trash"] ?? false) === true) {
221 $item["title"] .= " (" . $this->domain->lng()->txt("trash") . ")";
222 }
223 break;
224
225 case "mep":
226 $item["type"] = $this->domain->lng()->txt("obj_mep");
227 $item["title"] = \ilObject::_lookupTitle((int) $usage["id"]);
228 $ref_id = $this->getFirstWritableRefId((int) $usage["id"]);
229 if ($ref_id > 0) {
230 $item["link"] = \ilLink::_getStaticLink($ref_id, "mep");
231 }
232 break;
233
234 case "map":
235 $item["type"] = $this->domain->lng()->txt("obj_mob");
236 $item["title"] = \ilObject::_lookupTitle((int) $usage["id"]);
237 $item["sub_txt"] = $this->domain->lng()->txt("cont_link_area");
238 break;
239 }
240
241 $title = $item["title"];
242 if ($item["sub_txt"] !== "") {
243 $title .= ", " . $item["sub_txt"];
244 if ($item["sub_title"] !== "") {
245 $title .= ": " . $item["sub_title"];
246 }
247 }
248
249 if ($usage_type === "clip") {
250 $title = $this->domain->lng()->txt("cont_users_have_mob_in_clip1") .
251 " " . (int) ($usage["cnt"] ?? 0) . " " .
252 $this->domain->lng()->txt("cont_users_have_mob_in_clip2");
253 }
254
255 return [
256 "id" => $id,
257 "object" => $title,
258 "object_link" => $item["link"],
259 "type" => $item["type"],
260 "versions" => $this->buildVersions($usage)
261 ];
262 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
static _lookGlossaryTerm(int $term_id)
get glossary term
static _lookGlossaryID(int $term_id)
get glossary id form term id
static _lookupTitle(int $a_obj_id)
static _lookupType(int $id, bool $reference=false)
static _lookupTitle(int $obj_id)
Class ilPageObject Handles PageObjects of ILIAS Learning Modules (see ILIAS DTD)
static lookupTitle(int $a_page_id, string $lang="-")
foreach(array_slice($argv, 1) as $argument) $usage

References $id, $page, $usage, ilLink\_getStaticLink(), ilGlossaryTerm\_lookGlossaryID(), ilGlossaryTerm\_lookGlossaryTerm(), ilLMObject\_lookupTitle(), ilObject\_lookupTitle(), ilObject\_lookupType(), ILIAS\Repository\int(), and ilWikiPage\lookupTitle().

+ Here is the call graph for this function:

◆ buildVersions()

ILIAS\MediaPool\PageUsage\Retrieval::buildVersions ( array  $usage)
protected

Definition at line 264 of file Retrieval.php.

264 : string
265 {
266 if (!is_array($usage["versions"] ?? null) || !isset($usage["page"])) {
267 return " ";
268 }
269
270 $versions = $usage["versions"];
271 $version_text = "";
272 if (count($versions) > 5) {
273 $version_text = "..., ";
274 $versions = array_slice($versions, -5);
275 }
276
277 $separator = "";
278 foreach ($versions as $version) {
279 $history_number = $version["hist_nr"] ?? 0;
280 if ($history_number == 0) {
281 $history_number = $this->domain->lng()->txt("cont_current_version");
282 }
283 $version_text .= $separator . $history_number;
284 if (($version["lang"] ?? "") !== "") {
285 $version_text .= "/" . $version["lang"];
286 }
287 $separator = ", ";
288 }
289
290 return $version_text;
291 }
$version
Definition: plugin.php:24
count(array $filter=[], array $parameters=[])
Definition: Retrieval.php:56

References $usage, and $version.

◆ collectData()

ILIAS\MediaPool\PageUsage\Retrieval::collectData ( )
protected

Definition at line 68 of file Retrieval.php.

68 : array
69 {
70 if ($this->data !== null) {
71 return $this->data;
72 }
73
74 $usages = $this->page->getUsages($this->include_hist);
75 $clip_count = 0;
76 $aggregated_usages = [];
77
78 foreach ($usages as $usage) {
79 $usage["trash"] = false;
80 $usage_type = (string) ($usage["type"] ?? "");
81 if (str_contains($usage_type, ":")) {
82 [$container_type, $sub_type] = explode(":", $usage_type, 2);
83
84 if ($sub_type === "pg") {
86 $container_type,
87 (int) $usage["id"]
88 );
89 $usage["page"] = $page;
90 $repo_tree = $this->domain->repositoryTree();
91 $ref_ids = array_filter(
92 \ilObject::_getAllReferences($page->getRepoObjId()),
93 static fn($ref_id): bool => $repo_tree->isInTree($ref_id)
94 );
95 if ($ref_ids === []) {
96 $usage["trash"] = true;
97 }
98 }
99 }
100
101 if ($usage_type === "clip") {
102 $clip_count++;
103 continue;
104 }
105
106 if (!$this->include_hist && $usage["trash"]) {
107 continue;
108 }
109
110 $key = $usage_type . ":" . (string) $usage["id"];
111 if (!isset($aggregated_usages[$key])) {
112 $aggregated_usages[$key] = $usage;
113 }
114 $aggregated_usages[$key]["versions"][] = [
115 "hist_nr" => $usage["hist_nr"] ?? 0,
116 "lang" => $usage["lang"] ?? ""
117 ];
118 }
119
120 if ($clip_count > 0) {
121 $aggregated_usages["clip"] = [
122 "type" => "clip",
123 "cnt" => $clip_count
124 ];
125 }
126
127 $this->data = [];
128 foreach ($aggregated_usages as $id => $usage) {
129 $this->data[] = $this->buildRow((string) $id, $usage);
130 }
131
132 return $this->data;
133 }
buildRow(string $id, array $usage)
Definition: Retrieval.php:135
static _getAllReferences(int $id)
get all reference ids for object ID
static getInstance(string $a_parent_type, int $a_id=0, int $a_old_nr=0, string $a_lang="-")

References $data, $id, $page, $usage, ilObject\_getAllReferences(), and ilPageObjectFactory\getInstance().

+ Here is the call graph for this function:

◆ count()

ILIAS\MediaPool\PageUsage\Retrieval::count ( array  $filter = [],
array  $parameters = [] 
)

Implements ILIAS\Repository\RetrievalInterface.

Definition at line 56 of file Retrieval.php.

59 : int {
60 return count($this->collectData());
61 }

◆ getData()

ILIAS\MediaPool\PageUsage\Retrieval::getData ( array  $fields,
?Range  $range = null,
?Order  $order = null,
array  $filter = [],
array  $parameters = [] 
)

Implements ILIAS\Repository\RetrievalInterface.

Definition at line 42 of file Retrieval.php.

48 : \Generator {
49 $data = $this->collectData();
50 $data = $this->applyOrder($data, $order);
51 $data = $this->applyRange($data, $range);
52
53 yield from $data;
54 }

◆ getFirstWritableRefId()

ILIAS\MediaPool\PageUsage\Retrieval::getFirstWritableRefId ( int  $object_id)
protected

Definition at line 293 of file Retrieval.php.

293 : int
294 {
295 foreach (\ilObject::_getAllReferences($object_id) as $ref_id) {
296 if ($this->domain->access()->checkAccess("write", "", $ref_id)) {
297 return (int) $ref_id;
298 }
299 }
300 return 0;
301 }

References ilObject\_getAllReferences().

+ Here is the call graph for this function:

◆ isFieldNumeric()

ILIAS\MediaPool\PageUsage\Retrieval::isFieldNumeric ( string  $field)

Implements ILIAS\Repository\RetrievalInterface.

Definition at line 63 of file Retrieval.php.

63 : bool
64 {
65 return false;
66 }

Field Documentation

◆ $data

array ILIAS\MediaPool\PageUsage\Retrieval::$data = null
protected

Definition at line 33 of file Retrieval.php.


The documentation for this class was generated from the following file: