ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 ...> ... </types> <set entity="table_name"> <rec> <field_1>content</field_1> <field_2>my_date</field_2> <field_3>my_number</field_3> </rec> ... </set> </dataset> 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
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

ilGlossaryDataSet::__construct ( )

Constructor.

Reimplemented from ilDataSet.

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

31 {
32 global $DIC;
33
34 $this->db = $DIC->database();
35 $this->log = ilLoggerFactory::getLogger('glo');
36 parent::__construct();
37 }
static getLogger($a_component_id)
Get component logger.
global $DIC
Definition: saml.php:7

References $DIC, and ilLoggerFactory\getLogger().

+ 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 233 of file class.ilGlossaryDataSet.php.

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

◆ getSupportedVersions()

ilGlossaryDataSet::getSupportedVersions ( )

Get supported versions.

Returns
string version

Reimplemented from ilDataSet.

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

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

◆ 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

Reimplemented from ilDataSet.

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

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

◆ getXmlNamespace()

ilGlossaryDataSet::getXmlNamespace (   $a_entity,
  $a_schema_version 
)

Get xml namespace.

Parameters

return

Reimplemented from ilDataSet.

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

56 {
57 return "http://www.ilias.de/xml/Modules/Glossary/" . $a_entity;
58 }

◆ importRecord()

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

Import record.

Parameters

return

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

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

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

+ Here is the call graph for this function:

◆ readData()

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

Read data.

Parameters

return

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

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

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

+ Here is the call graph for this function:

Field Documentation

◆ $log

ilGlossaryDataSet::$log
protected

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


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