ILIAS  release_7 Revision v7.30-3-g800a261c036
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 ...> ... </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...
 

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...
 
 stripTags (array $rec, array $omit_keys=[])
 

Protected Attributes

 $current_installation_id = ""
 
 $db
 
 $ds_log
 
 $ds_namespace = 'ds'
 

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.

Reimplemented in ilBibliographicDataSet, ilDataCollectionDataSet, ilGlossaryDataSet, ilLearningModuleDataSet, ilSessionDataSet, ilWikiDataSet, ilMediaObjectDataSet, ilSkillDataSet, and ilStyleDataSet.

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

56 {
57 global $DIC;
58
59 $this->db = $DIC->database();
60 $this->ds_log = ilLoggerFactory::getLogger('ds');
61 }
static getLogger($a_component_id)
Get component logger.
global $DIC
Definition: goto.php:24

References $DIC, and ilLoggerFactory\getLogger().

+ 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

return

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

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

References $c, $d, $dircnt, Vendor\Package\$f, addRecordsXml(), afterXmlRecordWriting(), getDSPrefixString(), getXmlRecord(), getXmlTypes(), ilUtil\makeDirParents(), ilUtil\rCopy(), and readData().

Referenced by addRecordsXml(), and getXmlRepresentation().

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

412 {
413 $types = $this->getXmlTypes($a_entity, $a_schema_version);
414
415 // add types of current entity
416 if (is_array($types)) {
417 $a_writer->xmlStartTag(
418 $this->getDSPrefixString() . "Types",
419 array("Entity" => $this->getXmlEntityName($a_entity, $a_schema_version),
420 "SchemaVersion" => $a_schema_version)
421 );
422 foreach ($this->getXmlTypes($a_entity, $a_schema_version) as $f => $t) {
423 $a_writer->xmlElement(
424 $this->getDSPrefixString() . 'FieldType',
425 array("Name" => $f, "Type" => $t)
426 );
427 }
428 $a_writer->xmlEndTag($this->getDSPrefixString() . "Types");
429 }
430
431 // add types of dependent entities
432 $deps = $this->getDependencies($a_entity, $a_schema_version, null, null);
433 if (is_array($deps)) {
434 foreach ($deps as $dp => $w) {
435 $this->addTypesXml($a_writer, $dp, $a_schema_version);
436 }
437 }
438 }
addTypesXml($a_writer, $a_entity, $a_schema_version)
Add types to xml writer.

References Vendor\Package\$f, addTypesXml(), getDSPrefixString(), and getXmlTypes().

Referenced by addTypesXml(), and getXmlRepresentation().

+ 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

return

Reimplemented in ilScorm2004DataSet, and ilUserDataSet.

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

403 {
404 }

Referenced by addRecordsXml().

+ Here is the caller graph for this function:

◆ convertToLeadingUpper()

ilDataSet::convertToLeadingUpper (   $a_str)

Make xyz_abc a XyzAbc string.

Parameters

return

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

212 {
213 $a_str = strtoupper(substr($a_str, 0, 1)) . substr($a_str, 1);
214 while (is_int($pos = strpos($a_str, "_"))) {
215 $a_str = substr($a_str, 0, $pos) .
216 strtoupper(substr($a_str, $pos + 1, 1)) .
217 substr($a_str, $pos + 2);
218 }
219 return $a_str;
220 }

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

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

583 {
584 return "il_" . IL_INST_ID . "_" . $a_type . "_" . $a_id;
585 }
const IL_INST_ID
Definition: constants.php:38

References IL_INST_ID.

Referenced by ilBlogDataSet\readData().

+ Here is the caller graph for this function:

◆ getCurrentInstallationId()

ilDataSet::getCurrentInstallationId ( )

Get current installation id.

Returns
string current installation id

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

571 {
573 }

References $current_installation_id.

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

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

181 {
183
184 $set = $ilDB->query($a_query);
185 $this->data = array();
186 $ret = [];
187 while ($rec = $ilDB->fetchAssoc($set)) {
188 if ($a_convert_to_leading_upper) {
189 $tmp = array();
190 foreach ($rec as $k => $v) {
191 $tmp[$this->convertToLeadingUpper($k)]
192 = $v;
193 }
194 $rec = $tmp;
195 }
196
197 if ($a_set) {
198 $this->data[] = $rec;
199 }
200 $ret[] = $rec;
201 }
202 return $ret;
203 }
convertToLeadingUpper($a_str)
Make xyz_abc a XyzAbc string.
$ret
Definition: parser.php:6
global $ilDB

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

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

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

161 {
162 return $this->ds_namespace;
163 }

References $ds_namespace.

Referenced by getDSPrefixString().

+ Here is the caller graph for this function:

◆ getDSPrefixString()

ilDataSet::getDSPrefixString ( )

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

166 {
167 if ($this->getDSPrefix() != "") {
168 return $this->getDSPrefix() . ":";
169 }
170 }
getDSPrefix()
Get XML dataset namespace prefix.

References getDSPrefix().

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

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

551 {
552 return $this->import;
553 }

Referenced by ilSurveyDataSet\importRecord().

+ Here is the caller graph for this function:

◆ getImportDirectory()

◆ getJsonEntityName()

ilDataSet::getJsonEntityName (   $a_entity,
  $a_version 
)

Get entity name for json (may be overwritten)

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

531 {
532 return $a_entity;
533 }

Referenced by getJsonRepresentation().

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

480 {
481 return $a_set;
482 }

Referenced by getJsonRepresentation().

+ Here is the caller graph for this function:

◆ getJsonRepresentation()

ilDataSet::getJsonRepresentation ( )
final

Get json representation.

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

227 {
228 if ($this->version === false) {
229 return false;
230 }
231
232 $arr["entity"] = $this->getJsonEntityName();
233 $arr["version"] = $this->version;
234 $arr["install_id"] = IL_INST_ID;
235 $arr["install_url"] = ILIAS_HTTP_PATH;
236 $arr["types"] = $this->getJsonTypes();
237 $arr["set"] = array();
238 foreach ($this->data as $d) {
239 $arr["set"][] = $this->getJsonRecord($d);
240 }
241
242 include_once("./Services/JSON/classes/class.ilJsonUtil.php");
243
244 return ilJsonUtil::encode($arr);
245 }
getJsonEntityName($a_entity, $a_version)
Get entity name for json (may be overwritten)
getJsonRecord($a_set)
Get json record for version.
getJsonTypes($a_entity, $a_version)
Get json types.
static encode($mixed, $suppress_native=false)

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

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

500 {
501 return $this->getTypes($a_entity, $a_version);
502 }
getTypes($a_entity, $a_version)
Get (abstract) types for (abstract) field names.

References getTypes().

Referenced by getJsonRepresentation().

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

448 {
449 $ns = $this->getXmlNamespace($a_entity, $a_schema_version);
450 if ($ns != "") {
451 $namespaces[$a_entity] = $ns;
452 }
453 // add types of dependent entities
454 $deps = $this->getDependencies($a_entity, $a_schema_version, null, null);
455 if (is_array($deps)) {
456 foreach ($deps as $dp => $w) {
457 $this->getNamespaces($namespaces, $dp, $a_schema_version);
458 }
459 }
460 }
getNamespaces(&$namespaces, $a_entity, $a_schema_version)
Get xml namespaces.
getXmlNamespace($a_entity, $a_schema_version)
Get xml namespace.

References getNamespaces(), and getXmlNamespace().

Referenced by getNamespaces(), and getXmlRepresentation().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getSupportedVersions()

◆ getTypes()

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

◆ getXMLEntityName()

ilDataSet::getXMLEntityName (   $a_entity,
  $a_version 
)

Get entity name for xml (may be overwritten)

Returns
string

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

511 {
512 return $a_entity;
513 }

◆ getXMLEntityTag()

ilDataSet::getXMLEntityTag (   $a_entity,
  $a_schema_version 
)

Get entity tag.

Parameters

return

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

522 {
523 return $this->convertToLeadingUpper($a_entity);
524 }

References convertToLeadingUpper().

+ Here is the call graph for this function:

◆ getXmlNamespace()

◆ getXmlRecord()

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

Get xml record for version.

Parameters
arrayabstract data record
Returns
array xml record

Reimplemented in ilBlogDataSet, ilExerciseDataSet, ilHTMLLearningModuleDataSet, ilItemGroupDataSet, ilPollDataSet, ilPortfolioDataSet, ilScorm2004DataSet, ilSessionDataSet, ilMediaObjectDataSet, ilStyleDataSet, and ilUserDataSet.

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

469 {
470 return $a_set;
471 }

Referenced by addRecordsXml().

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

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

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

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

490 {
491 return $this->getTypes($a_entity, $a_version);
492 }

References getTypes().

Referenced by addRecordsXml(), and addTypesXml().

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

76 {
77 $this->entity = $a_entity;
78 $this->schema_version = $a_schema_version;
79 $this->data = array();
80 }

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

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

References $type, ilObject\_getIdForImportId(), ilObject\_lookupType(), and IL_INST_ID.

Referenced by ilBlogDataSet\importRecord().

+ 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

Reimplemented in ilBibliographicDataSet, ilContentPageDataSet, ilDataCollectionDataSet, ilExternalFeedDataSet, and ilIndividualAssessmentDataSet.

Referenced by addRecordsXml().

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

561 {
562 $this->current_installation_id = $a_val;
563 }

◆ setDSPrefix()

ilDataSet::setDSPrefix (   $a_val)

Set XML dataset namespace prefix.

Parameters
stringXML dataset namespace prefix

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

151 {
152 $this->ds_namespace = $a_val;
153 }

◆ setExportDirectories()

ilDataSet::setExportDirectories (   $a_relative,
  $a_absolute 
)

Set export directories.

Parameters

return

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

120 {
121 $this->relative_export_dir = $a_relative;
122 $this->absolute_export_dir = $a_absolute;
123 }

◆ setImport()

ilDataSet::setImport (   $a_val)

Set import object.

Parameters
objectimport object

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

541 {
542 $this->import = $a_val;
543 }

◆ setImportDirectory()

ilDataSet::setImportDirectory (   $a_val)

Set import directory.

Parameters
stringimport directory

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

131 {
132 $this->import_directory = $a_val;
133 }

◆ stripTags()

ilDataSet::stripTags ( array  $rec,
array  $omit_keys = [] 
)
protected

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

642 : array
643 {
644 $ret_rec = [];
645 foreach ($rec as $k => $v) {
646 if (in_array($k, $omit_keys, true)) {
647 $ret_rec[$k] = $v;
648 } else {
649 $ret_rec[$k] = ilUtil::stripSlashes($v);
650 }
651 }
652 return $ret_rec;
653 }
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled

References ilUtil\stripSlashes().

Referenced by ilBlogDataSet\importRecord(), ilExerciseDataSet\importRecord(), ilGlossaryDataSet\importRecord(), ilHTMLLearningModuleDataSet\importRecord(), ilItemGroupDataSet\importRecord(), ilLearningModuleDataSet\importRecord(), ilMediaCastDataSet\importRecord(), ilMediaPoolDataSet\importRecord(), ilPortfolioDataSet\importRecord(), ilSurveyDataSet\importRecord(), ilWikiDataSet\importRecord(), ilCOPageDataSet\importRecord(), ilHelpDataSet\importRecord(), ilMediaObjectDataSet\importRecord(), ilNewsDataSet\importRecord(), ilNotesDataSet\importRecord(), ilRatingDataSet\importRecord(), ilStyleDataSet\importRecord(), and ilTaxonomyDataSet\importRecord().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

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.

◆ $ds_namespace

ilDataSet::$ds_namespace = 'ds'
protected

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

Referenced by getDSPrefix().

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