ILIAS  release_8 Revision v8.23
class.ilGlossaryExporter.php
Go to the documentation of this file.
1 <?php
2 
25 {
27 
28  public function init(): void
29  {
30  $this->ds = new ilGlossaryDataSet();
31  $this->ds->setExportDirectories($this->dir_relative, $this->dir_absolute);
32  $this->ds->setDSPrefix("ds");
33  }
34 
36  string $a_entity,
37  string $a_target_release,
38  array $a_ids
39  ): array {
40  if ($a_entity == "glo") {
41  $md_ids = array();
42 
43  // glo related ids
44  foreach ($a_ids as $id) {
45  $md_ids[] = $id . ":0:glo";
46  }
47 
48  // definition related ids
49  $page_ids = array();
50  foreach ($a_ids as $id) {
51  // workaround for #0023923
52  $all_refs = ilObject::_getAllReferences($id);
53  $ref_id = current($all_refs);
54 
55  // see #29014, we include referenced terms in the export as well
57  [$ref_id],
58  "",
59  "",
60  "",
61  0,
62  false,
63  null,
64  true
65  );
66 
67  foreach ($terms as $t) {
69  foreach ($defs as $d) {
70  $page_ids[] = "gdf:" . $d["id"];
71  $md_ids[] = $id . ":" . $d["id"] . ":gdf";
72  }
73  }
74  }
75  // definition pages and their metadat
76  $deps = array(
77  array(
78  "component" => "Services/COPage",
79  "entity" => "pg",
80  "ids" => $page_ids),
81  array(
82  "component" => "Services/MetaData",
83  "entity" => "md",
84  "ids" => $md_ids),
85  );
86 
87  // taxonomy
88  $tax_ids = array();
89  foreach ($a_ids as $id) {
90  $t_ids = ilObjTaxonomy::getUsageOfObject((int) $id);
91  if (count($t_ids) > 0) {
92  $tax_ids[$t_ids[0]] = $t_ids[0];
93  }
94  }
95  if (count($tax_ids)) {
96  $deps[] = array(
97  "component" => "Services/Taxonomy",
98  "entity" => "tax",
99  "ids" => $tax_ids
100  );
101  }
102 
103  // advanced metadata
104  $advmd_ids = array();
105  foreach ($a_ids as $id) {
106  $rec_ids = $this->getActiveAdvMDRecords($id);
107  if (count($rec_ids)) {
108  foreach ($rec_ids as $rec_id) {
109  $advmd_ids[] = $id . ":" . $rec_id;
110  }
111  }
112  }
113  if (count($advmd_ids)) {
114  $deps[] = array(
115  "component" => "Services/AdvancedMetaData",
116  "entity" => "advmd",
117  "ids" => $advmd_ids
118  );
119  }
120 
121  // style
122  $obj_ids = (is_array($a_ids))
123  ? $a_ids
124  : array($a_ids);
125  $deps[] = array(
126  "component" => "Services/Style",
127  "entity" => "object_style",
128  "ids" => $obj_ids
129  );
130 
131  // service settings
132  $deps[] = array(
133  "component" => "Services/Object",
134  "entity" => "common",
135  "ids" => $a_ids);
136 
137  $md_ids = [];
138  foreach ($a_ids as $crs_id) {
139  $md_ids[] = $crs_id . ":0:glo";
140  }
141  if ($md_ids !== []) {
142  $deps[] = [
143  "component" => "Services/MetaData",
144  "entity" => "md",
145  "ids" => $md_ids
146  ];
147  }
148 
149  return $deps;
150  }
151  return array();
152  }
153 
154  protected function getActiveAdvMDRecords(int $a_id): array
155  {
156  $active = array();
157  // selected globals
158  $sel_globals = ilAdvancedMDRecord::getObjRecSelection($a_id, "term");
159 
160  foreach (ilAdvancedMDRecord::_getActivatedRecordsByObjectType("glo", "term") as $record_obj) {
161  // local ones and globally activated for the object
162  if ($record_obj->getParentObject() == $a_id || in_array($record_obj->getRecordId(), $sel_globals)) {
163  $active[] = $record_obj->getRecordId();
164  }
165  }
166 
167  return $active;
168  }
169 
170  public function getXmlRepresentation(
171  string $a_entity,
172  string $a_schema_version,
173  string $a_id
174  ): string {
175  return $this->ds->getXmlRepresentation($a_entity, $a_schema_version, [$a_id], "", true, true);
176  }
177 
178  public function getValidSchemaVersions(string $a_entity): array
179  {
180  return array(
181  "5.4.0" => array(
182  "namespace" => "https://www.ilias.de/Modules/Glossary/htlm/5_4",
183  "xsd_file" => "ilias_glo_5_4.xsd",
184  "uses_dataset" => true,
185  "min" => "5.4.0",
186  "max" => ""),
187  "5.1.0" => array(
188  "namespace" => "https://www.ilias.de/Modules/Glossary/htlm/5_1",
189  "xsd_file" => "ilias_glo_5_1.xsd",
190  "uses_dataset" => true,
191  "min" => "5.1.0",
192  "max" => ""),
193  "4.1.0" => array(
194  "namespace" => "https://www.ilias.de/Modules/Glossary/htlm/4_1",
195  "xsd_file" => "ilias_glo_4_1.xsd",
196  "uses_dataset" => false,
197  "min" => "4.1.0",
198  "max" => "")
199  );
200  }
201 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _getActivatedRecordsByObjectType(string $a_obj_type, string $a_sub_type="", bool $a_only_optional=false)
Get activated records by object type.
static _getAllReferences(int $id)
get all reference ids for object ID
getValidSchemaVersions(string $a_entity)
static getUsageOfObject(int $a_obj_id, bool $a_include_titles=false)
static getTermList(array $a_glo_ref_id, string $searchterm="", string $a_first_letter="", string $a_def="", int $a_tax_node=0, bool $a_add_amet_fields=false, array $a_amet_filter=null, bool $a_include_references=false)
Get all terms for given set of glossary ids.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getXmlExportTailDependencies(string $a_entity, string $a_target_release, array $a_ids)
static getObjRecSelection(int $a_obj_id, string $a_sub_type="")
Get repository object record selection.
$ref_id
Definition: ltiauth.php:67
getXmlRepresentation(string $a_entity, string $a_schema_version, string $a_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getDefinitionList(int $a_term_id)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
for($i=6; $i< 13; $i++) for($i=1; $i< 13; $i++) $d
Definition: date.php:296