ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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, $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...
 

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 = ""
 
 $db
 
 $ds_log
 

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 50 of file class.ilDataSet.php.

References $DIC, and ilLoggerFactory\getLogger().

51  {
52  global $DIC;
53 
54  $this->db = $DIC->database();
55  $this->ds_log = ilLoggerFactory::getLogger('ds');
56  }
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

◆ addRecordsXml()

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

Add records xml.

Parameters

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

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

Referenced by getXmlRepresentation().

328  {
329  $types = $this->getXmlTypes($a_entity, $a_schema_version);
330 
331  $this->ds_log->debug("...read data");
332  $this->readData($a_entity, $a_schema_version, $a_ids, $a_field);
333  $this->ds_log->debug("...data: " . print_r($this->data, true));
334  if (is_array($this->data)) {
335  foreach ($this->data as $d) {
336  $a_writer->xmlStartTag(
337  $this->getDSPrefixString() . "Rec",
338  array("Entity" => $this->getXmlEntityName($a_entity, $a_schema_version))
339  );
340 
341  // entity tag
342  $a_writer->xmlStartTag($this->getXmlEntityTag($a_entity, $a_schema_version));
343 
344  $rec = $this->getXmlRecord($a_entity, $a_schema_version, $d);
345  foreach ($rec as $f => $c) {
346  switch ($types[$f]) {
347  case "directory":
348  if ($this->absolute_export_dir != "" && $this->relative_export_dir != "") {
349  ilUtil::makeDirParents($this->absolute_export_dir . "/dsDir_" . $this->dircnt);
350  ilUtil::rCopy($c, $this->absolute_export_dir . "/dsDir_" . $this->dircnt);
351  //echo "<br>copy-".$c."-".$this->absolute_export_dir."/dsDir_".$this->dircnt."-";
352  $c = $this->relative_export_dir . "/dsDir_" . $this->dircnt;
353  $this->dircnt++;
354  }
355  break;
356  }
357  // this changes schema/dtd
358  //$a_writer->xmlElement($a_prefixes[$a_entity].":".$f,
359  // array(), $c);
360  $a_writer->xmlElement($f, array(), $c);
361  }
362 
363  $a_writer->xmlEndTag($this->getXmlEntityTag($a_entity, $a_schema_version));
364 
365  $a_writer->xmlEndTag($this->getDSPrefixString() . "Rec");
366 
367  $this->afterXmlRecordWriting($a_entity, $a_schema_version, $d);
368 
369  // foreach record records of dependent entities
370  $this->ds_log->debug("...get dependencies");
371  $deps = $this->getDependencies($a_entity, $a_schema_version, $rec, $a_ids);
372  $this->ds_log->debug("...dependencies: " . print_r($deps, true));
373  if (is_array($deps)) {
374  foreach ($deps as $dp => $par) {
375  $this->addRecordsXml($a_writer, $a_prefixes, $dp, $a_schema_version, $par["ids"], $par["field"]);
376  }
377  }
378  }
379  } elseif ($this->data === false) {
380  // false -> add records of dependent entities (no record)
381  $this->ds_log->debug("...get dependencies (no record)");
382  $deps = $this->getDependencies($a_entity, $a_schema_version, null, $a_ids);
383  if (is_array($deps)) {
384  foreach ($deps as $dp => $par) {
385  $this->addRecordsXml($a_writer, $a_prefixes, $dp, $a_schema_version, $par["ids"], $par["field"]);
386  }
387  }
388  }
389  }
static makeDirParents($a_dir)
Create a new directory and all parent directories.
Add some data
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.
Create styles array
The data for the language used.
getXmlTypes($a_entity, $a_version)
Get xml types.
for($i=6; $i< 13; $i++) for($i=1; $i< 13; $i++) $d
Definition: date.php:296
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 406 of file class.ilDataSet.php.

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

Referenced by getXmlRepresentation().

407  {
408  $types = $this->getXmlTypes($a_entity, $a_schema_version);
409 
410  // add types of current entity
411  if (is_array($types)) {
412  $a_writer->xmlStartTag(
413  $this->getDSPrefixString() . "Types",
414  array("Entity" => $this->getXmlEntityName($a_entity, $a_schema_version),
415  "SchemaVersion" => $a_schema_version)
416  );
417  foreach ($this->getXmlTypes($a_entity, $a_schema_version) as $f => $t) {
418  $a_writer->xmlElement(
419  $this->getDSPrefixString() . 'FieldType',
420  array("Name" => $f, "Type" => $t)
421  );
422  }
423  $a_writer->xmlEndTag($this->getDSPrefixString() . "Types");
424  }
425 
426  // add types of dependent entities
427  $deps = $this->getDependencies($a_entity, $a_schema_version, null, null);
428  if (is_array($deps)) {
429  foreach ($deps as $dp => $w) {
430  $this->addTypesXml($a_writer, $dp, $a_schema_version);
431  }
432  }
433  }
addTypesXml($a_writer, $a_entity, $a_schema_version)
Add types to xml writer.
$w
Create styles array
The data for the language used.
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 397 of file class.ilDataSet.php.

Referenced by addRecordsXml().

398  {
399  }
+ Here is the caller graph for this function:

◆ convertToLeadingUpper()

ilDataSet::convertToLeadingUpper (   $a_str)

Make xyz_abc a XyzAbc string.

Parameters

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

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

207  {
208  $a_str = strtoupper(substr($a_str, 0, 1)) . substr($a_str, 1);
209  while (is_int($pos = strpos($a_str, "_"))) {
210  $a_str = substr($a_str, 0, $pos) .
211  strtoupper(substr($a_str, $pos+1, 1)) .
212  substr($a_str, $pos+2);
213  }
214  return $a_str;
215  }
+ 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.

References $a_type.

Referenced by ilBlogDataSet\readData().

578  {
579  return "il_" . IL_INST_ID . "_" . $a_type . "_" . $a_id;
580  }
$a_type
Definition: workflow.php:92
+ 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 ilSurveyDataSet\importRecord(), ilGlossaryDataSet\importRecord(), ilMediaObjectDataSet\importRecord(), ilLearningModuleDataSet\importRecord(), and ilSkillDataSet\importRecord().

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

◆ getDirectDataFromQuery()

ilDataSet::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.

Parameters
string$a_query
bool$a_convert_to_leading_upper
bool$a_setshould internal data array already be set?
Returns
array

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

References $db, $ilDB, $ret, array, convertToLeadingUpper(), and data.

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

176  {
177  $ilDB = $this->db;
178 
179  $set = $ilDB->query($a_query);
180  $this->data = array();
181  $ret = [];
182  while ($rec = $ilDB->fetchAssoc($set)) {
183  if ($a_convert_to_leading_upper) {
184  $tmp = array();
185  foreach ($rec as $k => $v) {
186  $tmp[$this->convertToLeadingUpper($k)]
187  = $v;
188  }
189  $rec = $tmp;
190  }
191 
192  if ($a_set) {
193  $this->data[] = $rec;
194  }
195  $ret[] = $rec;
196  }
197  return $ret;
198  }
Add some data
convertToLeadingUpper($a_str)
Make xyz_abc a XyzAbc string.
Create styles array
The data for the language used.
global $ilDB
$ret
Definition: parser.php:6
+ 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 155 of file class.ilDataSet.php.

Referenced by getDSPrefixString().

156  {
157  return $this->var;
158  }
+ Here is the caller graph for this function:

◆ getDSPrefixString()

ilDataSet::getDSPrefixString ( )

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

References getDSPrefix().

Referenced by addRecordsXml(), addTypesXml(), ilScormAiccDataSet\getExtendedXmlRepresentation(), and getXmlRepresentation().

161  {
162  if ($this->getDSPrefix() != "") {
163  return $this->getDSPrefix() . ":";
164  }
165  }
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.

Referenced by ilSurveyDataSet\importRecord().

546  {
547  return $this->import;
548  }
+ Here is the caller graph for this function:

◆ getImportDirectory()

ilDataSet::getImportDirectory ( )

◆ 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 221 of file class.ilDataSet.php.

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

222  {
223  if ($this->version === false) {
224  return false;
225  }
226 
227  $arr["entity"] = $this->getJsonEntityName();
228  $arr["version"] = $this->version;
229  $arr["install_id"] = IL_INST_ID;
230  $arr["install_url"] = ILIAS_HTTP_PATH;
231  $arr["types"] = $this->getJsonTypes();
232  $arr["set"] = array();
233  foreach ($this->data as $d) {
234  $arr["set"][] = $this->getJsonRecord($d);
235  }
236 
237  include_once("./Services/JSON/classes/class.ilJsonUtil.php");
238 
239  return ilJsonUtil::encode($arr);
240  }
getJsonEntityName($a_entity, $a_version)
Get entity name for json (may be overwritten)
Add some data
getJsonTypes($a_entity, $a_version)
Get json types.
static encode($mixed, $suppress_native=false)
getJsonRecord($a_set)
Get json record for version.
Create styles array
The data for the language used.
for($i=6; $i< 13; $i++) for($i=1; $i< 13; $i++) $d
Definition: date.php:296
+ 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 442 of file class.ilDataSet.php.

References $w, and getXmlNamespace().

Referenced by getXmlRepresentation().

443  {
444  $ns = $this->getXmlNamespace($a_entity, $a_schema_version);
445  if ($ns != "") {
446  $namespaces[$a_entity] = $ns;
447  }
448  // add types of dependent entities
449  $deps = $this->getDependencies($a_entity, $a_schema_version, null, null);
450  if (is_array($deps)) {
451  foreach ($deps as $dp => $w) {
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 263 of file class.ilDataSet.php.

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

270  {
271  $this->dircnt = 1;
272 
273  // step 1: check target release and supported versions
274 
275 
276 
277  // step 2: init writer
278  include_once "./Services/Xml/classes/class.ilXmlWriter.php";
279  $writer = new ilXmlWriter();
280  if (!$a_omit_header) {
281  $writer->xmlHeader();
282  }
283 
284  // collect namespaces
285  $namespaces = $prefixes = array();
286  $this->getNamespaces($namespaces, $a_entity, $a_schema_version);
287  $atts = array("InstallationId" => IL_INST_ID,
288  "InstallationUrl" => ILIAS_HTTP_PATH, "TopEntity" => $a_entity);
289  $cnt = 1;
290  foreach ($namespaces as $entity => $ns) {
291  $prefix = "ns" . $cnt;
292  $prefixes[$entity] = $prefix;
293  // $atts["xmlns:".$prefix] = $ns;
294  $cnt++;
295  }
296 
297  $this->ds_log->debug("Start writing Dataset, entity: " . $a_entity . ", schema version: " . $a_schema_version .
298  ", ids: " . print_r($a_ids, true));
299  $writer->xmlStartTag($this->getDSPrefixString() . 'DataSet', $atts);
300 
301  // add types
302  if (!$a_omit_types) {
303  $this->ds_log->debug("...write types");
304  $this->addTypesXml($writer, $a_entity, $a_schema_version);
305  }
306 
307  // add records
308  $this->ds_log->debug("...write records");
309  $this->addRecordsXml($writer, $prefixes, $a_entity, $a_schema_version, $a_ids, $a_field);
310 
311 
312  $writer->xmlEndTag($this->getDSPrefixString() . "DataSet");
313  //if ($a_entity == "mep")
314  //{
315  // echo "<pre>".htmlentities($writer->xmlDumpMem(true))."</pre>"; exit;
316  //}
317  return $writer->xmlDumpMem(false);
318  }
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.
Create styles array
The data for the language used.
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 70 of file class.ilDataSet.php.

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

71  {
72  $this->entity = $a_entity;
73  $this->schema_version = $a_schema_version;
74  $this->data = array();
75  }
Add some data
Create styles array
The data for the language used.
+ 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 $id, $type, ilObject\_getIdForImportId(), ilObject\_lookupType(), and array.

Referenced by ilBlogDataSet\importRecord().

590  {
591  // ilias export id?
592  if (substr($a_id, 0, 3) == "il_") {
593  $parts = explode("_", $a_id);
594  $inst_id = $parts[1];
595  $type = $parts[2];
596  $id = $parts[3];
597 
598  // missing installation ids?
599  if (($inst_id == 0 || IL_INST_ID == 0) && !DEVMODE) {
600  return array("type"=>self::EXPORT_NO_INST_ID, "id"=>$a_fallback_id);
601  }
602 
603  // same installation?
604  if ($inst_id == IL_INST_ID) {
605  // still existing?
606  if (ilObject::_lookupType($id) == $type) {
607  return array("type"=>self::EXPORT_ID_ILIAS_LOCAL, "id"=>$id);
608  }
609  // not found
610  else {
611  return array("type"=>self::EXPORT_ID_ILIAS_LOCAL_INVALID, "id"=>$a_fallback_id);
612  }
613  }
614  // different installation
615  else {
617  // matching type?
618  if ($id && ilObject::_lookupType($id) == $type) {
619  return array("type"=>self::EXPORT_ID_ILIAS_REMOTE, "id"=>$id);
620  }
621  // not found
622  else {
623  return array("type"=>self::EXPORT_ID_ILIAS_REMOTE_INVALID, "id"=>$a_fallback_id);
624  }
625  }
626  }
627 
628  // external id
630  if ($id) {
631  return array("type"=>self::EXPORT_ID, "id"=>$id);
632  } else {
633  return array("type"=>self::EXPORT_ID_INVALID, "id"=>$a_fallback_id);
634  }
635  }
$type
if(!array_key_exists('StateId', $_REQUEST)) $id
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
static _getIdForImportId($a_import_id)
get current object id for import id (static)
+ 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 145 of file class.ilDataSet.php.

146  {
147  $this->var = $a_val;
148  }

◆ setExportDirectories()

ilDataSet::setExportDirectories (   $a_relative,
  $a_absolute 
)

Set export directories.

Parameters

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

115  {
116  $this->relative_export_dir = $a_relative;
117  $this->absolute_export_dir = $a_absolute;
118  }

◆ 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 125 of file class.ilDataSet.php.

126  {
127  $this->import_directory = $a_val;
128  }

Field Documentation

◆ $current_installation_id

ilDataSet::$current_installation_id = ""
protected

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

Referenced by getCurrentInstallationId().

◆ $db

◆ $dircnt

ilDataSet::$dircnt

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

Referenced by addRecordsXml().

◆ $ds_log

ilDataSet::$ds_log
protected

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

◆ 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: