ILIAS  release_8 Revision v8.24
class.ilAdvancedMetaDataExporter.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
5
13{
14 private static array $local_recs_done = [];
15
19 public function init(): void
20 {
21 }
22
23 public function getXmlExportHeadDependencies(string $a_entity, string $a_target_release, array $a_ids): array
24 {
25 return array();
26 }
27
28 public function getXmlExportTailDependencies(string $a_entity, string $a_target_release, array $a_ids): array
29 {
30 return array();
31 }
32
33 public function getXmlRepresentation(string $a_entity, string $a_schema_version, string $a_id): string
34 {
35 $parts = explode(":", $a_id);
36 if (sizeof($parts) != 2) {
37 return "";
38 }
39 $obj_id = (int) $parts[0];
40 $rec_id = (int) $parts[1];
41
42 // any data for current record and object?
44 if (!$raw) {
45 return "";
46 }
47
48 // gather sub-item data from value entries
49 $sub_items = array();
50 foreach ($raw as $item) {
51 $sub_items[$item["sub_type"]][] = $item["sub_id"];
52 }
53
54 // gather all relevant data
55 $items = array();
56 foreach ($sub_items as $sub_type => $sub_ids) {
57 foreach (array_unique($sub_ids) as $sub_id) {
58 $values_record = new ilAdvancedMDValues($rec_id, $obj_id, $sub_type, $sub_id);
59 $defs = $values_record->getDefinitions();
60 $values_record->read();
61 foreach ($values_record->getADTGroup()->getElements() as $element_id => $element) {
62 if (!$element->isNull()) {
63 $def = $defs[$element_id];
64 $items[$rec_id][] = array(
65 'id' => $def->generateImportId($def->getFieldId()),
66 'sub_type' => $sub_type,
67 'sub_id' => $sub_id,
68 'value' => $def->getValueForXML($element)
69 );
70 }
71 }
72 }
73 }
74
75 // #17066 - local advmd record
76 $local_recs = array();
77 $rec_obj = new ilAdvancedMDRecord($rec_id);
78 if ($rec_obj->getParentObject()) {
79 $xml = new ilXmlWriter();
80 $rec_obj->toXML($xml);
81 $xml = $xml->xmlDumpMem(false);
82
83 $local_recs[$rec_obj->getRecordId()] = base64_encode($xml);
84 }
85
86 // we only want non-empty fields
87 if (sizeof($items)) {
88 $xml = new ilXmlWriter();
89
90 foreach ($items as $record_id => $record_items) {
91 $xml->xmlStartTag('AdvancedMetaData');
92
93 $is_local = array_key_exists($record_id, $local_recs);
94
95 // add local record data?
96 if ($is_local) {
97 // we need to add this only once
98 if (!array_key_exists($record_id, self::$local_recs_done)) {
99 $xml->xmlElement(
100 'Record',
101 array('local_id' => $record_id),
102 $local_recs[$record_id]
103 );
104
105 self::$local_recs_done[] = $record_id;
106 }
107 }
108
109 foreach ($record_items as $item) {
110 $att = array(
111 'id' => $item['id'],
112 'sub_type' => $item['sub_type'],
113 'sub_id' => $item['sub_id']
114 );
115
116 if ($is_local) {
117 $att['local_rec_id'] = $record_id;
118 }
119
120 $xml->xmlElement(
121 'Value',
122 $att,
123 $item['value']
124 );
125 }
126
127 $xml->xmlEndTag('AdvancedMetaData');
128 }
129
130 return $xml->xmlDumpMem(false);
131 }
132 return "";
133 }
134
135 public function getValidSchemaVersions(string $a_entity): array
136 {
137 return array(
138 "4.4.0" => array(
139 "namespace" => "http://www.ilias.de/Services/AdvancedMetaData/advmd/4_4",
140 "xsd_file" => "ilias_advmd_4_4.xsd",
141 "uses_dataset" => true,
142 "min" => "4.4.0",
143 "max" => ""
144 )
145 );
146 }
147}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static findByObjectId(int $a_obj_id)
Find all entries for object (regardless of sub-type/sub-id)
getXmlRepresentation(string $a_entity, string $a_schema_version, string $a_id)
getValidSchemaVersions(string $a_entity)
Returns schema versions that the component can export to.
getXmlExportTailDependencies(string $a_entity, string $a_target_release, array $a_ids)
Get tail dependencies.
getXmlExportHeadDependencies(string $a_entity, string $a_target_release, array $a_ids)
Get head dependencies.
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...
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
Definition: ltitoken.php:64
$xml
Definition: metadata.php:351