ILIAS  release_8 Revision v8.19-1-g4e8f2f9140c
All Data Structures Namespaces Files Functions Variables Modules Pages
ilGlossaryDataSet Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilGlossaryDataSet:
+ Collaboration diagram for ilGlossaryDataSet:

Public Member Functions

 __construct ()
 
 getSupportedVersions ()
 
 readData (string $a_entity, string $a_version, array $a_ids)
 
 importRecord (string $a_entity, array $a_types, array $a_rec, ilImportMapping $a_mapping, string $a_schema_version)
 
- Public Member Functions inherited from ilDataSet
 __construct ()
 
 init (string $a_entity, string $a_schema_version)
 Init. More...
 
 getSupportedVersions ()
 
 readData (string $a_entity, string $a_version, array $a_ids)
 Read data from DB. More...
 
 setExportDirectories (string $a_relative, string $a_absolute)
 
 setImportDirectory (string $a_val)
 
 getImportDirectory ()
 
 setDSPrefix (string $a_val)
 
 getDSPrefix ()
 
 getDSPrefixString ()
 
 getDirectDataFromQuery (string $a_query, bool $a_convert_to_leading_upper=true, bool $a_set=true)
 Get data from query.This is a standard procedure, all db field names are directly mapped to abstract fields. More...
 
 convertToLeadingUpper (string $a_str)
 Make xyz_abc a XyzAbc string. More...
 
 getXmlRepresentation (string $a_entity, string $a_schema_version, ?array $a_ids, string $a_field="", bool $a_omit_header=false, bool $a_omit_types=false)
 Get xml representation <dataset install_id="123" install_url="..."> <types entity="table_name" version="4.0.1"> <ftype name="field_1" type="text"> <ftype name="field_2" type="date"> <ftype name="field_3" type="integer"> </types> <types ...> ... More...
 
 addRecordsXml (ilXmlWriter $a_writer, array $a_prefixes, string $a_entity, string $a_schema_version, array $a_ids, ?string $a_field="")
 
 afterXmlRecordWriting (string $a_entity, string $a_version, array $a_set)
 
 getNamespaces (array &$namespaces, string $a_entity, string $a_schema_version)
 
 getXmlRecord (string $a_entity, string $a_version, array $a_set)
 Get xml record for version. More...
 
 getXmlTypes (string $a_entity, string $a_version)
 Get xml types. More...
 
 getXMLEntityName (string $a_entity, string $a_version)
 Get entity name for xml (may be overwritten) More...
 
 getXMLEntityTag (string $a_entity, string $a_schema_version)
 Get entity tag. More...
 
 setImport (ilSurveyImporter $a_val)
 
 getImport ()
 
 setCurrentInstallationId (string $a_val)
 
 getCurrentInstallationId ()
 
 importRecord (string $a_entity, array $a_types, array $a_rec, ilImportMapping $a_mapping, string $a_schema_version)
 Needs to be overwritten for import use case. More...
 

Protected Member Functions

 getXmlNamespace (string $a_entity, string $a_schema_version)
 
 getTypes (string $a_entity, string $a_version)
 
 getDependencies (string $a_entity, string $a_version, ?array $a_rec=null, ?array $a_ids=null)
 Determine the dependent sets of data. More...
 
- Protected Member Functions inherited from ilDataSet
 getTypes (string $a_entity, string $a_version)
 Get (abstract) types for (abstract) field names. More...
 
 getXmlNamespace (string $a_entity, string $a_schema_version)
 
 getDependencies (string $a_entity, string $a_version, ?array $a_rec=null, ?array $a_ids=null)
 
 createObjectExportId (string $a_type, string $a_id)
 Build ilias export id. More...
 
 parseObjectExportId (string $a_id, ?string $a_fallback_id=null)
 Parse export id. More...
 
 stripTags (array $rec, array $omit_keys=[])
 

Protected Attributes

int $old_glo_id
 
ilObjGlossary $current_obj
 
ilLogger $log
 
- Protected Attributes inherited from ilDataSet
string $current_installation_id = ""
 
array $data = []
 
ilDBInterface $db
 
ilLogger $ds_log
 
string $import_directory = ""
 
string $entity = ""
 
string $schema_version = ""
 
string $relative_export_dir = ""
 
string $absolute_export_dir = ""
 
string $ds_prefix = "ds"
 
string $version = ""
 
ilSurveyImporter $import
 

Additional Inherited Members

- Data Fields inherited from ilDataSet
const EXPORT_NO_INST_ID = 1
 
const EXPORT_ID_ILIAS_LOCAL = 2
 
const EXPORT_ID_ILIAS_LOCAL_INVALID = 3
 
const EXPORT_ID_ILIAS_REMOTE = 4
 
const EXPORT_ID_ILIAS_REMOTE_INVALID = 5
 
const EXPORT_ID = 6
 
const EXPORT_ID_INVALID = 7
 
int $dircnt = 0
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Glossary Data set class

This class implements the following entities:

  • glo: data from glossary
  • glo_term: data from glossary_term
  • glo_definition: data from glossary_definition
  • glo_advmd_col_order: ordering md fields
  • glo_auto_glossaries: automatically linked glossaries
    Author
    Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 30 of file class.ilGlossaryDataSet.php.

Constructor & Destructor Documentation

◆ __construct()

ilGlossaryDataSet::__construct ( )

Definition at line 36 of file class.ilGlossaryDataSet.php.

References $DIC, ILIAS\GlobalScreen\Provider\__construct(), and ilLoggerFactory\getLogger().

37  {
38  global $DIC;
39 
40  $this->db = $DIC->database();
41  $this->log = ilLoggerFactory::getLogger('glo');
43  }
static getLogger(string $a_component_id)
Get component logger.
global $DIC
Definition: feed.php:28
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ getDependencies()

ilGlossaryDataSet::getDependencies ( string  $a_entity,
string  $a_version,
?array  $a_rec = null,
?array  $a_ids = null 
)
protected

Determine the dependent sets of data.

Definition at line 212 of file class.ilGlossaryDataSet.php.

217  : array {
218  switch ($a_entity) {
219  case "glo":
220  return array(
221  "glo_term" => array("ids" => $a_rec["Id"] ?? null),
222  "glo_advmd_col_order" => array("ids" => $a_rec["Id"] ?? null),
223  "glo_auto_glossaries" => array("ids" => $a_rec["Id"] ?? null)
224  );
225 
226  case "glo_term":
227  return array(
228  "glo_definition" => array("ids" => $a_rec["Id"] ?? null)
229  );
230  }
231 
232  return [];
233  }

◆ getSupportedVersions()

ilGlossaryDataSet::getSupportedVersions ( )

Definition at line 45 of file class.ilGlossaryDataSet.php.

45  : array
46  {
47  return array("5.1.0", "5.4.0");
48  }

◆ getTypes()

ilGlossaryDataSet::getTypes ( string  $a_entity,
string  $a_version 
)
protected

Definition at line 55 of file class.ilGlossaryDataSet.php.

55  : array
56  {
57  if ($a_entity == "glo") {
58  switch ($a_version) {
59  case "5.1.0":
60  case "5.4.0":
61  return array(
62  "Id" => "integer",
63  "Title" => "text",
64  "Description" => "text",
65  "Virtual" => "text",
66  "PresMode" => "text",
67  "SnippetLength" => "integer",
68  "GloMenuActive" => "text",
69  "ShowTax" => "integer"
70  );
71  }
72  }
73 
74  if ($a_entity == "glo_term") {
75  switch ($a_version) {
76  case "5.1.0":
77  case "5.4.0":
78  return array(
79  "Id" => "integer",
80  "GloId" => "integer",
81  "Term" => "text",
82  "Language" => "text",
83  "ImportId" => "text"
84  );
85  }
86  }
87 
88  if ($a_entity == "glo_definition") {
89  switch ($a_version) {
90  case "5.1.0":
91  case "5.4.0":
92  return array(
93  "Id" => "integer",
94  "TermId" => "integer",
95  "ShortText" => "text",
96  "Nr" => "integer",
97  "ShortTextDirty" => "integer"
98  );
99  }
100  }
101 
102  if ($a_entity == "glo_advmd_col_order") {
103  switch ($a_version) {
104  case "5.1.0":
105  case "5.4.0":
106  return array(
107  "GloId" => "integer",
108  "FieldId" => "text",
109  "OrderNr" => "integer"
110  );
111  }
112  }
113 
114  if ($a_entity == "glo_auto_glossaries") {
115  switch ($a_version) {
116  case "5.4.0":
117  return array(
118  "GloId" => "integer",
119  "AutoGloId" => "text"
120  );
121  }
122  }
123  return [];
124  }

◆ getXmlNamespace()

ilGlossaryDataSet::getXmlNamespace ( string  $a_entity,
string  $a_schema_version 
)
protected

Definition at line 50 of file class.ilGlossaryDataSet.php.

50  : string
51  {
52  return "https://www.ilias.de/xml/Modules/Glossary/" . $a_entity;
53  }

◆ importRecord()

ilGlossaryDataSet::importRecord ( string  $a_entity,
array  $a_types,
array  $a_rec,
ilImportMapping  $a_mapping,
string  $a_schema_version 
)

Definition at line 236 of file class.ilGlossaryDataSet.php.

References ilObject\_lookupObjIdByImportId(), ilObject\_lookupType(), ilImportMapping\addMapping(), ilDataSet\getCurrentInstallationId(), ilObjectFactory\getInstanceByObjId(), ilImportMapping\getMapping(), ILIAS\Repository\int(), and ilDataSet\stripTags().

242  : void {
243  $a_rec = $this->stripTags($a_rec);
244  switch ($a_entity) {
245  case "glo":
246 
247  if ($new_id = $a_mapping->getMapping('Services/Container', 'objs', $a_rec['Id'])) {
248  $newObj = ilObjectFactory::getInstanceByObjId($new_id, false);
249  } else {
250  $newObj = new ilObjGlossary();
251  $newObj->create(true);
252  }
253 
254  $newObj->setTitle($a_rec["Title"]);
255  $newObj->setDescription($a_rec["Description"]);
256  $newObj->setVirtualMode($a_rec["Virtual"]);
257  $newObj->setPresentationMode($a_rec["PresMode"]);
258  $newObj->setSnippetLength((int) ($a_rec["SnippetLength"] ?? 0));
259  $newObj->setActiveGlossaryMenu((bool) ($a_rec["GloMenuActive"] ?? false));
260  $newObj->setShowTaxonomy((bool) ($a_rec["ShowTax"] ?? false));
261  if ($this->getCurrentInstallationId() > 0) {
262  $newObj->setImportId("il_" . $this->getCurrentInstallationId() . "_glo_" . $a_rec["Id"]);
263  }
264  $newObj->update();
265 
266  $this->current_obj = $newObj;
267  $this->old_glo_id = $a_rec["Id"];
268  $a_mapping->addMapping("Modules/Glossary", "glo", $a_rec["Id"], $newObj->getId());
269  $a_mapping->addMapping("Services/Object", "obj", $a_rec["Id"], $newObj->getId());
270  $a_mapping->addMapping(
271  "Services/MetaData",
272  "md",
273  $a_rec["Id"] . ":0:glo",
274  $newObj->getId() . ":0:glo"
275  );
276  $a_mapping->addMapping("Services/AdvancedMetaData", "parent", $a_rec["Id"], $newObj->getId());
277  break;
278 
279  case "glo_term":
280 
281  // id, glo_id, term, language, import_id
282 
283  $glo_id = (int) $a_mapping->getMapping("Modules/Glossary", "glo", $a_rec["GloId"]);
284  $term = new ilGlossaryTerm();
285  $term->setGlossaryId($glo_id);
286  $term->setTerm($a_rec["Term"]);
287  $term->setLanguage($a_rec["Language"]);
288  if ($this->getCurrentInstallationId() > 0) {
289  $term->setImportId("il_" . $this->getCurrentInstallationId() . "_git_" . $a_rec["Id"]);
290  }
291  $term->create();
292  $term_id = $term->getId();
293  $this->log->debug("glo_term, import id: " . $term->getImportId() . ", term id: " . $term_id);
294 
295  $a_mapping->addMapping(
296  "Modules/Glossary",
297  "term",
298  $a_rec["Id"],
299  $term_id
300  );
301 
302  $a_mapping->addMapping(
303  "Services/Taxonomy",
304  "tax_item",
305  "glo:term:" . $a_rec["Id"],
306  $term_id
307  );
308 
309  $a_mapping->addMapping(
310  "Services/Taxonomy",
311  "tax_item_obj_id",
312  "glo:term:" . $a_rec["Id"],
313  $glo_id
314  );
315 
316  $a_mapping->addMapping(
317  "Services/AdvancedMetaData",
318  "advmd_sub_item",
319  "advmd:term:" . $a_rec["Id"],
320  $term_id
321  );
322  break;
323 
324  case "glo_definition":
325 
326  // id, term_id, short_text, nr, short_text_dirty
327 
328  $term_id = (int) $a_mapping->getMapping("Modules/Glossary", "term", $a_rec["TermId"]);
329  if ($term_id == 0) {
330  $this->log->debug("ERROR: Did not find glossary term glo_term id '" . $a_rec["TermId"] . "' for definition id '" . $a_rec["Id"] . "'.");
331  } else {
332  $def = new ilGlossaryDefinition();
333  $def->setTermId($term_id);
334  $def->setShortText($a_rec["ShortText"]);
335  $def->setNr($a_rec["Nr"]);
336  $def->setShortTextDirty($a_rec["ShortTextDirty"]);
337  // no metadata, no page creation
338  $def->create(true, true);
339 
340  $a_mapping->addMapping("Modules/Glossary", "def", $a_rec["Id"], $def->getId());
341  $a_mapping->addMapping(
342  "Services/COPage",
343  "pg",
344  "gdf:" . $a_rec["Id"],
345  "gdf:" . $def->getId()
346  );
347  $a_mapping->addMapping(
348  "Services/MetaData",
349  "md",
350  $this->old_glo_id . ":" . $a_rec["Id"] . ":gdf",
351  $this->current_obj->getId() . ":" . $def->getId() . ":gdf"
352  );
353  }
354  break;
355 
356  case "glo_advmd_col_order":
357  // glo_id, field_id, order_nr
358  // we save the ordering in the mapping, the glossary importer needs to fix this in the final
359  // processing
360  $a_mapping->addMapping("Modules/Glossary", "advmd_col_order", $a_rec["GloId"] . ":" . $a_rec["FieldId"], $a_rec["OrderNr"]);
361  break;
362 
363  case "glo_auto_glossaries":
364  $auto_glo_id = ilObject::_lookupObjIdByImportId($a_rec["AutoGloId"]);
365  $glo_id = (int) $a_mapping->getMapping("Modules/Glossary", "glo", $a_rec["GloId"]);
366  if ($glo_id > 0 && $auto_glo_id > 0 && ilObject::_lookupType($auto_glo_id) == "glo") {
367  $glo = new ilObjGlossary($glo_id, false);
368  $glo->addAutoGlossary($auto_glo_id);
369  $glo->updateAutoGlossaries();
370  }
371  break;
372  }
373  }
static _lookupObjIdByImportId(string $import_id)
Get (latest) object id for an import id.
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...
addMapping(string $a_comp, string $a_entity, string $a_old_id, string $a_new_id)
getMapping(string $a_comp, string $a_entity, string $a_old_id)
getCurrentInstallationId()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
stripTags(array $rec, array $omit_keys=[])
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:

◆ readData()

ilGlossaryDataSet::readData ( string  $a_entity,
string  $a_version,
array  $a_ids 
)

Definition at line 126 of file class.ilGlossaryDataSet.php.

References ilDataSet\$db, $ilDB, ilDataSet\getDirectDataFromQuery(), and IL_INST_ID.

126  : void
127  {
128  $ilDB = $this->db;
129 
130  if ($a_entity == "glo") {
131  switch ($a_version) {
132  case "5.1.0":
133  case "5.4.0":
134  $this->getDirectDataFromQuery("SELECT o.title, o.description, g.id, g.virtual, pres_mode, snippet_length, show_tax, glo_menu_active" .
135  " FROM glossary g JOIN object_data o " .
136  " ON (g.id = o.obj_id) " .
137  " WHERE " . $ilDB->in("g.id", $a_ids, false, "integer"));
138  break;
139  }
140  }
141 
142  if ($a_entity == "glo_term") {
143  switch ($a_version) {
144  case "5.1.0":
145  $this->getDirectDataFromQuery("SELECT id, glo_id, term, language" .
146  " FROM glossary_term " .
147  " WHERE " . $ilDB->in("glo_id", $a_ids, false, "integer"));
148  break;
149 
150  case "5.4.0":
151  $this->getDirectDataFromQuery("SELECT id, glo_id, term, language" .
152  " FROM glossary_term " .
153  " WHERE " . $ilDB->in("glo_id", $a_ids, false, "integer"));
154 
155  $set = $ilDB->query("SELECT r.term_id, r.glo_id, t.term, t.language " .
156  "FROM glo_term_reference r JOIN glossary_term t ON (r.term_id = t.id) " .
157  " WHERE " . $ilDB->in("r.glo_id", $a_ids, false, "integer"));
158  while ($rec = $ilDB->fetchAssoc($set)) {
159  $this->data[] = [
160  "Id" => $rec["term_id"],
161  "GloId" => $rec["glo_id"],
162  "Term" => $rec["term"],
163  "Language" => $rec["language"],
164  ];
165  }
166  break;
167  }
168  }
169 
170  if ($a_entity == "glo_definition") {
171  switch ($a_version) {
172  case "5.1.0":
173  case "5.4.0":
174  $this->getDirectDataFromQuery("SELECT id, term_id, short_text, nr, short_text_dirty" .
175  " FROM glossary_definition " .
176  " WHERE " . $ilDB->in("term_id", $a_ids, false, "integer"));
177  break;
178  }
179  }
180 
181  if ($a_entity == "glo_advmd_col_order") {
182  switch ($a_version) {
183  case "5.1.0":
184  case "5.4.0":
185  $this->getDirectDataFromQuery("SELECT glo_id, field_id, order_nr" .
186  " FROM glo_advmd_col_order " .
187  " WHERE " . $ilDB->in("glo_id", $a_ids, false, "integer"));
188  break;
189  }
190  }
191 
192  if ($a_entity == "glo_auto_glossaries") {
193  switch ($a_version) {
194  case "5.4.0":
195  $set = $ilDB->query("SELECT * FROM glo_glossaries " .
196  " WHERE " . $ilDB->in("id", $a_ids, false, "integer"));
197  $this->data = [];
198  while ($rec = $ilDB->fetchAssoc($set)) {
199  $this->data[] = [
200  "GloId" => $rec["id"],
201  "AutoGloId" => "il_" . IL_INST_ID . "_glo_" . $rec["glo_id"]
202  ];
203  }
204  break;
205  }
206  }
207  }
const IL_INST_ID
Definition: constants.php:40
ilDBInterface $db
getDirectDataFromQuery(string $a_query, bool $a_convert_to_leading_upper=true, bool $a_set=true)
Get data from query.This is a standard procedure, all db field names are directly mapped to abstract ...
+ Here is the call graph for this function:

Field Documentation

◆ $current_obj

ilObjGlossary ilGlossaryDataSet::$current_obj
protected

Definition at line 33 of file class.ilGlossaryDataSet.php.

◆ $log

ilLogger ilGlossaryDataSet::$log
protected

Definition at line 34 of file class.ilGlossaryDataSet.php.

◆ $old_glo_id

int ilGlossaryDataSet::$old_glo_id
protected

Definition at line 32 of file class.ilGlossaryDataSet.php.


The documentation for this class was generated from the following file: