ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ILIAS\COPage\PC\MediaObject\MediaObjectManager Class Reference
+ Collaboration diagram for ILIAS\COPage\PC\MediaObject\MediaObjectManager:

Public Member Functions

 __construct ()
 
 collectMediaObjects (\DOMDocument $dom, bool $a_inline_only=true)
 get all media objects, that are referenced and used within the page More...
 
 getMultimediaXML (\DOMDocument $dom, bool $offline=false)
 get a xml string that contains all media object elements, that are referenced by any media alias in the page More...
 
 getMediaAliasElement (\DOMDocument $dom, int $a_mob_id, int $a_nr=1)
 get complete media object (alias) element More...
 
 resolveMediaAliases (\ilPageObject $page, array $a_mapping, bool $a_reuse_existing_by_import=false)
 

Protected Attributes

ILIAS COPage Dom DomUtil $dom_util
 

Detailed Description

Author
Alexander Killing killi.nosp@m.ng@l.nosp@m.eifos.nosp@m..de

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

Constructor & Destructor Documentation

◆ __construct()

ILIAS\COPage\PC\MediaObject\MediaObjectManager::__construct ( )

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

References $DIC.

31  {
32  global $DIC;
33  $this->dom_util = $DIC->copage()->internal()->domain()->domUtil();
34  }
global $DIC
Definition: shib_login.php:26

Member Function Documentation

◆ collectMediaObjects()

ILIAS\COPage\PC\MediaObject\MediaObjectManager::collectMediaObjects ( \DOMDocument  $dom,
bool  $a_inline_only = true 
)

get all media objects, that are referenced and used within the page

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

References $path, ilObject\_exists(), and IL_INST_ID.

Referenced by ILIAS\COPage\PC\MediaObject\MediaObjectManager\getMultimediaXML().

43  : array {
44  // determine all media aliases of the page
45  $path = "//MediaObject/MediaAlias";
46  $mob_ids = array();
47  $nodes = $this->dom_util->path($dom, $path);
48  foreach ($nodes as $node) {
49  $id_arr = explode("_", $node->getAttribute("OriginId"));
50  $mob_id = $id_arr[count($id_arr) - 1];
51  $mob_ids[$mob_id] = $mob_id;
52  }
53 
54  // determine all media aliases of interactive images
55  $path = "//InteractiveImage/MediaAlias";
56  $nodes = $this->dom_util->path($dom, $path);
57  foreach ($nodes as $node) {
58  $id_arr = explode("_", $node->getAttribute("OriginId"));
59  $mob_id = $id_arr[count($id_arr) - 1];
60  $mob_ids[$mob_id] = $mob_id;
61  }
62 
63  // determine all inline internal media links
64  $path = "//IntLink[@Type = 'MediaObject']";
65  $nodes = $this->dom_util->path($dom, $path);
66  foreach ($nodes as $node) {
67  if (($node->getAttribute("TargetFrame") == "") ||
68  (!$a_inline_only)) {
69  $target = $node->getAttribute("Target");
70  $id_arr = explode("_", $target);
71  if (($id_arr[1] == IL_INST_ID) ||
72  (substr($target, 0, 4) == "il__")) {
73  $mob_id = $id_arr[count($id_arr) - 1];
74  if (\ilObject::_exists((int) $mob_id)) {
75  $mob_ids[$mob_id] = $mob_id;
76  }
77  }
78  }
79  }
80  return $mob_ids;
81  }
const IL_INST_ID
Definition: constants.php:40
$path
Definition: ltiservices.php:29
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMediaAliasElement()

ILIAS\COPage\PC\MediaObject\MediaObjectManager::getMediaAliasElement ( \DOMDocument  $dom,
int  $a_mob_id,
int  $a_nr = 1 
)

get complete media object (alias) element

Definition at line 107 of file class.MediaObjectManager.php.

References $path.

111  : string {
112  $path = "//MediaObject/MediaAlias[@OriginId='il__mob_$a_mob_id']";
113  $nodes = $this->dom_util->path($dom, $path);
114  $mal_node = $nodes->item($a_nr - 1);
115  $mob_node = $mal_node->parentNode;
116  return $this->dom_util->dump($mob_node);
117  }
$path
Definition: ltiservices.php:29

◆ getMultimediaXML()

ILIAS\COPage\PC\MediaObject\MediaObjectManager::getMultimediaXML ( \DOMDocument  $dom,
bool  $offline = false 
)

get a xml string that contains all media object elements, that are referenced by any media alias in the page

Definition at line 87 of file class.MediaObjectManager.php.

References ilObject\_lookupType(), ILIAS\COPage\PC\MediaObject\MediaObjectManager\collectMediaObjects(), and IL_MODE_OUTPUT.

90  : string {
91  $mob_ids = $this->collectMediaObjects($dom);
92 
93  // get xml of corresponding media objects
94  $mobs_xml = "";
95  foreach ($mob_ids as $mob_id => $dummy) {
96  if (\ilObject::_lookupType((int) $mob_id) === "mob") {
97  $mob_obj = new \ilObjMediaObject($mob_id);
98  $mobs_xml .= $mob_obj->getXML(IL_MODE_OUTPUT, $a_inst = 0, true, $offline);
99  }
100  }
101  return $mobs_xml;
102  }
const IL_MODE_OUTPUT
static _lookupType(int $id, bool $reference=false)
collectMediaObjects(\DOMDocument $dom, bool $a_inline_only=true)
get all media objects, that are referenced and used within the page
+ Here is the call graph for this function:

◆ resolveMediaAliases()

ILIAS\COPage\PC\MediaObject\MediaObjectManager::resolveMediaAliases ( \ilPageObject  $page,
array  $a_mapping,
bool  $a_reuse_existing_by_import = false 
)

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

References $path, ilObjMediaObject\_getMobsOfObject(), ilObject\_lookupImportId(), ilObject\_lookupType(), ilPageObject\getDomDoc(), ilPageObject\getId(), ilPageObject\getParentType(), and IL_INST_ID.

123  : bool {
124  // resolve normal internal links
125  $dom = $page->getDomDoc();
126  $path = "//MediaAlias";
127  $changed = false;
128  $nodes = $this->dom_util->path($dom, $path);
129  foreach ($nodes as $node) {
130  // get the ID of the import file from the xml
131  $old_id = $node->getAttribute("OriginId");
132  $old_id = explode("_", $old_id);
133  $old_id = $old_id[count($old_id) - 1];
134  $new_id = "";
135  $import_id = "";
136  // get the new id from the current mapping
137  if (($a_mapping[$old_id] ?? 0) > 0) {
138  $new_id = $a_mapping[$old_id];
139  if ($a_reuse_existing_by_import) {
140  // this should work, if the lm has been imported in a translation installation and re-exported
141  $import_id = \ilObject::_lookupImportId($new_id);
142  $imp = explode("_", $import_id);
143  if ($imp[1] == IL_INST_ID && $imp[2] == "mob" && \ilObject::_lookupType((int) ($imp[3] ?? 0)) == "mob") {
144  $new_id = $imp[3];
145  }
146  }
147  }
148  // now check, if the translation has been done just by changing text in the exported
149  // translation file
150  if ($import_id == "" && $a_reuse_existing_by_import) {
151  // if the old_id is also referred by the page content of the default language
152  // we assume that this media object is unchanged
153  $med_of_def_lang = \ilObjMediaObject::_getMobsOfObject(
154  $page->getParentType() . ":pg",
155  $page->getId(),
156  0,
157  "-"
158  );
159  if (in_array($old_id, $med_of_def_lang)) {
160  $new_id = $old_id;
161  }
162  }
163  if ($new_id != "") {
164  $node->setAttribute("OriginId", "il__mob_" . $new_id);
165  $changed = true;
166  }
167  }
168  return $changed;
169  }
const IL_INST_ID
Definition: constants.php:40
$path
Definition: ltiservices.php:29
static _lookupImportId(int $obj_id)
static _getMobsOfObject(string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:

Field Documentation

◆ $dom_util

ILIAS COPage Dom DomUtil ILIAS\COPage\PC\MediaObject\MediaObjectManager::$dom_util
protected

Definition at line 28 of file class.MediaObjectManager.php.


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