ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilMediaObjectDataSet 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 ilMediaObjectDataSet:
+ Collaboration diagram for ilMediaObjectDataSet:

Public Member Functions

 __construct ()
 
 setUsePreviousImportIds (bool $a_val)
 Set use previous import ids. More...
 
 getUsePreviousImportIds ()
 
 getSupportedVersions ()
 
 readData (string $a_entity, string $a_version, array $a_ids)
 
 getXmlRecord (string $a_entity, string $a_version, array $a_set)
 
 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...
 
 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 ...> ... 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)
 

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)
 Determine the dependent sets of data. More...
 
- 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

ilMediaItem $current_media_item
 
ilObjMediaObject $current_mob
 
ilLogger $mob_log
 
bool $use_previous_import_ids = false
 
- 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 $relative_export_dir = ""
 
string $absolute_export_dir = ""
 
string $ds_prefix = "ds"
 
string $version = ""
 
ilSurveyImporter $import
 

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:

  • mob: object data
  • mob_media_item: data from table media_item
  • mob_mi_map_area: data from a table map_area
  • mob_mi_parameter: data from a table mob_parameter
Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

Definition at line 30 of file class.ilMediaObjectDataSet.php.

Constructor & Destructor Documentation

◆ __construct()

ilMediaObjectDataSet::__construct ( )

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

References ILIAS\MetaData\Repository\Validation\Data\__construct(), and ilLoggerFactory\getLogger().

38  {
40  $this->mob_log = ilLoggerFactory::getLogger('mob');
41  }
static getLogger(string $a_component_id)
Get component logger.
__construct(VocabulariesInterface $vocabularies)
+ Here is the call graph for this function:

Member Function Documentation

◆ getDependencies()

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

Determine the dependent sets of data.

Definition at line 267 of file class.ilMediaObjectDataSet.php.

272  : array {
273  switch ($a_entity) {
274  case "mob":
275  return array(
276  "mob_media_item" => array("ids" => $a_rec["Id"] ?? null)
277  );
278 
279  case "mob_media_item":
280  return array(
281  "mob_mi_map_area" => array("ids" => $a_rec["Id"] ?? null),
282  "mob_mi_parameter" => array("ids" => $a_rec["Id"] ?? null)
283  );
284  }
285  return [];
286  }

◆ getSupportedVersions()

ilMediaObjectDataSet::getSupportedVersions ( )
Returns
string[]

Definition at line 61 of file class.ilMediaObjectDataSet.php.

61  : array
62  {
63  return array("5.1.0", "4.3.0", "4.1.0");
64  }

◆ getTypes()

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

Definition at line 71 of file class.ilMediaObjectDataSet.php.

71  : array
72  {
73  // mob
74  if ($a_entity == "mob") {
75  switch ($a_version) {
76  case "4.1.0":
77  case "4.3.0":
78  return array(
79  "Id" => "integer",
80  "Title" => "text",
81  "Description" => "text",
82  "Dir" => "directory"
83  );
84 
85  case "5.1.0":
86  return array(
87  "Id" => "integer",
88  "Title" => "text",
89  "Description" => "text",
90  "Dir" => "directory",
91  "ImportId" => "text"
92  );
93  }
94  }
95 
96  // media item
97  if ($a_entity == "mob_media_item") {
98  switch ($a_version) {
99  case "5.1.0":
100  case "4.3.0":
101  case "4.1.0":
102  return array(
103  "Id" => "integer",
104  "MobId" => "integer",
105  "Width" => "integer",
106  "Height" => "integer",
107  "Halign" => "text",
108  "Caption" => "text",
109  "Nr" => "integer",
110  "Purpose" => "text",
111  "Location" => "text",
112  "LocationType" => "text",
113  "Format" => "text",
114  "TextRepresentation" => "text"
115  );
116  }
117  }
118 
119  // map areas
120  if ($a_entity == "mob_mi_map_area") {
121  switch ($a_version) {
122  case "4.1.0":
123  case "4.3.0":
124  case "5.1.0":
125  return array(
126  "MiId" => "integer",
127  "Nr" => "integer",
128  "Shape" => "text",
129  "Coords" => "text",
130  "LinkType" => "text",
131  "Title" => "text",
132  "Href" => "text",
133  "Target" => "text",
134  "Type" => "text",
135  "TargetFrame" => "text",
136  "HighlightMode" => "text",
137  "HighlightText" => "text"
138  );
139  }
140  }
141 
142  // media item parameter
143  if ($a_entity == "mob_mi_parameter") {
144  switch ($a_version) {
145  case "4.1.0":
146  case "4.3.0":
147  case "5.1.0":
148  return array(
149  "MiId" => "integer",
150  "Name" => "text",
151  "Value" => "text"
152  );
153  }
154  }
155  return [];
156  }

◆ getUsePreviousImportIds()

ilMediaObjectDataSet::getUsePreviousImportIds ( )

Definition at line 53 of file class.ilMediaObjectDataSet.php.

References $use_previous_import_ids.

Referenced by importRecord().

53  : bool
54  {
56  }
+ Here is the caller graph for this function:

◆ getXmlNamespace()

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

Definition at line 66 of file class.ilMediaObjectDataSet.php.

66  : string
67  {
68  return "https://www.ilias.de/xml/Services/MediaObject/" . $a_entity;
69  }

◆ getXmlRecord()

ilMediaObjectDataSet::getXmlRecord ( string  $a_entity,
string  $a_version,
array  $a_set 
)

Definition at line 288 of file class.ilMediaObjectDataSet.php.

References ilObjMediaObject\_getDirectory(), and ilFileUtils\makeDirParents().

292  : array {
293  if ($a_entity == "mob") {
294  $dir = ilObjMediaObject::_getDirectory($a_set["Id"]);
295  if (!is_dir($dir)) {
297  }
298  $a_set["Dir"] = $dir;
299  }
300 
301  return $a_set;
302  }
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
static _getDirectory(int $a_mob_id)
Get absolute directory.
+ Here is the call graph for this function:

◆ importRecord()

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

Definition at line 304 of file class.ilMediaObjectDataSet.php.

References $current_media_item, $current_mob, ilObjMediaObject\_createThumbnailDirectory(), ilObjMediaObject\_getDirectory(), ilImportMapping\addMapping(), ilDataSet\getCurrentInstallationId(), ilDataSet\getImportDirectory(), ilImportMapping\getMapping(), getUsePreviousImportIds(), ILIAS\Repository\int(), ilFileUtils\rCopy(), ilObjMediaObject\renameExecutables(), ilMediaSvgSanitizer\sanitizeDir(), and ilDataSet\stripTags().

310  : void {
311  $a_rec = $this->stripTags($a_rec);
312  switch ($a_entity) {
313  case "mob":
314 
315  $newObj = new ilObjMediaObject();
316  $newObj->setType("mob");
317  $newObj->setTitle($a_rec["Title"]);
318  $newObj->setDescription($a_rec["Description"]);
319  // on translation re-import we are interested in the "previous" import id
320  if ($this->getUsePreviousImportIds()) {
321  $newObj->setImportId($a_rec["ImportId"]);
322  } else {
323  $newObj->setImportId("il_" . $this->getCurrentInstallationId() . "_mob_" . $a_rec["Id"]);
324  }
325  $newObj->create();
326  $newObj->createDirectory();
328  $this->current_mob = $newObj;
329 
330  $dir = str_replace("..", "", $a_rec["Dir"]);
331  if ($dir != "" && $this->getImportDirectory() != "") {
332  $source_dir = $this->getImportDirectory() . "/" . $dir;
333  $target_dir = $dir = ilObjMediaObject::_getDirectory($newObj->getId());
334  $this->mob_log->debug("s:-$source_dir-,t:-$target_dir-");
335  ilFileUtils::rCopy($source_dir, $target_dir);
337  ilMediaSvgSanitizer::sanitizeDir($target_dir); // see #20339
338  }
339 
340  $a_mapping->addMapping("Services/MediaObjects", "mob", $a_rec["Id"], $newObj->getId());
341  $a_mapping->addMapping(
342  "Services/MetaData",
343  "md",
344  "0:" . $a_rec["Id"] . ":mob",
345  "0:" . $newObj->getId() . ":mob"
346  );
347  break;
348 
349  case "mob_media_item":
350 
351  // determine parent mob
352  $mob_id = (int) $a_mapping->getMapping("Services/MediaObjects", "mob", $a_rec["MobId"]);
353  if (is_object($this->current_mob) && $this->current_mob->getId() == $mob_id) {
354  $mob = $this->current_mob;
355  } else {
356  $mob = new ilObjMediaObject($mob_id);
357  }
358 
359  $newObj = new ilMediaItem();
360  $newObj->setMobId($mob_id);
361  $newObj->setWidth($a_rec["Width"]);
362  $newObj->setHeight($a_rec["Height"]);
363  $newObj->setCaption($a_rec["Caption"]);
364  $newObj->setNr($a_rec["Nr"]);
365  $newObj->setPurpose($a_rec["Purpose"]);
366  $newObj->setLocation($a_rec["Location"]);
367  $newObj->setLocationType($a_rec["LocationType"]);
368  $newObj->setFormat($a_rec["Format"]);
369  $newObj->setTextRepresentation($a_rec["TextRepresentation"]);
370  $newObj->create();
371  $this->current_media_item = $newObj;
372 
373  $a_mapping->addMapping("Services/MediaObjects", "mob_media_item", $a_rec["Id"], $newObj->getId());
374 
375  break;
376 
377  case "mob_mi_parameter":
378 
379  // get media item
380  $med_id = (int) $a_mapping->getMapping("Services/MediaObjects", "mob_media_item", $a_rec["MiId"]);
381  if (is_object($this->current_media_item) && $this->current_media_item->getId() == $med_id) {
383  } else {
384  $med = new ilMediaItem($med_id);
385  }
386  $med->writeParameter($a_rec["Name"], $a_rec["Value"]);
387 
388  break;
389 
390  case "mob_mi_map_area":
391  // get media item
392  $med_id = (int) $a_mapping->getMapping("Services/MediaObjects", "mob_media_item", $a_rec["MiId"]);
393  if (is_object($this->current_media_item) && $this->current_media_item->getId() == $med_id) {
395  } else {
396  $med = new ilMediaItem($med_id);
397  }
398 
399  $map_area = new ilMapArea();
400  $map_area->setItemId($med_id);
401  $map_area->setNr($a_rec["Nr"]);
402  $map_area->setShape($a_rec["Shape"]);
403  $map_area->setCoords($a_rec["Coords"]);
404  $map_area->setLinkType($a_rec["LinkType"]);
405  $map_area->setTitle($a_rec["Title"]);
406  $map_area->setHref($a_rec["Href"]);
407  $map_area->setTarget($a_rec["Target"]);
408  $map_area->setType($a_rec["Type"]);
409  $map_area->setTargetFrame($a_rec["TargetFrame"]);
410  $map_area->setHighlightMode($a_rec["HighlightMode"]);
411  $map_area->setHighlightClass($a_rec["HighlightClass"]);
412  $map_area->create();
413  break;
414  }
415  }
static sanitizeDir(string $a_path)
Sanitize directory recursively.
static _createThumbnailDirectory(int $a_obj_id)
Create thumbnail directory.
static rCopy(string $a_sdir, string $a_tdir, bool $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
addMapping(string $a_comp, string $a_entity, string $a_old_id, string $a_new_id)
static renameExecutables(string $a_dir)
static _getDirectory(int $a_mob_id)
Get absolute directory.
getMapping(string $a_comp, string $a_entity, string $a_old_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getCurrentInstallationId()
Class ilMapArea.
stripTags(array $rec, array $omit_keys=[])
+ Here is the call graph for this function:

◆ readData()

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

Definition at line 158 of file class.ilMediaObjectDataSet.php.

References ilDataSet\$db, $id, $ilDB, $r, $ref_id, ilObject\_lookupDescription(), ilObject\_lookupImportId(), ilObject\_lookupObjId(), ilObject\_lookupTitle(), ilObject\_lookupType(), ilDataSet\getDirectDataFromQuery(), and ilUtil\insertInstIntoID().

162  : void {
163  $ilDB = $this->db;
164 
165  if (!is_array($a_ids)) {
166  $a_ids = array($a_ids);
167  }
168 
169  // mob
170  if ($a_entity == "mob") {
171  $this->data = array();
172 
173  switch ($a_version) {
174  case "4.1.0":
175  case "4.3.0":
176  foreach ($a_ids as $mob_id) {
177  if (ilObject::_lookupType($mob_id) == "mob") {
178  $this->data[] = array("Id" => $mob_id,
179  "Title" => ilObject::_lookupTitle($mob_id),
180  "Description" => ilObject::_lookupDescription($mob_id)
181  );
182  }
183  }
184  break;
185 
186  case "5.1.0":
187  foreach ($a_ids as $mob_id) {
188  if (ilObject::_lookupType($mob_id) == "mob") {
189  $this->data[] = array("Id" => $mob_id,
190  "Title" => ilObject::_lookupTitle($mob_id),
191  "Description" => ilObject::_lookupDescription($mob_id),
192  "ImportId" => ilObject::_lookupImportId($mob_id)
193  );
194  }
195  }
196  break;
197  }
198  }
199 
200  // media item
201  if ($a_entity == "mob_media_item") {
202  switch ($a_version) {
203  case "5.1.0":
204  case "4.3.0":
205  case "4.1.0":
206  $this->getDirectDataFromQuery("SELECT id, mob_id, width, height, halign," .
207  "caption, nr, purpose, location, location_type, format, text_representation" .
208  " FROM media_item WHERE " .
209  $ilDB->in("mob_id", $a_ids, false, "integer"));
210  break;
211  }
212  }
213 
214 
215  // media item map area
216  if ($a_entity == "mob_mi_map_area") {
217  switch ($a_version) {
218  case "4.1.0":
219  case "4.3.0":
220  case "5.1.0":
221  foreach ($this->getDirectDataFromQuery("SELECT item_id mi_id, nr" .
222  " ,shape, coords, link_type, title, href, target, type, target_frame, " .
223  " highlight_mode, highlight_class" .
224  " FROM map_area " .
225  " WHERE " .
226  $ilDB->in("item_id", $a_ids, false, "integer") .
227  " ORDER BY nr", true, false) as $r) {
228  $r["Target"] = ilUtil::insertInstIntoID((string) ($r["Target"] ?? ""));
229 
230  // see ilPageObject::insertInstIntoIDs
231  if ($r["Type"] == "RepositoryItem") {
232  $id_arr = explode("_", $r["Target"]);
233  $ref_id = $id_arr[3];
234  $obj_id = ilObject::_lookupObjId($id_arr[3]);
235 
236  $otype = ilObject::_lookupType($obj_id);
237  if ($obj_id > 0) {
238  $id = $otype . "_" . $obj_id . "_" . $ref_id;
239  $r["Target"] = "il_" . $id_arr[1] . "_" . $id;
240  }
241  }
242 
243  $this->data[] = $r;
244  }
245  break;
246  }
247  }
248 
249  // media item parameter
250  if ($a_entity == "mob_mi_parameter") {
251  switch ($a_version) {
252  case "4.1.0":
253  case "4.3.0":
254  case "5.1.0":
255  $this->getDirectDataFromQuery("SELECT med_item_id mi_id, name, value" .
256  " FROM mob_parameter " .
257  " WHERE " .
258  $ilDB->in("med_item_id", $a_ids, false, "integer"));
259  break;
260  }
261  }
262  }
static _lookupObjId(int $ref_id)
static _lookupImportId(int $obj_id)
$ref_id
Definition: ltiauth.php:67
ilDBInterface $db
static _lookupTitle(int $obj_id)
static _lookupDescription(int $obj_id)
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 ...
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
static _lookupType(int $id, bool $reference=false)
static insertInstIntoID(string $a_value)
inserts installation id into ILIAS id
$r
+ Here is the call graph for this function:

◆ setUsePreviousImportIds()

ilMediaObjectDataSet::setUsePreviousImportIds ( bool  $a_val)

Set use previous import ids.

Parameters
bool$a_valuse previous import ids

Definition at line 48 of file class.ilMediaObjectDataSet.php.

48  : void
49  {
50  $this->use_previous_import_ids = $a_val;
51  }

Field Documentation

◆ $current_media_item

ilMediaItem ilMediaObjectDataSet::$current_media_item
protected

Definition at line 32 of file class.ilMediaObjectDataSet.php.

Referenced by importRecord().

◆ $current_mob

ilObjMediaObject ilMediaObjectDataSet::$current_mob
protected

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

Referenced by importRecord().

◆ $mob_log

ilLogger ilMediaObjectDataSet::$mob_log
protected

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

◆ $use_previous_import_ids

bool ilMediaObjectDataSet::$use_previous_import_ids = false
protected

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

Referenced by getUsePreviousImportIds().


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