ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilMediaPoolDataSet Class Reference

Media Pool Data set class. More...

+ Inheritance diagram for ilMediaPoolDataSet:
+ Collaboration diagram for ilMediaPoolDataSet:

Public Member Functions

 getSupportedVersions ()
 Get supported versions. More...
 
 getXmlNamespace ($a_entity, $a_schema_version)
 Get xml namespace. More...
 
 setMasterLanguageOnly ($a_val)
 Set master language only (export) More...
 
 getMasterLanguageOnly ()
 Get master language only (export) More...
 
 setTranslationImportMode ($a_lm, $a_lang="")
 Set translation import mode. More...
 
 getTranslationImportMode ()
 Get translation import mode. More...
 
 getTranslationLM ()
 Get translation lm (import. More...
 
 getTranslationLang ()
 Get translation language (import. More...
 
 readData ($a_entity, $a_version, $a_ids, $a_field="")
 Read data. 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

 $master_lang_only = false
 
 $transl_into = false
 
 $transl_into_lm = null
 
 $transl_lang = ""
 
- 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:

  • mep_data: data from table mep_data
  • mep_tree: data from a join on mep_tree and mep_item
Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 17 of file class.ilMediaPoolDataSet.php.

Member Function Documentation

◆ getDependencies()

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

Determine the dependent sets of data.

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

References array.

268  {
269  switch ($a_entity) {
270  case "mep":
271  return array(
272  "mep_tree" => array("ids" => $a_rec["Id"])
273  );
274  }
275  return false;
276  }
Create styles array
The data for the language used.

◆ getMasterLanguageOnly()

ilMediaPoolDataSet::getMasterLanguageOnly ( )

Get master language only (export)

Returns
bool export only master language

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

References $master_lang_only.

Referenced by readData().

+ Here is the caller graph for this function:

◆ getSupportedVersions()

ilMediaPoolDataSet::getSupportedVersions ( )

Get supported versions.

Parameters

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

References array.

31  {
32  return array("5.1.0", "4.1.0");
33  }
Create styles array
The data for the language used.

◆ getTranslationImportMode()

ilMediaPoolDataSet::getTranslationImportMode ( )

Get translation import mode.

Returns
bool check if translation import is activated

Definition at line 88 of file class.ilMediaPoolDataSet.php.

References $transl_into.

Referenced by importRecord().

+ Here is the caller graph for this function:

◆ getTranslationLang()

ilMediaPoolDataSet::getTranslationLang ( )

Get translation language (import.

Returns
string language

Definition at line 108 of file class.ilMediaPoolDataSet.php.

References $transl_lang.

109  {
110  return $this->transl_lang;
111  }

◆ getTranslationLM()

ilMediaPoolDataSet::getTranslationLM ( )

Get translation lm (import.

Returns
ilObjLearningModule learning module

Definition at line 98 of file class.ilMediaPoolDataSet.php.

References $transl_into_lm.

Referenced by importRecord().

99  {
100  return $this->transl_into_lm;
101  }
+ Here is the caller graph for this function:

◆ getTypes()

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

Get field types for entity.

Parameters

Definition at line 119 of file class.ilMediaPoolDataSet.php.

References array.

120  {
121  // mep
122  if ($a_entity == "mep") {
123  switch ($a_version) {
124  case "4.1.0":
125  return array(
126  "Id" => "integer",
127  "Title" => "text",
128  "Description" => "text",
129  "DefaultWidth" => "integer",
130  "DefaultHeight" => "integer");
131 
132  case "5.1.0":
133  return array(
134  "Id" => "integer",
135  "Title" => "text",
136  "Description" => "text",
137  "DefaultWidth" => "integer",
138  "DefaultHeight" => "integer",
139  "ForTranslation" => "integer"
140  );
141  }
142  }
143 
144  // mep_tree
145  if ($a_entity == "mep_tree") {
146  switch ($a_version) {
147  case "4.1.0":
148  case "5.1.0":
149  return array(
150  "MepId" => "integer",
151  "Child" => "integer",
152  "Parent" => "integer",
153  "Depth" => "integer",
154  "Type" => "text",
155  "Title" => "text",
156  "ForeignId" => "integer",
157  "ImportId" => "text"
158  );
159  }
160  }
161  }
Create styles array
The data for the language used.

◆ getXmlNamespace()

ilMediaPoolDataSet::getXmlNamespace (   $a_entity,
  $a_schema_version 
)

Get xml namespace.

Parameters

Definition at line 41 of file class.ilMediaPoolDataSet.php.

42  {
43  return "http://www.ilias.de/xml/Modules/MediaPool/" . $a_entity;
44  }

◆ importRecord()

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

Import record.

Parameters

Definition at line 289 of file class.ilMediaPoolDataSet.php.

References ilObjectFactory\getInstanceByObjId(), ilMediaPoolItem\getPoolForItemId(), getTranslationImportMode(), and getTranslationLM().

290  {
291  //echo $a_entity;
292  //var_dump($a_rec);
293 
294  switch ($a_entity) {
295  case "mep":
296 
297  if ($this->getTranslationImportMode()) {
298  return;
299  }
300 
301  include_once("./Modules/MediaPool/classes/class.ilObjMediaPool.php");
302 
303  if ($new_id = $a_mapping->getMapping('Services/Container', 'objs', $a_rec['Id'])) {
304  $newObj = ilObjectFactory::getInstanceByObjId($new_id, false);
305  } else {
306  $newObj = new ilObjMediaPool();
307  $newObj->setType("mep");
308  $newObj->create(true);
309  }
310 
311  $newObj->setTitle($a_rec["Title"]);
312  $newObj->setDescription($a_rec["Description"]);
313  $newObj->setDefaultWidth($a_rec["DefaultWidth"]);
314  $newObj->setDefaultHeight($a_rec["DefaultHeight"]);
315  $newObj->setForTranslation($a_rec["ForTranslation"]);
316  $newObj->update();
317 
318  $this->current_obj = $newObj;
319  $a_mapping->addMapping("Modules/MediaPool", "mep", $a_rec["Id"], $newObj->getId());
320  $a_mapping->addMapping("Services/Object", "obj", $a_rec["Id"], $newObj->getId());
321  break;
322 
323  case "mep_tree":
324  if (!$this->getTranslationImportMode()) {
325  switch ($a_rec["Type"]) {
326  case "fold":
327  $parent = (int) $a_mapping->getMapping("Modules/MediaPool", "mep_tree", $a_rec["Parent"]);
328  $fold_id =
329  $this->current_obj->createFolder($a_rec["Title"], $parent);
330  $a_mapping->addMapping(
331  "Modules/MediaPool",
332  "mep_tree",
333  $a_rec["Child"],
334  $fold_id
335  );
336  break;
337 
338  case "mob":
339  $parent = (int) $a_mapping->getMapping("Modules/MediaPool", "mep_tree", $a_rec["Parent"]);
340  $mob_id = (int) $a_mapping->getMapping("Services/MediaObjects", "mob", $a_rec["ForeignId"]);
341  $item = new ilMediaPoolItem();
342  $item->setType("mob");
343  $item->setForeignId($mob_id);
344  $item->setImportId($a_rec["ImportId"]);
345  $item->setTitle($a_rec["Title"]);
346  $item->create();
347  if ($item->getId() > 0) {
348  $this->current_obj->insertInTree($item->getId(), $parent);
349  }
350  break;
351 
352  case "pg":
353  $parent = (int) $a_mapping->getMapping("Modules/MediaPool", "mep_tree", $a_rec["Parent"]);
354 
355  $item = new ilMediaPoolItem();
356  $item->setType("pg");
357  $item->setTitle($a_rec["Title"]);
358  $item->setImportId($a_rec["ImportId"]);
359  $item->create();
360  $a_mapping->addMapping("Modules/MediaPool", "pg", $a_rec["Child"], $item->getId());
361  $a_mapping->addMapping(
362  "Services/COPage",
363  "pg",
364  "mep:" . $a_rec["Child"],
365  "mep:" . $item->getId()
366  );
367  if ($item->getId() > 0) {
368  $this->current_obj->insertInTree($item->getId(), $parent);
369  }
370  break;
371 
372  }
373  } else {
374  if ($a_rec["Type"] == "pg") {
375  $imp_id = explode("_", $a_rec["ImportId"]);
376  if ($imp_id[0] == "il" &&
377  (int) $imp_id[1] == (int) IL_INST_ID &&
378  $imp_id[2] == "pg"
379  ) {
380  $pg_id = $imp_id[3];
381  include_once("./Modules/MediaPool/classes/class.ilMediaPoolItem.php");
382  $pool = ilMediaPoolItem::getPoolForItemId($pg_id);
383  $pool = current($pool);
384  if ($pool == $this->getTranslationLM()->getId()) {
385  $a_mapping->addMapping("Modules/MediaPool", "pg", $a_rec["Child"], $pg_id);
386  $a_mapping->addMapping(
387  "Services/COPage",
388  "pg",
389  "mep:" . $a_rec["Child"],
390  "mep:" . $pg_id
391  );
392  }
393  }
394  }
395  }
396  break;
397  }
398  }
static getPoolForItemId($a_id)
Get media pools for item id.
getTranslationImportMode()
Get translation import mode.
getTranslationLM()
Get translation lm (import.
static getInstanceByObjId($a_obj_id, $stop_on_error=true)
get an instance of an Ilias object by object id
Media Pool Item.
Media pool object.
+ Here is the call graph for this function:

◆ readData()

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

Read data.

Parameters

Definition at line 169 of file class.ilMediaPoolDataSet.php.

References ilDataSet\$db, $ilDB, $type, array, ilDataSet\convertToLeadingUpper(), data, ilDataSet\getDirectDataFromQuery(), and getMasterLanguageOnly().

170  {
171  $ilDB = $this->db;
172 
173  if (!is_array($a_ids)) {
174  $a_ids = array($a_ids);
175  }
176 
177  // mep_data
178  if ($a_entity == "mep") {
179  switch ($a_version) {
180  case "4.1.0":
181  $this->getDirectDataFromQuery("SELECT id, title, description, " .
182  " default_width, default_height" .
183  " FROM mep_data JOIN object_data ON (mep_data.id = object_data.obj_id) " .
184  "WHERE " .
185  $ilDB->in("id", $a_ids, false, "integer"));
186  break;
187 
188  case "5.1.0":
189  $q = "SELECT id, title, description, " .
190  " default_width, default_height" .
191  " FROM mep_data JOIN object_data ON (mep_data.id = object_data.obj_id) " .
192  "WHERE " .
193  $ilDB->in("id", $a_ids, false, "integer");
194 
195  $set = $ilDB->query($q);
196  $this->data = array();
197  while ($rec = $ilDB->fetchAssoc($set)) {
198  if ($this->getMasterLanguageOnly()) {
199  $rec["for_translation"] = 1;
200  }
201  $tmp = array();
202  foreach ($rec as $k => $v) {
203  $tmp[$this->convertToLeadingUpper($k)]
204  = $v;
205  }
206  $rec = $tmp;
207 
208  $this->data[] = $rec;
209  }
210  break;
211 
212  }
213  }
214 
215  // mep_tree
216  if ($a_entity == "mep_tree") {
217  switch ($a_version) {
218  case "4.1.0":
219  $this->getDirectDataFromQuery("SELECT mep_id, child " .
220  " ,parent,depth,type,title,foreign_id " .
221  " FROM mep_tree JOIN mep_item ON (child = obj_id) " .
222  " WHERE " .
223  $ilDB->in("mep_id", $a_ids, false, "integer") .
224  " ORDER BY depth");
225  break;
226 
227  case "5.1.0":
228  $type = "";
229  if ($this->getMasterLanguageOnly()) {
230  $type = " AND type <> " . $ilDB->quote("mob", "text");
231  }
232 
233  $q = "SELECT mep_id, child " .
234  " ,parent,depth,type,title,foreign_id, import_id " .
235  " FROM mep_tree JOIN mep_item ON (child = obj_id) " .
236  " WHERE " .
237  $ilDB->in("mep_id", $a_ids, false, "integer") .
238  $type .
239  " ORDER BY depth";
240 
241  $set = $ilDB->query($q);
242  $this->data = array();
243  while ($rec = $ilDB->fetchAssoc($set)) {
244  $set2 = $ilDB->query("SELECT for_translation FROM mep_data WHERE id = " . $ilDB->quote($rec["mep_id"], true));
245  $rec2 = $ilDB->fetchAssoc($set2);
246  if (!$rec2["for_translation"]) {
247  $rec["import_id"] = "il_" . IL_INST_ID . "_" . $rec["type"] . "_" . $rec["child"];
248  }
249  $tmp = array();
250  foreach ($rec as $k => $v) {
251  $tmp[$this->convertToLeadingUpper($k)]
252  = $v;
253  }
254  $rec = $tmp;
255 
256  $this->data[] = $rec;
257  }
258 
259  break;
260  }
261  }
262  }
getMasterLanguageOnly()
Get master language only (export)
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 ...
$type
convertToLeadingUpper($a_str)
Make xyz_abc a XyzAbc string.
Create styles array
The data for the language used.
global $ilDB
+ Here is the call graph for this function:

◆ setMasterLanguageOnly()

ilMediaPoolDataSet::setMasterLanguageOnly (   $a_val)

Set master language only (export)

Parameters
bool$a_valexport only master language

Definition at line 51 of file class.ilMediaPoolDataSet.php.

52  {
53  $this->master_lang_only = $a_val;
54  }

◆ setTranslationImportMode()

ilMediaPoolDataSet::setTranslationImportMode (   $a_lm,
  $a_lang = "" 
)

Set translation import mode.

Parameters
ilObjLearningModule$a_lmlearning module
string$a_langlanguage

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

73  {
74  if ($a_lm != null) {
75  $this->transl_into = true;
76  $this->transl_into_lm = $a_lm;
77  $this->transl_lang = $a_lang;
78  } else {
79  $this->transl_into = false;
80  }
81  }

Field Documentation

◆ $master_lang_only

ilMediaPoolDataSet::$master_lang_only = false
protected

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

Referenced by getMasterLanguageOnly().

◆ $transl_into

ilMediaPoolDataSet::$transl_into = false
protected

Definition at line 20 of file class.ilMediaPoolDataSet.php.

Referenced by getTranslationImportMode().

◆ $transl_into_lm

ilMediaPoolDataSet::$transl_into_lm = null
protected

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

Referenced by getTranslationLM().

◆ $transl_lang

ilMediaPoolDataSet::$transl_lang = ""
protected

Definition at line 22 of file class.ilMediaPoolDataSet.php.

Referenced by getTranslationLang().


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