ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 = ""
 

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 ilLoggerFactory\getLogger().

30  {
31  $this->log = ilLoggerFactory::getLogger('glo');
32  parent::__construct();
33  }
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 197 of file class.ilGlossaryDataSet.php.

References array.

198  {
199  switch ($a_entity)
200  {
201  case "glo":
202  return array (
203  "glo_term" => array("ids" => $a_rec["Id"]),
204  "glo_advmd_col_order" => array("ids" => $a_rec["Id"])
205  );
206 
207  case "glo_term":
208  return array (
209  "glo_definition" => array("ids" => $a_rec["Id"])
210  );
211  }
212 
213  return false;
214  }
Create styles array
The data for the language used.

◆ getSupportedVersions()

ilGlossaryDataSet::getSupportedVersions ( )

Get supported versions.

Returns
string version

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

References array.

41  {
42  return array("5.1.0");
43  }
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 63 of file class.ilGlossaryDataSet.php.

References array.

64  {
65  if ($a_entity == "glo")
66  {
67  switch ($a_version)
68  {
69  case "5.1.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  {
85  switch ($a_version)
86  {
87  case "5.1.0":
88  return array(
89  "Id" => "integer",
90  "GloId" => "integer",
91  "Term" => "text",
92  "Language" => "text",
93  "ImportId" => "text"
94  );
95  }
96  }
97 
98  if ($a_entity == "glo_definition")
99  {
100  switch ($a_version)
101  {
102  case "5.1.0":
103  return array(
104  "Id" => "integer",
105  "TermId" => "integer",
106  "ShortText" => "text",
107  "Nr" => "integer",
108  "ShortTextDirty" => "integer"
109  );
110  }
111  }
112 
113  if ($a_entity == "glo_advmd_col_order")
114  {
115  switch ($a_version)
116  {
117  case "5.1.0":
118  return array(
119  "GloId" => "integer",
120  "FieldId" => "text",
121  "OrderNr" => "integer"
122  );
123  }
124  }
125 
126  }
Create styles array
The data for the language used.

◆ getXmlNamespace()

ilGlossaryDataSet::getXmlNamespace (   $a_entity,
  $a_schema_version 
)

Get xml namespace.

Parameters

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

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

◆ importRecord()

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

Import record.

Parameters

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

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

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

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

135  {
136  global $ilDB;
137 
138  if (!is_array($a_ids))
139  {
140  $a_ids = array($a_ids);
141  }
142 
143  if ($a_entity == "glo")
144  {
145  switch ($a_version)
146  {
147  case "5.1.0":
148  $this->getDirectDataFromQuery("SELECT o.title, o.description, g.id, g.virtual, pres_mode, snippet_length, show_tax, glo_menu_active".
149  " FROM glossary g JOIN object_data o ".
150  " ON (g.id = o.obj_id) ".
151  " WHERE ".$ilDB->in("g.id", $a_ids, false, "integer"));
152  break;
153  }
154  }
155 
156  if ($a_entity == "glo_term")
157  {
158  switch ($a_version)
159  {
160  case "5.1.0":
161  // todo: how does import id needs to be set?
162  $this->getDirectDataFromQuery("SELECT id, glo_id, term, language".
163  " FROM glossary_term ".
164  " WHERE ".$ilDB->in("glo_id", $a_ids, false, "integer"));
165  break;
166  }
167  }
168 
169  if ($a_entity == "glo_definition")
170  {
171  switch ($a_version)
172  {
173  case "5.1.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  {
183  switch ($a_version)
184  {
185  case "5.1.0":
186  $this->getDirectDataFromQuery("SELECT glo_id, field_id, order_nr".
187  " FROM glo_advmd_col_order ".
188  " WHERE ".$ilDB->in("glo_id", $a_ids, false, "integer"));
189  break;
190  }
191  }
192  }
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: