ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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)
 
 importRecord (string $a_entity, array $a_types, array $a_rec, ilImportMapping $a_mapping, string $a_schema_version)
 
- 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...
 
 initByExporter (ilXmlExporter $xml_exporter)
 
 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 ...> ... 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...
 
 getCollection (array $record, string $entity, string $schema_version, string $field, string $value)
 
 getContainerExportConfig (array $record, string $entity, string $schema_version, string $field, string $value)
 

Protected Member Functions

 getXmlNamespace (string $a_entity, string $a_schema_version)
 
 getTypes (string $a_entity, string $a_version)
 
 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)
 
 getExportDirInContainer (string $exp_dir)
 
 getIRSSContainerExportConfig (StorableResource $source_container, string $source_path, string $target_path="")
 
 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
ILIAS ResourceStorage Services $irss
 
string $current_installation_id = ""
 
array $data = []
 
ilDBInterface $db
 
ilLogger $ds_log
 
string $import_directory = ""
 
string $entity = ""
 
string $schema_version = ""
 
string $component_export_dir = ""
 
string $ds_prefix = "ds"
 
string $version = ""
 
ilSurveyImporter $import
 
ilExport $export
 

Additional Inherited Members

- Data Fields inherited from ilDataSet
const DATASET_NS = 'http://www.ilias.de/Services/DataSet/ds/4_3'
 
const DATASET_NS_PREFIX = 'ds'
 
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

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

References null.

233  : array {
234  switch ($a_entity) {
235  case "mep":
236  return array(
237  "mep_tree" => array("ids" => $a_rec["Id"] ?? null)
238  );
239  }
240  return [];
241  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null

◆ getMasterLanguageOnly()

ilMediaPoolDataSet::getMasterLanguageOnly ( )

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

References $master_lang_only.

Referenced by readData().

57  : bool
58  {
60  }
+ Here is the caller graph for this function:

◆ getSupportedVersions()

ilMediaPoolDataSet::getSupportedVersions ( )

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.

References $transl_into.

Referenced by importRecord().

75  : bool
76  {
77  return $this->transl_into;
78  }
+ Here is the caller graph for this function:

◆ getTranslationLang()

ilMediaPoolDataSet::getTranslationLang ( )

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

References $transl_lang.

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.

References $transl_into_mep.

Referenced by importRecord().

84  {
86  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the caller graph for this function:

◆ getTypes()

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

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

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 
)

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

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

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

◆ readData()

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

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

References ilDataSet\$db, $ilDB, $q, ilDataSet\convertToLeadingUpper(), ilDataSet\getDirectDataFromQuery(), getMasterLanguageOnly(), and IL_INST_ID.

138  : void
139  {
140  $ilDB = $this->db;
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  // mep_tree
180  if ($a_entity === "mep_tree") {
181  switch ($a_version) {
182  case "4.1.0":
183  $this->getDirectDataFromQuery("SELECT mep_id, child " .
184  " ,parent,depth,type,title,foreign_id " .
185  " FROM mep_tree JOIN mep_item ON (child = obj_id) " .
186  " WHERE " .
187  $ilDB->in("mep_id", $a_ids, false, "integer") .
188  " ORDER BY depth");
189  break;
190 
191  case "5.1.0":
192  $type = "";
193  if ($this->getMasterLanguageOnly()) {
194  $type = " AND type <> " . $ilDB->quote("mob", "text");
195  }
196 
197  $q = "SELECT mep_id, child " .
198  " ,parent,depth,type,title,foreign_id, import_id " .
199  " FROM mep_tree JOIN mep_item ON (child = obj_id) " .
200  " WHERE " .
201  $ilDB->in("mep_id", $a_ids, false, "integer") .
202  $type .
203  " ORDER BY depth";
204 
205  $set = $ilDB->query($q);
206  $this->data = array();
207  while ($rec = $ilDB->fetchAssoc($set)) {
208  $set2 = $ilDB->query("SELECT for_translation FROM mep_data WHERE id = " . $ilDB->quote($rec["mep_id"], true));
209  $rec2 = $ilDB->fetchAssoc($set2);
210  if (!$rec2["for_translation"]) {
211  $rec["import_id"] = "il_" . IL_INST_ID . "_" . $rec["type"] . "_" . $rec["child"];
212  }
213  $tmp = array();
214  foreach ($rec as $k => $v) {
215  $tmp[$this->convertToLeadingUpper($k)]
216  = $v;
217  }
218  $rec = $tmp;
219 
220  $this->data[] = $rec;
221  }
222 
223  break;
224  }
225  }
226  }
convertToLeadingUpper(string $a_str)
Make xyz_abc a XyzAbc string.
const IL_INST_ID
Definition: constants.php:40
ilDBInterface $db
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 ...
$q
Definition: shib_logout.php:21
+ Here is the call graph for this function:

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

References null.

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  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null

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.

Referenced by getTranslationImportMode().

◆ $transl_into_mep

ilObjMediaPool ilMediaPoolDataSet::$transl_into_mep = null
protected

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

Referenced by getTranslationMep().

◆ $transl_lang

string ilMediaPoolDataSet::$transl_lang = ""
protected

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

Referenced by getTranslationLang().


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