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

Class ilPCMediaObject. More...

+ Inheritance diagram for ilPCMediaObject:
+ Collaboration diagram for ilPCMediaObject:

Public Member Functions

 init ()
 Init page content component. More...
 
 readMediaObject ($a_mob_id=0)
 Read/get Media Object. More...
 
 setNode ($a_node)
 Set xml node of page content. More...
 
 setDom (&$a_dom)
 set dom object More...
 
 setHierId ($a_hier_id)
 set hierarchical edit id More...
 
 setMediaObject ($a_mediaobject)
 Set Media Object. More...
 
 getMediaObject ()
 Get Media Object. More...
 
 createMediaObject ()
 
 create (&$a_pg_obj, $a_hier_id)
 Create pc media object. More...
 
 createAlias (&$a_pg_obj, $a_hier_id, $a_pc_id="")
 Create an media alias in page. More...
 
 updateObjectReference ()
 Updates the media object referenced by the media alias. More...
 
 dumpXML ()
 Dump node xml. More...
 
 setClass ($a_class)
 Set Style Class of table. More...
 
 getClass ()
 Get characteristic of section. More...
 
 modifyPageContentPostXsl ($a_html, $a_mode)
 Modify page content after xsl. More...
 
- Public Member Functions inherited from ilPageContent
 __construct ($a_pg_obj)
 Constructor. More...
 
 setPage ($a_val)
 Set page. More...
 
 getPage ()
 Get page. More...
 
 init ()
 Init object. More...
 
 getType ()
 Get type of page content. More...
 
 setNode ($a_node)
 Set xml node of page content. More...
 
getNode ()
 Get xml node of page content. More...
 
 getJavascriptFiles ($a_mode)
 Get Javascript files. More...
 
 getCssFiles ($a_mode)
 Get css files. More...
 
 getOnloadCode ($a_mode)
 Get on load code. More...
 
 setHierId ($a_hier_id)
 Set hierarchical ID in xml structure. More...
 
 getHierId ()
 Get hierarchical id. More...
 
 lookupHierId ()
 Get hierarchical id from dom. More...
 
 readHierId ()
 Read PC Id. More...
 
 setPcId ($a_pcid)
 Set PC Id. More...
 
 getPCId ()
 Get PC Id. More...
 
 setFileDownloadLink ($a_download_link)
 Set file download link. More...
 
 getFileDownloadLink ()
 Get file download link. More...
 
 setFullscreenLink ($a_fullscreen_link)
 Set fullscreen link. More...
 
 getFullscreenLink ()
 Get fullscreen link. More...
 
 setSourcecodeDownloadScript ($script_name)
 Set sourcecode download script. More...
 
 getSourcecodeDownloadScript ()
 Get sourcecode download script. More...
 
 readPCId ()
 Read PC Id. More...
 
 writePCId ($a_pc_id)
 Write pc id. More...
 
 setEnabled ($value)
 Set Enabled value for page content component. More...
 
 enable ()
 Enable page content. More...
 
 disable ()
 Disable page content. More...
 
 isEnabled ()
 Check whether page content is enabled. More...
 
 createPageContentNode ($a_set_this_node=true)
 Create page content node (always use this method first when adding a new element) More...
 
 modifyPageContentPostXsl ($a_output, $a_mode)
 Modify page content after xsl. More...
 

Static Public Member Functions

static getLangVars ()
 Get lang vars needed for editing. More...
 
static afterPageUpdate ($a_page, DOMDocument $a_domdoc, $a_xml, $a_creation)
 After page has been updated (or created) More...
 
static beforePageDelete ($a_page)
 Before page is being deleted. More...
 
static afterPageHistoryEntry ($a_page, DOMDocument $a_old_domdoc, $a_old_xml, $a_old_nr)
 After page history entry has been created. More...
 
static saveMobUsage ($a_page, $a_domdoc, $a_old_nr=0)
 Save all usages of media objects (media aliases, media objects, internal links) More...
 
- Static Public Member Functions inherited from ilPageContent
static incEdId ($ed_id)
 Increases an hierarchical editing id at lowest level (last number) More...
 
static decEdId ($ed_id)
 Decreases an hierarchical editing id at lowest level (last number) More...
 
static haveSameContainer ($ed_id1, $ed_id2)
 Check, if two ids are in same container. More...
 
static sortHierIds ($a_array)
 Sort an array of Hier IDS in ascending order. More...
 
static isGreaterHierId ($a, $b)
 Check whether Hier ID $a is greater than Hier ID $b. More...
 
static getLangVars ()
 Get lang vars needed for editing. More...
 
static handleCopiedContent (DOMDocument $a_domdoc, $a_self_ass=true, $a_clone_mobs=false)
 Handle copied content. More...
 
static afterPageUpdate ($a_page, DOMDocument $a_domdoc, $a_xml, $a_creation)
 After page has been updated (or created) More...
 
static beforePageDelete ($a_page)
 Before page is being deleted. More...
 
static afterPageHistoryEntry ($a_page, DOMDocument $a_old_domdoc, $a_old_xml, $a_old_nr)
 After page history entry has been created. More...
 

Protected Attributes

 $user
 
 $mob_node
 
- Protected Attributes inherited from ilPageContent
 $file_download_link
 
 $fullscreen_link
 
 $sourcecode_download_script
 
 $log
 

Additional Inherited Members

- Data Fields inherited from ilPageContent
 $hier_id
 
 $node
 
 $dom
 
 $page_lang
 
- Protected Member Functions inherited from ilPageContent
 setType ($a_type)
 Set Type. More...
 

Detailed Description

Class ilPCMediaObject.

Media content object (see ILIAS DTD)

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 16 of file class.ilPCMediaObject.php.

Member Function Documentation

◆ afterPageHistoryEntry()

static ilPCMediaObject::afterPageHistoryEntry (   $a_page,
DOMDocument  $a_old_domdoc,
  $a_old_xml,
  $a_old_nr 
)
static

After page history entry has been created.

Parameters
object$a_pagepage object
DOMDocument$a_old_domdocold dom document
string$a_old_xmlold xml
integer$a_old_nrhistory number

Reimplemented from ilPageContent.

Definition at line 343 of file class.ilPCMediaObject.php.

344 {
345 self::saveMobUsage($a_page, $a_old_domdoc, $a_old_nr);
346 }
static saveMobUsage($a_page, $a_domdoc, $a_old_nr=0)
Save all usages of media objects (media aliases, media objects, internal links)

References saveMobUsage().

+ Here is the call graph for this function:

◆ afterPageUpdate()

static ilPCMediaObject::afterPageUpdate (   $a_page,
DOMDocument  $a_domdoc,
  $a_xml,
  $a_creation 
)
static

After page has been updated (or created)

Parameters
object$a_pagepage object
DOMDocument$a_domdocdom document
string$a_xmlxml
bool$a_creationtrue on creation, otherwise false

Reimplemented from ilPageContent.

Definition at line 279 of file class.ilPCMediaObject.php.

280 {
281 if (!$a_page->getImportMode()) {
282 include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
284 $a_page->getParentType() . ":pg",
285 $a_page->getId(),
286 0,
287 $a_page->getLanguage()
288 );
289 self::saveMobUsage($a_page, $a_domdoc);
290 foreach ($mob_ids as $mob) { // check, whether media object can be deleted
291 if (ilObject::_exists($mob) && ilObject::_lookupType($mob) == "mob") {
292 $mob_obj = new ilObjMediaObject($mob);
293 $usages = $mob_obj->getUsages(false);
294 if (count($usages) == 0) { // delete, if no usage exists
295 $mob_obj->delete();
296 }
297 }
298 }
299 }
300 }
Class ilObjMediaObject.
static _getMobsOfObject($a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
get mobs of object
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data@access public
static _lookupType($a_id, $a_reference=false)
lookup object type

References ilObject\_exists(), ilObjMediaObject\_getMobsOfObject(), ilObject\_lookupType(), and saveMobUsage().

+ Here is the call graph for this function:

◆ beforePageDelete()

static ilPCMediaObject::beforePageDelete (   $a_page)
static

Before page is being deleted.

Parameters
object$a_pagepage object

Reimplemented from ilPageContent.

Definition at line 307 of file class.ilPCMediaObject.php.

308 {
309 include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
311 $a_page->getParentType() . ":pg",
312 $a_page->getId(),
313 0,
314 $a_page->getLanguage()
315 );
316
318 $a_page->getParentType() . ":pg",
319 $a_page->getId(),
320 false,
321 $a_page->getLanguage()
322 );
323
324 foreach ($mob_ids as $mob) { // check, whether media object can be deleted
325 if (ilObject::_exists($mob) && ilObject::_lookupType($mob) == "mob") {
326 $mob_obj = new ilObjMediaObject($mob);
327 $usages = $mob_obj->getUsages(false);
328 if (count($usages) == 0) { // delete, if no usage exists
329 $mob_obj->delete();
330 }
331 }
332 }
333 }
static _deleteAllUsages($a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
static

References ilObjMediaObject\_deleteAllUsages(), ilObject\_exists(), ilObjMediaObject\_getMobsOfObject(), and ilObject\_lookupType().

+ Here is the call graph for this function:

◆ create()

ilPCMediaObject::create ( $a_pg_obj,
  $a_hier_id 
)

Create pc media object.

Definition at line 99 of file class.ilPCMediaObject.php.

100 {
101 $this->node = $this->createPageContentNode();
102 }
createPageContentNode($a_set_this_node=true)
Create page content node (always use this method first when adding a new element)

References ilPageContent\createPageContentNode().

+ Here is the call graph for this function:

◆ createAlias()

ilPCMediaObject::createAlias ( $a_pg_obj,
  $a_hier_id,
  $a_pc_id = "" 
)

Create an media alias in page.

Parameters
object$a_pg_objpage object
string$a_hier_idhierarchical ID w

Definition at line 110 of file class.ilPCMediaObject.php.

111 {
112 $this->node = $this->dom->create_element("PageContent");
113 $a_pg_obj->insertContent($this, $a_hier_id, IL_INSERT_AFTER, $a_pc_id);
114 $this->mob_node = $this->dom->create_element("MediaObject");
115 $this->mob_node = $this->node->append_child($this->mob_node);
116 $this->mal_node = $this->dom->create_element("MediaAlias");
117 $this->mal_node = $this->mob_node->append_child($this->mal_node);
118 $this->mal_node->set_attribute("OriginId", "il__mob_" . $this->getMediaObject()->getId());
119
120 // standard view
121 $item_node = $this->dom->create_element("MediaAliasItem");
122 $item_node = $this->mob_node->append_child($item_node);
123 $item_node->set_attribute("Purpose", "Standard");
124 $media_item = $this->getMediaObject()->getMediaItem("Standard");
125
126 $layout_node = $this->dom->create_element("Layout");
127 $layout_node = $item_node->append_child($layout_node);
128 if ($media_item->getWidth() > 0) {
129 //$layout_node->set_attribute("Width", $media_item->getWidth());
130 }
131 if ($media_item->getHeight() > 0) {
132 //$layout_node->set_attribute("Height", $media_item->getHeight());
133 }
134 $layout_node->set_attribute("HorizontalAlign", "Left");
135
136 // caption
137 if ($media_item->getCaption() != "") {
138 $cap_node = $this->dom->create_element("Caption");
139 $cap_node = $item_node->append_child($cap_node);
140 $cap_node->set_attribute("Align", "bottom");
141 $cap_node->set_content($media_item->getCaption());
142 }
143
144 // text representation
145 if ($media_item->getTextRepresentation() != "") {
146 $tr_node = $this->dom->create_element("TextRepresentation");
147 $tr_node = $item_node->append_child($tr_node);
148 $tr_node->set_content($media_item->getTextRepresentation());
149 }
150
151 $pars = $media_item->getParameters();
152 foreach ($pars as $par => $val) {
153 $par_node = $this->dom->create_element("Parameter");
154 $par_node = $item_node->append_child($par_node);
155 $par_node->set_attribute("Name", $par);
156 $par_node->set_attribute("Value", $val);
157 }
158
159 // fullscreen view
160 $fullscreen_item = $this->getMediaObject()->getMediaItem("Fullscreen");
161 if (is_object($fullscreen_item)) {
162 $item_node = $this->dom->create_element("MediaAliasItem");
163 $item_node = $this->mob_node->append_child($item_node);
164 $item_node->set_attribute("Purpose", "Fullscreen");
165
166 // width and height
167 $layout_node = $this->dom->create_element("Layout");
168 $layout_node = $item_node->append_child($layout_node);
169 if ($fullscreen_item->getWidth() > 0) {
170 $layout_node->set_attribute("Width", $fullscreen_item->getWidth());
171 }
172 if ($fullscreen_item->getHeight() > 0) {
173 $layout_node->set_attribute("Height", $fullscreen_item->getHeight());
174 }
175
176 // caption
177 if ($fullscreen_item->getCaption() != "") {
178 $cap_node = $this->dom->create_element("Caption");
179 $cap_node = $item_node->append_child($cap_node);
180 $cap_node->set_attribute("Align", "bottom");
181 $cap_node->set_content($fullscreen_item->getCaption());
182 }
183
184 // text representation
185 if ($fullscreen_item->getTextRepresentation() != "") {
186 $tr_node = $this->dom->create_element("TextRepresentation");
187 $tr_node = $item_node->append_child($tr_node);
188 $tr_node->set_content($fullscreen_item->getTextRepresentation());
189 }
190
191 $pars = $fullscreen_item->getParameters();
192 foreach ($pars as $par => $val) {
193 $par_node = $this->dom->create_element("Parameter");
194 $par_node = $item_node->append_child($par_node);
195 $par_node->set_attribute("Name", $par);
196 $par_node->set_attribute("Value", $val);
197 }
198 }
199 }
const IL_INSERT_AFTER
getMediaObject()
Get Media Object.

References getMediaObject(), and IL_INSERT_AFTER.

+ Here is the call graph for this function:

◆ createMediaObject()

ilPCMediaObject::createMediaObject ( )

Definition at line 91 of file class.ilPCMediaObject.php.

92 {
93 $this->setMediaObject(new ilObjMediaObject());
94 }
setMediaObject($a_mediaobject)
Set Media Object.

References setMediaObject().

+ Here is the call graph for this function:

◆ dumpXML()

ilPCMediaObject::dumpXML ( )

Dump node xml.

Definition at line 219 of file class.ilPCMediaObject.php.

220 {
221 $xml = $this->dom->dump_node($this->node);
222 return $xml;
223 }

References $xml.

◆ getClass()

ilPCMediaObject::getClass ( )

Get characteristic of section.

Returns
string characteristic

Definition at line 251 of file class.ilPCMediaObject.php.

252 {
253 if (is_object($this->mob_node)) {
254 $mal_node = $this->mob_node->first_child();
255 if (is_object($mal_node)) {
256 $class = $mal_node->get_attribute("Class");
257 return $class;
258 }
259 }
260 }

◆ getLangVars()

static ilPCMediaObject::getLangVars ( )
static

Get lang vars needed for editing.

Returns
array array of lang var keys

Reimplemented from ilPageContent.

Definition at line 266 of file class.ilPCMediaObject.php.

267 {
268 return array("pc_mob");
269 }

◆ getMediaObject()

ilPCMediaObject::getMediaObject ( )

Get Media Object.

Returns
object Media Object

Definition at line 86 of file class.ilPCMediaObject.php.

87 {
88 return $this->mediaobject;
89 }

Referenced by createAlias(), and updateObjectReference().

+ Here is the caller graph for this function:

◆ init()

ilPCMediaObject::init ( )

Init page content component.

Reimplemented from ilPageContent.

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

29 {
30 global $DIC;
31
32 $this->user = $DIC->user();
33 $this->setType("media");
34 }
user()
Definition: user.php:4
setType($a_type)
Set Type.
global $DIC
Definition: saml.php:7

References $DIC, ilPageContent\setType(), and user().

+ Here is the call graph for this function:

◆ modifyPageContentPostXsl()

ilPCMediaObject::modifyPageContentPostXsl (   $a_html,
  $a_mode 
)

Modify page content after xsl.

Parameters
string$a_output
Returns
string

Reimplemented from ilPageContent.

Definition at line 424 of file class.ilPCMediaObject.php.

425 {
427
428 if ($a_mode == "offline") {
429 $page = $this->getPage();
430
432 $page->getParentType() . ":pg",
433 $page->getId(),
434 0,
435 $page->getLanguage()
436 );
437 foreach ($mob_ids as $mob_id) {
438 $mob = new ilObjMediaObject($mob_id);
439 $srts = $mob->getSrtFiles();
440 foreach ($srts as $srt) {
441 if ($ilUser->getLanguage() == $srt["language"]) {
442 $srt_content = file_get_contents(ilObjMediaObject::_getDirectory($mob->getId()) . "/" . $srt["full_path"]);
443 $a_html = str_replace("[[[[[mobsubtitle;il__mob_" . $mob->getId() . "_Standard]]]]]", $srt_content, $a_html);
444 }
445 }
446 }
447 }
448
449 return $a_html;
450 }
static _getDirectory($a_mob_id)
Get absolute directory.
$ilUser
Definition: imgupload.php:18

References $ilUser, $user, ilObjMediaObject\_getDirectory(), ilObjMediaObject\_getMobsOfObject(), and ilPageContent\getPage().

+ Here is the call graph for this function:

◆ readMediaObject()

ilPCMediaObject::readMediaObject (   $a_mob_id = 0)

Read/get Media Object.

Parameters
intmedia object ID

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

42 {
43 if ($a_mob_id > 0) {
44 $mob = new ilObjMediaObject($a_mob_id);
45 $this->setMediaObject($mob);
46 }
47 }

References setMediaObject().

+ Here is the call graph for this function:

◆ saveMobUsage()

static ilPCMediaObject::saveMobUsage (   $a_page,
  $a_domdoc,
  $a_old_nr = 0 
)
static

Save all usages of media objects (media aliases, media objects, internal links)

Parameters
string$a_xmlxml data of page

Definition at line 353 of file class.ilPCMediaObject.php.

354 {
355 $usages = array();
356
357 // media aliases
358 $xpath = new DOMXPath($a_domdoc);
359 $nodes = $xpath->query('//MediaAlias');
360 foreach ($nodes as $node) {
361 $id_arr = explode("_", $node->getAttribute("OriginId"));
362 $mob_id = $id_arr[count($id_arr) - 1];
363 if ($mob_id > 0 && $id_arr[1] == "") {
364 $usages[$mob_id] = true;
365 }
366 }
367
368 // media objects
369 $xpath = new DOMXPath($a_domdoc);
370 $nodes = $xpath->query('//MediaObject/MetaData/General/Identifier');
371 foreach ($nodes as $node) {
372 $mob_entry = $node->getAttribute("Entry");
373 $mob_arr = explode("_", $mob_entry);
374 $mob_id = $mob_arr[count($mob_arr) - 1];
375 if ($mob_id > 0 && $mob_arr[1] == "") {
376 $usages[$mob_id] = true;
377 }
378 }
379
380 // internal links
381 $xpath = new DOMXPath($a_domdoc);
382 $nodes = $xpath->query("//IntLink[@Type='MediaObject']");
383 foreach ($nodes as $node) {
384 $mob_target = $node->getAttribute("Target");
385 $mob_arr = explode("_", $mob_target);
386 //echo "<br>3<br>";
387 //echo $mob_target."<br>";
388 //var_dump($mob_arr);
389 $mob_id = $mob_arr[count($mob_arr) - 1];
390 if ($mob_id > 0 && $mob_arr[1] == "") {
391 $usages[$mob_id] = true;
392 }
393 }
394
395 include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
397 $a_page->getParentType() . ":pg",
398 $a_page->getId(),
399 $a_old_nr,
400 $a_page->getLanguage()
401 );
402 foreach ($usages as $mob_id => $val) {
403 // save usage, if object exists...
404 if (ilObject::_lookupType($mob_id) == "mob") {
406 $mob_id,
407 $a_page->getParentType() . ":pg",
408 $a_page->getId(),
409 $a_old_nr,
410 $a_page->getLanguage()
411 );
412 }
413 }
414
415 return $usages;
416 }
static _saveUsage($a_mob_id, $a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
Save usage of mob within another container (e.g.

References ilPageContent\$node, $nodes, ilObjMediaObject\_deleteAllUsages(), ilObject\_lookupType(), and ilObjMediaObject\_saveUsage().

Referenced by afterPageHistoryEntry(), and afterPageUpdate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setClass()

ilPCMediaObject::setClass (   $a_class)

Set Style Class of table.

Parameters
string$a_classclass

Definition at line 230 of file class.ilPCMediaObject.php.

231 {
232 if (is_object($this->mob_node)) {
233 $mal_node = $this->mob_node->first_child();
234 if (is_object($mal_node)) {
235 if (!empty($a_class)) {
236 $mal_node->set_attribute("Class", $a_class);
237 } else {
238 if ($mal_node->has_attribute("Class")) {
239 $mal_node->remove_attribute("Class");
240 }
241 }
242 }
243 }
244 }

◆ setDom()

ilPCMediaObject::setDom ( $a_dom)

set dom object

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

59 {
60 $this->dom = $a_dom;
61 }

◆ setHierId()

ilPCMediaObject::setHierId (   $a_hier_id)

set hierarchical edit id

Reimplemented from ilPageContent.

Definition at line 66 of file class.ilPCMediaObject.php.

67 {
68 $this->hier_id = $a_hier_id;
69 }

◆ setMediaObject()

ilPCMediaObject::setMediaObject (   $a_mediaobject)

Set Media Object.

Parameters
object$a_mediaobjectMedia Object

Definition at line 76 of file class.ilPCMediaObject.php.

77 {
78 $this->mediaobject = $a_mediaobject;
79 }

Referenced by createMediaObject(), and readMediaObject().

+ Here is the caller graph for this function:

◆ setNode()

ilPCMediaObject::setNode (   $a_node)

Set xml node of page content.

Parameters
object$a_nodenode object

Reimplemented from ilPageContent.

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

50 {
51 parent::setNode($a_node); // this is the PageContent node
52 $this->mob_node = $a_node->first_child();
53 }

◆ updateObjectReference()

ilPCMediaObject::updateObjectReference ( )

Updates the media object referenced by the media alias.

This makes only sense, after the media object has changed. (-> change object reference function)

Definition at line 206 of file class.ilPCMediaObject.php.

207 {
208 if (is_object($this->mob_node)) {
209 $this->mal_node = $this->mob_node->first_child();
210 if (is_object($this->mal_node) && $this->mal_node->node_name() == "MediaAlias") {
211 $this->mal_node->set_attribute("OriginId", "il__mob_" . $this->getMediaObject()->getId());
212 }
213 }
214 }

References getMediaObject().

+ Here is the call graph for this function:

Field Documentation

◆ $mob_node

ilPCMediaObject::$mob_node
protected

Definition at line 23 of file class.ilPCMediaObject.php.

◆ $user

ilPCMediaObject::$user
protected

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

Referenced by modifyPageContentPostXsl().


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