ILIAS  trunk Revision v12.0_alpha-16-g3e876e53c80
ILIAS\MediaObjects\OverviewGUI\Table\Retrieval Class Reference
+ Inheritance diagram for ILIAS\MediaObjects\OverviewGUI\Table\Retrieval:
+ Collaboration diagram for ILIAS\MediaObjects\OverviewGUI\Table\Retrieval:

Public Member Functions

 __construct (protected SubObjectRetrieval $sub_object_retrieval, protected InternalDomainService $domain, protected DataFactory $data_factory)
 
 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

 getInternalData (array $filter)
 get data only with internal usages and properties of the media objects More...
 
 addExternalData (array $internal_data)
 add external usages to data, requiring additional access checks More...
 
 isDatumExcludedByFilter (string $title, string $copyright_identifier, int $last_update, array $filter)
 

Protected Attributes

array $internal_data
 

Detailed Description

Definition at line 35 of file Retrieval.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\MediaObjects\OverviewGUI\Table\Retrieval::__construct ( protected SubObjectRetrieval  $sub_object_retrieval,
protected InternalDomainService  $domain,
protected DataFactory  $data_factory 
)

Definition at line 41 of file Retrieval.php.

45 {
46 }

Member Function Documentation

◆ addExternalData()

ILIAS\MediaObjects\OverviewGUI\Table\Retrieval::addExternalData ( array  $internal_data)
protected

add external usages to data, requiring additional access checks

Definition at line 108 of file Retrieval.php.

108 : array
109 {
110 $access = $this->domain->access();
111 $static_url = $this->domain->staticUrl();
112
114 foreach ($data as $key => $datum) {
115 $mob_id = $datum['id'];
116 $already_collected_obj_ids = [];
117 foreach (ilObjMediaObject::lookupUsages($mob_id, false) as $usage) {
118 /*
119 * filter out already collected usages, see getInternalData
120 */
121 if (in_array(
122 $usage['type'] . ':' . $usage['id'],
123 array_keys($datum['internal_usages'])
124 )) {
125 continue;
126 }
127
128 $parent_obj_id = ilObjMediaObject::getParentObjectIdForUsage($usage);
129 if (!$parent_obj_id || in_array($parent_obj_id, $already_collected_obj_ids)) {
130 continue;
131 }
132
133 $parent_ref_id = null;
134 $show_link = false;
135 foreach (ilObject::_getAllReferences($parent_obj_id) as $ref_id) {
136 if (!$access->checkAccess('visible', '', $ref_id)) {
137 continue;
138 }
139 $parent_ref_id = $ref_id;
140 $show_link = $access->checkAccess('read', '', $parent_ref_id);
141 break;
142 }
143 if (!$parent_ref_id) {
144 continue;
145 }
146
147 $parent_title = ilObject::_lookupTitle($parent_obj_id);
148 $parent_type = ilObject::_lookupType($parent_obj_id);
149 $link_to_parent = '';
150 if ($show_link) {
151 $link_to_parent = (string) $static_url->builder()->build(
152 $parent_type,
153 $this->data_factory->refId($parent_ref_id)
154 );
155 }
156
157 $already_collected_obj_ids[] = $parent_obj_id;
158 if ($parent_type === 'mep') {
159 $data[$key]['mep_usages'][] = [
160 'title' => $parent_title,
161 'link' => $link_to_parent
162 ];
163 continue;
164 }
165 $data[$key]['external_usages'][] = [
166 'title' => $parent_title,
167 'link' => $link_to_parent
168 ];
169 }
170 }
171 return $data;
172 }
static getParentObjectIdForUsage(array $a_usage, bool $a_include_all_access_obj_ids=false)
Get's the repository object ID of a parent object, if possible see ilWebAccessChecker.
static lookupUsages(int $a_id, bool $a_include_history=true)
Lookup usages of media object.
static _lookupType(int $id, bool $reference=false)
static _getAllReferences(int $id)
get all reference ids for object ID
static _lookupTitle(int $obj_id)
$static_url
Definition: goto.php:29
$ref_id
Definition: ltiauth.php:66

References $data, ILIAS\MediaObjects\OverviewGUI\Table\Retrieval\$internal_data, $ref_id, $static_url, ilObject\_getAllReferences(), ilObject\_lookupTitle(), ilObject\_lookupType(), ilObjMediaObject\getParentObjectIdForUsage(), and ilObjMediaObject\lookupUsages().

+ Here is the call graph for this function:

◆ count()

ILIAS\MediaObjects\OverviewGUI\Table\Retrieval::count ( array  $filter,
array  $parameters 
)

Implements ILIAS\Repository\RetrievalInterface.

Definition at line 226 of file Retrieval.php.

229 : int {
230 return count($this->getInternalData($filter));
231 }
count(array $filter, array $parameters)
Definition: Retrieval.php:226
getInternalData(array $filter)
get data only with internal usages and properties of the media objects
Definition: Retrieval.php:52

◆ getData()

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

Implements ILIAS\Repository\RetrievalInterface.

Definition at line 205 of file Retrieval.php.

211 : Generator {
212 $data = $this->getInternalData($filter);
213
214 $data = $this->applyOrder($data, $order);
215 $data = $this->applyRange($data, $range);
216
217 /*
218 * read out other usages after applying order and range,
219 * to avoid unnecessary access checks
220 */
221 $data = $this->addExternalData($data);
222
223 yield from $data;
224 }
addExternalData(array $internal_data)
add external usages to data, requiring additional access checks
Definition: Retrieval.php:108

◆ getInternalData()

ILIAS\MediaObjects\OverviewGUI\Table\Retrieval::getInternalData ( array  $filter)
protected

get data only with internal usages and properties of the media objects

Definition at line 52 of file Retrieval.php.

52 : array
53 {
54 $media_object_manager = $this->domain->mediaObject();
55 $lom = $this->domain->learningObjectMetadata();
56
57 if (isset($this->internal_data)) {
59 }
60 $this->internal_data = [];
61 foreach ($this->sub_object_retrieval->getPossibleTypes() as $type) {
62 foreach ($this->sub_object_retrieval->getAllIDsForType($type) as $id) {
63 $title = $this->sub_object_retrieval->getTitleOfSubObject($type, $id);
64 $link = $this->sub_object_retrieval->getLinkToSubObject($type, $id);
65 foreach (ilObjMediaObject::_getMobsOfObject($type, $id, 0) as $mob_id) {
66 /*
67 * type and id are only needed here internally to separate
68 * internal from external usages, see addExternalData
69 */
70 $this->internal_data[$mob_id]['internal_usages'][$type . ':' . $id] = [
71 'title' => $title,
72 'link' => $link
73 ];
74 }
75 }
76 }
77 foreach ($this->internal_data as $mob_id => $value) {
78 if (!ilObjMediaObject::_exists($mob_id)) {
79 unset($this->internal_data[$mob_id]);
80 continue;
81 }
82 $title = ilObject::_lookupTitle($mob_id);
83 $last_update = $media_object_manager->getLastChangeTimestamp($mob_id);
84
85 $reader = $lom->read(0, $mob_id, 'mob', $lom->paths()->copyright());
86 $preset_copyright = $lom->copyrightHelper()->readPresetCopyright($reader);
87
88 if ($this->isDatumExcludedByFilter($title, $preset_copyright->identifier(), $last_update, $filter)) {
89 unset($this->internal_data[$mob_id]);
90 continue;
91 }
92
93 $this->internal_data[$mob_id]['id'] = $mob_id;
94 $this->internal_data[$mob_id]['title'] = $title;
95 $this->internal_data[$mob_id]['last_update'] = $last_update;
96 $this->internal_data[$mob_id]['copyright_identifier'] = $preset_copyright->identifier();
97 $this->internal_data[$mob_id]['copyright'] = $lom->copyrightHelper()->hasPresetCopyright($reader) ?
98 $preset_copyright->presentAsString() :
99 $lom->copyrightHelper()->readCustomCopyright($reader);
100 }
102 }
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
isDatumExcludedByFilter(string $title, string $copyright_identifier, int $last_update, array $filter)
Definition: Retrieval.php:174
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
static _getMobsOfObject(string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")

References $id, ILIAS\MediaObjects\OverviewGUI\Table\Retrieval\$internal_data, ilObjMediaObject\_exists(), ilObjMediaObject\_getMobsOfObject(), ilObject\_lookupTitle(), and ILIAS\MediaObjects\OverviewGUI\Table\Retrieval\isDatumExcludedByFilter().

+ Here is the call graph for this function:

◆ isDatumExcludedByFilter()

ILIAS\MediaObjects\OverviewGUI\Table\Retrieval::isDatumExcludedByFilter ( string  $title,
string  $copyright_identifier,
int  $last_update,
array  $filter 
)
protected

Definition at line 174 of file Retrieval.php.

179 : bool {
180 if (
181 ($filter['title'] ?? '') !== '' &&
182 !str_contains(strtolower($title), strtolower($filter['title']))
183 ) {
184 return true;
185 }
186
187 if (
188 ($filter['copyright'] ?? []) !== [] &&
189 !in_array($copyright_identifier, $filter['copyright'])
190 ) {
191 return true;
192 }
193
194 $last_update = new DateTimeImmutable('@' . $last_update);
195 if (
196 (isset($filter['last_update'][0]) && $last_update < new DateTimeImmutable($filter['last_update'][0])) ||
197 (isset($filter['last_update'][1]) && $last_update > new DateTimeImmutable($filter['last_update'][1]))
198 ) {
199 return true;
200 }
201
202 return false;
203 }

Referenced by ILIAS\MediaObjects\OverviewGUI\Table\Retrieval\getInternalData().

+ Here is the caller graph for this function:

◆ isFieldNumeric()

ILIAS\MediaObjects\OverviewGUI\Table\Retrieval::isFieldNumeric ( string  $field)

Implements ILIAS\Repository\RetrievalInterface.

Definition at line 233 of file Retrieval.php.

233 : bool
234 {
235 return $field === 'last_update';
236 }

Field Documentation

◆ $internal_data

array ILIAS\MediaObjects\OverviewGUI\Table\Retrieval::$internal_data
protected

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