ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
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)
 
 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...
 
- 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...
 
 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

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

350  {
351  self::saveMobUsage($a_page, $a_old_domdoc, $a_old_nr);
352  }

◆ 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

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

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

294  {
295  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
297  $a_page->getParentType().":pg", $a_page->getId(), 0, $a_page->getLanguage());
298  self::saveMobUsage($a_page, $a_domdoc);
299  foreach($mob_ids as $mob) // check, whether media object can be deleted
300  {
301  if (ilObject::_exists($mob) && ilObject::_lookupType($mob) == "mob")
302  {
303  $mob_obj = new ilObjMediaObject($mob);
304  $usages = $mob_obj->getUsages(false);
305  if (count($usages) == 0) // delete, if no usage exists
306  {
307  $mob_obj->delete();
308  }
309  }
310  }
311  }
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data
Class ilObjMediaObject.
static _lookupType($a_id, $a_reference=false)
lookup object type
_getMobsOfObject($a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
get mobs of object
+ 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

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

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

319  {
320  include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
322  $a_page->getParentType().":pg", $a_page->getId(), 0, $a_page->getLanguage());
323 
324  ilObjMediaObject::_deleteAllUsages($a_page->getParentType().":pg", $a_page->getId(), false,
325  $a_page->getLanguage());
326 
327  foreach($mob_ids as $mob) // check, whether media object can be deleted
328  {
329  if (ilObject::_exists($mob) && ilObject::_lookupType($mob) == "mob")
330  {
331  $mob_obj = new ilObjMediaObject($mob);
332  $usages = $mob_obj->getUsages(false);
333  if (count($usages) == 0) // delete, if no usage exists
334  {
335  $mob_obj->delete();
336  }
337  }
338  }
339  }
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data
_deleteAllUsages($a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
static
Class ilObjMediaObject.
static _lookupType($a_id, $a_reference=false)
lookup object type
_getMobsOfObject($a_type, $a_id, $a_usage_hist_nr=0, $a_lang="-")
get mobs of object
+ 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.

References ilPageContent\createPageContentNode().

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) ...
+ 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.

References getMediaObject(), and IL_INSERT_AFTER.

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  }
getMediaObject()
Get Media Object.
const IL_INSERT_AFTER
+ Here is the call graph for this function:

◆ createMediaObject()

ilPCMediaObject::createMediaObject ( )

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

References setMediaObject().

85  {
86  $this->setMediaObject(new ilObjMediaObject());
87  }
Class ilObjMediaObject.
setMediaObject($a_mediaobject)
Set Media Object.
+ 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

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.

Referenced by createAlias(), and updateObjectReference().

80  {
81  return $this->mediaobject;
82  }
+ Here is the caller graph for this function:

◆ init()

ilPCMediaObject::init ( )

Init page content component.

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

References ilPageContent\setType().

24  {
25  $this->setType("media");
26  }
setType($a_type)
Set Type.
+ 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.

References setMediaObject().

34  {
35  if ($a_mob_id > 0)
36  {
37  $mob = new ilObjMediaObject($a_mob_id);
38  $this->setMediaObject($mob);
39  }
40  }
Class ilObjMediaObject.
setMediaObject($a_mediaobject)
Set Media Object.
+ 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 359 of file class.ilPCMediaObject.php.

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

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

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.

Referenced by createMediaObject(), and readMediaObject().

70  {
71  $this->mediaobject = $a_mediaobject;
72  }
+ Here is the caller graph for this function:

◆ setNode()

ilPCMediaObject::setNode ( $a_node)

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.

References getMediaObject().

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  }
getMediaObject()
Get Media Object.
+ 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: