ILIAS  release_8 Revision v8.24
class.ilMDTechnical.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
27{
28 private string $size = '';
29 private string $installation_remarks = '';
31 private string $other_platform_requirements = '';
33 private string $duration = '';
34
38 public function getPossibleSubelements(): array
39 {
40 $subs['Format'] = 'meta_format';
41 $subs['Location'] = 'meta_location';
42 if (!$this->getOrCompositeIds()) {
43 $subs['Requirement'] = 'meta_requirement';
44 }
45 if (!$this->getRequirementIds()) {
46 $subs['OrComposite'] = 'meta_or_composite';
47 }
48
49 return $subs;
50 }
51
52 // Methods for child objects (Format, Location, Requirement OrComposite)
53
57 public function getFormatIds(): array
58 {
59 return ilMDFormat::_getIds($this->getRBACId(), $this->getObjId());
60 }
61
62 public function getFormat(int $a_format_id): ?ilMDFormat
63 {
64 if (!$a_format_id) {
65 return null;
66 }
67 $for = new ilMDFormat($this->getRBACId(), $a_format_id);
68 $for->setMetaId($a_format_id);
69
70 return $for;
71 }
72
73 public function addFormat(): ilMDFormat
74 {
75 $for = new ilMDFormat($this->getRBACId(), $this->getObjId(), $this->getObjType());
76
77 return $for;
78 }
79
83 public function getLocationIds(): array
84 {
85 return ilMDLocation::_getIds($this->getRBACId(), $this->getObjId(), $this->getMetaId(), 'meta_technical');
86 }
87
88 public function getLocation(int $a_location_id): ?ilMDLocation
89 {
90 if (!$a_location_id) {
91 return null;
92 }
93 $loc = new ilMDLocation();
94 $loc->setMetaId($a_location_id);
95
96 return $loc;
97 }
98
99 public function addLocation(): ilMDLocation
100 {
101 $loc = new ilMDLocation($this->getRBACId(), $this->getObjId(), $this->getObjType());
102 $loc->setParentId($this->getMetaId());
103 $loc->setParentType('meta_technical');
104
105 return $loc;
106 }
107
111 public function getRequirementIds(): array
112 {
113 return ilMDRequirement::_getIds($this->getRBACId(), $this->getObjId(), $this->getMetaId(), 'meta_technical');
114 }
115
116 public function getRequirement(int $a_requirement_id): ?ilMDRequirement
117 {
118 if (!$a_requirement_id) {
119 return null;
120 }
121 $rec = new ilMDRequirement();
122 $rec->setMetaId($a_requirement_id);
123
124 return $rec;
125 }
126
128 {
129 $rec = new ilMDRequirement($this->getRBACId(), $this->getObjId(), $this->getObjType());
130 $rec->setParentId($this->getMetaId());
131 $rec->setParentType('meta_technical');
132
133 return $rec;
134 }
135
139 public function getOrCompositeIds(): array
140 {
141 return ilMDOrComposite::_getIds($this->getRBACId(), $this->getObjId(), $this->getMetaId(), 'meta_technical');
142 }
143
144 public function getOrComposite(int $a_or_composite_id): ?ilMDOrComposite
145 {
146 if (!$a_or_composite_id) {
147 return null;
148 }
149 $orc = new ilMDOrComposite($this->getRBACId(), $this->getObjId(), $this->getObjType());
150 $orc->setOrCompositeId($a_or_composite_id);
151 $orc->setParentId($this->getMetaId());
152 $orc->setParentType('meta_technical');
153
154 return $orc;
155 }
156
158 {
159 $orc = new ilMDOrComposite($this->getRBACId(), $this->getObjId(), $this->getObjType());
160 $orc->setParentId($this->getMetaId());
161 $orc->setParentType('meta_technical');
162
163 return $orc;
164 }
165
166 // SET/GET
167 public function setSize(string $a_size): void
168 {
169 $this->size = $a_size;
170 }
171
172 public function getSize(): string
173 {
174 return $this->size;
175 }
176
177 public function setInstallationRemarks(string $a_val): void
178 {
179 $this->installation_remarks = $a_val;
180 }
181
182 public function getInstallationRemarks(): string
183 {
185 }
186
187 public function setInstallationRemarksLanguage(ilMDLanguageItem $lng_obj): void
188 {
189 $this->installation_remarks_language = $lng_obj;
190 }
191
193 {
194 return is_object($this->installation_remarks_language) ? $this->installation_remarks_language : null;
195 }
196
197 public function getInstallationRemarksLanguageCode(): string
198 {
199 return is_object($this->installation_remarks_language) ? $this->installation_remarks_language->getLanguageCode() : '';
200 }
201
202 public function setOtherPlatformRequirements(string $a_val): void
203 {
204 $this->other_platform_requirements = $a_val;
205 }
206
207 public function getOtherPlatformRequirements(): string
208 {
210 }
211
213 {
214 $this->other_platform_requirements_language = $lng_obj;
215 }
216
218 {
219 return is_object($this->other_platform_requirements_language) ? $this->other_platform_requirements_language : null;
220 }
221
223 {
224 return is_object($this->other_platform_requirements_language)
225 ? $this->other_platform_requirements_language->getLanguageCode()
226 : '';
227 }
228
229 public function setDuration(string $a_val): void
230 {
231 $this->duration = $a_val;
232 }
233
234 public function getDuration(): string
235 {
236 return $this->duration;
237 }
238
239 public function save(): int
240 {
241 $fields = $this->__getFields();
242 $fields['meta_technical_id'] = array('integer', $next_id = $this->db->nextId('il_meta_technical'));
243
244 if ($this->db->insert('il_meta_technical', $fields)) {
245 $this->setMetaId($next_id);
246 return $this->getMetaId();
247 }
248 return 0;
249 }
250
251 public function update(): bool
252 {
253 return $this->getMetaId() && $this->db->update(
254 'il_meta_technical',
255 $this->__getFields(),
256 array("meta_technical_id" => array('integer', $this->getMetaId()))
257 );
258 }
259
260 public function delete(): bool
261 {
262 if ($this->getMetaId()) {
263 $query = "DELETE FROM il_meta_technical " .
264 "WHERE meta_technical_id = " . $this->db->quote($this->getMetaId(), 'integer');
265 $res = $this->db->manipulate($query);
266
267 foreach ($this->getFormatIds() as $id) {
268 $for = $this->getFormat($id);
269 $for->delete();
270 }
271
272 foreach ($this->getLocationIds() as $id) {
273 $loc = $this->getLocation($id);
274 $loc->delete();
275 }
276 foreach ($this->getRequirementIds() as $id) {
277 $req = $this->getRequirement($id);
278 $req->delete();
279 }
280 foreach ($this->getOrCompositeIds() as $id) {
281 $orc = $this->getOrComposite($id);
282 $orc->delete();
283 }
284
285 return true;
286 }
287 return false;
288 }
289
293 public function __getFields(): array
294 {
295 return array(
296 'rbac_id' => array('integer', $this->getRBACId()),
297 'obj_id' => array('integer', $this->getObjId()),
298 'obj_type' => array('text', $this->getObjType()),
299 't_size' => array('text', $this->getSize()),
300 'ir' => array('text', $this->getInstallationRemarks()),
301 'ir_language' => array('text', $this->getInstallationRemarksLanguageCode()),
302 'opr' => array('text', $this->getOtherPlatformRequirements()),
303 'opr_language' => array('text', $this->getOtherPlatformRequirementsLanguageCode()),
304 'duration' => array('text', $this->getDuration())
305 );
306 }
307
308 public function read(): bool
309 {
310 if ($this->getMetaId()) {
311 $query = "SELECT * FROM il_meta_technical " .
312 "WHERE meta_technical_id = " . $this->db->quote($this->getMetaId(), 'integer') . " ";
313
314 $res = $this->db->query($query);
315 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
316 $this->setRBACId((int) $row->rbac_id);
317 $this->setObjId((int) $row->obj_id);
318 $this->setObjType($row->obj_type);
319 $this->setSize($row->t_size ?? '');
320 $this->setInstallationRemarks($row->ir ?? '');
321 $this->setInstallationRemarksLanguage(new ilMDLanguageItem($row->ir_language ?? ''));
322 $this->setOtherPlatformRequirements($row->opr ?? '');
323 $this->setOtherPlatformRequirementsLanguage(new ilMDLanguageItem($row->opr_language ?? ''));
324 $this->setDuration($row->duration ?? '');
325 }
326 return true;
327 }
328 return false;
329 }
330
331 public function toXML(ilXmlWriter $writer): void
332 {
333 $writer->xmlStartTag('Technical');
334
335 // Format
336 foreach ($this->getFormatIds() as $id) {
337 $for = $this->getFormat($id);
338 $for->toXML($writer);
339 }
340
341 // Size
342 if ($this->getSize() !== '') {
343 $writer->xmlElement('Size', null, $this->getSize());
344 }
345
346 // Location
347 foreach ($this->getLocationIds() as $id) {
348 $loc = $this->getLocation($id);
349 $loc->toXML($writer);
350 }
351
352 // Requirement
353 foreach ($this->getRequirementIds() as $id) {
354 $req = $this->getRequirement($id);
355 $req->toXML($writer);
356 }
357
358 // OrComposite
359 foreach ($this->getOrCompositeIds() as $id) {
360 $orc = $this->getOrComposite($id);
361 $orc->toXML($writer);
362 }
363
364 // InstallationRemarks
365 if ($this->getInstallationRemarks() !== '') {
366 $writer->xmlElement(
367 'InstallationRemarks',
368 array(
369 'Language' => $this->getInstallationRemarksLanguageCode() ?: 'en'
370 ),
372 );
373 }
374
375 // OtherPlatformRequirements
376 if ($this->getOtherPlatformRequirements() !== '') {
377 $writer->xmlElement(
378 'OtherPlatformRequirements',
379 array(
380 'Language' => $this->getOtherPlatformRequirementsLanguageCode() ?: 'en'
381 ),
383 );
384 }
385 // Duration
386 if ($this->getDuration() !== '') {
387 $writer->xmlElement('Duration', null, $this->getDuration());
388 }
389
390 $writer->xmlEndTag('Technical');
391 }
392
393 public static function _getId(int $a_rbac_id, int $a_obj_id): int
394 {
395 global $DIC;
396
397 $ilDB = $DIC->database();
398
399 $query = "SELECT meta_technical_id FROM il_meta_technical " .
400 "WHERE rbac_id = " . $ilDB->quote($a_rbac_id, 'integer') . " " .
401 "AND obj_id = " . $ilDB->quote($a_obj_id, 'integer');
402
403 $res = $ilDB->query($query);
404 while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
405 return (int) $row->meta_technical_id;
406 }
407 return 0;
408 }
409}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
setObjType(string $a_type)
setObjId(int $a_id)
setMetaId(int $a_meta_id, bool $a_read_data=true)
setRBACId(int $a_id)
static _getIds(int $a_rbac_id, int $a_obj_id)
static _getIds(int $a_rbac_id, int $a_obj_id, int $a_parent_id, string $a_parent_type)
static _getIds(int $a_rbac_id, int $a_obj_id, int $a_parent_id, string $a_parent_type, int $a_or_composite_id=0)
static _getIds(int $a_rbac_id, int $a_obj_id, int $a_parent_id, string $a_parent_type, int $a_or_composite_id=0)
getRequirement(int $a_requirement_id)
setDuration(string $a_val)
setOtherPlatformRequirementsLanguage(ilMDLanguageItem $lng_obj)
ilMDLanguageItem $installation_remarks_language
ilMDLanguageItem $other_platform_requirements_language
getOrComposite(int $a_or_composite_id)
getFormat(int $a_format_id)
setInstallationRemarks(string $a_val)
string $other_platform_requirements
setSize(string $a_size)
static _getId(int $a_rbac_id, int $a_obj_id)
setOtherPlatformRequirements(string $a_val)
getOtherPlatformRequirementsLanguageCode()
getLocation(int $a_location_id)
setInstallationRemarksLanguage(ilMDLanguageItem $lng_obj)
toXML(ilXmlWriter $writer)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
xmlElement(string $tag, $attrs=null, $data=null, $encode=true, $escape=true)
Writes a basic element (no children, just textual content)
xmlEndTag(string $tag)
Writes an endtag.
xmlStartTag(string $tag, ?array $attrs=null, bool $empty=false, bool $encode=true, bool $escape=true)
Writes a starttag.
global $DIC
Definition: feed.php:28
$res
Definition: ltiservices.php:69
catch(\Exception $e) $req
Definition: xapiproxy.php:93
$query