ILIAS  release_5-2 Revision v5.2.25-18-g3f80b82851
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

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

References array.

186  {
187  return array (
188  "4.4.0" => array(
189  "namespace" => "http://www.ilias.de/Services/AdvancedMetaData/advmd/4_4",
190  "xsd_file" => "ilias_advmd_4_4.xsd",
191  "uses_dataset" => true,
192  "min" => "4.4.0",
193  "max" => "")
194  );
195  }
Create styles array
The data for the language used.

◆ 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"

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

References array.

36  {
37  return array();
38  }
Create styles array
The data for the language used.

◆ 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"

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

References array.

50  {
51  return array();
52  }
Create styles array
The data for the language used.

◆ getXmlRepresentation()

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

Get xml representation.

Parameters
stringentity
stringschema version
stringid
Returns
string xml string

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

References array, ilAdvancedMDValues\findByObjectId(), ilXmlWriter\xmlDumpMem(), and ilXmlWriter\xmlStartTag().

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

◆ init()

ilAdvancedMetaDataExporter::init ( )

Initialisation.

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

23  {
24 
25  }

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: