ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilDataCollectionExporter.php
Go to the documentation of this file.
1<?php
2require_once("./Services/Export/classes/class.ilExport.php");
3require_once('./Services/Export/classes/class.ilXmlExporter.php');
4require_once('class.ilDataCollectionDataSet.php');
5require_once('class.ilDataCollectionCache.php');
6require_once('./Modules/MediaPool/classes/class.ilObjMediaPool.php');
7
15
19 protected $ds;
23 protected $db;
24
25
26 public function init() {
27 global $ilDB;
28 $this->ds = new ilDataCollectionDataSet();
29 $this->ds->setDSPrefix('ds');
30 $this->db = $ilDB;
31 }
32
33
39 public function getValidSchemaVersions($a_entity) {
40 return array(
41 '4.5.0' => array(
42 'namespace' => 'http://www.ilias.de/Modules/DataCollection/dcl/4_5',
43 'xsd_file" => "ilias_dcl_4_5.xsd',
44 'uses_dataset' => true,
45 'min' => '4.5.0',
46 'max' => ''
47 )
48 );
49 }
50
51
52 public function getXmlRepresentation($a_entity, $a_schema_version, $a_id) {
54 $this->ds->setExportDirectories($this->dir_relative, $this->dir_absolute);
55
56 return $this->ds->getXmlRepresentation($a_entity, $a_schema_version, $a_id, '', true, true);
57 }
58
59
70 public function getXmlExportHeadDependencies($a_entity, $a_target_release, $a_ids) {
71
72 foreach ($a_ids as $id) {
73 $m_ids = ilObjMediaPool::getAllMobIds($id);
74 foreach ($m_ids as $m) {
75 $mob_ids[] = $m;
76 }
77 }
78
79 $dependencies = array(
81 'component' => 'Modules/File',
82 'entity' => 'file',
83 'ids' => array(),
84 ),
86 'component' => 'Services/MediaObjects',
87 'entity' => 'mob',
88 'ids' => array(),
89 ),
90 );
91
92 // Direct SQL query is faster than looping over objects
93 $page_object_ids = array();
94 foreach ($a_ids as $dcl_obj_id) {
95 $sql = "SELECT stloc2.value AS ext_id, f.`datatype_id` FROM il_dcl_stloc2_value AS stloc2 "
96 . " INNER JOIN il_dcl_record_field AS rf ON (rf.`id` = stloc2.`record_field_id`) "
97 . " INNER JOIN il_dcl_field AS f ON (rf.`field_id` = f.`id`) " . "INNER JOIN il_dcl_table AS t ON (t.`id` = f.`table_id`) "
98 . " WHERE t.`obj_id` = " . $this->db->quote($dcl_obj_id, 'integer') . " " . "AND f.datatype_id IN ("
99 . implode(',', array_keys($dependencies)) . ") AND stloc2.`value` IS NOT NULL";
100 $set = $this->db->query($sql);
101 while ($rec = $this->db->fetchObject($set)) {
102 $dependencies[$rec->datatype_id]['ids'][] = (int)$rec->ext_id;
103 }
104 }
105
106 // Return external dependencies/IDs if there are any
107 $return = array();
108 if (count($dependencies[ilDataCollectionDatatype::INPUTFORMAT_FILE]['ids'])) {
109 $return[] = $dependencies[ilDataCollectionDatatype::INPUTFORMAT_FILE];
110 }
111 if (count($dependencies[ilDataCollectionDatatype::INPUTFORMAT_MOB]['ids'])) {
112 $return[] = $dependencies[ilDataCollectionDatatype::INPUTFORMAT_MOB];
113 }
114
115 return $return;
116 }
117
118
119 public function getXmlExportTailDependencies($a_entity, $a_target_release, $a_ids) {
120 $page_object_ids = array();
121 foreach ($a_ids as $dcl_obj_id) {
122 // If a DCL table has a detail view, we need to export the associated page objects!
123 $sql = "SELECT il_dcl_view.id AS page_obj_id FROM il_dcl_view " . " INNER JOIN il_dcl_table ON (il_dcl_table.id = il_dcl_view.table_id) "
124 . "WHERE il_dcl_table.obj_id = " . $this->db->quote($dcl_obj_id, 'integer') . " "
125 . "AND il_dcl_view.type=0 AND il_dcl_view.formtype=0";
126 $set = $this->db->query($sql);
127 while ($rec = $this->db->fetchObject($set)) {
128 $page_object_ids[] = "dclf:" . $rec->page_obj_id;
129 }
130 }
131 if (count($page_object_ids)) {
132 return array(
133 array(
134 'component' => 'Services/COPage',
135 'entity' => 'pg',
136 'ids' => $page_object_ids,
137 )
138 );
139 }
140
141 return array();
142 }
143}
144
145?>
DataCollection dataset class.
Class ilDataCollectionExporter.
getXmlExportTailDependencies($a_entity, $a_target_release, $a_ids)
Get tail dependencies.
getXmlExportHeadDependencies($a_entity, $a_target_release, $a_ids)
MOB/File fieldtypes objects are head dependencies They must be exported and imported first,...
getXmlRepresentation($a_entity, $a_schema_version, $a_id)
Get xml representation.
getAllMobIds($a_id)
Get all media object ids.
static makeDirParents($a_dir)
Create a new directory and all parent directories.
Xml Exporter class.
getAbsoluteExportDirectory()
Get absolute export directory.
global $ilDB