ILIAS  release_7 Revision v7.30-3-g800a261c036
ilAdvancedMetaDataExporter Class Reference

Export class for adv md. More...

+ Inheritance diagram for ilAdvancedMetaDataExporter:
+ Collaboration diagram for ilAdvancedMetaDataExporter:

Public Member Functions

 init ()
 Initialisation. More...
 
 getXmlExportHeadDependencies ($a_entity, $a_target_release, $a_ids)
 Get head dependencies. More...
 
 getXmlExportTailDependencies ($a_entity, $a_target_release, $a_ids)
 Get tail dependencies. More...
 
 getXmlRepresentation ($a_entity, $a_schema_version, $a_id)
 Get xml representation. More...
 
 getValidSchemaVersions ($a_entity)
 Returns schema versions that the component can export to. More...
 
- Public Member Functions inherited from ilXmlExporter
 __construct ()
 Constructor. More...
 
 setExport (ilExport $a_exp)
 Set export object. More...
 
 getExport ()
 Get export. More...
 
 getXmlRepresentation ($a_entity, $a_schema_version, $a_id)
 Get xml representation. More...
 
 init ()
 
 setExportDirectories ($a_dir_relative, $a_dir_absolute)
 Export directories. More...
 
 getRelativeExportDirectory ()
 Get relative export directory. More...
 
 getAbsoluteExportDirectory ()
 Get absolute export directory. More...
 
 getXmlExportHeadDependencies ($a_entity, $a_target_release, $a_ids)
 Get head dependencies. More...
 
 getXmlExportTailDependencies ($a_entity, $a_target_release, $a_ids)
 Get tail dependencies. More...
 
 getValidSchemaVersions ($a_entity)
 Returns schema versions that the component can export to. More...
 
 determineSchemaVersion ($a_entity, $a_target_release)
 Determine schema version. More...
 

Private Attributes

 $ds
 

Static Private Attributes

static $local_recs_done = array()
 

Additional Inherited Members

- Static Public Member Functions inherited from ilXmlExporter
static lookupExportDirectory ($a_obj_type, $a_obj_id, $a_export_type='xml', $a_entity="")
 export directory lookup More...
 
- Protected Attributes inherited from ilXmlExporter
 $dir_relative
 
 $dir_absolute
 
 $exp
 

Detailed Description

Export class for adv md.

Author
Jörg Lützenkirchen luetz.nosp@m.enki.nosp@m.rchen.nosp@m.@lei.nosp@m.fos.c.nosp@m.om
Version
Id

Definition at line 13 of file class.ilAdvancedMetaDataExporter.php.

Member Function Documentation

◆ getValidSchemaVersions()

ilAdvancedMetaDataExporter::getValidSchemaVersions (   $a_entity)

Returns schema versions that the component can export to.

ILIAS chooses the first one, that has min/max constraints which fit to the target release. Please put the newest on top.

Returns

Reimplemented from ilXmlExporter.

Definition at line 170 of file class.ilAdvancedMetaDataExporter.php.

171 {
172 return array(
173 "4.4.0" => array(
174 "namespace" => "http://www.ilias.de/Services/AdvancedMetaData/advmd/4_4",
175 "xsd_file" => "ilias_advmd_4_4.xsd",
176 "uses_dataset" => true,
177 "min" => "4.4.0",
178 "max" => "")
179 );
180 }

◆ getXmlExportHeadDependencies()

ilAdvancedMetaDataExporter::getXmlExportHeadDependencies (   $a_entity,
  $a_target_release,
  $a_ids 
)

Get head dependencies.

Parameters
stringentity
stringtarget release
arrayids
Returns
array array of array with keys "component", entity", "ids"

Reimplemented from ilXmlExporter.

Definition at line 34 of file class.ilAdvancedMetaDataExporter.php.

35 {
36 return array();
37 }

◆ getXmlExportTailDependencies()

ilAdvancedMetaDataExporter::getXmlExportTailDependencies (   $a_entity,
  $a_target_release,
  $a_ids 
)

Get tail dependencies.

Parameters
stringentity
stringtarget release
arrayids
Returns
array array of array with keys "component", entity", "ids"

Reimplemented from ilXmlExporter.

Definition at line 48 of file class.ilAdvancedMetaDataExporter.php.

49 {
50 return array();
51 }

◆ getXmlRepresentation()

ilAdvancedMetaDataExporter::getXmlRepresentation (   $a_entity,
  $a_schema_version,
  $a_id 
)

Get xml representation.

Parameters
stringentity
stringschema version
stringid
Returns
string xml string

Reimplemented from ilXmlExporter.

Definition at line 61 of file class.ilAdvancedMetaDataExporter.php.

62 {
63 $parts = explode(":", $a_id);
64 if (sizeof($parts) != 2) {
65 return;
66 }
67 $obj_id = $parts[0];
68 $rec_id = $parts[1];
69
70 // any data for current record and object?
71 include_once('Services/AdvancedMetaData/classes/class.ilAdvancedMDValues.php');
73 if (!$raw) {
74 return;
75 }
76
77 // gather sub-item data from value entries
78 $sub_items = array();
79 foreach ($raw as $item) {
80 $sub_items[$item["sub_type"]][] = $item["sub_id"];
81 }
82
83 // gather all relevant data
84 $items = array();
85 foreach ($sub_items as $sub_type => $sub_ids) {
86 foreach (array_unique($sub_ids) as $sub_id) {
87 $values_record = new ilAdvancedMDValues($rec_id, $obj_id, $sub_type, $sub_id);
88 $defs = $values_record->getDefinitions();
89 $values_record->read();
90 foreach ($values_record->getADTGroup()->getElements() as $element_id => $element) {
91 if (!$element->isNull()) {
92 $def = $defs[$element_id];
93 $items[$rec_id][] = array(
94 'id' => $def->generateImportId($def->getFieldId()),
95 'sub_type' => $sub_type,
96 'sub_id' => $sub_id,
97 'value' => $def->getValueForXML($element)
98 );
99 }
100 }
101 }
102 }
103
104 // #17066 - local advmd record
105 $local_recs = array();
106 $rec_obj = new ilAdvancedMDRecord($rec_id);
107 if ($rec_obj->getParentObject()) {
108 $xml = new ilXmlWriter;
109 $rec_obj->toXML($xml);
110 $xml = $xml->xmlDumpMem(false);
111
112 $local_recs[$rec_obj->getRecordId()] = base64_encode($xml);
113 }
114
115 // we only want non-empty fields
116 if (sizeof($items)) {
117 $xml = new ilXmlWriter;
118
119 foreach ($items as $record_id => $record_items) {
120 $xml->xmlStartTag('AdvancedMetaData');
121
122 $is_local = array_key_exists($record_id, $local_recs);
123
124 // add local record data?
125 if ($is_local) {
126 // we need to add this only once
127 if (!array_key_exists($record_id, self::$local_recs_done)) {
128 $xml->xmlElement(
129 'Record',
130 array('local_id' => $record_id),
131 $local_recs[$record_id]
132 );
133
134 self::$local_recs_done[] = $record_id;
135 }
136 }
137
138 foreach ($record_items as $item) {
139 $att = array(
140 'id' => $item['id'],
141 'sub_type' => $item['sub_type'],
142 'sub_id' => $item['sub_id']
143 );
144
145 if ($is_local) {
146 $att['local_rec_id'] = $record_id;
147 }
148
149 $xml->xmlElement(
150 'Value',
151 $att,
152 $item['value']
153 );
154 }
155
156 $xml->xmlEndTag('AdvancedMetaData');
157 }
158
159 return $xml->xmlDumpMem(false);
160 }
161 }
static findByObjectId($a_obj_id)
Find all entries for object (regardless of sub-type/sub-id)
XML writer class.
$xml
Definition: metadata.php:332

References $xml, and ilAdvancedMDValues\findByObjectId().

+ Here is the call graph for this function:

◆ init()

ilAdvancedMetaDataExporter::init ( )

Initialisation.

Reimplemented from ilXmlExporter.

Definition at line 22 of file class.ilAdvancedMetaDataExporter.php.

23 {
24 }

Field Documentation

◆ $ds

ilAdvancedMetaDataExporter::$ds
private

Definition at line 15 of file class.ilAdvancedMetaDataExporter.php.

◆ $local_recs_done

ilAdvancedMetaDataExporter::$local_recs_done = array()
staticprivate

Definition at line 17 of file class.ilAdvancedMetaDataExporter.php.


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