ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 = ""
 

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

References array.

287  {
288  switch ($a_entity)
289  {
290  case "mep":
291  return array (
292  "mep_tree" => array("ids" => $a_rec["Id"])
293  );
294  }
295  return false;
296  }
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 91 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 111 of file class.ilMediaPoolDataSet.php.

References $transl_lang.

112  {
113  return $this->transl_lang;
114  }

◆ getTranslationLM()

ilMediaPoolDataSet::getTranslationLM ( )

Get translation lm (import.

Returns
ilObjLearningModule learning module

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

References $transl_into_lm.

Referenced by importRecord().

102  {
103  return $this->transl_into_lm;
104  }
+ 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 122 of file class.ilMediaPoolDataSet.php.

References array.

123  {
124  // mep
125  if ($a_entity == "mep")
126  {
127  switch ($a_version)
128  {
129  case "4.1.0":
130  return array(
131  "Id" => "integer",
132  "Title" => "text",
133  "Description" => "text",
134  "DefaultWidth" => "integer",
135  "DefaultHeight" => "integer");
136 
137  case "5.1.0":
138  return array(
139  "Id" => "integer",
140  "Title" => "text",
141  "Description" => "text",
142  "DefaultWidth" => "integer",
143  "DefaultHeight" => "integer",
144  "ForTranslation" => "integer"
145  );
146  }
147  }
148 
149  // mep_tree
150  if ($a_entity == "mep_tree")
151  {
152  switch ($a_version)
153  {
154  case "4.1.0":
155  case "5.1.0":
156  return array(
157  "MepId" => "integer",
158  "Child" => "integer",
159  "Parent" => "integer",
160  "Depth" => "integer",
161  "Type" => "text",
162  "Title" => "text",
163  "ForeignId" => "integer",
164  "ImportId" => "text"
165  );
166  }
167  }
168  }
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 309 of file class.ilMediaPoolDataSet.php.

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

310  {
311 //echo $a_entity;
312 //var_dump($a_rec);
313 
314  switch ($a_entity)
315  {
316  case "mep":
317 
318  if ($this->getTranslationImportMode())
319  {
320  return;
321  }
322 
323  include_once("./Modules/MediaPool/classes/class.ilObjMediaPool.php");
324 
325  if($new_id = $a_mapping->getMapping('Services/Container','objs',$a_rec['Id']))
326  {
327  $newObj = ilObjectFactory::getInstanceByObjId($new_id,false);
328  }
329  else
330  {
331  $newObj = new ilObjMediaPool();
332  $newObj->setType("mep");
333  $newObj->create(true);
334  }
335 
336  $newObj->setTitle($a_rec["Title"]);
337  $newObj->setDescription($a_rec["Description"]);
338  $newObj->setDefaultWidth($a_rec["DefaultWidth"]);
339  $newObj->setDefaultHeight($a_rec["DefaultHeight"]);
340  $newObj->setForTranslation($a_rec["ForTranslation"]);
341  $newObj->update();
342 
343  $this->current_obj = $newObj;
344  $a_mapping->addMapping("Modules/MediaPool", "mep", $a_rec["Id"], $newObj->getId());
345  $a_mapping->addMapping("Services/Object", "obj", $a_rec["Id"], $newObj->getId());
346  break;
347 
348  case "mep_tree":
349  if (!$this->getTranslationImportMode())
350  {
351  switch ($a_rec["Type"])
352  {
353  case "fold":
354  $parent = (int) $a_mapping->getMapping("Modules/MediaPool", "mep_tree", $a_rec["Parent"]);
355  $fold_id =
356  $this->current_obj->createFolder($a_rec["Title"], $parent);
357  $a_mapping->addMapping("Modules/MediaPool", "mep_tree", $a_rec["Child"],
358  $fold_id);
359  break;
360 
361  case "mob":
362  $parent = (int) $a_mapping->getMapping("Modules/MediaPool", "mep_tree", $a_rec["Parent"]);
363  $mob_id = (int) $a_mapping->getMapping("Services/MediaObjects", "mob", $a_rec["ForeignId"]);
364  $item = new ilMediaPoolItem();
365  $item->setType("mob");
366  $item->setForeignId($mob_id);
367  $item->setImportId($a_rec["ImportId"]);
368  $item->setTitle($a_rec["Title"]);
369  $item->create();
370  if ($item->getId() > 0)
371  {
372  $this->current_obj->insertInTree($item->getId(), $parent);
373  }
374  break;
375 
376  case "pg":
377  $parent = (int) $a_mapping->getMapping("Modules/MediaPool", "mep_tree", $a_rec["Parent"]);
378 
379  $item = new ilMediaPoolItem();
380  $item->setType("pg");
381  $item->setTitle($a_rec["Title"]);
382  $item->setImportId($a_rec["ImportId"]);
383  $item->create();
384  $a_mapping->addMapping("Modules/MediaPool", "pg", $a_rec["Child"], $item->getId());
385  $a_mapping->addMapping("Services/COPage", "pg", "mep:".$a_rec["Child"],
386  "mep:".$item->getId());
387  if ($item->getId() > 0)
388  {
389  $this->current_obj->insertInTree($item->getId(), $parent);
390  }
391  break;
392 
393  }
394  }
395  else
396  {
397  if ($a_rec["Type"] == "pg")
398  {
399  $imp_id = explode("_", $a_rec["ImportId"]);
400  if ($imp_id[0] == "il" &&
401  (int) $imp_id[1] == (int) IL_INST_ID &&
402  $imp_id[2] == "pg"
403  )
404  {
405  $pg_id = $imp_id[3];
406  include_once("./Modules/MediaPool/classes/class.ilMediaPoolItem.php");
407  $pool = ilMediaPoolItem::getPoolForItemId($pg_id);
408  $pool = current($pool);
409  if ($pool == $this->getTranslationLM()->getId())
410  {
411  $a_mapping->addMapping("Modules/MediaPool", "pg", $a_rec["Child"], $pg_id);
412  $a_mapping->addMapping("Services/COPage", "pg", "mep:".$a_rec["Child"],
413  "mep:".$pg_id);
414  }
415  }
416  }
417  }
418  break;
419  }
420  }
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 176 of file class.ilMediaPoolDataSet.php.

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

177  {
178  global $ilDB;
179 
180  if (!is_array($a_ids))
181  {
182  $a_ids = array($a_ids);
183  }
184 
185  // mep_data
186  if ($a_entity == "mep")
187  {
188  switch ($a_version)
189  {
190  case "4.1.0":
191  $this->getDirectDataFromQuery("SELECT id, title, description, ".
192  " default_width, default_height".
193  " FROM mep_data JOIN object_data ON (mep_data.id = object_data.obj_id) ".
194  "WHERE ".
195  $ilDB->in("id", $a_ids, false, "integer"));
196  break;
197 
198  case "5.1.0":
199  $q = "SELECT id, title, description, ".
200  " default_width, default_height".
201  " FROM mep_data JOIN object_data ON (mep_data.id = object_data.obj_id) ".
202  "WHERE ".
203  $ilDB->in("id", $a_ids, false, "integer");
204 
205  $set = $ilDB->query($q);
206  $this->data = array();
207  while ($rec = $ilDB->fetchAssoc($set))
208  {
209  if ($this->getMasterLanguageOnly())
210  {
211  $rec["for_translation"] = 1;
212  }
213  $tmp = array();
214  foreach ($rec as $k => $v)
215  {
216  $tmp[$this->convertToLeadingUpper($k)]
217  = $v;
218  }
219  $rec = $tmp;
220 
221  $this->data[] = $rec;
222  }
223  break;
224 
225  }
226  }
227 
228  // mep_tree
229  if ($a_entity == "mep_tree")
230  {
231  switch ($a_version)
232  {
233  case "4.1.0":
234  $this->getDirectDataFromQuery("SELECT mep_id, child ".
235  " ,parent,depth,type,title,foreign_id ".
236  " FROM mep_tree JOIN mep_item ON (child = obj_id) ".
237  " WHERE ".
238  $ilDB->in("mep_id", $a_ids, false, "integer").
239  " ORDER BY depth");
240  break;
241 
242  case "5.1.0":
243  $type = "";
244  if ($this->getMasterLanguageOnly())
245  {
246  $type = " AND type <> ".$ilDB->quote("mob", "text");
247  }
248 
249  $q = "SELECT mep_id, child ".
250  " ,parent,depth,type,title,foreign_id, import_id ".
251  " FROM mep_tree JOIN mep_item ON (child = obj_id) ".
252  " WHERE ".
253  $ilDB->in("mep_id", $a_ids, false, "integer").
254  $type.
255  " ORDER BY depth";
256 
257  $set = $ilDB->query($q);
258  $this->data = array();
259  while ($rec = $ilDB->fetchAssoc($set))
260  {
261  $set2 = $ilDB->query("SELECT for_translation FROM mep_data WHERE id = ".$ilDB->quote($rec["mep_id"], true));
262  $rec2 = $ilDB->fetchAssoc($set2);
263  if (!$rec2["for_translation"])
264  {
265  $rec["import_id"] = "il_".IL_INST_ID."_".$rec["type"]."_".$rec["child"];
266  }
267  $tmp = array();
268  foreach ($rec as $k => $v)
269  {
270  $tmp[$this->convertToLeadingUpper($k)]
271  = $v;
272  }
273  $rec = $tmp;
274 
275  $this->data[] = $rec;
276  }
277 
278  break;
279  }
280  }
281  }
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 ...
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  {
76  $this->transl_into = true;
77  $this->transl_into_lm = $a_lm;
78  $this->transl_lang = $a_lang;
79  }
80  else
81  {
82  $this->transl_into = false;
83  }
84  }

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: