ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilAdvancedMetaDataExporter.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
27{
28 private static array $local_recs_done = [];
29
33 public function init(): void
34 {
35 }
36
37 public function getXmlExportHeadDependencies(string $a_entity, string $a_target_release, array $a_ids): array
38 {
39 return array();
40 }
41
42 public function getXmlExportTailDependencies(string $a_entity, string $a_target_release, array $a_ids): array
43 {
44 return array();
45 }
46
47 public function getXmlRepresentation(string $a_entity, string $a_schema_version, string $a_id): string
48 {
49 $parts = explode(":", $a_id);
50 if (sizeof($parts) != 2) {
51 return "";
52 }
53 $obj_id = (int) $parts[0];
54 $rec_id = (int) $parts[1];
55
56 // any data for current record and object?
58 if (!$raw) {
59 return "";
60 }
61
62 // gather sub-item data from value entries
63 $sub_items = array();
64 foreach ($raw as $item) {
65 $sub_items[$item["sub_type"]][] = $item["sub_id"];
66 }
67
68 // gather all relevant data
69 $items = array();
70 foreach ($sub_items as $sub_type => $sub_ids) {
71 foreach (array_unique($sub_ids) as $sub_id) {
72 $values_record = new ilAdvancedMDValues($rec_id, $obj_id, $sub_type, $sub_id);
73 $defs = $values_record->getDefinitions();
74 $values_record->read();
75 foreach ($values_record->getADTGroup()->getElements() as $element_id => $element) {
76 if (!$element->isNull()) {
77 $def = $defs[$element_id];
78 $items[$rec_id][] = array(
79 'id' => $def->getImportId(),
80 'sub_type' => $sub_type,
81 'sub_id' => $sub_id,
82 'value' => $def->getValueForXML($element)
83 );
84 }
85 }
86 }
87 }
88
89 // #17066 - local advmd record
90 $local_recs = array();
91 $rec_obj = new ilAdvancedMDRecord($rec_id);
92 if ($rec_obj->getParentObject()) {
93 $xml = new ilXmlWriter();
94 $rec_obj->toXML($xml);
95 $xml = $xml->xmlDumpMem(false);
96
97 $local_recs[$rec_obj->getRecordId()] = base64_encode($xml);
98 }
99
100 // we only want non-empty fields
101 if (sizeof($items)) {
102 $xml = new ilXmlWriter();
103
104 foreach ($items as $record_id => $record_items) {
105 $xml->xmlStartTag('AdvancedMetaData');
106
107 $is_local = array_key_exists($record_id, $local_recs);
108
109 // add local record data?
110 if ($is_local) {
111 // we need to add this only once
112 if (!array_key_exists($record_id, self::$local_recs_done)) {
113 $xml->xmlElement(
114 'Record',
115 array('local_id' => $record_id),
116 $local_recs[$record_id]
117 );
118
119 self::$local_recs_done[] = $record_id;
120 }
121 }
122
123 foreach ($record_items as $item) {
124 $att = array(
125 'id' => $item['id'],
126 'sub_type' => $item['sub_type'],
127 'sub_id' => $item['sub_id']
128 );
129
130 if ($is_local) {
131 $att['local_rec_id'] = $record_id;
132 }
133
134 $xml->xmlElement(
135 'Value',
136 $att,
137 $item['value']
138 );
139 }
140
141 $xml->xmlEndTag('AdvancedMetaData');
142 }
143
144 return $xml->xmlDumpMem(false);
145 }
146 return "";
147 }
148
149 public function getValidSchemaVersions(string $a_entity): array
150 {
151 return array(
152 "4.4.0" => array(
153 "namespace" => "http://www.ilias.de/Services/AdvancedMetaData/advmd/4_4",
154 "xsd_file" => "ilias_advmd_4_4.xsd",
155 "uses_dataset" => true,
156 "min" => "4.4.0",
157 "max" => ""
158 )
159 );
160 }
161}
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.
Xml Exporter class.
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:61