ILIAS  release_8 Revision v8.24
ilMediaPoolDataSet Class Reference

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V. More...

+ Inheritance diagram for ilMediaPoolDataSet:
+ Collaboration diagram for ilMediaPoolDataSet:

Public Member Functions

 getSupportedVersions ()
 
 setMasterLanguageOnly (bool $a_val)
 Set master language only (export) More...
 
 getMasterLanguageOnly ()
 
 setTranslationImportMode (?ilObjMediaPool $a_mep, string $a_lang="")
 
 getTranslationImportMode ()
 
 getTranslationMep ()
 Get translation pool (import) More...
 
 getTranslationLang ()
 
 readData (string $a_entity, string $a_version, array $a_ids)
 Read data from DB. More...
 
 importRecord (string $a_entity, array $a_types, array $a_rec, ilImportMapping $a_mapping, string $a_schema_version)
 Needs to be overwritten for import use case. More...
 
- Public Member Functions inherited from ilDataSet
 __construct ()
 
 init (string $a_entity, string $a_schema_version)
 Init. More...
 
 getSupportedVersions ()
 
 readData (string $a_entity, string $a_version, array $a_ids)
 Read data from DB. More...
 
 setExportDirectories (string $a_relative, string $a_absolute)
 
 setImportDirectory (string $a_val)
 
 getImportDirectory ()
 
 setDSPrefix (string $a_val)
 
 getDSPrefix ()
 
 getDSPrefixString ()
 
 getDirectDataFromQuery (string $a_query, bool $a_convert_to_leading_upper=true, bool $a_set=true)
 Get data from query.This is a standard procedure, all db field names are directly mapped to abstract fields. More...
 
 convertToLeadingUpper (string $a_str)
 Make xyz_abc a XyzAbc string. More...
 
 getXmlRepresentation (string $a_entity, string $a_schema_version, ?array $a_ids, string $a_field="", bool $a_omit_header=false, bool $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 (ilXmlWriter $a_writer, array $a_prefixes, string $a_entity, string $a_schema_version, array $a_ids, ?string $a_field="")
 
 afterXmlRecordWriting (string $a_entity, string $a_version, array $a_set)
 
 getNamespaces (array &$namespaces, string $a_entity, string $a_schema_version)
 
 getXmlRecord (string $a_entity, string $a_version, array $a_set)
 Get xml record for version. More...
 
 getXmlTypes (string $a_entity, string $a_version)
 Get xml types. More...
 
 getXMLEntityName (string $a_entity, string $a_version)
 Get entity name for xml (may be overwritten) More...
 
 getXMLEntityTag (string $a_entity, string $a_schema_version)
 Get entity tag. More...
 
 setImport (ilSurveyImporter $a_val)
 
 getImport ()
 
 setCurrentInstallationId (string $a_val)
 
 getCurrentInstallationId ()
 
 importRecord (string $a_entity, array $a_types, array $a_rec, ilImportMapping $a_mapping, string $a_schema_version)
 Needs to be overwritten for import use case. More...
 

Protected Member Functions

 getXmlNamespace (string $a_entity, string $a_schema_version)
 
 getTypes (string $a_entity, string $a_version)
 Get (abstract) types for (abstract) field names. More...
 
 getDependencies (string $a_entity, string $a_version, ?array $a_rec=null, ?array $a_ids=null)
 
- Protected Member Functions inherited from ilDataSet
 getTypes (string $a_entity, string $a_version)
 Get (abstract) types for (abstract) field names. More...
 
 getXmlNamespace (string $a_entity, string $a_schema_version)
 
 getDependencies (string $a_entity, string $a_version, ?array $a_rec=null, ?array $a_ids=null)
 
 createObjectExportId (string $a_type, string $a_id)
 Build ilias export id. More...
 
 parseObjectExportId (string $a_id, ?string $a_fallback_id=null)
 Parse export id. More...
 
 stripTags (array $rec, array $omit_keys=[])
 

Protected Attributes

ilObjMediaPool $current_obj = null
 
bool $master_lang_only = false
 
bool $transl_into = false
 
ilObjMediaPool $transl_into_mep = null
 
string $transl_lang = ""
 
- Protected Attributes inherited from ilDataSet
string $current_installation_id = ""
 
array $data = []
 
ilDBInterface $db
 
ilLogger $ds_log
 
string $import_directory = ""
 
string $entity = ""
 
string $schema_version = ""
 
string $relative_export_dir = ""
 
string $absolute_export_dir = ""
 
string $ds_prefix = "ds"
 
string $version = ""
 
ilSurveyImporter $import
 

Additional Inherited Members

- Data Fields inherited from ilDataSet
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
 
int $dircnt = 0
 

Detailed Description

This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Learning e.V.

ILIAS is licensed with the GPL-3.0, see https://www.gnu.org/licenses/gpl-3.0.en.html You should have received a copy of said license along with the source code, too.

If this is not the case or you just want to try ILIAS, you'll find us at: https://www.ilias.de https://github.com/ILIAS-eLearning Media Pool Data set class

This class implements the following entities:

  • mep_data: data from table mep_data
  • mep_tree: data from a join on mep_tree and mep_item
Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 28 of file class.ilMediaPoolDataSet.php.

Member Function Documentation

◆ getDependencies()

ilMediaPoolDataSet::getDependencies ( string  $a_entity,
string  $a_version,
?array  $a_rec = null,
?array  $a_ids = null 
)
protected

Reimplemented from ilDataSet.

Definition at line 229 of file class.ilMediaPoolDataSet.php.

234 : array {
235 switch ($a_entity) {
236 case "mep":
237 return array(
238 "mep_tree" => array("ids" => $a_rec["Id"] ?? null)
239 );
240 }
241 return [];
242 }

◆ getMasterLanguageOnly()

ilMediaPoolDataSet::getMasterLanguageOnly ( )

Definition at line 57 of file class.ilMediaPoolDataSet.php.

57 : bool
58 {
60 }

References $master_lang_only.

◆ getSupportedVersions()

ilMediaPoolDataSet::getSupportedVersions ( )

Reimplemented from ilDataSet.

Definition at line 39 of file class.ilMediaPoolDataSet.php.

39 : array
40 {
41 return array("5.1.0", "4.1.0");
42 }

◆ getTranslationImportMode()

ilMediaPoolDataSet::getTranslationImportMode ( )

Definition at line 75 of file class.ilMediaPoolDataSet.php.

75 : bool
76 {
77 return $this->transl_into;
78 }

◆ getTranslationLang()

ilMediaPoolDataSet::getTranslationLang ( )

Definition at line 88 of file class.ilMediaPoolDataSet.php.

88 : string
89 {
90 return $this->transl_lang;
91 }

◆ getTranslationMep()

ilMediaPoolDataSet::getTranslationMep ( )

Get translation pool (import)

Definition at line 83 of file class.ilMediaPoolDataSet.php.

84 {
86 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

◆ getTypes()

ilMediaPoolDataSet::getTypes ( string  $a_entity,
string  $a_version 
)
protected

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

Definition at line 93 of file class.ilMediaPoolDataSet.php.

93 : array
94 {
95 // mep
96 if ($a_entity === "mep") {
97 switch ($a_version) {
98 case "4.1.0":
99 return array(
100 "Id" => "integer",
101 "Title" => "text",
102 "Description" => "text",
103 "DefaultWidth" => "integer",
104 "DefaultHeight" => "integer");
105
106 case "5.1.0":
107 return array(
108 "Id" => "integer",
109 "Title" => "text",
110 "Description" => "text",
111 "DefaultWidth" => "integer",
112 "DefaultHeight" => "integer",
113 "ForTranslation" => "integer"
114 );
115 }
116 }
117
118 // mep_tree
119 if ($a_entity === "mep_tree") {
120 switch ($a_version) {
121 case "4.1.0":
122 case "5.1.0":
123 return array(
124 "MepId" => "integer",
125 "Child" => "integer",
126 "Parent" => "integer",
127 "Depth" => "integer",
128 "Type" => "text",
129 "Title" => "text",
130 "ForeignId" => "integer",
131 "ImportId" => "text"
132 );
133 }
134 }
135 return [];
136 }

◆ getXmlNamespace()

ilMediaPoolDataSet::getXmlNamespace ( string  $a_entity,
string  $a_schema_version 
)
protected

Reimplemented from ilDataSet.

Definition at line 44 of file class.ilMediaPoolDataSet.php.

44 : string
45 {
46 return "https://www.ilias.de/xml/Modules/MediaPool/" . $a_entity;
47 }

◆ importRecord()

ilMediaPoolDataSet::importRecord ( string  $a_entity,
array  $a_types,
array  $a_rec,
ilImportMapping  $a_mapping,
string  $a_schema_version 
)

Needs to be overwritten for import use case.

Reimplemented from ilDataSet.

Definition at line 244 of file class.ilMediaPoolDataSet.php.

250 : void {
251 $a_rec = $this->stripTags($a_rec);
252
253 switch ($a_entity) {
254 case "mep":
255
256 if ($this->getTranslationImportMode()) {
257 return;
258 }
259
260 if ($new_id = $a_mapping->getMapping('Services/Container', 'objs', $a_rec['Id'])) {
261 $newObj = ilObjectFactory::getInstanceByObjId($new_id, false);
262 } else {
263 $newObj = new ilObjMediaPool();
264 $newObj->setType("mep");
265 $newObj->create();
266 }
267
268 $newObj->setTitle($a_rec["Title"]);
269 $newObj->setDescription($a_rec["Description"]);
270 $newObj->setDefaultWidth((int) $a_rec["DefaultWidth"]);
271 $newObj->setDefaultHeight((int) $a_rec["DefaultHeight"]);
272 $newObj->setForTranslation((bool) ($a_rec["ForTranslation"] ?? false));
273 $newObj->update();
274
275 $this->current_obj = $newObj;
276 $a_mapping->addMapping("Modules/MediaPool", "mep", $a_rec["Id"], $newObj->getId());
277 $a_mapping->addMapping("Services/Object", "obj", $a_rec["Id"], $newObj->getId());
278 break;
279
280 case "mep_tree":
281 if (!$this->getTranslationImportMode()) {
282 switch ($a_rec["Type"]) {
283 case "fold":
284 $parent = (int) $a_mapping->getMapping("Modules/MediaPool", "mep_tree", $a_rec["Parent"]);
285 $fold_id =
286 $this->current_obj->createFolder($a_rec["Title"], $parent);
287 $a_mapping->addMapping(
288 "Modules/MediaPool",
289 "mep_tree",
290 $a_rec["Child"],
291 $fold_id
292 );
293 break;
294
295 case "mob":
296 $parent = (int) $a_mapping->getMapping("Modules/MediaPool", "mep_tree", $a_rec["Parent"]);
297 $mob_id = (int) $a_mapping->getMapping("Services/MediaObjects", "mob", $a_rec["ForeignId"]);
298 $item = new ilMediaPoolItem();
299 $item->setType("mob");
300 $item->setForeignId($mob_id);
301 $item->setImportId($a_rec["ImportId"]);
302 $item->setTitle($a_rec["Title"]);
303 $item->create();
304 if ($item->getId() > 0) {
305 if ($parent === 0) {
306 $parent = null;
307 }
308 $this->current_obj->insertInTree($item->getId(), $parent);
309 }
310 break;
311
312 case "pg":
313 $parent = (int) $a_mapping->getMapping("Modules/MediaPool", "mep_tree", $a_rec["Parent"]);
314
315 $item = new ilMediaPoolItem();
316 $item->setType("pg");
317 $item->setTitle($a_rec["Title"]);
318 $item->setImportId($a_rec["ImportId"]);
319 $item->create();
320 $a_mapping->addMapping("Modules/MediaPool", "pg", $a_rec["Child"], $item->getId());
321 $a_mapping->addMapping(
322 "Services/COPage",
323 "pg",
324 "mep:" . $a_rec["Child"],
325 "mep:" . $item->getId()
326 );
327 if ($item->getId() > 0) {
328 if ($parent === 0) {
329 $parent = null;
330 }
331 $this->current_obj->insertInTree($item->getId(), $parent);
332 }
333 break;
334
335 }
336 } elseif ($a_rec["Type"] === "pg") {
337 $imp_id = explode("_", $a_rec["ImportId"]);
338 if ($imp_id[0] === "il" &&
339 (int) $imp_id[1] == (int) IL_INST_ID &&
340 $imp_id[2] === "pg"
341 ) {
342 $pg_id = $imp_id[3];
343 $pool = ilMediaPoolItem::getPoolForItemId($pg_id);
344 $pool = current($pool);
345 if ($pool == $this->getTranslationMep()->getId()) {
346 $a_mapping->addMapping("Modules/MediaPool", "pg", $a_rec["Child"], $pg_id);
347 $a_mapping->addMapping(
348 "Services/COPage",
349 "pg",
350 "mep:" . $a_rec["Child"],
351 "mep:" . $pg_id
352 );
353 }
354 }
355 }
356 break;
357 }
358 }
stripTags(array $rec, array $omit_keys=[])
addMapping(string $a_comp, string $a_entity, string $a_old_id, string $a_new_id)
getMapping(string $a_comp, string $a_entity, string $a_old_id)
getTranslationMep()
Get translation pool (import)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getPoolForItemId(int $a_id)
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
const IL_INST_ID
Definition: constants.php:40

References ilImportMapping\addMapping(), ILIAS\Survey\Mode\getId(), ilObjectFactory\getInstanceByObjId(), ilImportMapping\getMapping(), ilMediaPoolItem\getPoolForItemId(), IL_INST_ID, and ILIAS\Repository\int().

+ Here is the call graph for this function:

◆ readData()

ilMediaPoolDataSet::readData ( string  $a_entity,
string  $a_version,
array  $a_ids 
)

Read data from DB.

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

Reimplemented from ilDataSet.

Definition at line 138 of file class.ilMediaPoolDataSet.php.

138 : void
139 {
141
142 // mep_data
143 if ($a_entity === "mep") {
144 switch ($a_version) {
145 case "4.1.0":
146 $this->getDirectDataFromQuery("SELECT id, title, description, " .
147 " default_width, default_height" .
148 " FROM mep_data JOIN object_data ON (mep_data.id = object_data.obj_id) " .
149 "WHERE " .
150 $ilDB->in("id", $a_ids, false, "integer"));
151 break;
152
153 case "5.1.0":
154 $q = "SELECT id, title, description, " .
155 " default_width, default_height" .
156 " FROM mep_data JOIN object_data ON (mep_data.id = object_data.obj_id) " .
157 "WHERE " .
158 $ilDB->in("id", $a_ids, false, "integer");
159
160 $set = $ilDB->query($q);
161 $this->data = array();
162 while ($rec = $ilDB->fetchAssoc($set)) {
163 if ($this->getMasterLanguageOnly()) {
164 $rec["for_translation"] = 1;
165 }
166 $tmp = array();
167 foreach ($rec as $k => $v) {
168 $tmp[$this->convertToLeadingUpper($k)]
169 = $v;
170 }
171 $rec = $tmp;
172
173 $this->data[] = $rec;
174 }
175 break;
176
177 }
178 }
179
180 // mep_tree
181 if ($a_entity === "mep_tree") {
182 switch ($a_version) {
183 case "4.1.0":
184 $this->getDirectDataFromQuery("SELECT mep_id, child " .
185 " ,parent,depth,type,title,foreign_id " .
186 " FROM mep_tree JOIN mep_item ON (child = obj_id) " .
187 " WHERE " .
188 $ilDB->in("mep_id", $a_ids, false, "integer") .
189 " ORDER BY depth");
190 break;
191
192 case "5.1.0":
193 $type = "";
194 if ($this->getMasterLanguageOnly()) {
195 $type = " AND type <> " . $ilDB->quote("mob", "text");
196 }
197
198 $q = "SELECT mep_id, child " .
199 " ,parent,depth,type,title,foreign_id, import_id " .
200 " FROM mep_tree JOIN mep_item ON (child = obj_id) " .
201 " WHERE " .
202 $ilDB->in("mep_id", $a_ids, false, "integer") .
203 $type .
204 " ORDER BY depth";
205
206 $set = $ilDB->query($q);
207 $this->data = array();
208 while ($rec = $ilDB->fetchAssoc($set)) {
209 $set2 = $ilDB->query("SELECT for_translation FROM mep_data WHERE id = " . $ilDB->quote($rec["mep_id"], true));
210 $rec2 = $ilDB->fetchAssoc($set2);
211 if (!$rec2["for_translation"]) {
212 $rec["import_id"] = "il_" . IL_INST_ID . "_" . $rec["type"] . "_" . $rec["child"];
213 }
214 $tmp = array();
215 foreach ($rec as $k => $v) {
216 $tmp[$this->convertToLeadingUpper($k)]
217 = $v;
218 }
219 $rec = $tmp;
220
221 $this->data[] = $rec;
222 }
223
224 break;
225 }
226 }
227 }
convertToLeadingUpper(string $a_str)
Make xyz_abc a XyzAbc string.
getDirectDataFromQuery(string $a_query, bool $a_convert_to_leading_upper=true, bool $a_set=true)
Get data from query.This is a standard procedure, all db field names are directly mapped to abstract ...
ilDBInterface $db
$type

References $ilDB, $type, and IL_INST_ID.

◆ setMasterLanguageOnly()

ilMediaPoolDataSet::setMasterLanguageOnly ( bool  $a_val)

Set master language only (export)

Definition at line 52 of file class.ilMediaPoolDataSet.php.

52 : void
53 {
54 $this->master_lang_only = $a_val;
55 }

◆ setTranslationImportMode()

ilMediaPoolDataSet::setTranslationImportMode ( ?ilObjMediaPool  $a_mep,
string  $a_lang = "" 
)

Definition at line 62 of file class.ilMediaPoolDataSet.php.

65 : void {
66 if ($a_mep !== null) {
67 $this->transl_into = true;
68 $this->transl_into_mep = $a_mep;
69 $this->transl_lang = $a_lang;
70 } else {
71 $this->transl_into = false;
72 }
73 }

Field Documentation

◆ $current_obj

ilObjMediaPool ilMediaPoolDataSet::$current_obj = null
protected

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

◆ $master_lang_only

bool ilMediaPoolDataSet::$master_lang_only = false
protected

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

Referenced by getMasterLanguageOnly().

◆ $transl_into

bool ilMediaPoolDataSet::$transl_into = false
protected

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

◆ $transl_into_mep

ilObjMediaPool ilMediaPoolDataSet::$transl_into_mep = null
protected

Definition at line 36 of file class.ilMediaPoolDataSet.php.

◆ $transl_lang

string ilMediaPoolDataSet::$transl_lang = ""
protected

Definition at line 37 of file class.ilMediaPoolDataSet.php.


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