ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
class.ilAdvancedMetaDataExporter.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once("./Services/Export/classes/class.ilXmlExporter.php");
5
14{
15 private $ds;
16
20 function init()
21 {
22
23 }
24
33 function getXmlExportHeadDependencies($a_entity, $a_target_release, $a_ids)
34 {
35 return array();
36 }
37
38
47 function getXmlExportTailDependencies($a_entity, $a_target_release, $a_ids)
48 {
49 return array();
50 }
51
60 public function getXmlRepresentation($a_entity, $a_schema_version, $a_id)
61 {
62 $parts = explode(":", $a_id);
63 if(sizeof($parts) != 2)
64 {
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 {
75 return;
76 }
77
78 // gather sub-item data from value entries
79 $sub_items = array();
80 foreach($raw as $item)
81 {
82 $sub_items[$item["sub_type"]][] = $item["sub_id"];
83 }
84
85 // gather all relevant data
86 $items = array();
87 foreach($sub_items as $sub_type => $sub_ids)
88 {
89 foreach(array_unique($sub_ids) as $sub_id)
90 {
91 $values_record = new ilAdvancedMDValues($rec_id, $obj_id, $sub_type, $sub_id);
92 $defs = $values_record->getDefinitions();
93 $values_record->read();
94 foreach($values_record->getADTGroup()->getElements() as $element_id => $element)
95 {
96 if(!$element->isNull())
97 {
98 $def = $defs[$element_id];
99 $items[$rec_id][] =array(
100 'id' => $def->getImportId(),
101 'sub_type' => $sub_type,
102 'sub_id' => $sub_id,
103 'value' => $def->getValueForXML($element)
104 );
105 }
106 }
107 }
108 }
109
110 // we only want non-empty fields
111 if(sizeof($items))
112 {
113 $xml = new ilXmlWriter;
114
115 foreach($items as $record_id => $record_items)
116 {
117 // no need to state record id here
118 $xml->xmlStartTag('AdvancedMetaData');
119
120 foreach($record_items as $item)
121 {
122 $xml->xmlElement(
123 'Value',
124 array(
125 'id' => $item['id'],
126 'sub_type' => $item['sub_type'],
127 'sub_id' => $item['sub_id']
128 ),
129 $item['value']
130 );
131 }
132
133 $xml->xmlEndTag('AdvancedMetaData');
134 }
135
136 return $xml->xmlDumpMem(false);
137 }
138 }
139
147 function getValidSchemaVersions($a_entity)
148 {
149 return array (
150 "4.4.0" => array(
151 "namespace" => "http://www.ilias.de/Services/AdvancedMetaData/advmd/4_4",
152 "xsd_file" => "ilias_advmd_4_4.xsd",
153 "uses_dataset" => true,
154 "min" => "4.4.0",
155 "max" => "")
156 );
157 }
158
159}
160
161?>
static findByObjectId($a_obj_id)
Find all entries for object (regardless of sub-type/sub-id)
getXmlExportHeadDependencies($a_entity, $a_target_release, $a_ids)
Get head dependencies.
getValidSchemaVersions($a_entity)
Returns schema versions that the component can export to.
getXmlRepresentation($a_entity, $a_schema_version, $a_id)
Get xml representation.
getXmlExportTailDependencies($a_entity, $a_target_release, $a_ids)
Get tail dependencies.
Xml Exporter class.
XML writer class.
xmlStartTag($tag, $attrs=NULL, $empty=FALSE, $encode=TRUE, $escape=TRUE)
Writes a starttag.