ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilMediaObjectDataSet Class Reference

Media Pool Data set class. More...

+ Inheritance diagram for ilMediaObjectDataSet:
+ Collaboration diagram for ilMediaObjectDataSet:

Public Member Functions

 __construct ()
 Constructor. More...
 
 setUsePreviousImportIds ($a_val)
 Set use previous import ids. More...
 
 getUsePreviousImportIds ()
 Get use previous import ids. More...
 
 getSupportedVersions ()
 Get supported versions. More...
 
 getXmlNamespace ($a_entity, $a_schema_version)
 Get xml namespace. More...
 
 readData ($a_entity, $a_version, $a_ids, $a_field="")
 Read data. More...
 
 getXmlRecord ($a_entity, $a_version, $a_set)
 Get xml record. More...
 
 importRecord ($a_entity, $a_types, $a_rec, $a_mapping, $a_schema_version)
 Import record. More...
 
- Public Member Functions inherited from ilDataSet
 __construct ()
 Constructor. More...
 
 init ($a_entity, $a_schema_version)
 Init. More...
 
 getSupportedVersions ()
 Get supported version. More...
 
 readData ($a_entity, $a_version, $a_ids)
 Read data from DB. More...
 
 setExportDirectories ($a_relative, $a_absolute)
 Set export directories. More...
 
 setImportDirectory ($a_val)
 Set import directory. More...
 
 getImportDirectory ()
 Get import directory. More...
 
 setDSPrefix ($a_val)
 Set XML dataset namespace prefix. More...
 
 getDSPrefix ()
 Get XML dataset namespace prefix. More...
 
 getDSPrefixString ()
 
 getDirectDataFromQuery ($a_query, $a_convert_to_leading_upper=true, $a_set=true)
 Get data from query.This is a standard procedure, all db field names are directly mapped to abstract fields. More...
 
 convertToLeadingUpper ($a_str)
 Make xyz_abc a XyzAbc string. More...
 
 getJsonRepresentation ()
 Get json representation. More...
 
 getXmlRepresentation ( $a_entity, $a_schema_version, $a_ids, $a_field="", $a_omit_header=false, $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 ($a_writer, $a_prefixes, $a_entity, $a_schema_version, $a_ids, $a_field="")
 Add records xml. More...
 
 afterXmlRecordWriting ($a_entity, $a_version, $a_set)
 After xml record writing hook record. More...
 
 getNamespaces (&$namespaces, $a_entity, $a_schema_version)
 Get xml namespaces. More...
 
 getXmlRecord ($a_entity, $a_version, $a_set)
 Get xml record for version. More...
 
 getJsonRecord ($a_set)
 Get json record for version. More...
 
 getXmlTypes ($a_entity, $a_version)
 Get xml types. More...
 
 getJsonTypes ($a_entity, $a_version)
 Get json types. More...
 
 getXMLEntityName ($a_entity, $a_version)
 Get entity name for xml (may be overwritten) More...
 
 getXMLEntityTag ($a_entity, $a_schema_version)
 Get entity tag. More...
 
 getJsonEntityName ($a_entity, $a_version)
 Get entity name for json (may be overwritten) More...
 
 setImport ($a_val)
 Set import object. More...
 
 getImport ()
 Get import object. More...
 
 setCurrentInstallationId ($a_val)
 Set current installation id. More...
 
 getCurrentInstallationId ()
 Get current installation id. More...
 

Protected Member Functions

 getTypes ($a_entity, $a_version)
 Get field types for entity. More...
 
 getDependencies ($a_entity, $a_version, $a_rec, $a_ids)
 Determine the dependent sets of data. More...
 
- Protected Member Functions inherited from ilDataSet
 getTypes ($a_entity, $a_version)
 Get (abstract) types for (abstract) field names. More...
 
 getXmlNamespace ($a_entity, $a_schema_version)
 Get xml namespace. More...
 
 createObjectExportId ($a_type, $a_id)
 Build ilias export id. More...
 
 parseObjectExportId ($a_id, $a_fallback_id=null)
 Parse export id. More...
 

Protected Attributes

 $use_previous_import_ids = false
 
- Protected Attributes inherited from ilDataSet
 $current_installation_id = ""
 
 $db
 
 $ds_log
 

Additional Inherited Members

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

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
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

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

Constructor & Destructor Documentation

◆ __construct()

ilMediaObjectDataSet::__construct ( )

Constructor.

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

References ilLoggerFactory\getLogger().

27  {
28  parent::__construct();
29  $this->mob_log = ilLoggerFactory::getLogger('mob');
30  }
static getLogger($a_component_id)
Get component logger.
+ Here is the call graph for this function:

Member Function Documentation

◆ getDependencies()

ilMediaObjectDataSet::getDependencies (   $a_entity,
  $a_version,
  $a_rec,
  $a_ids 
)
protected

Determine the dependent sets of data.

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

300  {
301  switch ($a_entity) {
302  case "mob":
303  return array(
304  "mob_media_item" => array("ids" => $a_rec["Id"])
305  );
306 
307  case "mob_media_item":
308  return array(
309  "mob_mi_map_area" => array("ids" => $a_rec["Id"]),
310  "mob_mi_parameter" => array("ids" => $a_rec["Id"])
311  );
312  }
313  return false;
314  }

◆ getSupportedVersions()

ilMediaObjectDataSet::getSupportedVersions ( )

Get supported versions.

Parameters

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

59  {
60  return array("5.1.0", "4.3.0", "4.1.0");
61  }

◆ getTypes()

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

Get field types for entity.

Parameters

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

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

◆ getUsePreviousImportIds()

ilMediaObjectDataSet::getUsePreviousImportIds ( )

Get use previous import ids.

Returns
bool use previous import ids

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

References $use_previous_import_ids.

Referenced by importRecord().

+ Here is the caller graph for this function:

◆ getXmlNamespace()

ilMediaObjectDataSet::getXmlNamespace (   $a_entity,
  $a_schema_version 
)

Get xml namespace.

Parameters

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

70  {
71  return "http://www.ilias.de/xml/Services/MediaObject/" . $a_entity;
72  }

◆ getXmlRecord()

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

Get xml record.

Parameters

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

References ilObjMediaObject\_getDirectory().

323  {
324  if ($a_entity == "mob") {
325  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
326  $dir = ilObjMediaObject::_getDirectory($a_set["Id"]);
327  $a_set["Dir"] = $dir;
328  }
329 
330  return $a_set;
331  }
static _getDirectory($a_mob_id)
Get absolute directory.
+ Here is the call graph for this function:

◆ importRecord()

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

Import record.

Parameters

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

References ilObjMediaObject\_createThumbnailDirectory(), ilObjMediaObject\_getDirectory(), ilDataSet\getCurrentInstallationId(), ilDataSet\getImportDirectory(), getUsePreviousImportIds(), ilUtil\rCopy(), ilObjMediaObject\renameExecutables(), and ilMediaSvgSanitizer\sanitizeDir().

340  {
341  //echo $a_entity;
342  //var_dump($a_rec);
343 
344  switch ($a_entity) {
345  case "mob":
346 
347 //var_dump($a_rec);
348 
349  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
350  $newObj = new ilObjMediaObject();
351  $newObj->setType("mob");
352  $newObj->setTitle($a_rec["Title"]);
353  $newObj->setDescription($a_rec["Description"]);
354  // on translation re-import we are interested in the "previous" import id
355  if ($this->getUsePreviousImportIds()) {
356  $newObj->setImportId($a_rec["ImportId"]);
357  } else {
358  $newObj->setImportId("il_" . $this->getCurrentInstallationId() . "_mob_" . $a_rec["Id"]);
359  }
360  $newObj->create();
361  $newObj->createDirectory();
363  $this->current_mob = $newObj;
364 
365  $dir = str_replace("..", "", $a_rec["Dir"]);
366  if ($dir != "" && $this->getImportDirectory() != "") {
367  $source_dir = $this->getImportDirectory() . "/" . $dir;
368  $target_dir = $dir = ilObjMediaObject::_getDirectory($newObj->getId());
369  $this->mob_log->debug("s:-$source_dir-,t:-$target_dir-");
370  ilUtil::rCopy($source_dir, $target_dir);
372  include_once("./Services/MediaObjects/classes/class.ilMediaSvgSanitizer.php");
373  ilMediaSvgSanitizer::sanitizeDir($target_dir); // see #20339
374  }
375 
376  $a_mapping->addMapping("Services/MediaObjects", "mob", $a_rec["Id"], $newObj->getId());
377 //echo "<br>++add++"."0:".$a_rec["Id"].":mob+0:".$newObj->getId().":mob"."+";
378  $a_mapping->addMapping(
379  "Services/MetaData",
380  "md",
381  "0:" . $a_rec["Id"] . ":mob",
382  "0:" . $newObj->getId() . ":mob"
383  );
384  break;
385 
386  case "mob_media_item":
387 
388  // determine parent mob
389  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
390  $mob_id = (int) $a_mapping->getMapping("Services/MediaObjects", "mob", $a_rec["MobId"]);
391  if (is_object($this->current_mob) && $this->current_mob->getId() == $mob_id) {
392  $mob = $this->current_mob;
393  } else {
394  $mob = new ilObjMediaObject($mob_id);
395  }
396 
397  include_once("./Services/MediaObjects/classes/class.ilMediaItem.php");
398  $newObj = new ilMediaItem();
399  $newObj->setMobId($mob_id);
400  $newObj->setWidth($a_rec["Width"]);
401  $newObj->setHeight($a_rec["Height"]);
402  $newObj->setCaption($a_rec["Caption"]);
403  $newObj->setNr($a_rec["Nr"]);
404  $newObj->setPurpose($a_rec["Purpose"]);
405  $newObj->setLocation($a_rec["Location"]);
406  $newObj->setLocationType($a_rec["LocationType"]);
407  $newObj->setFormat($a_rec["Format"]);
408  $newObj->setTextRepresentation($a_rec["TextRepresentation"]);
409  $newObj->create();
410  $this->current_media_item = $newObj;
411 
412  $a_mapping->addMapping("Services/MediaObjects", "mob_media_item", $a_rec["Id"], $newObj->getId());
413 
414  break;
415 
416  case "mob_mi_parameter":
417 
418  // get media item
419  include_once("./Services/MediaObjects/classes/class.ilMediaItem.php");
420  $med_id = (int) $a_mapping->getMapping("Services/MediaObjects", "mob_media_item", $a_rec["MiId"]);
421  if (is_object($this->current_media_item) && $this->current_media_item->getId() == $med_id) {
422  $med = $this->current_media_item;
423  } else {
424  $med = new ilMediaItem($med_id);
425  }
426  $med->writeParameter($a_rec["Name"], $a_rec["Value"]);
427 
428  break;
429 
430  case "mob_mi_map_area":
431  // get media item
432  include_once("./Services/MediaObjects/classes/class.ilMediaItem.php");
433  $med_id = (int) $a_mapping->getMapping("Services/MediaObjects", "mob_media_item", $a_rec["MiId"]);
434  if (is_object($this->current_media_item) && $this->current_media_item->getId() == $med_id) {
435  $med = $this->current_media_item;
436  } else {
437  $med = new ilMediaItem($med_id);
438  }
439 
440  include_once("./Services/MediaObjects/classes/class.ilMapArea.php");
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 
456  break;
457  }
458  }
static rCopy($a_sdir, $a_tdir, $preserveTimeAttributes=false)
Copies content of a directory $a_sdir recursively to a directory $a_tdir.
static sanitizeDir($a_path)
Sanitize directory recursively.
getImportDirectory()
Get import directory.
static _getDirectory($a_mob_id)
Get absolute directory.
static renameExecutables($a_dir)
Rename executables.
Class ilMediaItem.
Class ilObjMediaObject.
getCurrentInstallationId()
Get current installation id.
getUsePreviousImportIds()
Get use previous import ids.
static _createThumbnailDirectory($a_obj_id)
Create thumbnail directory.
Class ilMapArea.
+ Here is the call graph for this function:

◆ readData()

ilMediaObjectDataSet::readData (   $a_entity,
  $a_version,
  $a_ids,
  $a_field = "" 
)

Read data.

Parameters

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

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

188  {
189  $ilDB = $this->db;
190 
191  if (!is_array($a_ids)) {
192  $a_ids = array($a_ids);
193  }
194 
195  // mob
196  if ($a_entity == "mob") {
197  $this->data = array();
198 
199  switch ($a_version) {
200  case "4.1.0":
201  case "4.3.0":
202  foreach ($a_ids as $mob_id) {
203  if (ilObject::_lookupType($mob_id) == "mob") {
204  $this->data[] = array("Id" => $mob_id,
205  "Title" => ilObject::_lookupTitle($mob_id),
206  "Description" => ilObject::_lookupDescription($mob_id)
207  );
208  }
209  }
210  break;
211 
212  case "5.1.0":
213  foreach ($a_ids as $mob_id) {
214  if (ilObject::_lookupType($mob_id) == "mob") {
215  $this->data[] = array("Id" => $mob_id,
216  "Title" => ilObject::_lookupTitle($mob_id),
217  "Description" => ilObject::_lookupDescription($mob_id),
218  "ImportId" => ilObject::_lookupImportId($mob_id)
219  );
220  }
221  }
222  break;
223  }
224  }
225 
226  // media item
227  if ($a_entity == "mob_media_item") {
228  switch ($a_version) {
229  case "4.1.0":
230  $this->getDirectDataFromQuery("SELECT id, mob_id, width, height, halign," .
231  "caption, nr, purpose, location, location_type, format, text_representation" .
232  " FROM media_item WHERE " .
233  $ilDB->in("mob_id", $a_ids, false, "integer"));
234  break;
235 
236  case "4.3.0":
237  case "5.1.0":
238  $this->getDirectDataFromQuery("SELECT id, mob_id, width, height, halign," .
239  "caption, nr, purpose, location, location_type, format, text_representation" .
240  " FROM media_item WHERE " .
241  $ilDB->in("mob_id", $a_ids, false, "integer"));
242  break;
243  }
244  }
245 
246 
247  // media item map area
248  if ($a_entity == "mob_mi_map_area") {
249  switch ($a_version) {
250  case "4.1.0":
251  case "4.3.0":
252  case "5.1.0":
253  foreach ($this->getDirectDataFromQuery("SELECT item_id mi_id, nr" .
254  " ,shape, coords, link_type, title, href, target, type, target_frame, " .
255  " highlight_mode, highlight_class" .
256  " FROM map_area " .
257  " WHERE " .
258  $ilDB->in("item_id", $a_ids, false, "integer") .
259  " ORDER BY nr", true, false) as $r) {
260  $r["Target"] = ilUtil::insertInstIntoID($r["Target"]);
261 
262  // see ilPageObject::insertInstIntoIDs
263  if ($r["Type"] == "RepositoryItem") {
264  $id_arr = explode("_", $r["Target"]);
265  $ref_id = $id_arr[3];
266  $obj_id = ilObject::_lookupObjId($id_arr[3]);
267 
268  $otype = ilObject::_lookupType($obj_id);
269  if ($obj_id > 0) {
270  $id = $otype . "_" . $obj_id . "_" . $ref_id;
271  $r["Target"] = "il_" . $id_arr[1] . "_" . $id;
272  }
273  }
274 
275  $this->data[] = $r;
276  }
277  break;
278  }
279  }
280 
281  // media item parameter
282  if ($a_entity == "mob_mi_parameter") {
283  switch ($a_version) {
284  case "4.1.0":
285  case "4.3.0":
286  case "5.1.0":
287  $this->getDirectDataFromQuery("SELECT med_item_id mi_id, name, value" .
288  " FROM mob_parameter " .
289  " WHERE " .
290  $ilDB->in("med_item_id", $a_ids, false, "integer"));
291  break;
292  }
293  }
294  }
getDirectDataFromQuery($a_query, $a_convert_to_leading_upper=true, $a_set=true)
Get data from query.This is a standard procedure, all db field names are directly mapped to abstract ...
if(!array_key_exists('StateId', $_REQUEST)) $id
static _lookupTitle($a_id)
lookup object title
$r
Definition: example_031.php:79
static _lookupDescription($a_id)
lookup object description
static _lookupObjId($a_id)
static _lookupImportId($a_obj_id)
static _lookupType($a_id, $a_reference=false)
lookup object type
$this data['403_header']
global $ilDB
static insertInstIntoID($a_value)
inserts installation id into ILIAS id
+ Here is the call graph for this function:

◆ setUsePreviousImportIds()

ilMediaObjectDataSet::setUsePreviousImportIds (   $a_val)

Set use previous import ids.

Parameters
bool$a_valuse previous import ids

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

38  {
39  $this->use_previous_import_ids = $a_val;
40  }

Field Documentation

◆ $use_previous_import_ids

ilMediaObjectDataSet::$use_previous_import_ids = false
protected

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

Referenced by getUsePreviousImportIds().


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