ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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
Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

ilGlossaryDataSet::__construct ( )

Constructor.

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

References $DIC, and ilLoggerFactory\getLogger().

30  {
31  global $DIC;
32 
33  $this->db = $DIC->database();
34  $this->log = ilLoggerFactory::getLogger('glo');
35  parent::__construct();
36  }
global $DIC
Definition: saml.php:7
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 182 of file class.ilGlossaryDataSet.php.

References array.

183  {
184  switch ($a_entity) {
185  case "glo":
186  return array(
187  "glo_term" => array("ids" => $a_rec["Id"]),
188  "glo_advmd_col_order" => array("ids" => $a_rec["Id"])
189  );
190 
191  case "glo_term":
192  return array(
193  "glo_definition" => array("ids" => $a_rec["Id"])
194  );
195  }
196 
197  return false;
198  }
Create styles array
The data for the language used.

◆ getSupportedVersions()

ilGlossaryDataSet::getSupportedVersions ( )

Get supported versions.

Returns
string version

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

References array.

44  {
45  return array("5.1.0");
46  }
Create styles array
The data for the language used.

◆ 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 66 of file class.ilGlossaryDataSet.php.

References array.

67  {
68  if ($a_entity == "glo") {
69  switch ($a_version) {
70  case "5.1.0":
71  return array(
72  "Id" => "integer",
73  "Title" => "text",
74  "Description" => "text",
75  "Virtual" => "text",
76  "PresMode" => "text",
77  "SnippetLength" => "integer",
78  "GloMenuActive" => "text",
79  "ShowTax" => "integer"
80  );
81  }
82  }
83 
84  if ($a_entity == "glo_term") {
85  switch ($a_version) {
86  case "5.1.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  return array(
101  "Id" => "integer",
102  "TermId" => "integer",
103  "ShortText" => "text",
104  "Nr" => "integer",
105  "ShortTextDirty" => "integer"
106  );
107  }
108  }
109 
110  if ($a_entity == "glo_advmd_col_order") {
111  switch ($a_version) {
112  case "5.1.0":
113  return array(
114  "GloId" => "integer",
115  "FieldId" => "text",
116  "OrderNr" => "integer"
117  );
118  }
119  }
120  }
Create styles array
The data for the language used.

◆ getXmlNamespace()

ilGlossaryDataSet::getXmlNamespace (   $a_entity,
  $a_schema_version 
)

Get xml namespace.

Parameters

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

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

◆ importRecord()

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

Import record.

Parameters

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

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

208  {
209  switch ($a_entity) {
210  case "glo":
211 
212  include_once("./Modules/Glossary/classes/class.ilObjGlossary.php");
213  if ($new_id = $a_mapping->getMapping('Services/Container', 'objs', $a_rec['Id'])) {
214  $newObj = ilObjectFactory::getInstanceByObjId($new_id, false);
215  } else {
216  $newObj = new ilObjGlossary();
217  $newObj->create(true);
218  }
219 
220  $newObj->setTitle($a_rec["Title"]);
221  $newObj->setDescription($a_rec["Description"]);
222  $newObj->setVirtualMode($a_rec["Virtual"]);
223  $newObj->setPresentationMode($a_rec["PresMode"]);
224  $newObj->setSnippetLength($a_rec["SnippetLength"]);
225  $newObj->setActiveGlossaryMenu($a_rec["GloMenuActive"]);
226  $newObj->setShowTaxonomy($a_rec["ShowTax"]);
227  $newObj->update(true);
228 
229  $this->current_obj = $newObj;
230  $this->old_glo_id = $a_rec["Id"];
231  $a_mapping->addMapping("Modules/Glossary", "glo", $a_rec["Id"], $newObj->getId());
232  $a_mapping->addMapping("Services/Object", "obj", $a_rec["Id"], $newObj->getId());
233  $a_mapping->addMapping(
234  "Services/MetaData",
235  "md",
236  $a_rec["Id"] . ":0:glo",
237  $newObj->getId() . ":0:glo"
238  );
239  $a_mapping->addMapping("Services/AdvancedMetaData", "parent", $a_rec["Id"], $newObj->getId());
240  break;
241 
242  case "glo_term":
243 
244  // id, glo_id, term, language, import_id
245 
246  include_once("./Modules/Glossary/classes/class.ilGlossaryTerm.php");
247  $glo_id = (int) $a_mapping->getMapping("Modules/Glossary", "glo", $a_rec["GloId"]);
248  $term = new ilGlossaryTerm();
249  $term->setGlossaryId($glo_id);
250  $term->setTerm($a_rec["Term"]);
251  $term->setLanguage($a_rec["Language"]);
252  if ($this->getCurrentInstallationId() > 0) {
253  $term->setImportId("il_" . $this->getCurrentInstallationId() . "_git_" . $a_rec["Id"]);
254  }
255  $term->create();
256  $term_id = $term->getId();
257  $this->log->debug("glo_term, import id: " . $term->getImportId() . ", term id: " . $term_id);
258 
259  $a_mapping->addMapping(
260  "Modules/Glossary",
261  "term",
262  $a_rec["Id"],
263  $term_id
264  );
265 
266  $a_mapping->addMapping(
267  "Services/Taxonomy",
268  "tax_item",
269  "glo:term:" . $a_rec["Id"],
270  $term_id
271  );
272 
273  $a_mapping->addMapping(
274  "Services/Taxonomy",
275  "tax_item_obj_id",
276  "glo:term:" . $a_rec["Id"],
277  $glo_id
278  );
279 
280  $a_mapping->addMapping(
281  "Services/AdvancedMetaData",
282  "advmd_sub_item",
283  "advmd:term:" . $a_rec["Id"],
284  $term_id
285  );
286  break;
287 
288  case "glo_definition":
289 
290  // id, term_id, short_text, nr, short_text_dirty
291 
292  include_once("./Modules/Glossary/classes/class.ilGlossaryDefinition.php");
293  $term_id = (int) $a_mapping->getMapping("Modules/Glossary", "term", $a_rec["TermId"]);
294  if ((int) $term_id == 0) {
295  $this->log->debug("ERROR: Did not find glossary term glo_term id '" . $a_rec["TermId"] . "' for definition id '" . $a_rec["Id"] . "'.");
296  } else {
297  $def = new ilGlossaryDefinition();
298  $def->setTermId($term_id);
299  $def->setShortText($a_rec["ShortText"]);
300  $def->setNr($a_rec["Nr"]);
301  $def->setShortTextDirty($a_rec["ShortTextDirty"]);
302  // no metadata, no page creation
303  $def->create(true, true);
304 
305  $a_mapping->addMapping("Modules/Glossary", "def", $a_rec["Id"], $def->getId());
306  $a_mapping->addMapping(
307  "Services/COPage",
308  "pg",
309  "gdf:" . $a_rec["Id"],
310  "gdf:" . $def->getId()
311  );
312  $a_mapping->addMapping(
313  "Services/MetaData",
314  "md",
315  $this->old_glo_id . ":" . $a_rec["Id"] . ":gdf",
316  $this->current_obj->getId() . ":" . $def->getId() . ":gdf"
317  );
318  }
319  break;
320 
321  case "glo_advmd_col_order":
322  // glo_id, field_id, order_nr
323  // we save the ordering in the mapping, the glossary importer needs to fix this in the final
324  // processing
325  $a_mapping->addMapping("Modules/Glossary", "advmd_col_order", $a_rec["GloId"] . ":" . $a_rec["FieldId"], $a_rec["OrderNr"]);
326  break;
327  }
328  }
Class ilGlossaryTerm.
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
Class ilGlossaryDefinition.
$def
Definition: croninfo.php:21
+ 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 128 of file class.ilGlossaryDataSet.php.

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

129  {
130  $ilDB = $this->db;
131 
132  if (!is_array($a_ids)) {
133  $a_ids = array($a_ids);
134  }
135 
136  if ($a_entity == "glo") {
137  switch ($a_version) {
138  case "5.1.0":
139  $this->getDirectDataFromQuery("SELECT o.title, o.description, g.id, g.virtual, pres_mode, snippet_length, show_tax, glo_menu_active" .
140  " FROM glossary g JOIN object_data o " .
141  " ON (g.id = o.obj_id) " .
142  " WHERE " . $ilDB->in("g.id", $a_ids, false, "integer"));
143  break;
144  }
145  }
146 
147  if ($a_entity == "glo_term") {
148  switch ($a_version) {
149  case "5.1.0":
150  // todo: how does import id needs to be set?
151  $this->getDirectDataFromQuery("SELECT id, glo_id, term, language" .
152  " FROM glossary_term " .
153  " WHERE " . $ilDB->in("glo_id", $a_ids, false, "integer"));
154  break;
155  }
156  }
157 
158  if ($a_entity == "glo_definition") {
159  switch ($a_version) {
160  case "5.1.0":
161  $this->getDirectDataFromQuery("SELECT id, term_id, short_text, nr, short_text_dirty" .
162  " FROM glossary_definition " .
163  " WHERE " . $ilDB->in("term_id", $a_ids, false, "integer"));
164  break;
165  }
166  }
167 
168  if ($a_entity == "glo_advmd_col_order") {
169  switch ($a_version) {
170  case "5.1.0":
171  $this->getDirectDataFromQuery("SELECT glo_id, field_id, order_nr" .
172  " FROM glo_advmd_col_order " .
173  " WHERE " . $ilDB->in("glo_id", $a_ids, false, "integer"));
174  break;
175  }
176  }
177  }
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 ...
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:

Field Documentation

◆ $log

ilGlossaryDataSet::$log
protected

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


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