ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilDataSet Class Reference

A dataset contains in data in a common structure that can be shared and transformed for different purposes easily, examples. More...

+ Inheritance diagram for ilDataSet:
+ Collaboration diagram for ilDataSet:

Public Member Functions

 __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)
 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...
 

Data Fields

 $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
 

Protected Member Functions

 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

 $current_installation_id = ""
 

Private Member Functions

 addTypesXml ($a_writer, $a_entity, $a_schema_version)
 Add types to xml writer. More...
 

Detailed Description

A dataset contains in data in a common structure that can be shared and transformed for different purposes easily, examples.

  • transform associative arrays into (set-)xml and back (e.g. for import/export)
  • transform assiciative arrays into json and back (e.g. for ajax requests)

The general structure is:

  • entity name (many times this corresponds to a table name)
  • structure (this is a set of field names and types pairs) currently supported types: text, integer, timestamp planned: date, time, clob types correspond to db types, see http://www.ilias.de/docu/goto.php?target=pg_25354_42&client_id=docu
  • records (similar to records of a database query; associative arrays)
Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

ilDataSet::__construct ( )

Constructor.

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

References ilLoggerFactory\getLogger().

42  {
43  $this->ds_log = ilLoggerFactory::getLogger('ds');
44  }
static getLogger($a_component_id)
Get component logger.
+ Here is the call graph for this function:

Member Function Documentation

◆ addRecordsXml()

ilDataSet::addRecordsXml (   $a_writer,
  $a_prefixes,
  $a_entity,
  $a_schema_version,
  $a_ids,
  $a_field = "" 
)

Add records xml.

Parameters

Definition at line 314 of file class.ilDataSet.php.

References $d, $dircnt, afterXmlRecordWriting(), getDSPrefixString(), getXmlRecord(), getXmlTypes(), ilUtil\makeDirParents(), ilUtil\rCopy(), and readData().

Referenced by getXmlRepresentation().

315  {
316  $types = $this->getXmlTypes($a_entity, $a_schema_version);
317 
318  $this->ds_log->debug("...read data");
319  $this->readData($a_entity, $a_schema_version, $a_ids, $a_field);
320  $this->ds_log->debug("...data: ".print_r($this->data, true));
321  if (is_array($this->data))
322  {
323  foreach ($this->data as $d)
324  {
325  $a_writer->xmlStartTag($this->getDSPrefixString()."Rec",
326  array("Entity" => $this->getXmlEntityName($a_entity, $a_schema_version)));
327 
328  // entity tag
329  $a_writer->xmlStartTag($this->getXmlEntityTag($a_entity, $a_schema_version));
330 
331  $rec = $this->getXmlRecord($a_entity, $a_schema_version, $d);
332  foreach ($rec as $f => $c)
333  {
334  switch ($types[$f])
335  {
336  case "directory":
337  if ($this->absolute_export_dir != "" && $this->relative_export_dir != "")
338  {
339  ilUtil::makeDirParents($this->absolute_export_dir."/dsDir_".$this->dircnt);
340  ilUtil::rCopy($c, $this->absolute_export_dir."/dsDir_".$this->dircnt);
341 //echo "<br>copy-".$c."-".$this->absolute_export_dir."/dsDir_".$this->dircnt."-";
342  $c = $this->relative_export_dir."/dsDir_".$this->dircnt;
343  $this->dircnt++;
344  }
345  break;
346  }
347  // this changes schema/dtd
348  //$a_writer->xmlElement($a_prefixes[$a_entity].":".$f,
349  // array(), $c);
350  $a_writer->xmlElement($f, array(), $c);
351  }
352 
353  $a_writer->xmlEndTag($this->getXmlEntityTag($a_entity, $a_schema_version));
354 
355  $a_writer->xmlEndTag($this->getDSPrefixString()."Rec");
356 
357  $this->afterXmlRecordWriting($a_entity, $a_schema_version, $d);
358 
359  // foreach record records of dependent entities
360  $this->ds_log->debug("...get dependencies");
361  $deps = $this->getDependencies($a_entity, $a_schema_version, $rec, $a_ids);
362  $this->ds_log->debug("...dependencies: ".print_r($deps, true));
363  if (is_array($deps))
364  {
365  foreach ($deps as $dp => $par)
366  {
367  $this->addRecordsXml($a_writer, $a_prefixes, $dp, $a_schema_version, $par["ids"], $par["field"]);
368  }
369  }
370  }
371  }
372  else if ($this->data === false)
373  {
374  // false -> add records of dependent entities (no record)
375  $this->ds_log->debug("...get dependencies (no record)");
376  $deps = $this->getDependencies($a_entity, $a_schema_version, null, $a_ids);
377  if (is_array($deps))
378  {
379  foreach ($deps as $dp => $par)
380  {
381  $this->addRecordsXml($a_writer, $a_prefixes, $dp, $a_schema_version, $par["ids"], $par["field"]);
382  }
383  }
384  }
385  }
static makeDirParents($a_dir)
Create a new directory and all parent directories.
static rCopy($a_sdir, $a_tdir, $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
afterXmlRecordWriting($a_entity, $a_version, $a_set)
After xml record writing hook record.
readData($a_entity, $a_version, $a_ids)
Read data from DB.
getXmlRecord($a_entity, $a_version, $a_set)
Get xml record for version.
getXmlTypes($a_entity, $a_version)
Get xml types.
addRecordsXml($a_writer, $a_prefixes, $a_entity, $a_schema_version, $a_ids, $a_field="")
Add records xml.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addTypesXml()

ilDataSet::addTypesXml (   $a_writer,
  $a_entity,
  $a_schema_version 
)
private

Add types to xml writer.

Parameters

Definition at line 402 of file class.ilDataSet.php.

References $t, $w, getDSPrefixString(), and getXmlTypes().

Referenced by getXmlRepresentation().

403  {
404  $types = $this->getXmlTypes($a_entity, $a_schema_version);
405 
406  // add types of current entity
407  if (is_array($types))
408  {
409  $a_writer->xmlStartTag($this->getDSPrefixString()."Types",
410  array("Entity" => $this->getXmlEntityName($a_entity, $a_schema_version),
411  "SchemaVersion" => $a_schema_version));
412  foreach ($this->getXmlTypes($a_entity, $a_schema_version) as $f => $t)
413  {
414  $a_writer->xmlElement($this->getDSPrefixString().'FieldType',
415  array("Name" => $f, "Type" => $t));
416  }
417  $a_writer->xmlEndTag($this->getDSPrefixString()."Types");
418  }
419 
420  // add types of dependent entities
421  $deps = $this->getDependencies($a_entity, $a_schema_version, null, null);
422  if (is_array($deps))
423  {
424  foreach ($deps as $dp => $w)
425  {
426  $this->addTypesXml($a_writer, $dp, $a_schema_version);
427  }
428  }
429 
430  }
addTypesXml($a_writer, $a_entity, $a_schema_version)
Add types to xml writer.
$w
getXmlTypes($a_entity, $a_version)
Get xml types.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ afterXmlRecordWriting()

ilDataSet::afterXmlRecordWriting (   $a_entity,
  $a_version,
  $a_set 
)

After xml record writing hook record.

Parameters

Definition at line 393 of file class.ilDataSet.php.

Referenced by addRecordsXml().

394  {
395  }
+ Here is the caller graph for this function:

◆ convertToLeadingUpper()

ilDataSet::convertToLeadingUpper (   $a_str)

Make xyz_abc a XyzAbc string.

Parameters

Definition at line 192 of file class.ilDataSet.php.

Referenced by getDirectDataFromQuery(), getXMLEntityTag(), ilUserDataSet\importRecord(), ilMediaPoolDataSet\readData(), and ilLearningModuleDataSet\readData().

193  {
194  $a_str = strtoupper(substr($a_str, 0, 1)).substr($a_str, 1);
195  while (is_int($pos = strpos($a_str, "_")))
196  {
197  $a_str = substr($a_str, 0, $pos).
198  strtoupper(substr($a_str, $pos+1, 1)).
199  substr($a_str, $pos+2);
200  }
201  return $a_str;
202  }
+ Here is the caller graph for this function:

◆ createObjectExportId()

ilDataSet::createObjectExportId (   $a_type,
  $a_id 
)
protected

Build ilias export id.

Parameters
string$a_type
int$a_id
Returns
string

Definition at line 577 of file class.ilDataSet.php.

Referenced by ilBlogDataSet\readData().

578  {
579  return "il_".IL_INST_ID."_".$a_type."_".$a_id;
580  }
+ Here is the caller graph for this function:

◆ getCurrentInstallationId()

ilDataSet::getCurrentInstallationId ( )

Get current installation id.

Returns
string current installation id

Definition at line 565 of file class.ilDataSet.php.

References $current_installation_id.

Referenced by ilGlossaryDataSet\importRecord(), ilMediaObjectDataSet\importRecord(), and ilLearningModuleDataSet\importRecord().

566  {
568  }
+ Here is the caller graph for this function:

◆ getDirectDataFromQuery()

ilDataSet::getDirectDataFromQuery (   $a_query,
  $a_convert_to_leading_upper = true 
)

Get data from query.This is a standard procedure, all db field names are directly mapped to abstract fields.

Parameters

Definition at line 163 of file class.ilDataSet.php.

References $ilDB, and convertToLeadingUpper().

Referenced by ilExternalFeedDataSet\readData(), ilHTMLLearningModuleDataSet\readData(), ilRatingDataSet\readData(), ilNewsDataSet\readData(), ilNotesDataSet\readData(), ilItemGroupDataSet\readData(), ilBookmarkDataSet\readData(), ilHelpDataSet\readData(), ilMediaCastDataSet\readData(), ilPortfolioDataSet\readData(), ilObjectDataSet\readData(), ilCOPageDataSet\readData(), ilPollDataSet\readData(), ilBlogDataSet\readData(), ilTaxonomyDataSet\readData(), ilCalendarDataSet\readData(), ilSessionDataSet\readData(), ilGlossaryDataSet\readData(), ilMediaPoolDataSet\readData(), ilUserDataSet\readData(), ilWikiDataSet\readData(), ilMediaObjectDataSet\readData(), ilExerciseDataSet\readData(), ilLearningModuleDataSet\readData(), and ilStyleDataSet\readData().

164  {
165  global $ilDB;
166 
167  $set = $ilDB->query($a_query);
168  $this->data = array();
169  while ($rec = $ilDB->fetchAssoc($set))
170  {
171  if ($a_convert_to_leading_upper)
172  {
173  $tmp = array();
174  foreach ($rec as $k => $v)
175  {
176  $tmp[$this->convertToLeadingUpper($k)]
177  = $v;
178  }
179  $rec = $tmp;
180  }
181 
182  $this->data[] = $rec;
183  }
184  }
convertToLeadingUpper($a_str)
Make xyz_abc a XyzAbc string.
global $ilDB
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDSPrefix()

ilDataSet::getDSPrefix ( )

Get XML dataset namespace prefix.

Returns
string XML dataset namespace prefix

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

Referenced by getDSPrefixString().

144  {
145  return $this->var;
146  }
+ Here is the caller graph for this function:

◆ getDSPrefixString()

ilDataSet::getDSPrefixString ( )

Definition at line 148 of file class.ilDataSet.php.

References getDSPrefix().

Referenced by addRecordsXml(), addTypesXml(), and getXmlRepresentation().

149  {
150  if ($this->getDSPrefix() != "")
151  {
152  return $this->getDSPrefix().":";
153  }
154  }
getDSPrefix()
Get XML dataset namespace prefix.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getImport()

ilDataSet::getImport ( )

Get import object.

Returns
object import object

Definition at line 545 of file class.ilDataSet.php.

546  {
547  return $this->import;
548  }

◆ getImportDirectory()

ilDataSet::getImportDirectory ( )

Get import directory.

Returns
string import directory

Definition at line 123 of file class.ilDataSet.php.

Referenced by ilBibliographicDataSet\importLibraryFile(), ilHTMLLearningModuleDataSet\importRecord(), ilPortfolioDataSet\importRecord(), ilPollDataSet\importRecord(), ilBlogDataSet\importRecord(), ilUserDataSet\importRecord(), ilMediaObjectDataSet\importRecord(), ilExerciseDataSet\importRecord(), and ilStyleDataSet\importRecord().

124  {
125  return $this->import_directory;
126  }
+ Here is the caller graph for this function:

◆ getJsonEntityName()

ilDataSet::getJsonEntityName (   $a_entity,
  $a_version 
)

Get entity name for json (may be overwritten)

Definition at line 525 of file class.ilDataSet.php.

Referenced by getJsonRepresentation().

526  {
527  return $a_entity;
528  }
+ Here is the caller graph for this function:

◆ getJsonRecord()

ilDataSet::getJsonRecord (   $a_set)

Get json record for version.

Parameters
arrayabstract data record
Returns
array json record

Definition at line 474 of file class.ilDataSet.php.

Referenced by getJsonRepresentation().

475  {
476  return $a_set;
477  }
+ Here is the caller graph for this function:

◆ getJsonRepresentation()

ilDataSet::getJsonRepresentation ( )
final

Get json representation.

Definition at line 208 of file class.ilDataSet.php.

References $d, ilJsonUtil\encode(), getJsonEntityName(), getJsonRecord(), and getJsonTypes().

209  {
210  if ($this->version === false)
211  {
212  return false;
213  }
214 
215  $arr["entity"] = $this->getJsonEntityName();
216  $arr["version"] = $this->version;
217  $arr["install_id"] = IL_INST_ID;
218  $arr["install_url"] = ILIAS_HTTP_PATH;
219  $arr["types"] = $this->getJsonTypes();
220  $arr["set"] = array();
221  foreach ($this->data as $d)
222  {
223  $arr["set"][] = $this->getJsonRecord($d);
224  }
225 
226  include_once("./Services/JSON/classes/class.ilJsonUtil.php");
227 
228  return ilJsonUtil::encode($arr);
229  }
getJsonEntityName($a_entity, $a_version)
Get entity name for json (may be overwritten)
getJsonTypes($a_entity, $a_version)
Get json types.
static encode($mixed, $suppress_native=false)
getJsonRecord($a_set)
Get json record for version.
+ Here is the call graph for this function:

◆ getJsonTypes()

ilDataSet::getJsonTypes (   $a_entity,
  $a_version 
)

Get json types.

Returns
array types array for json/version set in constructor

Definition at line 494 of file class.ilDataSet.php.

References getTypes().

Referenced by getJsonRepresentation().

495  {
496  return $this->getTypes($a_entity, $a_version);
497  }
getTypes($a_entity, $a_version)
Get (abstract) types for (abstract) field names.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getNamespaces()

ilDataSet::getNamespaces ( $namespaces,
  $a_entity,
  $a_schema_version 
)

Get xml namespaces.

Parameters
arraynamespaces per entity
stringentity
stringtarget release

Definition at line 439 of file class.ilDataSet.php.

References $w, and getXmlNamespace().

Referenced by getXmlRepresentation().

440  {
441  $ns = $this->getXmlNamespace($a_entity, $a_schema_version);
442  if ($ns != "")
443  {
444  $namespaces[$a_entity] = $ns;
445  }
446  // add types of dependent entities
447  $deps = $this->getDependencies($a_entity, $a_schema_version, null, null);
448  if (is_array($deps))
449  {
450  foreach ($deps as $dp => $w)
451  {
452  $this->getNamespaces($namespaces, $dp, $a_schema_version);
453  }
454  }
455  }
$w
getXmlNamespace($a_entity, $a_schema_version)
Get xml namespace.
getNamespaces(&$namespaces, $a_entity, $a_schema_version)
Get xml namespaces.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSupportedVersions()

ilDataSet::getSupportedVersions ( )
abstract

Get supported version.

Returns
array array of supported version

Referenced by init().

+ Here is the caller graph for this function:

◆ getTypes()

ilDataSet::getTypes (   $a_entity,
  $a_version 
)
abstractprotected

Get (abstract) types for (abstract) field names.

Please note that the abstract fields/types only depend on the version! Not on a choosen representation!

Returns
array types array, e.g. array("field_1" => "text", "field_2" => "integer", ...)

Referenced by getJsonTypes(), getXmlTypes(), and init().

+ Here is the caller graph for this function:

◆ getXMLEntityName()

ilDataSet::getXMLEntityName (   $a_entity,
  $a_version 
)

Get entity name for xml (may be overwritten)

Returns
string

Definition at line 505 of file class.ilDataSet.php.

506  {
507  return $a_entity;
508  }

◆ getXMLEntityTag()

ilDataSet::getXMLEntityTag (   $a_entity,
  $a_schema_version 
)

Get entity tag.

Parameters

Definition at line 516 of file class.ilDataSet.php.

References convertToLeadingUpper().

517  {
518  return $this->convertToLeadingUpper($a_entity);
519  }
convertToLeadingUpper($a_str)
Make xyz_abc a XyzAbc string.
+ Here is the call graph for this function:

◆ getXmlNamespace()

ilDataSet::getXmlNamespace (   $a_entity,
  $a_schema_version 
)
abstractprotected

Get xml namespace.

Referenced by getNamespaces(), and init().

+ Here is the caller graph for this function:

◆ getXmlRecord()

ilDataSet::getXmlRecord (   $a_entity,
  $a_version,
  $a_set 
)

Get xml record for version.

Parameters
arrayabstract data record
Returns
array xml record

Definition at line 463 of file class.ilDataSet.php.

Referenced by addRecordsXml().

464  {
465  return $a_set;
466  }
+ Here is the caller graph for this function:

◆ getXmlRepresentation()

ilDataSet::getXmlRepresentation (   $a_entity,
  $a_schema_version,
  $a_ids,
  $a_field = "",
  $a_omit_header = false,
  $a_omit_types = false 
)
final

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>

Definition at line 252 of file class.ilDataSet.php.

References addRecordsXml(), addTypesXml(), getDSPrefixString(), and getNamespaces().

254  {
255  $this->dircnt = 1;
256 
257  // step 1: check target release and supported versions
258 
259 
260 
261  // step 2: init writer
262  include_once "./Services/Xml/classes/class.ilXmlWriter.php";
263  $writer = new ilXmlWriter();
264  if (!$a_omit_header)
265  {
266  $writer->xmlHeader();
267  }
268 
269  // collect namespaces
270  $namespaces = $prefixes = array();
271  $this->getNamespaces($namespaces, $a_entity, $a_schema_version);
272  $atts = array("InstallationId" => IL_INST_ID,
273  "InstallationUrl" => ILIAS_HTTP_PATH, "TopEntity" => $a_entity);
274  $cnt = 1;
275  foreach ($namespaces as $entity => $ns)
276  {
277  $prefix = "ns".$cnt;
278  $prefixes[$entity] = $prefix;
279 // $atts["xmlns:".$prefix] = $ns;
280  $cnt++;
281  }
282 
283  $this->ds_log->debug("Start writing Dataset, entity: ".$a_entity.", schema version: ".$a_schema_version.
284  ", ids: ".print_r($a_ids, true));
285  $writer->xmlStartTag($this->getDSPrefixString().'DataSet', $atts);
286 
287  // add types
288  if (!$a_omit_types)
289  {
290  $this->ds_log->debug("...write types");
291  $this->addTypesXml($writer, $a_entity, $a_schema_version);
292  }
293 
294  // add records
295  $this->ds_log->debug("...write records");
296  $this->addRecordsXml($writer, $prefixes, $a_entity, $a_schema_version, $a_ids, $a_field);
297 
298 
299  $writer->xmlEndTag($this->getDSPrefixString()."DataSet");
300 //if ($a_entity == "mep")
301 //{
302 // echo "<pre>".htmlentities($writer->xmlDumpMem(true))."</pre>"; exit;
303 //}
304  return $writer->xmlDumpMem(false);
305  }
XML writer class.
addTypesXml($a_writer, $a_entity, $a_schema_version)
Add types to xml writer.
getNamespaces(&$namespaces, $a_entity, $a_schema_version)
Get xml namespaces.
addRecordsXml($a_writer, $a_prefixes, $a_entity, $a_schema_version, $a_ids, $a_field="")
Add records xml.
+ Here is the call graph for this function:

◆ getXmlTypes()

ilDataSet::getXmlTypes (   $a_entity,
  $a_version 
)

Get xml types.

Returns
array types array for xml/version set in constructor

Definition at line 484 of file class.ilDataSet.php.

References getTypes().

Referenced by addRecordsXml(), and addTypesXml().

485  {
486  return $this->getTypes($a_entity, $a_version);
487  }
getTypes($a_entity, $a_version)
Get (abstract) types for (abstract) field names.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ init()

ilDataSet::init (   $a_entity,
  $a_schema_version 
)
final

Init.

Parameters
string(abstract) entity name
stringversion string, always the ILIAS release versions that defined the a structure or made changes to it, never use another version. Example: structure is defined in 4.1.0 and changed in 4.3.0 -> use these values only, not 4.2.0 (ask for the 4.1.0 version in ILIAS 4.2.0)

Definition at line 58 of file class.ilDataSet.php.

References getSupportedVersions(), getTypes(), getXmlNamespace(), and readData().

59  {
60  $this->entity = $a_entity;
61  $this->schema_version = $a_schema_version;
62  $this->data = array();
63  }
+ Here is the call graph for this function:

◆ parseObjectExportId()

ilDataSet::parseObjectExportId (   $a_id,
  $a_fallback_id = NULL 
)
protected

Parse export id.

Parameters
string$a_id
int$a_fallback_id
Returns
array type, id

Definition at line 589 of file class.ilDataSet.php.

References ilObject\_getIdForImportId(), and ilObject\_lookupType().

Referenced by ilBlogDataSet\importRecord().

590  {
591  // ilias export id?
592  if(substr($a_id, 0, 3) == "il_")
593  {
594  $parts = explode("_", $a_id);
595  $inst_id = $parts[1];
596  $type = $parts[2];
597  $id = $parts[3];
598 
599  // missing installation ids?
600  if(($inst_id == 0 || IL_INST_ID == 0) && !DEVMODE)
601  {
602  return array("type"=>self::EXPORT_NO_INST_ID, "id"=>$a_fallback_id);
603  }
604 
605  // same installation?
606  if($inst_id == IL_INST_ID)
607  {
608  // still existing?
609  if(ilObject::_lookupType($id) == $type)
610  {
611  return array("type"=>self::EXPORT_ID_ILIAS_LOCAL, "id"=>$id);
612  }
613  // not found
614  else
615  {
616  return array("type"=>self::EXPORT_ID_ILIAS_LOCAL_INVALID, "id"=>$a_fallback_id);
617  }
618  }
619  // different installation
620  else
621  {
622  $id = ilObject::_getIdForImportId($a_id);
623  // matching type?
624  if($id && ilObject::_lookupType($id) == $type)
625  {
626  return array("type"=>self::EXPORT_ID_ILIAS_REMOTE, "id"=>$id);
627  }
628  // not found
629  else
630  {
631  return array("type"=>self::EXPORT_ID_ILIAS_REMOTE_INVALID, "id"=>$a_fallback_id);
632  }
633  }
634  }
635 
636  // external id
637  $id = ilObject::_getIdForImportId($a_id);
638  if($id)
639  {
640  return array("type"=>self::EXPORT_ID, "id"=>$id);
641  }
642  else
643  {
644  return array("type"=>self::EXPORT_ID_INVALID, "id"=>$a_fallback_id);
645  }
646  }
_getIdForImportId($a_import_id)
get current object id for import id (static)
static _lookupType($a_id, $a_reference=false)
lookup object type
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readData()

ilDataSet::readData (   $a_entity,
  $a_version,
  $a_ids 
)
abstract

Read data from DB.

This should result in the abstract field structure of the version set in the constructor.

Parameters
arrayone or multiple ids

Referenced by addRecordsXml(), and init().

+ Here is the caller graph for this function:

◆ setCurrentInstallationId()

ilDataSet::setCurrentInstallationId (   $a_val)

Set current installation id.

Parameters
string$a_valcurrent installation id

Definition at line 555 of file class.ilDataSet.php.

556  {
557  $this->current_installation_id = $a_val;
558  }

◆ setDSPrefix()

ilDataSet::setDSPrefix (   $a_val)

Set XML dataset namespace prefix.

Parameters
stringXML dataset namespace prefix

Definition at line 133 of file class.ilDataSet.php.

134  {
135  $this->var = $a_val;
136  }

◆ setExportDirectories()

ilDataSet::setExportDirectories (   $a_relative,
  $a_absolute 
)

Set export directories.

Parameters

Definition at line 102 of file class.ilDataSet.php.

103  {
104  $this->relative_export_dir = $a_relative;
105  $this->absolute_export_dir = $a_absolute;
106  }

◆ setImport()

ilDataSet::setImport (   $a_val)

Set import object.

Parameters
objectimport object

Definition at line 535 of file class.ilDataSet.php.

536  {
537  $this->import = $a_val;
538  }

◆ setImportDirectory()

ilDataSet::setImportDirectory (   $a_val)

Set import directory.

Parameters
stringimport directory

Definition at line 113 of file class.ilDataSet.php.

114  {
115  $this->import_directory = $a_val;
116  }

Field Documentation

◆ $current_installation_id

ilDataSet::$current_installation_id = ""
protected

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

Referenced by getCurrentInstallationId().

◆ $dircnt

ilDataSet::$dircnt

Definition at line 26 of file class.ilDataSet.php.

Referenced by addRecordsXml().

◆ EXPORT_ID

const ilDataSet::EXPORT_ID = 6

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

◆ EXPORT_ID_ILIAS_LOCAL

const ilDataSet::EXPORT_ID_ILIAS_LOCAL = 2

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

◆ EXPORT_ID_ILIAS_LOCAL_INVALID

const ilDataSet::EXPORT_ID_ILIAS_LOCAL_INVALID = 3

Definition at line 31 of file class.ilDataSet.php.

◆ EXPORT_ID_ILIAS_REMOTE

const ilDataSet::EXPORT_ID_ILIAS_REMOTE = 4

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

◆ EXPORT_ID_ILIAS_REMOTE_INVALID

const ilDataSet::EXPORT_ID_ILIAS_REMOTE_INVALID = 5

Definition at line 33 of file class.ilDataSet.php.

◆ EXPORT_ID_INVALID

const ilDataSet::EXPORT_ID_INVALID = 7

Definition at line 35 of file class.ilDataSet.php.

◆ EXPORT_NO_INST_ID

const ilDataSet::EXPORT_NO_INST_ID = 1

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


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