ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
ilGlossaryDataSet Class Reference

Glossary Data set class. More...

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

Public Member Functions

 __construct ()
 Constructor. More...
 
 getSupportedVersions ()
 Get supported versions. More...
 
 getXmlNamespace ($a_entity, $a_schema_version)
 Get xml namespace. More...
 
 readData ($a_entity, $a_version, $a_ids, $a_field="")
 Read data. More...
 
 importRecord ($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
 Import record. More...
 
- Public Member Functions inherited from ilDataSet
 __construct ()
 Constructor. More...
 
 init ($a_entity, $a_schema_version)
 Init. More...
 
 getSupportedVersions ()
 Get supported version. More...
 
 readData ($a_entity, $a_version, $a_ids)
 Read data from DB. More...
 
 setExportDirectories ($a_relative, $a_absolute)
 Set export directories. More...
 
 setImportDirectory ($a_val)
 Set import directory. More...
 
 getImportDirectory ()
 Get import directory. More...
 
 setDSPrefix ($a_val)
 Set XML dataset namespace prefix. More...
 
 getDSPrefix ()
 Get XML dataset namespace prefix. More...
 
 getDSPrefixString ()
 
 getDirectDataFromQuery ($a_query, $a_convert_to_leading_upper=true, $a_set=true)
 Get data from query.This is a standard procedure, all db field names are directly mapped to abstract fields. More...
 
 convertToLeadingUpper ($a_str)
 Make xyz_abc a XyzAbc string. More...
 
 getJsonRepresentation ()
 Get json representation. More...
 
 getXmlRepresentation ( $a_entity, $a_schema_version, $a_ids, $a_field="", $a_omit_header=false, $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 ($a_writer, $a_prefixes, $a_entity, $a_schema_version, $a_ids, $a_field="")
 Add records xml. More...
 
 afterXmlRecordWriting ($a_entity, $a_version, $a_set)
 After xml record writing hook record. More...
 
 getNamespaces (&$namespaces, $a_entity, $a_schema_version)
 Get xml namespaces. More...
 
 getXmlRecord ($a_entity, $a_version, $a_set)
 Get xml record for version. More...
 
 getJsonRecord ($a_set)
 Get json record for version. More...
 
 getXmlTypes ($a_entity, $a_version)
 Get xml types. More...
 
 getJsonTypes ($a_entity, $a_version)
 Get json types. More...
 
 getXMLEntityName ($a_entity, $a_version)
 Get entity name for xml (may be overwritten) More...
 
 getXMLEntityTag ($a_entity, $a_schema_version)
 Get entity tag. More...
 
 getJsonEntityName ($a_entity, $a_version)
 Get entity name for json (may be overwritten) More...
 
 setImport ($a_val)
 Set import object. More...
 
 getImport ()
 Get import object. More...
 
 setCurrentInstallationId ($a_val)
 Set current installation id. More...
 
 getCurrentInstallationId ()
 Get current installation id. More...
 

Protected Member Functions

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

Protected Attributes

 $log
 
- Protected Attributes inherited from ilDataSet
 $current_installation_id = ""
 
 $db
 
 $ds_log
 

Additional Inherited Members

- Data Fields inherited from ilDataSet
 $dircnt
 
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
 

Detailed Description

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
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e

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

Constructor & Destructor Documentation

◆ __construct()

ilGlossaryDataSet::__construct ( )

Constructor.

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

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

28  {
29  global $DIC;
30 
31  $this->db = $DIC->database();
32  $this->log = ilLoggerFactory::getLogger('glo');
34  }
__construct(Container $dic, ilPlugin $plugin)
$DIC
Definition: xapitoken.php:46
static getLogger($a_component_id)
Get component logger.
+ Here is the call graph for this function:

Member Function Documentation

◆ getDependencies()

ilGlossaryDataSet::getDependencies (   $a_entity,
  $a_version,
  $a_rec,
  $a_ids 
)
protected

Determine the dependent sets of data.

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

231  {
232  switch ($a_entity) {
233  case "glo":
234  return array(
235  "glo_term" => array("ids" => $a_rec["Id"]),
236  "glo_advmd_col_order" => array("ids" => $a_rec["Id"]),
237  "glo_auto_glossaries" => array("ids" => $a_rec["Id"])
238  );
239 
240  case "glo_term":
241  return array(
242  "glo_definition" => array("ids" => $a_rec["Id"])
243  );
244  }
245 
246  return false;
247  }

◆ getSupportedVersions()

ilGlossaryDataSet::getSupportedVersions ( )

Get supported versions.

Returns
string version

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

42  {
43  return array("5.1.0", "5.4.0");
44  }

◆ getTypes()

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

Get field types for entity.

Parameters
string$a_entityentity
string$a_versionversion number
Returns
array types array

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

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

◆ getXmlNamespace()

ilGlossaryDataSet::getXmlNamespace (   $a_entity,
  $a_schema_version 
)

Get xml namespace.

Parameters

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

53  {
54  return "http://www.ilias.de/xml/Modules/Glossary/" . $a_entity;
55  }

◆ importRecord()

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

Import record.

Parameters

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

References ilObject\_lookupObjIdByImportId(), ilObject\_lookupType(), ilDataSet\getCurrentInstallationId(), and ilObjectFactory\getInstanceByObjId().

257  {
258  switch ($a_entity) {
259  case "glo":
260 
261  if ($new_id = $a_mapping->getMapping('Services/Container', 'objs', $a_rec['Id'])) {
262  $newObj = ilObjectFactory::getInstanceByObjId($new_id, false);
263  } else {
264  $newObj = new ilObjGlossary();
265  $newObj->create(true);
266  }
267 
268  $newObj->setTitle($a_rec["Title"]);
269  $newObj->setDescription($a_rec["Description"]);
270  $newObj->setVirtualMode($a_rec["Virtual"]);
271  $newObj->setPresentationMode($a_rec["PresMode"]);
272  $newObj->setSnippetLength($a_rec["SnippetLength"]);
273  $newObj->setActiveGlossaryMenu($a_rec["GloMenuActive"]);
274  $newObj->setShowTaxonomy($a_rec["ShowTax"]);
275  if ($this->getCurrentInstallationId() > 0) {
276  $newObj->setImportId("il_" . $this->getCurrentInstallationId() . "_glo_" . $a_rec["Id"]);
277  }
278  $newObj->update(true);
279 
280  $this->current_obj = $newObj;
281  $this->old_glo_id = $a_rec["Id"];
282  $a_mapping->addMapping("Modules/Glossary", "glo", $a_rec["Id"], $newObj->getId());
283  $a_mapping->addMapping("Services/Object", "obj", $a_rec["Id"], $newObj->getId());
284  $a_mapping->addMapping(
285  "Services/MetaData",
286  "md",
287  $a_rec["Id"] . ":0:glo",
288  $newObj->getId() . ":0:glo"
289  );
290  $a_mapping->addMapping("Services/AdvancedMetaData", "parent", $a_rec["Id"], $newObj->getId());
291  break;
292 
293  case "glo_term":
294 
295  // id, glo_id, term, language, import_id
296 
297  $glo_id = (int) $a_mapping->getMapping("Modules/Glossary", "glo", $a_rec["GloId"]);
298  $term = new ilGlossaryTerm();
299  $term->setGlossaryId($glo_id);
300  $term->setTerm($a_rec["Term"]);
301  $term->setLanguage($a_rec["Language"]);
302  if ($this->getCurrentInstallationId() > 0) {
303  $term->setImportId("il_" . $this->getCurrentInstallationId() . "_git_" . $a_rec["Id"]);
304  }
305  $term->create();
306  $term_id = $term->getId();
307  $this->log->debug("glo_term, import id: " . $term->getImportId() . ", term id: " . $term_id);
308 
309  $a_mapping->addMapping(
310  "Modules/Glossary",
311  "term",
312  $a_rec["Id"],
313  $term_id
314  );
315 
316  $a_mapping->addMapping(
317  "Services/Taxonomy",
318  "tax_item",
319  "glo:term:" . $a_rec["Id"],
320  $term_id
321  );
322 
323  $a_mapping->addMapping(
324  "Services/Taxonomy",
325  "tax_item_obj_id",
326  "glo:term:" . $a_rec["Id"],
327  $glo_id
328  );
329 
330  $a_mapping->addMapping(
331  "Services/AdvancedMetaData",
332  "advmd_sub_item",
333  "advmd:term:" . $a_rec["Id"],
334  $term_id
335  );
336  break;
337 
338  case "glo_definition":
339 
340  // id, term_id, short_text, nr, short_text_dirty
341 
342  $term_id = (int) $a_mapping->getMapping("Modules/Glossary", "term", $a_rec["TermId"]);
343  if ((int) $term_id == 0) {
344  $this->log->debug("ERROR: Did not find glossary term glo_term id '" . $a_rec["TermId"] . "' for definition id '" . $a_rec["Id"] . "'.");
345  } else {
346  $def = new ilGlossaryDefinition();
347  $def->setTermId($term_id);
348  $def->setShortText($a_rec["ShortText"]);
349  $def->setNr($a_rec["Nr"]);
350  $def->setShortTextDirty($a_rec["ShortTextDirty"]);
351  // no metadata, no page creation
352  $def->create(true, true);
353 
354  $a_mapping->addMapping("Modules/Glossary", "def", $a_rec["Id"], $def->getId());
355  $a_mapping->addMapping(
356  "Services/COPage",
357  "pg",
358  "gdf:" . $a_rec["Id"],
359  "gdf:" . $def->getId()
360  );
361  $a_mapping->addMapping(
362  "Services/MetaData",
363  "md",
364  $this->old_glo_id . ":" . $a_rec["Id"] . ":gdf",
365  $this->current_obj->getId() . ":" . $def->getId() . ":gdf"
366  );
367  }
368  break;
369 
370  case "glo_advmd_col_order":
371  // glo_id, field_id, order_nr
372  // we save the ordering in the mapping, the glossary importer needs to fix this in the final
373  // processing
374  $a_mapping->addMapping("Modules/Glossary", "advmd_col_order", $a_rec["GloId"] . ":" . $a_rec["FieldId"], $a_rec["OrderNr"]);
375  break;
376 
377  case "glo_auto_glossaries":
378  $auto_glo_id = ilObject::_lookupObjIdByImportId($a_rec["AutoGloId"]);
379  $glo_id = (int) $a_mapping->getMapping("Modules/Glossary", "glo", $a_rec["GloId"]);
380  if ($glo_id > 0 && $auto_glo_id > 0 && ilObject::_lookupType($auto_glo_id) == "glo") {
381  $glo = new ilObjGlossary($glo_id, false);
382  $glo->addAutoGlossary($auto_glo_id);
383  $glo->updateAutoGlossaries();
384  }
385  break;
386  }
387  }
Glossary terms.
Class ilObjGlossary.
getCurrentInstallationId()
Get current installation id.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
static _lookupType($a_id, $a_reference=false)
lookup object type
Class ilGlossaryDefinition.
static _lookupObjIdByImportId($a_import_id)
+ Here is the call graph for this function:

◆ readData()

ilGlossaryDataSet::readData (   $a_entity,
  $a_version,
  $a_ids,
  $a_field = "" 
)

Read data.

Parameters

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

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

141  {
142  $ilDB = $this->db;
143 
144  if (!is_array($a_ids)) {
145  $a_ids = array($a_ids);
146  }
147 
148  if ($a_entity == "glo") {
149  switch ($a_version) {
150  case "5.1.0":
151  case "5.4.0":
152  $this->getDirectDataFromQuery("SELECT o.title, o.description, g.id, g.virtual, pres_mode, snippet_length, show_tax, glo_menu_active" .
153  " FROM glossary g JOIN object_data o " .
154  " ON (g.id = o.obj_id) " .
155  " WHERE " . $ilDB->in("g.id", $a_ids, false, "integer"));
156  break;
157  }
158  }
159 
160  if ($a_entity == "glo_term") {
161  switch ($a_version) {
162  case "5.1.0":
163  $this->getDirectDataFromQuery("SELECT id, glo_id, term, language" .
164  " FROM glossary_term " .
165  " WHERE " . $ilDB->in("glo_id", $a_ids, false, "integer"));
166  break;
167 
168  case "5.4.0":
169  $this->getDirectDataFromQuery("SELECT id, glo_id, term, language" .
170  " FROM glossary_term " .
171  " WHERE " . $ilDB->in("glo_id", $a_ids, false, "integer"));
172 
173  $set = $ilDB->query("SELECT r.term_id, r.glo_id, t.term, t.language " .
174  "FROM glo_term_reference r JOIN glossary_term t ON (r.term_id = t.id) " .
175  " WHERE " . $ilDB->in("r.glo_id", $a_ids, false, "integer"));
176  while ($rec = $ilDB->fetchAssoc($set)) {
177  $this->data[] = [
178  "Id" => $rec["term_id"],
179  "GloId" => $rec["glo_id"],
180  "Term" => $rec["term"],
181  "Language" => $rec["language"],
182  ];
183  }
184  break;
185  }
186  }
187 
188  if ($a_entity == "glo_definition") {
189  switch ($a_version) {
190  case "5.1.0":
191  case "5.4.0":
192  $this->getDirectDataFromQuery("SELECT id, term_id, short_text, nr, short_text_dirty" .
193  " FROM glossary_definition " .
194  " WHERE " . $ilDB->in("term_id", $a_ids, false, "integer"));
195  break;
196  }
197  }
198 
199  if ($a_entity == "glo_advmd_col_order") {
200  switch ($a_version) {
201  case "5.1.0":
202  case "5.4.0":
203  $this->getDirectDataFromQuery("SELECT glo_id, field_id, order_nr" .
204  " FROM glo_advmd_col_order " .
205  " WHERE " . $ilDB->in("glo_id", $a_ids, false, "integer"));
206  break;
207  }
208  }
209 
210  if ($a_entity == "glo_auto_glossaries") {
211  switch ($a_version) {
212  case "5.4.0":
213  $set = $ilDB->query("SELECT * FROM glo_glossaries " .
214  " WHERE " . $ilDB->in("id", $a_ids, false, "integer"));
215  $this->data = [];
216  while ($rec = $ilDB->fetchAssoc($set)) {
217  $this->data[] = [
218  "GloId" => $rec["id"],
219  "AutoGloId" => "il_" . IL_INST_ID . "_glo_" . $rec["glo_id"]
220  ];
221  }
222  break;
223  }
224  }
225  }
getDirectDataFromQuery($a_query, $a_convert_to_leading_upper=true, $a_set=true)
Get data from query.This is a standard procedure, all db field names are directly mapped to abstract ...
global $ilDB
+ Here is the call graph for this function:

Field Documentation

◆ $log

ilGlossaryDataSet::$log
protected

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


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