ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilMediaObjectDataSet Class Reference

Media Pool Data set class. 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)
 
 getContainerExportConfig (array $record, string $entity, string $schema_version, string $field, string $value)
 
 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)
 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)
 
 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

ILIAS MediaObjects MediaObjectManager $media_manager
 
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 $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

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

Constructor & Destructor Documentation

◆ __construct()

ilMediaObjectDataSet::__construct ( )

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

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

41  {
42  global $DIC;
43 
45  $this->mob_log = ilLoggerFactory::getLogger('mob');
46  $this->media_manager = $DIC->mediaObjects()->internal()->domain()->mediaObject();
47  }
static getLogger(string $a_component_id)
Get component logger.
global $DIC
Definition: shib_login.php:22
__construct(Container $dic, ilPlugin $plugin)
+ Here is the call graph for this function:

Member Function Documentation

◆ getContainerExportConfig()

ilMediaObjectDataSet::getContainerExportConfig ( array  $record,
string  $entity,
string  $schema_version,
string  $field,
string  $value 
)

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

References $container, ilDataSet\getIRSSContainerExportConfig(), and null.

327  if ($entity === "mob" && $field === "MediaContainer") {
328  $rid = $this->media_manager->getContainerResourceId((int) $record["Id"]);
329  if ($rid) {
330  $container = $this->irss->manageContainer()->getResource($rid);
331  return
333  $container,
334  ""
335  );
336  }
337  }
338  return null;
339  }
getIRSSContainerExportConfig(StorableResource $source_container, string $source_path, string $target_path="")
$container
Definition: wac.php:36
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
string $entity
+ Here is the call graph for this function:

◆ 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 286 of file class.ilMediaObjectDataSet.php.

References null.

291  : array {
292  switch ($a_entity) {
293  case "mob":
294  return array(
295  "mob_media_item" => array("ids" => $a_rec["Id"] ?? null)
296  );
297 
298  case "mob_media_item":
299  return array(
300  "mob_mi_map_area" => array("ids" => $a_rec["Id"] ?? null),
301  "mob_mi_parameter" => array("ids" => $a_rec["Id"] ?? null)
302  );
303  }
304  return [];
305  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null

◆ getSupportedVersions()

ilMediaObjectDataSet::getSupportedVersions ( )
Returns
string[]

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

67  : array
68  {
69  return array("10.0", "5.1.0", "4.3.0", "4.1.0");
70  }

◆ getTypes()

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

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

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

◆ getUsePreviousImportIds()

ilMediaObjectDataSet::getUsePreviousImportIds ( )

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

References $use_previous_import_ids.

Referenced by importRecord().

59  : bool
60  {
62  }
+ Here is the caller graph for this function:

◆ getXmlNamespace()

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

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

72  : string
73  {
74  return "https://www.ilias.de/xml/Services/MediaObject/" . $a_entity;
75  }

◆ getXmlRecord()

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

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

311  : array {
312 
313  if ($a_entity === "mob") {
314  $a_set["MediaContainer"] = serialize($this->media_manager->getContainerResourceId((int) $a_set["Id"]));
315  }
316 
317  return $a_set;
318  }

◆ importRecord()

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

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

References $current_media_item, $current_mob, ilImportMapping\addMapping(), ilDataSet\getCurrentInstallationId(), ilDataSet\getImportDirectory(), ilImportMapping\getMapping(), getUsePreviousImportIds(), ILIAS\Repository\int(), and ilDataSet\stripTags().

348  : void {
349  $a_rec = $this->stripTags($a_rec);
350  switch ($a_entity) {
351  case "mob":
352 
353  $newObj = new ilObjMediaObject();
354  $newObj->setType("mob");
355  $newObj->setTitle($a_rec["Title"]);
356  $newObj->setDescription($a_rec["Description"]);
357  // on translation re-import we are interested in the "previous" import id
358  if ($this->getUsePreviousImportIds()) {
359  $newObj->setImportId($a_rec["ImportId"]);
360  } else {
361  $newObj->setImportId("il_" . $this->getCurrentInstallationId() . "_mob_" . $a_rec["Id"]);
362  }
363  $newObj->create();
364  $this->current_mob = $newObj;
365 
366  // up to 9
367  $dir = str_replace("..", "", ($a_rec["Dir"] ?? ""));
368  if ($dir != "" && $this->getImportDirectory() != "") {
369  $source_dir = $this->getImportDirectory() . "/" . $dir;
370  $this->media_manager->addLocalDirectory($newObj->getId(), $source_dir);
371  }
372 
373  // from 10
374  $dir = str_replace("..", "", ($a_rec["MediaContainer"] ?? ""));
375  if ($dir != "" && $this->getImportDirectory() != "") {
376  $source_dir = $this->getImportDirectory() . "/" . $dir;
377  if (is_dir($source_dir)) {
378  $this->media_manager->addLocalDirectory($newObj->getId(), $source_dir);
379  }
380  }
381 
382  $a_mapping->addMapping("components/ILIAS/MediaObjects", "mob", $a_rec["Id"], $newObj->getId());
383  $a_mapping->addMapping(
384  "components/ILIAS/MetaData",
385  "md",
386  "0:" . $a_rec["Id"] . ":mob",
387  "0:" . $newObj->getId() . ":mob"
388  );
389  break;
390 
391  case "mob_media_item":
392 
393  // determine parent mob
394  $mob_id = (int) $a_mapping->getMapping("components/ILIAS/MediaObjects", "mob", $a_rec["MobId"]);
395  if (is_object($this->current_mob) && $this->current_mob->getId() == $mob_id) {
396  $mob = $this->current_mob;
397  } else {
398  $mob = new ilObjMediaObject($mob_id);
399  }
400 
401  $newObj = new ilMediaItem();
402  $newObj->setMobId($mob_id);
403  $newObj->setWidth($a_rec["Width"]);
404  $newObj->setHeight($a_rec["Height"]);
405  $newObj->setCaption($a_rec["Caption"]);
406  $newObj->setNr($a_rec["Nr"]);
407  $newObj->setPurpose($a_rec["Purpose"]);
408  $newObj->setLocation($a_rec["Location"]);
409  $newObj->setLocationType($a_rec["LocationType"]);
410  $newObj->setFormat($a_rec["Format"]);
411  $newObj->setTextRepresentation($a_rec["TextRepresentation"]);
412  $newObj->create();
413  $this->current_media_item = $newObj;
414 
415  $a_mapping->addMapping("components/ILIAS/MediaObjects", "mob_media_item", $a_rec["Id"], $newObj->getId());
416 
417  break;
418 
419  case "mob_mi_parameter":
420 
421  // get media item
422  $med_id = (int) $a_mapping->getMapping("components/ILIAS/MediaObjects", "mob_media_item", $a_rec["MiId"]);
423  if (is_object($this->current_media_item) && $this->current_media_item->getId() == $med_id) {
425  } else {
426  $med = new ilMediaItem($med_id);
427  }
428  $med->writeParameter($a_rec["Name"], $a_rec["Value"]);
429 
430  break;
431 
432  case "mob_mi_map_area":
433  // get media item
434  $med_id = (int) $a_mapping->getMapping("components/ILIAS/MediaObjects", "mob_media_item", $a_rec["MiId"]);
435  if (is_object($this->current_media_item) && $this->current_media_item->getId() == $med_id) {
437  } else {
438  $med = new ilMediaItem($med_id);
439  }
440 
441  $map_area = new ilMapArea();
442  $map_area->setItemId($med_id);
443  $map_area->setNr($a_rec["Nr"]);
444  $map_area->setShape($a_rec["Shape"]);
445  $map_area->setCoords($a_rec["Coords"]);
446  $map_area->setLinkType($a_rec["LinkType"]);
447  $map_area->setTitle($a_rec["Title"]);
448  $map_area->setHref($a_rec["Href"]);
449  $map_area->setTarget($a_rec["Target"]);
450  $map_area->setType($a_rec["Type"]);
451  $map_area->setTargetFrame($a_rec["TargetFrame"]);
452  $map_area->setHighlightMode($a_rec["HighlightMode"]);
453  $map_area->setHighlightClass($a_rec["HighlightClass"]);
454  $map_area->create();
455  break;
456  }
457  }
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 ilMediaItem Media Item, component of a media object (file or reference)
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 174 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().

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

54  : void
55  {
56  $this->use_previous_import_ids = $a_val;
57  }

Field Documentation

◆ $current_media_item

ilMediaItem ilMediaObjectDataSet::$current_media_item
protected

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

Referenced by importRecord().

◆ $current_mob

ilObjMediaObject ilMediaObjectDataSet::$current_mob
protected

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

Referenced by importRecord().

◆ $media_manager

ILIAS MediaObjects MediaObjectManager ilMediaObjectDataSet::$media_manager
protected

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

◆ $mob_log

ilLogger ilMediaObjectDataSet::$mob_log
protected

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

◆ $use_previous_import_ids

bool ilMediaObjectDataSet::$use_previous_import_ids = false
protected

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

Referenced by getUsePreviousImportIds().


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