ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilMediaObjectDataSet Class Reference

Media Pool Data set class. More...

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

Public Member Functions

 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 = ""
 

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.

Member Function Documentation

◆ getDependencies()

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

Determine the dependent sets of data.

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

References array.

316  {
317  switch ($a_entity)
318  {
319  case "mob":
320  return array (
321  "mob_media_item" => array("ids" => $a_rec["Id"])
322  );
323 
324  case "mob_media_item":
325  return array (
326  "mob_mi_map_area" => array("ids" => $a_rec["Id"]),
327  "mob_mi_parameter" => array("ids" => $a_rec["Id"])
328  );
329  }
330  return false;
331  }
Create styles array
The data for the language used.

◆ getSupportedVersions()

ilMediaObjectDataSet::getSupportedVersions ( )

Get supported versions.

Parameters

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

References array.

50  {
51  return array("5.1.0", "4.3.0", "4.1.0");
52  }
Create styles array
The data for the language used.

◆ getTypes()

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

Get field types for entity.

Parameters

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

References array.

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

◆ getUsePreviousImportIds()

ilMediaObjectDataSet::getUsePreviousImportIds ( )

Get use previous import ids.

Returns
bool use previous import ids

Definition at line 38 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 60 of file class.ilMediaObjectDataSet.php.

61  {
62  return "http://www.ilias.de/xml/Services/MediaObject/".$a_entity;
63  }

◆ getXmlRecord()

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

Get xml record.

Parameters

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

References ilObjMediaObject\_getDirectory().

340  {
341  if ($a_entity == "mob")
342  {
343  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
344  $dir = ilObjMediaObject::_getDirectory($a_set["Id"]);
345  $a_set["Dir"] = $dir;
346  }
347 
348  return $a_set;
349  }
static _getDirectory($a_mob_id)
get directory for files of media object (static)
+ 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 357 of file class.ilMediaObjectDataSet.php.

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

358  {
359 //echo $a_entity;
360 //var_dump($a_rec);
361 
362  switch ($a_entity)
363  {
364  case "mob":
365 
366 //var_dump($a_rec);
367 
368  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
369  $newObj = new ilObjMediaObject();
370  $newObj->setType("mob");
371  $newObj->setTitle($a_rec["Title"]);
372  $newObj->setDescription($a_rec["Description"]);
373  // on translation re-import we are interested in the "previous" import id
374  if ($this->getUsePreviousImportIds())
375  {
376  $newObj->setImportId($a_rec["ImportId"]);
377  }
378  else
379  {
380  $newObj->setImportId("il_".$this->getCurrentInstallationId()."_mob_".$a_rec["Id"]);
381  }
382  $newObj->create();
383  $newObj->createDirectory();
385  $this->current_mob = $newObj;
386 
387  $dir = str_replace("..", "", $a_rec["Dir"]);
388  if ($dir != "" && $this->getImportDirectory() != "")
389  {
390  $source_dir = $this->getImportDirectory()."/".$dir;
391  $target_dir = $dir = ilObjMediaObject::_getDirectory($newObj->getId());
392  ilUtil::rCopy($source_dir, $target_dir);
394  include_once("./Services/MediaObjects/classes/class.ilMediaSvgSanitizer.php");
395  ilMediaSvgSanitizer::sanitizeDir($target_dir); // see #20339
396  }
397 
398  $a_mapping->addMapping("Services/MediaObjects", "mob", $a_rec["Id"], $newObj->getId());
399 //echo "<br>++add++"."0:".$a_rec["Id"].":mob+0:".$newObj->getId().":mob"."+";
400  $a_mapping->addMapping("Services/MetaData", "md",
401  "0:".$a_rec["Id"].":mob", "0:".$newObj->getId().":mob");
402  break;
403 
404  case "mob_media_item":
405 
406  // determine parent mob
407  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
408  $mob_id = (int) $a_mapping->getMapping("Services/MediaObjects", "mob", $a_rec["MobId"]);
409  if (is_object($this->current_mob) && $this->current_mob->getId() == $mob_id)
410  {
411  $mob = $this->current_mob;
412  }
413  else
414  {
415  $mob = new ilObjMediaObject($mob_id);
416  }
417 
418  include_once("./Services/MediaObjects/classes/class.ilMediaItem.php");
419  $newObj = new ilMediaItem();
420  $newObj->setMobId($mob_id);
421  $newObj->setWidth($a_rec["Width"]);
422  $newObj->setHeight($a_rec["Height"]);
423  $newObj->setCaption($a_rec["Caption"]);
424  $newObj->setNr($a_rec["Nr"]);
425  $newObj->setPurpose($a_rec["Purpose"]);
426  $newObj->setLocation($a_rec["Location"]);
427  $newObj->setLocationType($a_rec["LocationType"]);
428  $newObj->setFormat($a_rec["Format"]);
429  $newObj->setTextRepresentation($a_rec["TextRepresentation"]);
430  $newObj->create();
431  $this->current_media_item = $newObj;
432 
433  $a_mapping->addMapping("Services/MediaObjects", "mob_media_item", $a_rec["Id"], $newObj->getId());
434 
435  break;
436 
437  case "mob_mi_parameter":
438 
439  // get media item
440  include_once("./Services/MediaObjects/classes/class.ilMediaItem.php");
441  $med_id = (int) $a_mapping->getMapping("Services/MediaObjects", "mob_media_item", $a_rec["MiId"]);
442  if (is_object($this->current_media_item) && $this->current_media_item->getId() == $med_id)
443  {
444  $med = $this->current_media_item;
445  }
446  else
447  {
448  $med = new ilMediaItem($med_id);
449  }
450  $med->writeParameter($a_rec["Name"], $a_rec["Value"]);
451 
452  break;
453 
454  case "mob_mi_map_area":
455  // get media item
456  include_once("./Services/MediaObjects/classes/class.ilMediaItem.php");
457  $med_id = (int) $a_mapping->getMapping("Services/MediaObjects", "mob_media_item", $a_rec["MiId"]);
458  if (is_object($this->current_media_item) && $this->current_media_item->getId() == $med_id)
459  {
460  $med = $this->current_media_item;
461  }
462  else
463  {
464  $med = new ilMediaItem($med_id);
465  }
466 
467  include_once("./Services/MediaObjects/classes/class.ilMapArea.php");
468  $map_area = new ilMapArea();
469  $map_area->setItemId($med_id);
470  $map_area->setNr($a_rec["Nr"]);
471  $map_area->setShape($a_rec["Shape"]);
472  $map_area->setCoords($a_rec["Coords"]);
473  $map_area->setLinkType($a_rec["LinkType"]);
474  $map_area->setTitle($a_rec["Title"]);
475  $map_area->setHref($a_rec["Href"]);
476  $map_area->setTarget($a_rec["Target"]);
477  $map_area->setType($a_rec["Type"]);
478  $map_area->setTargetFrame($a_rec["TargetFrame"]);
479  $map_area->setHighlightMode($a_rec["HighlightMode"]);
480  $map_area->setHighlightClass($a_rec["HighlightClass"]);
481  $map_area->create();
482 
483  break;
484  }
485  }
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 directory for files of media object (static)
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 186 of file class.ilMediaObjectDataSet.php.

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

187  {
188  global $ilDB;
189 
190  if (!is_array($a_ids))
191  {
192  $a_ids = array($a_ids);
193  }
194 
195  // mob
196  if ($a_entity == "mob")
197  {
198  $this->data = array();
199 
200  switch ($a_version)
201  {
202  case "4.1.0":
203  case "4.3.0":
204  foreach ($a_ids as $mob_id)
205  {
206  if (ilObject::_lookupType($mob_id) == "mob")
207  {
208  $this->data[] = array ("Id" => $mob_id,
209  "Title" => ilObject::_lookupTitle($mob_id),
210  "Description" => ilObject::_lookupDescription($mob_id)
211  );
212  }
213  }
214  break;
215 
216  case "5.1.0":
217  foreach ($a_ids as $mob_id)
218  {
219  if (ilObject::_lookupType($mob_id) == "mob")
220  {
221  $this->data[] = array ("Id" => $mob_id,
222  "Title" => ilObject::_lookupTitle($mob_id),
223  "Description" => ilObject::_lookupDescription($mob_id),
224  "ImportId" => ilObject::_lookupImportId($mob_id)
225  );
226  }
227  }
228  break;
229  }
230  }
231 
232  // media item
233  if ($a_entity == "mob_media_item")
234  {
235  switch ($a_version)
236  {
237  case "4.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  case "4.3.0":
245  case "5.1.0":
246  $this->getDirectDataFromQuery("SELECT id, mob_id, width, height, halign,".
247  "caption, nr, purpose, location, location_type, format, text_representation".
248  " FROM media_item WHERE ".
249  $ilDB->in("mob_id", $a_ids, false, "integer"));
250  break;
251  }
252  }
253 
254 
255  // media item map area
256  if ($a_entity == "mob_mi_map_area")
257  {
258  switch ($a_version)
259  {
260  case "4.1.0":
261  case "4.3.0":
262  case "5.1.0":
263  foreach ($this->getDirectDataFromQuery("SELECT item_id mi_id, nr".
264  " ,shape, coords, link_type, title, href, target, type, target_frame, ".
265  " highlight_mode, highlight_class".
266  " FROM map_area ".
267  " WHERE ".
268  $ilDB->in("item_id", $a_ids, false, "integer").
269  " ORDER BY nr", true, false) as $r)
270  {
271  $r["Target"] = ilUtil::insertInstIntoID($r["Target"]);
272 
273  // see ilPageObject::insertInstIntoIDs
274  if ($r["Type"] == "RepositoryItem")
275  {
276  $id_arr = explode("_", $r["Target"]);
277  $ref_id = $id_arr[3];
278  $obj_id = ilObject::_lookupObjId($id_arr[3]);
279 
280  $otype = ilObject::_lookupType($obj_id);
281  if ($obj_id > 0)
282  {
283  $id = $otype."_".$obj_id."_".$ref_id;
284  $r["Target"] = "il_".$id_arr[1]."_".$id;
285  }
286  }
287 
288  $this->data[] = $r;
289  }
290  break;
291  }
292  }
293 
294  // media item parameter
295  if ($a_entity == "mob_mi_parameter")
296  {
297  switch ($a_version)
298  {
299  case "4.1.0":
300  case "4.3.0":
301  case "5.1.0":
302  $this->getDirectDataFromQuery("SELECT med_item_id mi_id, name, value".
303  " FROM mob_parameter ".
304  " WHERE ".
305  $ilDB->in("med_item_id", $a_ids, false, "integer"));
306  break;
307  }
308  }
309 
310  }
Add some data
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 ...
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)
Create styles array
The data for the language used.
static _lookupType($a_id, $a_reference=false)
lookup object type
$ref_id
Definition: sahs_server.php:39
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 28 of file class.ilMediaObjectDataSet.php.

29  {
30  $this->use_previous_import_ids = $a_val;
31  }

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: