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

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.

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

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

42 {
43 $this->ds_log = ilLoggerFactory::getLogger('ds');
44 }
static getLogger($a_component_id)
Get component logger.

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

322 {
323 $types = $this->getXmlTypes($a_entity, $a_schema_version);
324
325 $this->ds_log->debug("...read data");
326 $this->readData($a_entity, $a_schema_version, $a_ids, $a_field);
327 $this->ds_log->debug("...data: ".print_r($this->data, true));
328 if (is_array($this->data))
329 {
330 foreach ($this->data as $d)
331 {
332 $a_writer->xmlStartTag($this->getDSPrefixString()."Rec",
333 array("Entity" => $this->getXmlEntityName($a_entity, $a_schema_version)));
334
335 // entity tag
336 $a_writer->xmlStartTag($this->getXmlEntityTag($a_entity, $a_schema_version));
337
338 $rec = $this->getXmlRecord($a_entity, $a_schema_version, $d);
339 foreach ($rec as $f => $c)
340 {
341 switch ($types[$f])
342 {
343 case "directory":
344 if ($this->absolute_export_dir != "" && $this->relative_export_dir != "")
345 {
346 ilUtil::makeDirParents($this->absolute_export_dir."/dsDir_".$this->dircnt);
347 ilUtil::rCopy($c, $this->absolute_export_dir."/dsDir_".$this->dircnt);
348//echo "<br>copy-".$c."-".$this->absolute_export_dir."/dsDir_".$this->dircnt."-";
349 $c = $this->relative_export_dir."/dsDir_".$this->dircnt;
350 $this->dircnt++;
351 }
352 break;
353 }
354 // this changes schema/dtd
355 //$a_writer->xmlElement($a_prefixes[$a_entity].":".$f,
356 // array(), $c);
357 $a_writer->xmlElement($f, array(), $c);
358 }
359
360 $a_writer->xmlEndTag($this->getXmlEntityTag($a_entity, $a_schema_version));
361
362 $a_writer->xmlEndTag($this->getDSPrefixString()."Rec");
363
364 $this->afterXmlRecordWriting($a_entity, $a_schema_version, $d);
365
366 // foreach record records of dependent entities
367 $this->ds_log->debug("...get dependencies");
368 $deps = $this->getDependencies($a_entity, $a_schema_version, $rec, $a_ids);
369 $this->ds_log->debug("...dependencies: ".print_r($deps, true));
370 if (is_array($deps))
371 {
372 foreach ($deps as $dp => $par)
373 {
374 $this->addRecordsXml($a_writer, $a_prefixes, $dp, $a_schema_version, $par["ids"], $par["field"]);
375 }
376 }
377 }
378 }
379 else if ($this->data === false)
380 {
381 // false -> add records of dependent entities (no record)
382 $this->ds_log->debug("...get dependencies (no record)");
383 $deps = $this->getDependencies($a_entity, $a_schema_version, null, $a_ids);
384 if (is_array($deps))
385 {
386 foreach ($deps as $dp => $par)
387 {
388 $this->addRecordsXml($a_writer, $a_prefixes, $dp, $a_schema_version, $par["ids"], $par["field"]);
389 }
390 }
391 }
392 }
for($col=0; $col< 50; $col++) $d
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.

References $d, $dircnt, 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 409 of file class.ilDataSet.php.

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

References $t, $w, 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 ilUserDataSet.

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

401 {
402 }

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

200 {
201 $a_str = strtoupper(substr($a_str, 0, 1)).substr($a_str, 1);
202 while (is_int($pos = strpos($a_str, "_")))
203 {
204 $a_str = substr($a_str, 0, $pos).
205 strtoupper(substr($a_str, $pos+1, 1)).
206 substr($a_str, $pos+2);
207 }
208 return $a_str;
209 }

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

585 {
586 return "il_".IL_INST_ID."_".$a_type."_".$a_id;
587 }
$a_type
Definition: workflow.php:93

References $a_type.

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

573 {
575 }

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

165 {
166 global $ilDB;
167
168 $set = $ilDB->query($a_query);
169 $this->data = array();
170 $ret = [];
171 while ($rec = $ilDB->fetchAssoc($set))
172 {
173 if ($a_convert_to_leading_upper)
174 {
175 $tmp = array();
176 foreach ($rec as $k => $v)
177 {
178 $tmp[$this->convertToLeadingUpper($k)]
179 = $v;
180 }
181 $rec = $tmp;
182 }
183
184 if ($a_set)
185 {
186 $this->data[] = $rec;
187 }
188 $ret[] = $rec;
189 }
190 return $ret;
191 }
convertToLeadingUpper($a_str)
Make xyz_abc a XyzAbc string.
$ret
Definition: parser.php:6
global $ilDB

References $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(), ilBookmarkDataSet\readData(), ilCalendarDataSet\readData(), ilCOPageDataSet\readData(), ilHelpDataSet\readData(), ilMediaObjectDataSet\readData(), ilNewsDataSet\readData(), ilNotesDataSet\readData(), ilObjectDataSet\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 143 of file class.ilDataSet.php.

144 {
145 return $this->var;
146 }

Referenced by getDSPrefixString().

+ Here is the caller graph for this function:

◆ getDSPrefixString()

ilDataSet::getDSPrefixString ( )

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

149 {
150 if ($this->getDSPrefix() != "")
151 {
152 return $this->getDSPrefix().":";
153 }
154 }
getDSPrefix()
Get XML dataset namespace prefix.

References getDSPrefix().

Referenced by addRecordsXml(), addTypesXml(), ilScormAiccDataSet\getExtendedXmlRepresentation(), 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 552 of file class.ilDataSet.php.

553 {
554 return $this->import;
555 }

Referenced by ilSurveyDataSet\importRecord().

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

533 {
534 return $a_entity;
535 }

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

482 {
483 return $a_set;
484 }

Referenced by getJsonRepresentation().

+ Here is the caller graph for this function:

◆ getJsonRepresentation()

ilDataSet::getJsonRepresentation ( )
final

Get json representation.

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

216 {
217 if ($this->version === false)
218 {
219 return false;
220 }
221
222 $arr["entity"] = $this->getJsonEntityName();
223 $arr["version"] = $this->version;
224 $arr["install_id"] = IL_INST_ID;
225 $arr["install_url"] = ILIAS_HTTP_PATH;
226 $arr["types"] = $this->getJsonTypes();
227 $arr["set"] = array();
228 foreach ($this->data as $d)
229 {
230 $arr["set"][] = $this->getJsonRecord($d);
231 }
232
233 include_once("./Services/JSON/classes/class.ilJsonUtil.php");
234
235 return ilJsonUtil::encode($arr);
236 }
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, $version, ilJsonUtil\encode(), getJsonEntityName(), getJsonRecord(), and getJsonTypes().

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

502 {
503 return $this->getTypes($a_entity, $a_version);
504 }
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 446 of file class.ilDataSet.php.

447 {
448 $ns = $this->getXmlNamespace($a_entity, $a_schema_version);
449 if ($ns != "")
450 {
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 {
457 foreach ($deps as $dp => $w)
458 {
459 $this->getNamespaces($namespaces, $dp, $a_schema_version);
460 }
461 }
462 }
getNamespaces(&$namespaces, $a_entity, $a_schema_version)
Get xml namespaces.
getXmlNamespace($a_entity, $a_schema_version)
Get xml namespace.

References $w, 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

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", ...)

Reimplemented in ilBibliographicDataSet, ilBlogDataSet, ilDataCollectionDataSet, ilExerciseDataSet, ilExternalFeedDataSet, ilGlossaryDataSet, ilHTMLLearningModuleDataSet, ilIndividualAssessmentDataSet, ilItemGroupDataSet, ilLearningModuleDataSet, ilMediaCastDataSet, ilMediaPoolDataSet, ilPollDataSet, ilPortfolioDataSet, ilScormAiccDataSet, ilSessionDataSet, ilSurveyDataSet, ilWikiDataSet, ilBookmarkDataSet, ilCalendarDataSet, ilCOPageDataSet, ilHelpDataSet, ilMediaObjectDataSet, ilNewsDataSet, ilNotesDataSet, ilObjectDataSet, ilRatingDataSet, ilSkillDataSet, ilStyleDataSet, ilTaxonomyDataSet, and ilUserDataSet.

Referenced by getJsonTypes(), and getXmlTypes().

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

513 {
514 return $a_entity;
515 }

◆ getXMLEntityTag()

ilDataSet::getXMLEntityTag (   $a_entity,
  $a_schema_version 
)

Get entity tag.

Parameters

return

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

524 {
525 return $this->convertToLeadingUpper($a_entity);
526 }

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, ilSessionDataSet, ilMediaObjectDataSet, ilStyleDataSet, and ilUserDataSet.

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

471 {
472 return $a_set;
473 }

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

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

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

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

492 {
493 return $this->getTypes($a_entity, $a_version);
494 }

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

59 {
60 $this->entity = $a_entity;
61 $this->schema_version = $a_schema_version;
62 $this->data = array();
63 }

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

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

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

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

563 {
564 $this->current_installation_id = $a_val;
565 }

◆ 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

return

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

543 {
544 $this->import = $a_val;
545 }

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