ILIAS  release_8 Revision v8.24
class.ilDataCollectionExporter.php
Go to the documentation of this file.
1<?php
2
20{
22 protected ilDBInterface $db;
23
24 public function init(): void
25 {
26 global $DIC;
27 $ilDB = $DIC['ilDB'];
28 $this->ds = new ilDataCollectionDataSet();
29 $this->ds->setDSPrefix('ds');
30 $this->db = $ilDB;
31 }
32
37 public function getValidSchemaVersions(string $a_entity): array
38 {
39 return array(
40 '4.5.0' => array(
41 'namespace' => 'https://www.ilias.de/Modules/DataCollection/dcl/4_5',
42 'xsd_file" => "ilias_dcl_4_5.xsd',
43 'uses_dataset' => true,
44 'min' => '4.5.0',
45 'max' => '8.12',
46 ),
47 '8.13' => array(
48 'namespace' => 'https://www.ilias.de/Modules/DataCollection/dcl/4_5',
49 'xsd_file" => "ilias_dcl_4_5.xsd',
50 'uses_dataset' => true,
51 'min' => '8.13',
52 'max' => '',
53 ),
54 );
55 }
56
57 public function getXmlRepresentation(string $a_entity, string $a_schema_version, string $a_id): string
58 {
60 $this->ds->setExportDirectories($this->dir_relative, $this->dir_absolute);
61
62 return $this->ds->getXmlRepresentation($a_entity, $a_schema_version, [$a_id], '', true, true);
63 }
64
73 public function getXmlExportHeadDependencies(string $a_entity, string $a_target_release, array $a_ids): array
74 {
75 $dependencies = array(
77 'component' => 'Modules/File',
78 'entity' => 'file',
79 'ids' => array(),
80 ),
82 'component' => 'Services/MediaObjects',
83 'entity' => 'mob',
84 'ids' => array(),
85 ),
86 );
87
88 // Direct SQL query is faster than looping over objects
89 foreach ($a_ids as $dcl_obj_id) {
90 $sql = "SELECT stloc2.value AS ext_id, f." . $this->db->quoteIdentifier('datatype_id') . " FROM il_dcl_stloc2_value AS stloc2 "
91 . "INNER JOIN il_dcl_record_field AS rf ON (rf." . $this->db->quoteIdentifier('id') . " = stloc2." . $this->db->quoteIdentifier('record_field_id') . ") "
92 . "INNER JOIN il_dcl_field AS f ON (rf." . $this->db->quoteIdentifier('field_id') . " = f." . $this->db->quoteIdentifier('id') . ") " . "INNER JOIN il_dcl_table AS t ON (t."
93 . $this->db->quoteIdentifier('id') . " = f." . $this->db->quoteIdentifier('table_id') . ") "
94 . "WHERE t." . $this->db->quoteIdentifier('obj_id') . " = " . $this->db->quote(
95 $dcl_obj_id,
96 'integer'
97 ) . " " . "AND f.datatype_id IN ("
98 . implode(
99 ',',
100 array_keys($dependencies)
101 ) . ") AND stloc2." . $this->db->quoteIdentifier('value') . " IS NOT NULL";
102 $set = $this->db->query($sql);
103 while ($rec = $this->db->fetchObject($set)) {
104 $dependencies[$rec->datatype_id]['ids'][] = (int) $rec->ext_id;
105 }
106 }
107
108 // Return external dependencies/IDs if there are any
109 $return = array();
110 if (count($dependencies[ilDclDatatype::INPUTFORMAT_FILE]['ids'])) {
111 $return[] = $dependencies[ilDclDatatype::INPUTFORMAT_FILE];
112 }
113 if (count($dependencies[ilDclDatatype::INPUTFORMAT_MOB]['ids'])) {
114 $return[] = $dependencies[ilDclDatatype::INPUTFORMAT_MOB];
115 }
116
117 return $return;
118 }
119
126 public function getXmlExportTailDependencies(string $a_entity, string $a_target_release, array $a_ids): array
127 {
128 $page_object_ids = array();
129 foreach ($a_ids as $dcl_obj_id) {
130 // If a DCL table has a detail view, we need to export the associated page objects!
131 $sql = "SELECT page_id FROM page_object "
132 . "WHERE parent_type = " . $this->db->quote(
133 'dclf',
134 'text'
135 ) . " AND parent_id = " . $this->db->quote($dcl_obj_id, 'integer');
136 $set = $this->db->query($sql);
137 while ($rec = $this->db->fetchObject($set)) {
138 $page_object_ids[] = "dclf:" . $rec->page_id;
139 }
140 }
141 if (count($page_object_ids)) {
142 return array(
143 array(
144 'component' => 'Services/COPage',
145 'entity' => 'pg',
146 'ids' => $page_object_ids,
147 ),
148 );
149 }
150
151 return array();
152 }
153}
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...
getXmlRepresentation(string $a_entity, string $a_schema_version, string $a_id)
getXmlExportHeadDependencies(string $a_entity, string $a_target_release, array $a_ids)
MOB/File fieldtypes objects are head dependencies They must be exported and imported first,...
getXmlExportTailDependencies(string $a_entity, string $a_target_release, array $a_ids)
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
Interface ilDBInterface.