ILIAS  trunk Revision v11.0_alpha-1811-gd2d5443e411
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilPCMediaObject Class Reference

Class ilPCMediaObject Media content object (see ILIAS DTD) More...

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

Public Member Functions

 init ()
 
 readMediaObject (int $a_mob_id=0)
 
 setHierId (string $a_hier_id)
 
 setMediaObject (ilObjMediaObject $a_mediaobject)
 
 getMediaObject ()
 
 createMediaObject ()
 
 create ()
 
 createAlias (ilPageObject $a_pg_obj, string $a_hier_id, string $a_pc_id="")
 
 updateObjectReference ()
 Updates the media object referenced by the media alias. More...
 
 dumpXML ()
 
 setClass (string $a_class)
 
 getClass ()
 Get characteristic of section. More...
 
 setCaptionClass (string $a_class)
 Set caption style class of media object. More...
 
 getCaptionClass ()
 
 modifyPageContentPostXsl (string $a_output, string $a_mode, bool $a_abstract_only=false)
 
 getOnloadCode (string $a_mode)
 
 getJavascriptFiles (string $a_mode)
 
 getCssFiles (string $a_mode)
 
 getStandardMediaAliasItem ()
 
 getFullscreenMediaAliasItem ()
 
- Public Member Functions inherited from ilPageContent
 __construct (ilPageObject $a_pg_obj, ?PageManagerInterface $page_manager=null, ?ObjectAdapterInterface $object_adapter=null)
 
 setPage (ilPageObject $a_val)
 
 getPage ()
 
 init ()
 Init object. More...
 
 getType ()
 
 getDomNode ()
 
 getDomDoc ()
 
 setDomNode (DOMNode $node)
 
 getChildNode ()
 
 getJavascriptFiles (string $a_mode)
 
 getCssFiles (string $a_mode)
 
 getOnloadCode (string $a_mode)
 
 setHierId (string $a_hier_id)
 
 getHierId ()
 
 lookupHierId ()
 
 readHierId ()
 
 setPcId (string $a_pcid)
 
 getPCId ()
 
 setFileDownloadLink (string $a_download_link)
 
 getFileDownloadLink ()
 
 setProfileBackUrl (string $url)
 
 getProfileBackUrl ()
 
 setFullscreenLink (string $a_fullscreen_link)
 
 getFullscreenLink ()
 
 setSourcecodeDownloadScript (string $script_name)
 
 getSourcecodeDownloadScript ()
 
 readPCId ()
 
 writePCId (string $a_pc_id)
 
 setEnabled (string $value)
 Set Enabled value for page content component. More...
 
 enable ()
 
 disable ()
 
 isEnabled ()
 
 createPageContentNode (bool $a_set_this_node=true)
 Create page content node (always use this method first when adding a new element) More...
 
 getNewPageContentNode ()
 
 modifyPageContentPostXsl (string $a_output, string $a_mode, bool $a_abstract_only=false)
 Modify page content after xsl. More...
 
 getModel ()
 Get model as needed for the front-end editor. More...
 

Static Public Member Functions

static getLangVars ()
 
static afterPageUpdate (ilPageObject $a_page, DOMDocument $a_domdoc, string $a_xml, bool $a_creation)
 After page has been updated (or created) More...
 
static beforePageDelete (ilPageObject $a_page)
 
static afterPageHistoryEntry (ilPageObject $a_page, DOMDocument $a_old_domdoc, string $a_old_xml, int $a_old_nr)
 After page history entry has been created. More...
 
static saveMobUsage (ilPageObject $a_page, DOMDocument $a_domdoc, int $a_old_nr=0)
 
static deleteHistoryLowerEqualThan (string $parent_type, int $page_id, string $lang, int $delete_lower_than_nr)
 
static handleCopiedContent (DOMDocument $a_domdoc, bool $a_self_ass=true, bool $a_clone_mobs=false, int $new_parent_id=0, int $obj_copy_id=0)
 
- Static Public Member Functions inherited from ilPageContent
static sortHierIds (array $a_array)
 Sort an array of Hier IDS in ascending order. More...
 
static isGreaterHierId (string $a, string $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, bool $a_self_ass=true, bool $a_clone_mobs=false, int $new_parent_id=0, int $obj_copy_id=0)
 Handle copied content. More...
 
static afterPageUpdate (ilPageObject $a_page, DOMDocument $a_domdoc, string $a_xml, bool $a_creation)
 After page has been updated (or created) More...
 
static beforePageDelete (ilPageObject $a_page)
 Before page is being deleted. More...
 
static afterRepositoryCopy (ilPageObject $page, array $mapping, int $source_ref_id)
 After repository (container) copy action. More...
 
static afterPageHistoryEntry (ilPageObject $a_page, DOMDocument $a_old_domdoc, string $a_old_xml, int $a_old_nr)
 After page history entry has been created. More...
 
static deleteHistoryLowerEqualThan (string $parent_type, int $page_id, string $lang, int $delete_lower_than_nr)
 Overwrite in derived classes, if old history entries are being deleted. More...
 

Protected Member Functions

 getMediaAliasNode ()
 
- Protected Member Functions inherited from ilPageContent
 getPageManager ()
 
 setType (string $a_type)
 Set Type. More...
 
 hasNode ()
 
 createInitialChildNode (string $hier_id, string $pc_id, string $child, array $child_attributes=[])
 

Protected Attributes

ilCtrlInterface $ctrl
 
UsageDBRepository $mob_usage_repo
 
DOMNode $mal_node
 
ilObjUser $user
 
DOMNode $mob_node
 
ILIAS DI UIServices $ui
 
ilObjMediaObject $mediaobject = null
 
ilLanguage $lng
 
ilGlobalPageTemplate $global_tpl
 
- Protected Attributes inherited from ilPageContent
DOMDocument $dom_doc
 
ILIAS COPage InternalDomainService $domain
 
string $pcid
 
string $type = ""
 
ilPageObject $pg_obj
 
string $file_download_link
 
string $fullscreen_link
 
string $sourcecode_download_script
 
ilLogger $log
 
string $profile_back_url = ""
 
ILIAS COPage Dom DomUtil $dom_util
 
PageManagerInterface $page_manager = null
 
ObjectAdapterInterface $object = null
 

Static Protected Attributes

static string $modal_show_signal = ""
 
static string $modal_suffix = ""
 

Additional Inherited Members

- Data Fields inherited from ilPageContent
string $hier_id = ""
 
DOMNode $dom_node = null
 
string $page_lang = ""
 

Detailed Description

Class ilPCMediaObject Media content object (see ILIAS DTD)

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

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

Member Function Documentation

◆ afterPageHistoryEntry()

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

After page history entry has been created.

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

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

315  : void {
316  self::saveMobUsage($a_page, $a_old_domdoc, $a_old_nr);
317  }

◆ afterPageUpdate()

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

After page has been updated (or created)

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

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

References ilObject\_exists(), ilObjMediaObject\_getMobsOfObject(), ilObject\_lookupType(), ilPageObject\getId(), ilPageObject\getImportMode(), ilPageObject\getLanguage(), and ilPageObject\getParentType().

254  : void {
255  if (!$a_page->getImportMode()) {
257  $a_page->getParentType() . ":pg",
258  $a_page->getId(),
259  0,
260  $a_page->getLanguage()
261  );
262  self::saveMobUsage($a_page, $a_domdoc);
263  foreach ($mob_ids as $mob) { // check, whether media object can be deleted
264  if (ilObject::_exists($mob) && ilObject::_lookupType($mob) == "mob") {
265  $mob_obj = new ilObjMediaObject($mob);
266  $usages = $mob_obj->getUsages(false);
267  if (count($usages) == 0) { // delete, if no usage exists
268  $mob_obj->delete();
269  }
270  }
271  }
272  }
273  }
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
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:

◆ beforePageDelete()

static ilPCMediaObject::beforePageDelete ( ilPageObject  $a_page)
static

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

References ilObjMediaObject\_deleteAllUsages(), ilObject\_exists(), ilObjMediaObject\_getMobsOfObject(), ilObject\_lookupType(), ilPageObject\getId(), ilPageObject\getLanguage(), ilPageObject\getParentType(), and null.

277  : void {
279  $a_page->getParentType() . ":pg",
280  $a_page->getId(),
281  0,
282  $a_page->getLanguage()
283  );
284 
286  $a_page->getParentType() . ":pg",
287  $a_page->getId(),
288  null,
289  $a_page->getLanguage()
290  );
291 
292  foreach ($mob_ids as $mob) { // check, whether media object can be deleted
293  if (ilObject::_exists($mob) && ilObject::_lookupType($mob) == "mob") {
294  $mob_obj = new ilObjMediaObject($mob);
295  $usages = $mob_obj->getUsages(false);
296  if (count($usages) == 0) { // delete, if no usage exists
297  $mob_obj->delete();
298  }
299  }
300  }
301  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static _exists(int $id, bool $reference=false, ?string $type=null)
checks if an object exists in object_data
static _getMobsOfObject(string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
static _deleteAllUsages(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:

◆ create()

ilPCMediaObject::create ( )

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

References ilPageContent\createPageContentNode().

83  : void
84  {
85  $this->createPageContentNode();
86  }
createPageContentNode(bool $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 ( ilPageObject  $a_pg_obj,
string  $a_hier_id,
string  $a_pc_id = "" 
)

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

References ilPageContent\getDomNode(), ILIAS\Survey\Mode\getId(), getMediaObject(), IL_INSERT_AFTER, ilPageObject\insertContent(), and ilPageContent\setDomNode().

92  : void {
93  $this->setDomNode($this->dom_doc->createElement("PageContent"));
94  $a_pg_obj->insertContent($this, $a_hier_id, IL_INSERT_AFTER, $a_pc_id);
95  $mob_node = $this->dom_doc->createElement("MediaObject");
96  $mob_node = $this->getDomNode()->appendChild($mob_node);
97  $this->mal_node = $this->dom_doc->createElement("MediaAlias");
98  $this->mal_node = $mob_node->appendChild($this->mal_node);
99  $this->mal_node->setAttribute("OriginId", "il__mob_" . $this->getMediaObject()->getId());
100 
101  // standard view
102  $item_node = $this->dom_doc->createElement("MediaAliasItem");
103  $item_node = $mob_node->appendChild($item_node);
104  $item_node->setAttribute("Purpose", "Standard");
105  $media_item = $this->getMediaObject()->getMediaItem("Standard");
106  if (is_null($media_item)) {
107  return;
108  }
109 
110  $layout_node = $this->dom_doc->createElement("Layout");
111  $layout_node = $item_node->appendChild($layout_node);
112  if ($media_item->getWidth() > 0) {
113  //$layout_node->set_attribute("Width", $media_item->getWidth());
114  }
115  if ($media_item->getHeight() > 0) {
116  //$layout_node->set_attribute("Height", $media_item->getHeight());
117  }
118  $layout_node->setAttribute("HorizontalAlign", "Left");
119 
120  // caption
121  if ($media_item->getCaption() != "") {
122  $cap_node = $this->dom_doc->createElement("Caption");
123  $cap_node = $item_node->appendChild($cap_node);
124  $cap_node->setAttribute("Align", "bottom");
125  $this->dom_util->setContent($cap_node, $media_item->getCaption());
126  }
127 
128  // text representation
129  if ($media_item->getTextRepresentation() != "") {
130  $tr_node = $this->dom_doc->createElement("TextRepresentation");
131  $tr_node = $item_node->appendChild($tr_node);
132  $this->dom_util->setContent($tr_node, $media_item->getTextRepresentation());
133  }
134 
135  $pars = $media_item->getParameters();
136  foreach ($pars as $par => $val) {
137  $par_node = $this->dom_doc->createElement("Parameter");
138  $par_node = $item_node->appendChild($par_node);
139  $par_node->setAttribute("Name", $par);
140  $par_node->setAttribute("Value", $val);
141  }
142 
143  // fullscreen view
144  $fullscreen_item = $this->getMediaObject()->getMediaItem("Fullscreen");
145  if (is_object($fullscreen_item)) {
146  $item_node = $this->dom_doc->createElement("MediaAliasItem");
147  $item_node = $mob_node->appendChild($item_node);
148  $item_node->setAttribute("Purpose", "Fullscreen");
149 
150  // width and height
151  $layout_node = $this->dom_doc->createElement("Layout");
152  $layout_node = $item_node->appendChild($layout_node);
153  if ($fullscreen_item->getWidth() > 0) {
154  $layout_node->setAttribute("Width", $fullscreen_item->getWidth());
155  }
156  if ($fullscreen_item->getHeight() > 0) {
157  $layout_node->setAttribute("Height", $fullscreen_item->getHeight());
158  }
159 
160  // caption
161  if ($fullscreen_item->getCaption() != "") {
162  $cap_node = $this->dom_doc->createElement("Caption");
163  $cap_node = $item_node->appendChild($cap_node);
164  $cap_node->setAttribute("Align", "bottom");
165  $this->dom_util->setContent($cap_node, $fullscreen_item->getCaption());
166  }
167 
168  // text representation
169  if ($fullscreen_item->getTextRepresentation() != "") {
170  $tr_node = $this->dom_doc->createElement("TextRepresentation");
171  $tr_node = $item_node->appendChild($tr_node);
172  $this->dom_util->setContent($tr_node, $fullscreen_item->getTextRepresentation());
173  }
174 
175  $pars = $fullscreen_item->getParameters();
176  foreach ($pars as $par => $val) {
177  $par_node = $this->dom_doc->createElement("Parameter");
178  $par_node = $item_node->appendChild($par_node);
179  $par_node->setAttribute("Name", $par);
180  $par_node->setAttribute("Value", $val);
181  }
182  }
183  }
insertContent(ilPageContent $a_cont_obj, string $a_pos, int $a_mode=IL_INSERT_AFTER, string $a_pcid="", bool $remove_placeholder=true)
insert a content node before/after a sibling or as first child of a parent
setDomNode(DOMNode $node)
const IL_INSERT_AFTER
+ Here is the call graph for this function:

◆ createMediaObject()

ilPCMediaObject::createMediaObject ( )

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

References setMediaObject().

78  : void
79  {
80  $this->setMediaObject(new ilObjMediaObject());
81  }
setMediaObject(ilObjMediaObject $a_mediaobject)
+ Here is the call graph for this function:

◆ deleteHistoryLowerEqualThan()

static ilPCMediaObject::deleteHistoryLowerEqualThan ( string  $parent_type,
int  $page_id,
string  $lang,
int  $delete_lower_than_nr 
)
static

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

References $DIC, ilPageContent\$log, ilObject\_lookupType(), ilLogger\debug(), ILIAS\Skill\Usage\UsageDBRepository\deleteHistoryUsagesLowerEqualThan(), ILIAS\Skill\Usage\UsageDBRepository\getHistoryUsagesLowerEqualThan(), ilLoggerFactory\getLogger(), and ilObjMediaObject\lookupUsages().

569  : void {
570  global $DIC;
571 
572  $mob_usage_repo = $DIC->mediaObjects()
573  ->internal()
574  ->repo()
575  ->usage();
576 
578 
580  $parent_type . ":pg",
581  $page_id,
582  $delete_lower_than_nr,
583  $lang
584  );
585 
587  $parent_type . ":pg",
588  $page_id,
589  $delete_lower_than_nr,
590  $lang
591  );
592 
593  foreach ($mob_ids as $mob_id) {
594  $usages = ilObjMediaObject::lookupUsages($mob_id, true);
595  $log->debug("...check deletion of mob $mob_id. Usages: " . count($usages));
596  if (count($usages) == 0) {
597  if (ilObject::_lookupType($mob_id) === "mob") {
598  $mob = new ilObjMediaObject($mob_id);
599  $log->debug("Deleting Mob ID: " . $mob_id);
600  $mob->delete();
601  }
602  }
603  }
604  }
static getLogger(string $a_component_id)
Get component logger.
static lookupUsages(int $a_id, bool $a_include_history=true)
Lookup usages of media object.
getHistoryUsagesLowerEqualThan(string $a_type, int $a_id, int $a_usage_hist_nr, string $a_lang="-")
global $DIC
Definition: shib_login.php:22
deleteHistoryUsagesLowerEqualThan(string $a_type, int $a_id, int $a_usage_hist_nr, string $a_lang="-")
$lang
Definition: xapiexit.php:25
UsageDBRepository $mob_usage_repo
debug(string $message, array $context=[])
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:

◆ dumpXML()

ilPCMediaObject::dumpXML ( )

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

References ilPageContent\getDomNode().

206  : string
207  {
208  return $this->dom_util->dump($this->getDomNode());
209  }
+ Here is the call graph for this function:

◆ getCaptionClass()

ilPCMediaObject::getCaptionClass ( )

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

References getMediaAliasNode().

232  : string
233  {
234  return (string) $this->getMediaAliasNode()?->getAttribute("CaptionClass");
235  }
+ Here is the call graph for this function:

◆ getClass()

ilPCMediaObject::getClass ( )

Get characteristic of section.

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

References getMediaAliasNode().

219  : string
220  {
221  return (string) $this->getMediaAliasNode()?->getAttribute("Class");
222  }
+ Here is the call graph for this function:

◆ getCssFiles()

ilPCMediaObject::getCssFiles ( string  $a_mode)

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

503  : array {
504  return [];
505  }

◆ getFullscreenMediaAliasItem()

ilPCMediaObject::getFullscreenMediaAliasItem ( )

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

References ilPageContent\getDomDoc(), ilPageContent\getHierId(), getMediaObject(), ilPageContent\getPage(), ilPageContent\getPCId(), and getStandardMediaAliasItem().

519  {
520  $std_alias_item = new ilMediaAliasItem(
521  $this->getDomDoc(),
522  $this->getHierId(),
523  "Fullscreen",
524  $this->getPCId()
525  );
526  return $std_alias_item;
527  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:

◆ getJavascriptFiles()

ilPCMediaObject::getJavascriptFiles ( string  $a_mode)

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

References iljQueryUtil\getLocalMaphilightPath().

495  : array {
496  //$js_files = ilPlayerUtil::getJsFilePaths();
497  $js_files[] = iljQueryUtil::getLocalMaphilightPath();
498  return $js_files;
499  }
static getLocalMaphilightPath()
Get local path of maphilight file.
+ Here is the call graph for this function:

◆ getLangVars()

static ilPCMediaObject::getLangVars ( )
static

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

237  : array
238  {
239  return array("pc_mob");
240  }

◆ getMediaAliasNode()

ilPCMediaObject::getMediaAliasNode ( )
protected

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

References $mal_node, ilPageContent\getChildNode(), and null.

Referenced by getCaptionClass(), getClass(), setCaptionClass(), setClass(), and updateObjectReference().

185  : ?DOMNode
186  {
187  if (is_object($this->getChildNode())) {
188  $mal_node = $this->getChildNode()->firstChild;
189  if (is_object($mal_node) && $mal_node->nodeName == "MediaAlias") {
190  return $mal_node;
191  }
192  }
193  return null;
194  }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getMediaObject()

ilPCMediaObject::getMediaObject ( )

◆ getOnloadCode()

ilPCMediaObject::getOnloadCode ( string  $a_mode)

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

482  : array
483  {
484  $onload_code = [];
485  // necessary due to 32198 (other main template used)
486  if (self::$modal_show_signal !== "") {
487  $onload_code[] = "il.COPagePres.setFullscreenModalShowSignal('" . self::$modal_show_signal .
488  "', '" . self::$modal_suffix . "');";
489  }
490  return $onload_code;
491  }

◆ getStandardMediaAliasItem()

ilPCMediaObject::getStandardMediaAliasItem ( )

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

References ilPageContent\getDomDoc(), ilPageContent\getHierId(), and ilPageContent\getPCId().

Referenced by getFullscreenMediaAliasItem().

508  {
509  $std_alias_item = new ilMediaAliasItem(
510  $this->getDomDoc(),
511  $this->getHierId(),
512  "Standard",
513  $this->getPCId()
514  );
515  return $std_alias_item;
516  }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handleCopiedContent()

static ilPCMediaObject::handleCopiedContent ( DOMDocument  $a_domdoc,
bool  $a_self_ass = true,
bool  $a_clone_mobs = false,
int  $new_parent_id = 0,
int  $obj_copy_id = 0 
)
static

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

References $DIC, ilPageContent\$dom_util, $path, ilInternalLink\_extractInstOfTarget(), and ilInternalLink\_extractObjIdOfTarget().

612  : void {
613  global $DIC;
614 
615  if (!$a_clone_mobs) {
616  return;
617  }
618 
619  $dom_util = $DIC->copage()->internal()->domain()->domUtil();
620  $path = "//MediaObject/MediaAlias";
621  $nodes = $dom_util->path($a_domdoc, $path);
622  foreach ($nodes as $node) {
623  $or_id = $node->getAttribute("OriginId");
624 
625  $inst_id = ilInternalLink::_extractInstOfTarget($or_id);
626  $mob_id = ilInternalLink::_extractObjIdOfTarget($or_id);
627 
628  if (!($inst_id > 0)) {
629  if ($mob_id > 0) {
630  $media_object = new ilObjMediaObject($mob_id);
631  $new_mob = $media_object->duplicate();
632  $node->setAttribute("OriginId", "il__mob_" . $new_mob->getId());
633  }
634  }
635  }
636  }
$path
Definition: ltiservices.php:29
global $DIC
Definition: shib_login.php:22
ILIAS COPage Dom DomUtil $dom_util
+ Here is the call graph for this function:

◆ init()

ilPCMediaObject::init ( )

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

References $DIC, ILIAS\Repository\ctrl(), ILIAS\Repository\lng(), ilPageContent\setType(), ILIAS\Repository\ui(), and ILIAS\Repository\user().

40  : void
41  {
42  global $DIC;
43 
44  $this->user = $DIC->user();
45  $this->setType("media");
46  $this->ui = $DIC->ui();
47  $this->lng = $DIC->language();
48  $this->mob_usage_repo = $DIC->mediaObjects()
49  ->internal()
50  ->repo()
51  ->usage();
52  $this->ctrl = $DIC->ctrl();
53  }
setType(string $a_type)
Set Type.
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

◆ modifyPageContentPostXsl()

ilPCMediaObject::modifyPageContentPostXsl ( string  $a_output,
string  $a_mode,
bool  $a_abstract_only = false 
)

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

References $DIC, $user, ilObjMediaObject\_getDirectory(), ilObjMediaObject\_getMobsOfObject(), ILIAS\Repository\ctrl(), ilPageContent\getPage(), ILIAS\Repository\lng(), and ILIAS\Repository\ui().

390  : string {
391  global $DIC;
392 
393  $this->global_tpl = $DIC['tpl'];
394  $ilUser = $this->user;
395 
396  if ($a_mode == "offline") {
397  $page = $this->getPage();
398 
400  $page->getParentType() . ":pg",
401  $page->getId(),
402  0,
403  $page->getLanguage()
404  );
405  foreach ($mob_ids as $mob_id) {
406  $mob = new ilObjMediaObject($mob_id);
407  $srts = $mob->getSrtFiles();
408  foreach ($srts as $srt) {
409  if ($ilUser->getLanguage() == $srt["language"]) {
410  $srt_content = file_get_contents(ilObjMediaObject::_getDirectory($mob->getId()) . "/" . $srt["full_path"]);
411  $a_output = str_replace("[[[[[mobsubtitle;il__mob_" . $mob->getId() . "_Standard]]]]]", $srt_content, $a_output);
412  }
413  }
414  }
415  }
416 
417  if ($a_abstract_only) {
418  return $a_output;
419  }
420 
421  if ($a_mode === "edit") {
422  $a_output = str_replace(
423  "{{{{{Unsupported Media Type}}}}}",
424  $this->ui->renderer()->render(
425  $this->ui->factory()->messageBox()->info(
426  $this->lng->txt("copg_unsupported_media_type")
427  )
428  ),
429  $a_output
430  );
431  // currently media objects, when in translation mode
432  $a_output = str_replace(
433  "{{{{{No Media Type}}}}}",
434  '<div class="copg-new-content-placeholder">' .
435  $this->ui->renderer()->render(
436  $this->ui->factory()->symbol()->icon()->standard("pemed", "pemed", 'medium')
437  ) . "</div>",
438  $a_output
439  );
440  } else {
441  $a_output = str_replace(
442  "{{{{{Unsupported Media Type}}}}}",
443  "",
444  $a_output
445  );
446  $a_output = str_replace(
447  "{{{{{No Media Type}}}}}",
448  "",
449  $a_output
450  );
451  }
452 
453  // add fullscreen modals
454  $page = $this->getPage();
455  $suffix = "-" . $page->getParentType() . "-" . $page->getId();
456  $modal = $this->ui->factory()->modal()->roundtrip(
457  $this->lng->txt("cont_fullscreen"),
458  $this->ui->factory()->legacy()->content("<iframe class='il-copg-mob-fullscreen' id='il-copg-mob-fullscreen" . $suffix . "'></iframe>")
459  );
460  $show_signal = $modal->getShowSignal();
461 
462  $js = "
463  $(function () {
464  il.COPagePres.setFullscreenModalShowSignal('$show_signal', '$suffix');
465  });
466  ";
467  self::$modal_show_signal = $show_signal;
468  self::$modal_suffix = $suffix;
469  $this->global_tpl->addOnloadCode($js);
470 
471  // async ensures to have onloadcode of modal in output
472  // if other main tpl is used, see #32198
473  // note: if always rendered async, $ not defined errors will be thrown in non-async cases
474  if ($this->ctrl->isAsynch()) {
475  $html = $this->ui->renderer()->renderAsync($modal);
476  } else {
477  $html = $this->ui->renderer()->render($modal);
478  }
479  return $a_output . "<div class='il-copg-mob-fullscreen-modal'>" . $html . "</div>";
480  }
static _getDirectory(int $a_mob_id)
Get absolute directory.
global $DIC
Definition: shib_login.php:22
static _getMobsOfObject(string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
+ Here is the call graph for this function:

◆ readMediaObject()

ilPCMediaObject::readMediaObject ( int  $a_mob_id = 0)

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

References setMediaObject().

55  : void
56  {
57  if ($a_mob_id > 0) {
58  $mob = new ilObjMediaObject($a_mob_id);
59  $this->setMediaObject($mob);
60  }
61  }
setMediaObject(ilObjMediaObject $a_mediaobject)
+ Here is the call graph for this function:

◆ saveMobUsage()

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

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

References ilObjMediaObject\_deleteAllUsages(), ilObject\_lookupType(), ilObjMediaObject\_saveUsage(), ilPageObject\getId(), ilPageObject\getLanguage(), and ilPageObject\getParentType().

323  : array {
324  $usages = array();
325 
326  // media aliases
327  $xpath = new DOMXPath($a_domdoc);
328  $nodes = $xpath->query('//MediaAlias');
329  foreach ($nodes as $node) {
330  $id_arr = explode("_", $node->getAttribute("OriginId"));
331  $mob_id = $id_arr[count($id_arr) - 1];
332  if ($mob_id > 0 && $id_arr[1] == "") {
333  $usages[$mob_id] = true;
334  }
335  }
336 
337  // media objects
338  $xpath = new DOMXPath($a_domdoc);
339  $nodes = $xpath->query('//MediaObject/MetaData/General/Identifier');
340  foreach ($nodes as $node) {
341  $mob_entry = $node->getAttribute("Entry");
342  $mob_arr = explode("_", $mob_entry);
343  $mob_id = $mob_arr[count($mob_arr) - 1];
344  if ($mob_id > 0 && $mob_arr[1] == "") {
345  $usages[$mob_id] = true;
346  }
347  }
348 
349  // internal links
350  $xpath = new DOMXPath($a_domdoc);
351  $nodes = $xpath->query("//IntLink[@Type='MediaObject']");
352  foreach ($nodes as $node) {
353  $mob_target = $node->getAttribute("Target");
354  $mob_arr = explode("_", $mob_target);
355  //echo "<br>3<br>";
356  //echo $mob_target."<br>";
357  //var_dump($mob_arr);
358  $mob_id = $mob_arr[count($mob_arr) - 1];
359  if ($mob_id > 0 && $mob_arr[1] == "") {
360  $usages[$mob_id] = true;
361  }
362  }
363 
365  $a_page->getParentType() . ":pg",
366  $a_page->getId(),
367  $a_old_nr,
368  $a_page->getLanguage()
369  );
370  foreach ($usages as $mob_id => $val) {
371  // save usage, if object exists...
372  if (ilObject::_lookupType($mob_id) == "mob") {
374  $mob_id,
375  $a_page->getParentType() . ":pg",
376  $a_page->getId(),
377  $a_old_nr,
378  $a_page->getLanguage()
379  );
380  }
381  }
382 
383  return $usages;
384  }
static _saveUsage(int $a_mob_id, string $a_type, int $a_id, int $a_usage_hist_nr=0, string $a_lang="-")
Save usage of mob within another container (e.g.
static _deleteAllUsages(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:

◆ setCaptionClass()

ilPCMediaObject::setCaptionClass ( string  $a_class)

Set caption style class of media object.

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

References getMediaAliasNode().

227  : void
228  {
229  $this->dom_util->setAttribute($this->getMediaAliasNode(), "CaptionClass", $a_class);
230  }
+ Here is the call graph for this function:

◆ setClass()

ilPCMediaObject::setClass ( string  $a_class)

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

References getMediaAliasNode().

211  : void
212  {
213  $this->dom_util->setAttribute($this->getMediaAliasNode(), "Class", $a_class);
214  }
+ Here is the call graph for this function:

◆ setHierId()

ilPCMediaObject::setHierId ( string  $a_hier_id)

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

63  : void
64  {
65  $this->hier_id = $a_hier_id;
66  }

◆ setMediaObject()

ilPCMediaObject::setMediaObject ( ilObjMediaObject  $a_mediaobject)

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

Referenced by createMediaObject(), and readMediaObject().

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

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

References ILIAS\Survey\Mode\getId(), getMediaAliasNode(), and getMediaObject().

201  : void
202  {
203  $this->getMediaAliasNode()?->setAttribute("OriginId", "il__mob_" . $this->getMediaObject()->getId());
204  }
+ Here is the call graph for this function:

Field Documentation

◆ $ctrl

ilCtrlInterface ilPCMediaObject::$ctrl
protected

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

◆ $global_tpl

ilGlobalPageTemplate ilPCMediaObject::$global_tpl
protected

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

◆ $lng

ilLanguage ilPCMediaObject::$lng
protected

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

◆ $mal_node

DOMNode ilPCMediaObject::$mal_node
protected

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

Referenced by getMediaAliasNode().

◆ $mediaobject

ilObjMediaObject ilPCMediaObject::$mediaobject = null
protected

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

Referenced by getMediaObject().

◆ $mob_node

DOMNode ilPCMediaObject::$mob_node
protected

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

◆ $mob_usage_repo

UsageDBRepository ilPCMediaObject::$mob_usage_repo
protected

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

◆ $modal_show_signal

string ilPCMediaObject::$modal_show_signal = ""
staticprotected

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

◆ $modal_suffix

string ilPCMediaObject::$modal_suffix = ""
staticprotected

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

◆ $ui

ILIAS DI UIServices ilPCMediaObject::$ui
protected

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

◆ $user

ilObjUser ilPCMediaObject::$user
protected

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

Referenced by modifyPageContentPostXsl().


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