ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 ()
 Get Javascript files. More...
 
 getCssFiles ()
 Get css files. More...
 
 getOnloadCode ()
 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...
 
 readPCId ()
 Read PC Id. More...
 
 writePCId ($a_pc_id)
 Write pc id. More...
 
 isGreaterHierId ($a, $b)
 Check whether Hier ID $a is greater than Hier ID $b. 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 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...
 

Data Fields

 $mob_node
 
- Data Fields inherited from ilPageContent
 $hier_id
 
 $node
 
 $dom
 

Additional Inherited Members

- 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 352 of file class.ilPCMediaObject.php.

353 {
354 self::saveMobUsage($a_page, $a_old_domdoc, $a_old_nr);
355 }
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 293 of file class.ilPCMediaObject.php.

294 {
295 if (!$a_page->getImportMode())
296 {
297 include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
299 $a_page->getParentType().":pg", $a_page->getId(), 0, $a_page->getLanguage());
300 self::saveMobUsage($a_page, $a_domdoc);
301 foreach($mob_ids as $mob) // check, whether media object can be deleted
302 {
303 if (ilObject::_exists($mob) && ilObject::_lookupType($mob) == "mob")
304 {
305 $mob_obj = new ilObjMediaObject($mob);
306 $usages = $mob_obj->getUsages(false);
307 if (count($usages) == 0) // delete, if no usage exists
308 {
309 $mob_obj->delete();
310 }
311 }
312 }
313 }
314 }
Class ilObjMediaObject.
_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 321 of file class.ilPCMediaObject.php.

322 {
323 include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
325 $a_page->getParentType().":pg", $a_page->getId(), 0, $a_page->getLanguage());
326
327 ilObjMediaObject::_deleteAllUsages($a_page->getParentType().":pg", $a_page->getId(), false,
328 $a_page->getLanguage());
329
330 foreach($mob_ids as $mob) // check, whether media object can be deleted
331 {
332 if (ilObject::_exists($mob) && ilObject::_lookupType($mob) == "mob")
333 {
334 $mob_obj = new ilObjMediaObject($mob);
335 $usages = $mob_obj->getUsages(false);
336 if (count($usages) == 0) // delete, if no usage exists
337 {
338 $mob_obj->delete();
339 }
340 }
341 }
342 }
_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 92 of file class.ilPCMediaObject.php.

93 {
94 $this->node = $this->createPageContentNode();
95 }
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 103 of file class.ilPCMediaObject.php.

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

85 {
86 $this->setMediaObject(new ilObjMediaObject());
87 }
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 225 of file class.ilPCMediaObject.php.

226 {
227 $xml = $this->dom->dump_node($this->node);
228 return $xml;
229 }

◆ getClass()

ilPCMediaObject::getClass ( )

Get characteristic of section.

Returns
string characteristic

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

264 {
265 if (is_object($this->mob_node))
266 {
267 $mal_node = $this->mob_node->first_child();
268 if (is_object($mal_node))
269 {
270 $class = $mal_node->get_attribute("Class");
271 return $class;
272 }
273 }
274 }

◆ getLangVars()

static ilPCMediaObject::getLangVars ( )
static

Get lang vars needed for editing.

Returns
array array of lang var keys

Reimplemented from ilPageContent.

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

281 {
282 return array("pc_mob");
283 }

◆ getMediaObject()

ilPCMediaObject::getMediaObject ( )

Get Media Object.

Returns
object Media Object

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

80 {
81 return $this->mediaobject;
82 }

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 23 of file class.ilPCMediaObject.php.

24 {
25 $this->setType("media");
26 }
setType($a_type)
Set Type.

References ilPageContent\setType().

+ 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 432 of file class.ilPCMediaObject.php.

433 {
434 global $ilUser;
435
436 if ($a_mode == "offline")
437 {
438 $page = $this->getPage();
439
441 $page->getParentType().":pg", $page->getId(), 0, $page->getLanguage());
442 foreach ($mob_ids as $mob_id)
443 {
444 $mob = new ilObjMediaObject($mob_id);
445 $srts = $mob->getSrtFiles();
446 foreach ($srts as $srt)
447 {
448 if ($ilUser->getLanguage() == $srt["language"])
449 {
450 $srt_content = file_get_contents(ilObjMediaObject::_getDirectory($mob->getId())."/".$srt["full_path"]);
451 $a_html = str_replace("[[[[[mobsubtitle;il__mob_".$mob->getId()."_Standard]]]]]", $srt_content, $a_html);
452 }
453 }
454 }
455 }
456
457 return $a_html;
458 }
_getDirectory($a_mob_id)
get directory for files of media object (static)
global $ilUser
Definition: imgupload.php:15

References $ilUser, 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 33 of file class.ilPCMediaObject.php.

34 {
35 if ($a_mob_id > 0)
36 {
37 $mob = new ilObjMediaObject($a_mob_id);
38 $this->setMediaObject($mob);
39 }
40 }

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 362 of file class.ilPCMediaObject.php.

363 {
364 $usages = array();
365
366 // media aliases
367 $xpath = new DOMXPath($a_domdoc);
368 $nodes = $xpath->query('//MediaAlias');
369 foreach($nodes as $node)
370 {
371 $id_arr = explode("_", $node->getAttribute("OriginId"));
372 $mob_id = $id_arr[count($id_arr) - 1];
373 if ($mob_id > 0 && $id_arr[1] == "")
374 {
375 $usages[$mob_id] = true;
376 }
377 }
378
379 // media objects
380 $xpath = new DOMXPath($a_domdoc);
381 $nodes = $xpath->query('//MediaObject/MetaData/General/Identifier');
382 foreach($nodes as $node)
383 {
384 $mob_entry = $node->getAttribute("Entry");
385 $mob_arr = explode("_", $mob_entry);
386 $mob_id = $mob_arr[count($mob_arr) - 1];
387 if ($mob_id > 0 && $mob_arr[1] == "")
388 {
389 $usages[$mob_id] = true;
390 }
391 }
392
393 // internal links
394 $xpath = new DOMXPath($a_domdoc);
395 $nodes = $xpath->query("//IntLink[@Type='MediaObject']");
396 foreach($nodes as $node)
397 {
398 $mob_target = $node->getAttribute("Target");
399 $mob_arr = explode("_", $mob_target);
400//echo "<br>3<br>";
401//echo $mob_target."<br>";
402//var_dump($mob_arr);
403 $mob_id = $mob_arr[count($mob_arr) - 1];
404 if ($mob_id > 0 && $mob_arr[1] == "")
405 {
406 $usages[$mob_id] = true;
407 }
408 }
409
410 include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
411 ilObjMediaObject::_deleteAllUsages($a_page->getParentType().":pg", $a_page->getId(), $a_old_nr,
412 $a_page->getLanguage());
413 foreach($usages as $mob_id => $val)
414 {
415 // save usage, if object exists...
416 if (ilObject::_lookupType($mob_id) == "mob")
417 {
418 ilObjMediaObject::_saveUsage($mob_id, $a_page->getParentType().":pg", $a_page->getId(), $a_old_nr,
419 $a_page->getLanguage());
420 }
421 }
422
423 return $usages;
424 }
_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, 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 236 of file class.ilPCMediaObject.php.

237 {
238 if (is_object($this->mob_node))
239 {
240 $mal_node = $this->mob_node->first_child();
241 if (is_object($mal_node))
242 {
243 if (!empty($a_class))
244 {
245 $mal_node->set_attribute("Class", $a_class);
246 }
247 else
248 {
249 if ($mal_node->has_attribute("Class"))
250 {
251 $mal_node->remove_attribute("Class");
252 }
253 }
254 }
255 }
256 }

◆ setDom()

ilPCMediaObject::setDom ( $a_dom)

set dom object

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

52 {
53 $this->dom =& $a_dom;
54 }

◆ setHierId()

ilPCMediaObject::setHierId (   $a_hier_id)

set hierarchical edit id

Reimplemented from ilPageContent.

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

60 {
61 $this->hier_id = $a_hier_id;
62 }

◆ setMediaObject()

ilPCMediaObject::setMediaObject (   $a_mediaobject)

Set Media Object.

Parameters
object$a_mediaobjectMedia Object

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

70 {
71 $this->mediaobject = $a_mediaobject;
72 }

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 42 of file class.ilPCMediaObject.php.

43 {
44 parent::setNode($a_node); // this is the PageContent node
45 $this->mob_node =& $a_node->first_child();
46 }

◆ 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 210 of file class.ilPCMediaObject.php.

211 {
212 if (is_object($this->mob_node))
213 {
214 $this->mal_node =& $this->mob_node->first_child();
215 if (is_object($this->mal_node) && $this->mal_node->node_name() == "MediaAlias")
216 {
217 $this->mal_node->set_attribute("OriginId", "il__mob_".$this->getMediaObject()->getId());
218 }
219 }
220 }

References getMediaObject().

+ Here is the call graph for this function:

Field Documentation

◆ $mob_node

ilPCMediaObject::$mob_node

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


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