ILIAS  release_8 Revision v8.24
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)
 Read data from DB. More...
 
 getXmlRecord (string $a_entity, string $a_version, array $a_set)
 Get xml record for version. 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)
 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
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:

  • 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 ( )

Reimplemented from ilDataSet.

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

38 {
40 $this->mob_log = ilLoggerFactory::getLogger('mob');
41 }
static getLogger(string $a_component_id)
Get component logger.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc

References ILIAS\GlobalScreen\Provider\__construct(), and ilLoggerFactory\getLogger().

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

Reimplemented from ilDataSet.

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

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

◆ getSupportedVersions()

ilMediaObjectDataSet::getSupportedVersions ( )
Returns
string[]

Reimplemented from ilDataSet.

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

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 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
120 // map areas
121 if ($a_entity == "mob_mi_map_area") {
122 switch ($a_version) {
123 case "4.1.0":
124 case "4.3.0":
125 case "5.1.0":
126 return array(
127 "MiId" => "integer",
128 "Nr" => "integer",
129 "Shape" => "text",
130 "Coords" => "text",
131 "LinkType" => "text",
132 "Title" => "text",
133 "Href" => "text",
134 "Target" => "text",
135 "Type" => "text",
136 "TargetFrame" => "text",
137 "HighlightMode" => "text",
138 "HighlightText" => "text"
139 );
140 }
141 }
142
143 // media item parameter
144 if ($a_entity == "mob_mi_parameter") {
145 switch ($a_version) {
146 case "4.1.0":
147 case "4.3.0":
148 case "5.1.0":
149 return array(
150 "MiId" => "integer",
151 "Name" => "text",
152 "Value" => "text"
153 );
154 }
155 }
156 return [];
157 }

◆ getUsePreviousImportIds()

ilMediaObjectDataSet::getUsePreviousImportIds ( )

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

53 : bool
54 {
56 }

References $use_previous_import_ids.

◆ getXmlNamespace()

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

Reimplemented from ilDataSet.

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 
)

Get xml record for version.

Parameters
array$a_setabstract data record

Reimplemented from ilDataSet.

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

294 : array {
295 if ($a_entity == "mob") {
296 $dir = ilObjMediaObject::_getDirectory($a_set["Id"]);
297 if (!is_dir($dir)) {
299 }
300 $a_set["Dir"] = $dir;
301 }
302
303 return $a_set;
304 }
static makeDirParents(string $a_dir)
Create a new directory and all parent directories.
static _getDirectory(int $a_mob_id)
Get absolute directory.

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

+ 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 
)

Needs to be overwritten for import use case.

Reimplemented from ilDataSet.

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

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

References ilObjMediaObject\_createThumbnailDirectory(), ilObjMediaObject\_getDirectory(), ilImportMapping\addMapping(), ilImportMapping\getMapping(), ILIAS\Repository\int(), ilFileUtils\rCopy(), ilObjMediaObject\renameExecutables(), and ilMediaSvgSanitizer\sanitizeDir().

+ Here is the call graph for this function:

◆ readData()

ilMediaObjectDataSet::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 159 of file class.ilMediaObjectDataSet.php.

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

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

◆ $current_mob

ilObjMediaObject ilMediaObjectDataSet::$current_mob
protected

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

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