ILIAS  trunk Revision v11.0_alpha-1761-g6dbbfa7b760
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator 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...
 
 initByExporter (ilXmlExporter $xml_exporter)
 
 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...
 
 getCollection (array $record, string $entity, string $schema_version, string $field, string $value)
 
 getContainerExportConfig (array $record, string $entity, string $schema_version, string $field, string $value)
 

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)
 
 getExportDirInContainer (string $exp_dir)
 
 getIRSSContainerExportConfig (StorableResource $source_container, string $source_path, string $target_path="")
 
 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
 
array $used_term_ids = []
 
ilLogger $log
 
- Protected Attributes inherited from ilDataSet
ILIAS ResourceStorage Services $irss
 
string $current_installation_id = ""
 
array $data = []
 
ilDBInterface $db
 
ilLogger $ds_log
 
string $import_directory = ""
 
string $entity = ""
 
string $schema_version = ""
 
string $component_export_dir = ""
 
string $ds_prefix = "ds"
 
string $version = ""
 
ilSurveyImporter $import
 
ilExport $export
 

Additional Inherited Members

- Data Fields inherited from ilDataSet
const DATASET_NS = 'http://www.ilias.de/Services/DataSet/ds/4_3'
 
const DATASET_NS_PREFIX = 'ds'
 
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 37 of file class.ilGlossaryDataSet.php.

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

38  {
39  global $DIC;
40 
41  $this->db = $DIC->database();
42  $this->log = ilLoggerFactory::getLogger('glo');
44  }
static getLogger(string $a_component_id)
Get component logger.
global $DIC
Definition: shib_login.php:22
__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 242 of file class.ilGlossaryDataSet.php.

References null.

247  : array {
248  switch ($a_entity) {
249  case "glo":
250  return array(
251  "glo_term" => array("ids" => $a_rec["Id"] ?? null),
252  "glo_advmd_col_order" => array("ids" => $a_rec["Id"] ?? null),
253  "glo_auto_glossaries" => array("ids" => $a_rec["Id"] ?? null)
254  );
255  }
256 
257  return [];
258  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null

◆ getSupportedVersions()

ilGlossaryDataSet::getSupportedVersions ( )

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

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

◆ getTypes()

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

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

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

◆ getXmlNamespace()

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

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

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

◆ importRecord()

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

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

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

267  : void {
268  $a_rec = $this->stripTags($a_rec);
269  switch ($a_entity) {
270  case "glo":
271 
272  if ($new_id = $a_mapping->getMapping('components/ILIAS/Container', 'objs', $a_rec['Id'])) {
273  $newObj = ilObjectFactory::getInstanceByObjId($new_id, false);
274  } else {
275  $newObj = new ilObjGlossary();
276  $newObj->create(true);
277  }
278 
279  $newObj->setTitle($a_rec["Title"]);
280  $newObj->setDescription($a_rec["Description"]);
281  $newObj->setVirtualMode($a_rec["Virtual"]);
282  $newObj->setPresentationMode($a_rec["PresMode"]);
283  $newObj->setSnippetLength((int) ($a_rec["SnippetLength"] ?? 0));
284  $newObj->setActiveGlossaryMenu((bool) ($a_rec["GloMenuActive"] ?? false));
285  $newObj->setShowTaxonomy((bool) ($a_rec["ShowTax"] ?? false));
286  $newObj->setActiveFlashcards((bool) ($a_rec["FlashActive"] ?? false));
287  $newObj->setFlashcardsMode($a_rec["FlashMode"] ?? "");
288  if ($this->getCurrentInstallationId() > 0) {
289  $newObj->setImportId("il_" . $this->getCurrentInstallationId() . "_glo_" . $a_rec["Id"]);
290  }
291  $newObj->update();
292 
293  $this->current_obj = $newObj;
294  $this->old_glo_id = $a_rec["Id"];
295  $a_mapping->addMapping("components/ILIAS/Glossary", "glo", $a_rec["Id"], $newObj->getId());
296  $a_mapping->addMapping("components/ILIAS/ILIASObject", "obj", $a_rec["Id"], $newObj->getId());
297  $a_mapping->addMapping(
298  "components/ILIAS/MetaData",
299  "md",
300  $a_rec["Id"] . ":0:glo",
301  $newObj->getId() . ":0:glo"
302  );
303  $a_mapping->addMapping("components/ILIAS/AdvancedMetaData", "parent", $a_rec["Id"], $newObj->getId());
304  break;
305 
306  case "glo_definition":
307 
308  // note: this must be kept for older glossaries <= 8
309 
310  $term_id = (int) $a_mapping->getMapping("Modules/Glossary", "term", $a_rec["TermId"]);
311  if ($term_id == 0) {
312  $this->log->debug("ERROR: Did not find glossary term glo_term id '" . $a_rec["TermId"] . "' for definition id '" . $a_rec["Id"] . "'.");
313  } elseif (!in_array($term_id, $this->used_term_ids)) {
314  $a_mapping->addMapping(
315  "Services/COPage",
316  "pg",
317  "gdf:" . $a_rec["Id"],
318  "term:" . $term_id
319  );
320  // use only first definition for term, because multiple definitons are abandoned since ILIAS 9
321  $this->used_term_ids[] = $term_id;
322  }
323  break;
324 
325  case "glo_term":
326 
327  // id, glo_id, term, language, import_id, short_text, short_text_dirty
328 
329  $glo_id = (int) $a_mapping->getMapping("components/ILIAS/Glossary", "glo", $a_rec["GloId"]);
330  $term = new ilGlossaryTerm();
331  $term->setGlossaryId($glo_id);
332  $term->setTerm($a_rec["Term"]);
333  $term->setLanguage($a_rec["Language"]);
334  $term->setShortText($a_rec["ShortText"] ?? "");
335  $term->setShortTextDirty($a_rec["ShortTextDirty"] ?? true);
336  if ($this->getCurrentInstallationId() > 0) {
337  $term->setImportId("il_" . $this->getCurrentInstallationId() . "_git_" . $a_rec["Id"]);
338  }
339  $term->create(true);
340  $term_id = $term->getId();
341  $this->log->debug("glo_term, import id: " . $term->getImportId() . ", term id: " . $term_id);
342 
343  $a_mapping->addMapping(
344  "components/ILIAS/Glossary",
345  "term",
346  $a_rec["Id"],
347  $term_id
348  );
349 
350  $a_mapping->addMapping(
351  "components/ILIAS/Taxonomy",
352  "tax_item",
353  "glo:term:" . $a_rec["Id"],
354  $term_id
355  );
356 
357  $a_mapping->addMapping(
358  "components/ILIAS/Taxonomy",
359  "tax_item_obj_id",
360  "glo:term:" . $a_rec["Id"],
361  $glo_id
362  );
363 
364  $a_mapping->addMapping(
365  "components/ILIAS/AdvancedMetaData",
366  "advmd_sub_item",
367  "advmd:term:" . $a_rec["Id"],
368  $term_id
369  );
370 
371  $a_mapping->addMapping(
372  "components/ILIAS/COPage",
373  "pg",
374  "term:" . $a_rec["Id"],
375  "term:" . $term_id
376  );
377  break;
378 
379  case "glo_advmd_col_order":
380  // glo_id, field_id, order_nr
381  // we save the ordering in the mapping, the glossary importer needs to fix this in the final
382  // processing
383  $a_mapping->addMapping("components/ILIAS/Glossary", "advmd_col_order", $a_rec["GloId"] . ":" . $a_rec["FieldId"], $a_rec["OrderNr"]);
384  break;
385 
386  case "glo_auto_glossaries":
387  $auto_glo_id = ilObject::_lookupObjIdByImportId($a_rec["AutoGloId"]);
388  $glo_id = (int) $a_mapping->getMapping("components/ILIAS/Glossary", "glo", $a_rec["GloId"]);
389  if ($glo_id > 0 && $auto_glo_id > 0 && ilObject::_lookupType($auto_glo_id) == "glo") {
390  $glo = new ilObjGlossary($glo_id, false);
391  $glo->addAutoGlossary($auto_glo_id);
392  $glo->updateAutoGlossaries();
393  }
394  break;
395  }
396  }
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()
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 133 of file class.ilGlossaryDataSet.php.

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

133  : void
134  {
135  $ilDB = $this->db;
136 
137  if ($a_entity == "glo") {
138  switch ($a_version) {
139  case "5.1.0":
140  case "5.4.0":
141  case "9.0.0":
142  $this->getDirectDataFromQuery("SELECT o.title, o.description, g.id, g.virtual, pres_mode, snippet_length, show_tax, glo_menu_active" .
143  " FROM glossary g JOIN object_data o " .
144  " ON (g.id = o.obj_id) " .
145  " WHERE " . $ilDB->in("g.id", $a_ids, false, "integer"));
146  break;
147  }
148  }
149 
150  if ($a_entity == "glo_term") {
151  switch ($a_version) {
152  case "5.1.0":
153  $this->getDirectDataFromQuery("SELECT id, glo_id, term, language" .
154  " FROM glossary_term " .
155  " WHERE " . $ilDB->in("glo_id", $a_ids, false, "integer"));
156  break;
157 
158  case "5.4.0":
159  $this->getDirectDataFromQuery("SELECT id, glo_id, term, language" .
160  " FROM glossary_term " .
161  " WHERE " . $ilDB->in("glo_id", $a_ids, false, "integer"));
162 
163  $set = $ilDB->query("SELECT r.term_id, r.glo_id, t.term, t.language " .
164  "FROM glo_term_reference r JOIN glossary_term t ON (r.term_id = t.id) " .
165  " WHERE " . $ilDB->in("r.glo_id", $a_ids, false, "integer"));
166  while ($rec = $ilDB->fetchAssoc($set)) {
167  $this->data[] = [
168  "Id" => $rec["term_id"],
169  "GloId" => $rec["glo_id"],
170  "Term" => $rec["term"],
171  "Language" => $rec["language"],
172  ];
173  }
174  break;
175  case "9.0.0":
176  $this->getDirectDataFromQuery("SELECT id, glo_id, term, language" .
177  " FROM glossary_term " .
178  " WHERE " . $ilDB->in("glo_id", $a_ids, false, "integer"));
179 
180  $set = $ilDB->query("SELECT r.term_id, r.glo_id, t.term, t.language, " .
181  "t.short_text, t.short_text_dirty " .
182  "FROM glo_term_reference r JOIN glossary_term t ON (r.term_id = t.id) " .
183  " WHERE " . $ilDB->in("r.glo_id", $a_ids, false, "integer"));
184  while ($rec = $ilDB->fetchAssoc($set)) {
185  $this->data[] = [
186  "Id" => $rec["term_id"],
187  "GloId" => $rec["glo_id"],
188  "Term" => $rec["term"],
189  "Language" => $rec["language"],
190  "ShortText" => $rec["short_text"],
191  "ShortTextDirty" => $rec["short_text_dirty"]
192  ];
193  }
194  break;
195  }
196  }
197 
198  if ($a_entity == "glo_definition") {
199  switch ($a_version) {
200  case "5.1.0":
201  case "5.4.0":
202  $this->getDirectDataFromQuery("SELECT id, term_id, short_text, nr, short_text_dirty" .
203  " FROM glossary_definition " .
204  " WHERE " . $ilDB->in("term_id", $a_ids, false, "integer"));
205  break;
206  }
207  }
208 
209  if ($a_entity == "glo_advmd_col_order") {
210  switch ($a_version) {
211  case "5.1.0":
212  case "5.4.0":
213  case "9.0.0":
214  $this->getDirectDataFromQuery("SELECT glo_id, field_id, order_nr" .
215  " FROM glo_advmd_col_order " .
216  " WHERE " . $ilDB->in("glo_id", $a_ids, false, "integer"));
217  break;
218  }
219  }
220 
221  if ($a_entity == "glo_auto_glossaries") {
222  switch ($a_version) {
223  case "5.4.0":
224  case "9.0.0":
225  $set = $ilDB->query("SELECT * FROM glo_glossaries " .
226  " WHERE " . $ilDB->in("id", $a_ids, false, "integer"));
227  $this->data = [];
228  while ($rec = $ilDB->fetchAssoc($set)) {
229  $this->data[] = [
230  "GloId" => $rec["id"],
231  "AutoGloId" => "il_" . IL_INST_ID . "_glo_" . $rec["glo_id"]
232  ];
233  }
234  break;
235  }
236  }
237  }
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 35 of file class.ilGlossaryDataSet.php.

◆ $old_glo_id

int ilGlossaryDataSet::$old_glo_id
protected

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

◆ $used_term_ids

array ilGlossaryDataSet::$used_term_ids = []
protected

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


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