ILIAS  trunk Revision v12.0_alpha-16-g3e876e53c80
SubitemPropertiesReader.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
25use ILIAS\Data\Factory as DataFactory;
26use ilLanguage;
34use Generator;
35
37{
38 protected ilLanguage $lng;
39 protected DataFactory $data_factory;
42
43 public static function type(): string
44 {
45 return 'mep';
46 }
47
48 public function init(Container $dic): void
49 {
50 $this->lng = $dic->language();
51 $this->data_factory = new DataFactory();
52 $this->static_url = $dic['static_url'];
53 $this->ctrl = $dic->ctrl();
54 }
55
56 public function getSubitemProperties(
57 PropertiesFactory $factory,
58 int $parent_ref_id,
59 ID ...$subitem_ids
60 ): Generator {
61 foreach ($subitem_ids as $subitem_id) {
62 $link = null;
63 switch ($subitem_id->type()) {
64 case 'fold':
65 $link = $this->static_url->builder()->build(
66 'mep',
67 $this->data_factory->refId($parent_ref_id),
68 [$subitem_id->id()]
69 );
70 break;
71
72 case 'mob':
73 $this->ctrl->setParameterByClass(ilMediaPoolPresentationGUI::class, 'ref_id', $parent_ref_id);
74 $this->ctrl->setParameterByClass(ilMediaPoolPresentationGUI::class, 'force_filter', $subitem_id->id());
75 $link = $this->data_factory->uri(rtrim(ILIAS_HTTP_PATH, '/') . '/' .
76 $this->ctrl->getLinkTargetByClass(ilMediaPoolPresentationGUI::class, 'allMedia'));
77 $this->ctrl->clearParameterByClass(ilMediaPoolPresentationGUI::class, 'force_filter');
78 $this->ctrl->clearParameterByClass(ilMediaPoolPresentationGUI::class, 'ref_id');
79 break;
80
81 case 'pg':
82 $pool = new ilObjMediaPool($parent_ref_id);
83 $parent_id = $pool->getParentId((int) $subitem_id->id());
84 $link = $this->static_url->builder()->build(
85 'mep',
86 $this->data_factory->refId($parent_ref_id),
87 $parent_id === null ? [] : [$parent_id]
88 );
89 break;
90 }
91 if ($link === null) {
92 continue;
93 }
94 yield $factory->get(
95 $subitem_id,
96 ilMediaPoolItem::lookupTitle((int) $subitem_id->id()),
97 $link,
98 false,
99 $this->lng->txt('obj_' . $subitem_id->type())
100 );
101 }
102 }
103}
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:36
language()
Get interface to the i18n service.
Definition: Container.php:95
ctrl()
Get the interface to the control structure.
Definition: Container.php:63
Builds data types.
Definition: Factory.php:36
Class Services.
Definition: Services.php:38
getSubitemProperties(PropertiesFactory $factory, int $parent_ref_id, ID ... $subitem_ids)
Order of the output should respect the order of the subitem_ids.
language handling
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static lookupTitle(int $a_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
get(ID $id, string $title, ?URI $link_to_subitem, bool $open_link_in_new_viewport, string $presentable_subitem_type)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$dic
Definition: ltiresult.php:33