ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilPCMediaObject Class Reference

Class ilPCMediaObject. More...

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

Public Member Functions

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

Static Public Member Functions

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

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.

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

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.

References saveMobUsage().

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

+ Here is the call graph for this function:

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.

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

{
if (!$a_page->getImportMode())
{
include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
$a_page->getParentType().":pg", $a_page->getId(), 0, $a_page->getLanguage());
self::saveMobUsage($a_page, $a_domdoc);
foreach($mob_ids as $mob) // check, whether media object can be deleted
{
if (ilObject::_exists($mob) && ilObject::_lookupType($mob) == "mob")
{
$mob_obj = new ilObjMediaObject($mob);
$usages = $mob_obj->getUsages(false);
if (count($usages) == 0) // delete, if no usage exists
{
$mob_obj->delete();
}
}
}
}
}

+ Here is the call graph for this function:

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.

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

{
include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
$a_page->getParentType().":pg", $a_page->getId(), 0, $a_page->getLanguage());
ilObjMediaObject::_deleteAllUsages($a_page->getParentType().":pg", $a_page->getId(), false,
$a_page->getLanguage());
foreach($mob_ids as $mob) // check, whether media object can be deleted
{
if (ilObject::_exists($mob) && ilObject::_lookupType($mob) == "mob")
{
$mob_obj = new ilObjMediaObject($mob);
$usages = $mob_obj->getUsages(false);
if (count($usages) == 0) // delete, if no usage exists
{
$mob_obj->delete();
}
}
}
}

+ Here is the call graph for this function:

ilPCMediaObject::create ( $a_pg_obj,
  $a_hier_id 
)

Create pc media object.

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

References ilPageContent\createPageContentNode().

{
$this->node = $this->createPageContentNode();
}

+ Here is the call graph for this function:

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.

{
$this->node =& $this->dom->create_element("PageContent");
$a_pg_obj->insertContent($this, $a_hier_id, IL_INSERT_AFTER, $a_pc_id);
$this->mob_node =& $this->dom->create_element("MediaObject");
$this->mob_node =& $this->node->append_child($this->mob_node);
$this->mal_node =& $this->dom->create_element("MediaAlias");
$this->mal_node =& $this->mob_node->append_child($this->mal_node);
$this->mal_node->set_attribute("OriginId", "il__mob_".$this->getMediaObject()->getId());
// standard view
$item_node =& $this->dom->create_element("MediaAliasItem");
$item_node =& $this->mob_node->append_child($item_node);
$item_node->set_attribute("Purpose", "Standard");
$media_item =& $this->getMediaObject()->getMediaItem("Standard");
$layout_node =& $this->dom->create_element("Layout");
$layout_node =& $item_node->append_child($layout_node);
if ($media_item->getWidth() > 0)
{
//$layout_node->set_attribute("Width", $media_item->getWidth());
}
if ($media_item->getHeight() > 0)
{
//$layout_node->set_attribute("Height", $media_item->getHeight());
}
$layout_node->set_attribute("HorizontalAlign", "Left");
// caption
if ($media_item->getCaption() != "")
{
$cap_node =& $this->dom->create_element("Caption");
$cap_node =& $item_node->append_child($cap_node);
$cap_node->set_attribute("Align", "bottom");
$cap_node->set_content($media_item->getCaption());
}
// text representation
if ($media_item->getTextRepresentation() != "")
{
$tr_node =& $this->dom->create_element("TextRepresentation");
$tr_node =& $item_node->append_child($tr_node);
$tr_node->set_content($media_item->getTextRepresentation());
}
$pars = $media_item->getParameters();
foreach($pars as $par => $val)
{
$par_node =& $this->dom->create_element("Parameter");
$par_node =& $item_node->append_child($par_node);
$par_node->set_attribute("Name", $par);
$par_node->set_attribute("Value", $val);
}
// fullscreen view
$fullscreen_item =& $this->getMediaObject()->getMediaItem("Fullscreen");
if (is_object($fullscreen_item))
{
$item_node =& $this->dom->create_element("MediaAliasItem");
$item_node =& $this->mob_node->append_child($item_node);
$item_node->set_attribute("Purpose", "Fullscreen");
// width and height
$layout_node =& $this->dom->create_element("Layout");
$layout_node =& $item_node->append_child($layout_node);
if ($fullscreen_item->getWidth() > 0)
{
$layout_node->set_attribute("Width", $fullscreen_item->getWidth());
}
if ($fullscreen_item->getHeight() > 0)
{
$layout_node->set_attribute("Height", $fullscreen_item->getHeight());
}
// caption
if ($fullscreen_item->getCaption() != "")
{
$cap_node =& $this->dom->create_element("Caption");
$cap_node =& $item_node->append_child($cap_node);
$cap_node->set_attribute("Align", "bottom");
$cap_node->set_content($fullscreen_item->getCaption());
}
// text representation
if ($fullscreen_item->getTextRepresentation() != "")
{
$tr_node =& $this->dom->create_element("TextRepresentation");
$tr_node =& $item_node->append_child($tr_node);
$tr_node->set_content($fullscreen_item->getTextRepresentation());
}
$pars = $fullscreen_item->getParameters();
foreach($pars as $par => $val)
{
$par_node =& $this->dom->create_element("Parameter");
$par_node =& $item_node->append_child($par_node);
$par_node->set_attribute("Name", $par);
$par_node->set_attribute("Value", $val);
}
}
}

+ Here is the call graph for this function:

ilPCMediaObject::createMediaObject ( )

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

References setMediaObject().

{
}

+ Here is the call graph for this function:

ilPCMediaObject::dumpXML ( )

Dump node xml.

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

{
$xml = $this->dom->dump_node($this->node);
return $xml;
}
ilPCMediaObject::getClass ( )

Get characteristic of section.

Returns
string characteristic

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

{
if (is_object($this->mob_node))
{
$mal_node = $this->mob_node->first_child();
if (is_object($mal_node))
{
$class = $mal_node->get_attribute("Class");
return $class;
}
}
}
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.

{
return array("pc_mob");
}
ilPCMediaObject::getMediaObject ( )

Get Media Object.

Returns
object Media Object

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

Referenced by createAlias(), and updateObjectReference().

{
return $this->mediaobject;
}

+ Here is the caller graph for this function:

ilPCMediaObject::init ( )

Init page content component.

Reimplemented from ilPageContent.

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

References ilPageContent\setType().

{
$this->setType("media");
}

+ Here is the call graph for this function:

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

{
if ($a_mob_id > 0)
{
$mob = new ilObjMediaObject($a_mob_id);
$this->setMediaObject($mob);
}
}

+ Here is the call graph for this function:

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.

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

Referenced by afterPageHistoryEntry(), and afterPageUpdate().

{
$usages = array();
// media aliases
$xpath = new DOMXPath($a_domdoc);
$nodes = $xpath->query('//MediaAlias');
foreach($nodes as $node)
{
$id_arr = explode("_", $node->getAttribute("OriginId"));
$mob_id = $id_arr[count($id_arr) - 1];
if ($mob_id > 0 && $id_arr[1] == "")
{
$usages[$mob_id] = true;
}
}
// media objects
$xpath = new DOMXPath($a_domdoc);
$nodes = $xpath->query('//MediaObject/MetaData/General/Identifier');
foreach($nodes as $node)
{
$mob_entry = $node->getAttribute("Entry");
$mob_arr = explode("_", $mob_entry);
$mob_id = $mob_arr[count($mob_arr) - 1];
if ($mob_id > 0 && $mob_arr[1] == "")
{
$usages[$mob_id] = true;
}
}
// internal links
$xpath = new DOMXPath($a_domdoc);
$nodes = $xpath->query("//IntLink[@Type='MediaObject']");
foreach($nodes as $node)
{
$mob_target = $node->getAttribute("Target");
$mob_arr = explode("_", $mob_target);
//echo "<br>3<br>";
//echo $mob_target."<br>";
//var_dump($mob_arr);
$mob_id = $mob_arr[count($mob_arr) - 1];
if ($mob_id > 0 && $mob_arr[1] == "")
{
$usages[$mob_id] = true;
}
}
include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
ilObjMediaObject::_deleteAllUsages($a_page->getParentType().":pg", $a_page->getId(), $a_old_nr,
$a_page->getLanguage());
foreach($usages as $mob_id => $val)
{
// save usage, if object exists...
if (ilObject::_lookupType($mob_id) == "mob")
{
ilObjMediaObject::_saveUsage($mob_id, $a_page->getParentType().":pg", $a_page->getId(), $a_old_nr,
$a_page->getLanguage());
}
}
return $usages;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilPCMediaObject::setClass (   $a_class)

Set Style Class of table.

Parameters
string$a_classclass

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

{
if (is_object($this->mob_node))
{
$mal_node = $this->mob_node->first_child();
if (is_object($mal_node))
{
if (!empty($a_class))
{
$mal_node->set_attribute("Class", $a_class);
}
else
{
if ($mal_node->has_attribute("Class"))
{
$mal_node->remove_attribute("Class");
}
}
}
}
}
ilPCMediaObject::setDom ( $a_dom)

set dom object

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

{
$this->dom =& $a_dom;
}
ilPCMediaObject::setHierId (   $a_hier_id)

set hierarchical edit id

Reimplemented from ilPageContent.

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

{
$this->hier_id = $a_hier_id;
}
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().

{
$this->mediaobject = $a_mediaobject;
}

+ Here is the caller graph for this function:

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.

{
parent::setNode($a_node); // this is the PageContent node
$this->mob_node =& $a_node->first_child();
}
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().

{
if (is_object($this->mob_node))
{
$this->mal_node =& $this->mob_node->first_child();
if (is_object($this->mal_node) && $this->mal_node->node_name() == "MediaAlias")
{
$this->mal_node->set_attribute("OriginId", "il__mob_".$this->getMediaObject()->getId());
}
}
}

+ Here is the call graph for this function:

Field Documentation

ilPCMediaObject::$mob_node

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


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