ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilDataCollectionExporter.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22{
24 protected ilDBInterface $db;
25
26 public function init(): void
27 {
28 global $DIC;
29 $ilDB = $DIC['ilDB'];
30 $this->ds = new ilDataCollectionDataSet();
31 $this->ds->setDSPrefix('ds');
32 $this->db = $ilDB;
33 }
34
39 public function getValidSchemaVersions(string $a_entity): array
40 {
41 return [
42 '4.5.0' => [
43 'namespace' => 'https://www.ilias.de/Modules/DataCollection/dcl/4_5',
44 'xsd_file" => "ilias_dcl_4_5.xsd',
45 'uses_dataset' => true,
46 'min' => '4.5.0',
47 'max' => '8.12',
48 ],
49 '8.13' => [
50 'namespace' => 'https://www.ilias.de/Modules/DataCollection/dcl/4_5',
51 'xsd_file" => "ilias_dcl_4_5.xsd',
52 'uses_dataset' => true,
53 'min' => '8.13',
54 'max' => '',
55 ],
56 ];
57 }
58
59 public function getXmlRepresentation(string $a_entity, string $a_schema_version, string $a_id): string
60 {
62 $this->ds->initByExporter($this);
63
64 return $this->ds->getXmlRepresentation($a_entity, $a_schema_version, [$a_id], '', true, true);
65 }
66
75 public function getXmlExportHeadDependencies(string $a_entity, string $a_target_release, array $a_ids): array
76 {
77 $dependencies = [
79 'component' => 'components/ILIAS/File',
80 'entity' => 'file',
81 'ids' => [],
82 ],
84 'component' => 'components/ILIAS/MediaObjects',
85 'entity' => 'mob',
86 'ids' => [],
87 ],
88 ];
89
90 // Direct SQL query is faster than looping over objects
91 foreach ($a_ids as $dcl_obj_id) {
92 $sql = "SELECT stloc2.value AS ext_id, f." . $this->db->quoteIdentifier('datatype_id') . " FROM il_dcl_stloc2_value AS stloc2 "
93 . "INNER JOIN il_dcl_record_field AS rf ON (rf." . $this->db->quoteIdentifier('id') . " = stloc2." . $this->db->quoteIdentifier('record_field_id') . ") "
94 . "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."
95 . $this->db->quoteIdentifier('id') . " = f." . $this->db->quoteIdentifier('table_id') . ") "
96 . "WHERE t." . $this->db->quoteIdentifier('obj_id') . " = " . $this->db->quote(
97 $dcl_obj_id,
98 'integer'
99 ) . " " . "AND f.datatype_id IN ("
100 . implode(
101 ',',
102 array_keys($dependencies)
103 ) . ") AND stloc2." . $this->db->quoteIdentifier('value') . " IS NOT NULL";
104 $set = $this->db->query($sql);
105 while ($rec = $this->db->fetchObject($set)) {
106 $dependencies[$rec->datatype_id]['ids'][] = (int) $rec->ext_id;
107 }
108 }
109
110 // Return external dependencies/IDs if there are any
111 $return = [];
112 if (count($dependencies[ilDclDatatype::INPUTFORMAT_FILEUPLOAD]['ids'])) {
113 $return[] = $dependencies[ilDclDatatype::INPUTFORMAT_FILEUPLOAD];
114 }
115 if (count($dependencies[ilDclDatatype::INPUTFORMAT_MOB]['ids'])) {
116 $return[] = $dependencies[ilDclDatatype::INPUTFORMAT_MOB];
117 }
118
119 return $return;
120 }
121
128 public function getXmlExportTailDependencies(string $a_entity, string $a_target_release, array $a_ids): array
129 {
130 $deps = [];
131 $page_object_ids = [];
132 foreach ($a_ids as $dcl_obj_id) {
133 // If a DCL table has a detail view, we need to export the associated page objects!
134 $sql = "SELECT page_id FROM page_object "
135 . "WHERE parent_type = " . $this->db->quote(
136 'dclf',
137 'text'
138 ) . " AND parent_id = " . $this->db->quote($dcl_obj_id, 'integer');
139 $set = $this->db->query($sql);
140 while ($rec = $this->db->fetchObject($set)) {
141 $page_object_ids[] = "dclf:" . $rec->page_id;
142 }
143 }
144 if (count($page_object_ids)) {
145 $deps[] = [
146 'component' => 'components/ILIAS/COPage',
147 'entity' => 'pg',
148 'ids' => $page_object_ids
149 ];
150 }
151
152 $md_ids = [];
153 foreach ($a_ids as $id) {
154 $md_ids[] = $id . ':0:dcl';
155 }
156 if ($md_ids !== []) {
157 $deps[] = [
158 'component' => 'components/ILIAS/MetaData',
159 'entity' => 'md',
160 'ids' => $md_ids,
161 ];
162 }
163
164 return $deps;
165 }
166}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
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.
Xml Exporter class.
Interface ilDBInterface.
global $DIC
Definition: shib_login.php:26