ILIAS  trunk Revision v11.0_alpha-2662-g519ff7d528f
ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager Class Reference
+ Collaboration diagram for ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager:

Public Member Functions

 __construct (\DOMDocument $dom, ?PCDefinition $def=null)
 
 getContentDomNode (string $a_hier_id, string $a_pc_id="")
 
 deleteContent (\ilPageObject $page, string $a_hid, string $a_pcid="", bool $move_operation=false)
 
 deleteContents (\ilPageObject $page, array $a_hids, bool $a_self_ass=false, bool $move_operation=false)
 
 handleDeleteContent (\ilPageObject $page, $a_node=null, $move_operation=false)
 
 switchEnableMultiple (\ilPageObject $page, array $a_hids, bool $a_self_ass=false)
 
 setInitialOpenedContent (string $a_type="", int $a_id=0, string $a_target="")
 
 getInitialOpenedContent ()
 Get initial opened content. More...
 
 downloadFile (\ilPageObject $page, string $file_link_id)
 
 insertInstIntoIDs (string $a_inst, bool $a_res_ref_to_obj_id=true)
 inserts installation id into ids (e.g. More...
 
 pasteContents (\ilObjUser $user, string $a_hier_id, \ilPageObject $page, bool $a_self_ass=false)
 
 copyXmlContent (\ilPageObject $page, bool $a_clone_mobs=false, int $a_new_parent_id=0, int $obj_copy_id=0, bool $self_ass=true)
 
 insertContentNode (\DOMNode $a_cont_node, string $a_pos, int $a_mode=IL_INSERT_AFTER, string $a_pcid="")
 
 insertContent (\ilPageContent $a_cont_obj, string $a_pos, int $a_mode=IL_INSERT_AFTER, string $a_pcid="", bool $remove_placeholder=true, bool $placeholder_enabled=false)
 
 moveContentAfter (\ilPageObject $page, string $a_source, string $a_target, string $a_spcid="", string $a_tpcid="")
 move content object from position $a_source before position $a_target (both hierarchical content ids) More...
 
 copyContents (array $a_hids, \ilObjUser $user)
 Copy contents to clipboard. More...
 

Protected Member Functions

 getPageObjectNode ()
 
 checkForTag (string $a_content_tag, string $a_hier_id, string $a_pc_id="")
 
 handleCopiedContent (\ilPageObject $page, \DOMDocument $dom, bool $a_self_ass=true, bool $a_clone_mobs=false, int $new_parent_id=0, int $obj_copy_id=0)
 Handle copied content This function copies items, that must be copied, if page content is duplicated. More...
 

Protected Attributes

ILIAS COPage Dom DomUtil $dom_util
 
DOMDocument $dom
 
ILIAS COPage Link LinkManager $link
 
ILIAS COPage PC DomainService $pc_service
 
DOMNode $page_object_node
 

Detailed Description

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

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

Constructor & Destructor Documentation

◆ __construct()

ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager::__construct ( \DOMDocument  $dom,
?PCDefinition  $def = null 
)

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

References $DIC, ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager\$dom, $path, and ILIAS\Repository\link().

39  {
40  global $DIC;
41 
42  $this->dom = $dom;
43  $this->dom_util = $DIC->copage()->internal()->domain()->domUtil();
44  $this->pc_service = $DIC->copage()->internal()->domain()->pc($def);
45  $this->link = $DIC->copage()->internal()->domain()->link();
46 
47  $path = "//PageObject";
48  $nodes = $this->dom_util->path($dom, $path);
49  if (count($nodes) == 1) {
50  $this->page_object_node = $nodes->item(0);
51  }
52  }
$path
Definition: ltiservices.php:29
global $DIC
Definition: shib_login.php:26
link(string $caption, string $href, bool $new_viewport=false)
+ Here is the call graph for this function:

Member Function Documentation

◆ checkForTag()

ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager::checkForTag ( string  $a_content_tag,
string  $a_hier_id,
string  $a_pc_id = "" 
)
protected

Definition at line 114 of file class.PageContentManager.php.

References $path.

Referenced by ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager\deleteContents(), and ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager\switchEnableMultiple().

118  : bool {
119  // get per pc id
120  if ($a_pc_id != "") {
121  $path = "//*[@PCID = '$a_pc_id']//" . $a_content_tag;
122  } else {
123  $path = "//*[@HierId = '$a_hier_id']//" . $a_content_tag;
124  }
125 
126  $nodes = $this->dom_util->path($this->dom, $path);
127  if (count($nodes) > 0) {
128  return true;
129  }
130  return false;
131  }
$path
Definition: ltiservices.php:29
+ Here is the caller graph for this function:

◆ copyContents()

ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager::copyContents ( array  $a_hids,
\ilObjUser  $user 
)

Copy contents to clipboard.

Definition at line 693 of file class.PageContentManager.php.

References ilObjUser\addToPCClipboard(), ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager\getContentDomNode(), null, ilEditClipboard\setAction(), and ilPageContent\sortHierIds().

696  : void {
697  $pc_id = null;
698 
699  if (!is_array($a_hids)) {
700  return;
701  }
702 
703  $time = date("Y-m-d H:i:s", time());
704 
705  $hier_ids = array();
706  $skip = array();
707  foreach ($a_hids as $a_hid) {
708  if ($a_hid == "") {
709  continue;
710  }
711  $a_hid = explode(":", $a_hid);
712 
713  // check, whether new hid is child of existing one or vice versa
714  reset($hier_ids);
715  foreach ($hier_ids as $h) {
716  if ($h . "_" == substr($a_hid[0], 0, strlen($h) + 1)) {
717  $skip[] = $a_hid[0];
718  }
719  if ($a_hid[0] . "_" == substr($h, 0, strlen($a_hid[0]) + 1)) {
720  $skip[] = $h;
721  }
722  }
723  $pc_id[$a_hid[0]] = $a_hid[1];
724  if ($a_hid[0] != "") {
725  $hier_ids[$a_hid[0]] = $a_hid[0];
726  }
727  }
728  foreach ($skip as $s) {
729  unset($hier_ids[$s]);
730  }
731  $hier_ids = \ilPageContent::sortHierIds($hier_ids);
732  $nr = 1;
733  foreach ($hier_ids as $hid) {
734  $curr_node = $this->getContentDomNode($hid, $pc_id[$hid]);
735  if (is_object($curr_node)) {
736  if ($curr_node->nodeName == "PageContent") {
737  $content = $this->dom_util->dump($curr_node);
738  // remove pc and hier ids
739  $content = preg_replace('/PCID=\"[a-z0-9]*\"/i', "", $content);
740  $content = preg_replace('/HierId=\"[a-z0-9_]*\"/i', "", $content);
741 
742  $user->addToPCClipboard($content, $time, $nr);
743  $nr++;
744  }
745  }
746  }
748  }
static setAction(string $a_action)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
static sortHierIds(array $a_array)
Sort an array of Hier IDS in ascending order.
+ Here is the call graph for this function:

◆ copyXmlContent()

ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager::copyXmlContent ( \ilPageObject  $page,
bool  $a_clone_mobs = false,
int  $a_new_parent_id = 0,
int  $obj_copy_id = 0,
bool  $self_ass = true 
)

Definition at line 435 of file class.PageContentManager.php.

References ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager\handleCopiedContent().

441  : string {
442  $this->handleCopiedContent($page, $this->dom, $self_ass, $a_clone_mobs, $a_new_parent_id, $obj_copy_id);
443  $this->dom->documentElement;
444  $xml = $this->dom_util->dump($this->dom->documentElement);
445  $xml = preg_replace('/<\?xml[^>]*>/i', "", $xml);
446  $xml = preg_replace('/<!DOCTYPE[^>]*>/i', "", $xml);
447  return $xml;
448  }
handleCopiedContent(\ilPageObject $page, \DOMDocument $dom, bool $a_self_ass=true, bool $a_clone_mobs=false, int $new_parent_id=0, int $obj_copy_id=0)
Handle copied content This function copies items, that must be copied, if page content is duplicated...
+ Here is the call graph for this function:

◆ deleteContent()

ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager::deleteContent ( \ilPageObject  $page,
string  $a_hid,
string  $a_pcid = "",
bool  $move_operation = false 
)

Definition at line 80 of file class.PageContentManager.php.

References ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager\getContentDomNode(), and ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager\handleDeleteContent().

Referenced by ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager\moveContentAfter().

85  {
86  $curr_node = $this->getContentDomNode($a_hid, $a_pcid);
87  $this->handleDeleteContent($page, $curr_node, $move_operation);
88  $curr_node->parentNode->removeChild($curr_node);
89  }
handleDeleteContent(\ilPageObject $page, $a_node=null, $move_operation=false)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ deleteContents()

ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager::deleteContents ( \ilPageObject  $page,
array  $a_hids,
bool  $a_self_ass = false,
bool  $move_operation = false 
)

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

References ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager\checkForTag(), ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager\getContentDomNode(), and ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager\handleDeleteContent().

96  {
97  foreach ($a_hids as $a_hid) {
98  $a_hid = explode(":", $a_hid);
99  // @todo 1: hook
100  // do not delete question nodes in assessment pages
101  if (!$this->checkForTag("Question", $a_hid[0], (string) ($a_hid[1] ?? "")) || $a_self_ass) {
102  $curr_node = $this->getContentDomNode((string) $a_hid[0], (string) ($a_hid[1] ?? ""));
103  if (is_object($curr_node)) {
104  $parent_node = $curr_node->parentNode;
105  if ($parent_node->nodeName != "TableRow") {
106  $this->handleDeleteContent($page, $curr_node, $move_operation);
107  $curr_node->parentNode->removeChild($curr_node);
108  }
109  }
110  }
111  }
112  }
checkForTag(string $a_content_tag, string $a_hier_id, string $a_pc_id="")
handleDeleteContent(\ilPageObject $page, $a_node=null, $move_operation=false)
+ Here is the call graph for this function:

◆ downloadFile()

ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager::downloadFile ( \ilPageObject  $page,
string  $file_link_id 
)

Definition at line 272 of file class.PageContentManager.php.

References ilPageObject\buildDom(), exit, ilPageObject\getDomDoc(), ilPageObject\getId(), ilPageObject\getParentType(), ilPageContentUsage\getUsagesOfPage(), and ILIAS\Repository\link().

275  : void {
276  $file_id = 0;
277 
278  $page->buildDom();
279  $dom = $page->getDomDoc();
280 
281  if ($this->link->containsFileLinkId($dom, $file_link_id)) {
282  $file_id = $this->link->extractFileFromLinkId($file_link_id);
283  }
284  if (in_array($file_link_id, $this->pc_service->fileList()->getAllFileObjIds($dom))) {
285  $file_id = $this->link->extractFileFromLinkId($file_link_id);
286  }
287 
288  $pcs = \ilPageContentUsage::getUsagesOfPage($page->getId(), $page->getParentType() . ":pg", 0, false);
289  foreach ($pcs as $pc) {
290  $files = \ilObjFile::_getFilesOfObject("mep:pg", $pc["id"], 0);
291  $c_file = $this->link->extractFileFromLinkId($file_link_id);
292  if (in_array($c_file, $files)) {
293  $file_id = $c_file;
294  }
295  }
296 
297  if ($file_id > 0) {
298  $fileObj = new \ilObjFile($file_id, false);
299  $fileObj->sendFile();
300  exit;
301  }
302  }
static getUsagesOfPage(int $a_usage_id, string $a_usage_type, int $a_hist_nr=0, bool $a_all_hist_nrs=false, string $a_lang="-")
Get page content usages for page.
exit
link(string $caption, string $href, bool $new_viewport=false)
+ Here is the call graph for this function:

◆ getContentDomNode()

ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager::getContentDomNode ( string  $a_hier_id,
string  $a_pc_id = "" 
)

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

References $path, and null.

Referenced by ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager\copyContents(), ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager\deleteContent(), ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager\deleteContents(), ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager\insertContent(), ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager\insertContentNode(), and ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager\switchEnableMultiple().

59  : ?\DOMNode
60  {
61  if ($a_hier_id == "pg") {
62  $path = "//PageObject";
63  } else {
64  // get per pc id
65  if ($a_pc_id != "") {
66  $path = "//*[@PCID = '$a_pc_id']";
67  } else {
68  // fall back to hier id
69  $path = "//*[@HierId = '$a_hier_id']";
70  }
71  }
72  $nodes = $this->dom_util->path($this->dom, $path);
73  if (count($nodes) === 1) {
74  $cont_node = $nodes->item(0);
75  return $cont_node;
76  }
77  return null;
78  }
$path
Definition: ltiservices.php:29
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
+ Here is the caller graph for this function:

◆ getInitialOpenedContent()

ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager::getInitialOpenedContent ( )

Get initial opened content.

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

References $id, $path, ilInternalLink\_extractObjIdOfTarget(), and null.

232  : array
233  {
234  $type = "";
235  $path = "//PageObject/InitOpenedContent";
236  $il_node = null;
237  $nodes = $this->dom_util->path($this->dom, $path);
238  if (count($nodes) > 0) {
239  $init_node = $nodes->item(0);
240  foreach ($init_node->childNodes as $child) {
241  if ($child->nodeName == "IntLink") {
242  $il_node = $child;
243  }
244  }
245  }
246  if (!is_null($il_node)) {
247  $id = $il_node->getAttribute("Target");
248  $link_type = $il_node->getAttribute("Type");
249  $target = $il_node->getAttribute("TargetFrame");
250 
251  switch ($link_type) {
252  case "MediaObject":
253  $type = "media";
254  break;
255 
256  case "PageObject":
257  $type = "page";
258  break;
259 
260  case "GlossaryItem":
261  $type = "term";
262  break;
263  }
265  return array("id" => $id, "type" => $type, "target" => $target);
266  }
267 
268  return array();
269  }
$path
Definition: ltiservices.php:29
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
+ Here is the call graph for this function:

◆ getPageObjectNode()

ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager::getPageObjectNode ( )
protected

◆ handleCopiedContent()

ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager::handleCopiedContent ( \ilPageObject  $page,
\DOMDocument  $dom,
bool  $a_self_ass = true,
bool  $a_clone_mobs = false,
int  $new_parent_id = 0,
int  $obj_copy_id = 0 
)
protected

Handle copied content This function copies items, that must be copied, if page content is duplicated.

Currently called by

  • copyXmlContent
  • called by pasteContents
  • called by ilPageEditorGUI->paste -> pasteContents

Definition at line 459 of file class.PageContentManager.php.

Referenced by ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager\copyXmlContent(), and ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager\pasteContents().

466  : void {
467  $defs = $this->pc_service->definition()->getPCDefinitions();
468  foreach ($defs as $def) {
469  $cl = $def["pc_class"];
470  if ($cl == 'ilPCPlugged') {
471  // the page object is provided for ilPageComponentPlugin
472  \ilPCPlugged::handleCopiedPluggedContent($page, $dom);
473  } else {
474  $cl::handleCopiedContent($dom, $a_self_ass, $a_clone_mobs, $new_parent_id, $obj_copy_id);
475  }
476  }
477  }
+ Here is the caller graph for this function:

◆ handleDeleteContent()

ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager::handleDeleteContent ( \ilPageObject  $page,
  $a_node = null,
  $move_operation = false 
)

Definition at line 134 of file class.PageContentManager.php.

References $path.

Referenced by ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager\deleteContent(), and ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager\deleteContents().

134  : void
135  {
136  if (!isset($a_node)) {
137  $path = "//PageContent";
138  $nodes = $this->dom_util->path($this->dom, $path);
139  } else {
140  $nodes = array($a_node);
141  }
142 
143  foreach ($nodes as $node) {
144  if ($node->firstChild->nodeName === 'Plugged') {
145  \ilPCPlugged::handleDeletedPluggedNode($page, $node->firstChild, $move_operation);
146  }
147  }
148  }
$path
Definition: ltiservices.php:29
+ Here is the caller graph for this function:

◆ insertContent()

ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager::insertContent ( \ilPageContent  $a_cont_obj,
string  $a_pos,
int  $a_mode = IL_INSERT_AFTER,
string  $a_pcid = "",
bool  $remove_placeholder = true,
bool  $placeholder_enabled = false 
)

Definition at line 553 of file class.PageContentManager.php.

References ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager\getContentDomNode(), ilPageContent\getDomNode(), ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager\getPageObjectNode(), IL_INSERT_AFTER, IL_INSERT_BEFORE, IL_INSERT_CHILD, and ilPageContent\setDomNode().

Referenced by ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager\moveContentAfter().

560  : void {
561  if ($a_pcid == "" && $a_pos == "") {
562  $a_pos = "pg";
563  }
564  // move mode into container elements is always INSERT_CHILD
565  $curr_node = $this->getContentDomNode($a_pos, $a_pcid);
566  $curr_name = $curr_node->nodeName;
567 
568  // @todo: try to generalize this
569  if (($curr_name == "TableData") || ($curr_name == "PageObject") ||
570  ($curr_name == "ListItem") || ($curr_name == "Section")
571  || ($curr_name == "Tab") || ($curr_name == "ContentPopup")
572  || ($curr_name == "GridCell")) {
573  $a_mode = IL_INSERT_CHILD;
574  }
575 
576  $hid = $curr_node->getAttribute("HierId");
577  if ($hid != "") {
578  //echo "-".$a_pos."-".$hid."-";
579  $a_pos = $hid;
580  }
581 
582  if ($a_mode != IL_INSERT_CHILD) { // determine parent hierarchical id
583  // of sibling at $a_pos
584  $pos = explode("_", $a_pos);
585  $target_pos = array_pop($pos);
586  $parent_pos = implode("_", $pos);
587  } else { // if we should insert a child, $a_pos is alreade the hierarchical id
588  // of the parent node
589  $parent_pos = $a_pos;
590  }
591 
592  // get the parent node
593  if ($parent_pos != "") {
594  $parent_node = $this->getContentDomNode($parent_pos);
595  } else {
596  $parent_node = $this->getPageObjectNode();
597  }
598 
599  // count the parent children
600  $parent_childs = $parent_node->childNodes;
601  $cnt_parent_childs = count($parent_childs);
602  //echo "ZZ$a_mode";
603  switch ($a_mode) {
604  // insert new node after sibling at $a_pos
605  case IL_INSERT_AFTER:
606  $new_node = $a_cont_obj->getDomNode();
607  //$a_pos = ilPageContent::incEdId($a_pos);
608  //$curr_node = $this->getContentNode($a_pos);
609  //echo "behind $a_pos:";
610  if ($succ_node = $curr_node->nextSibling) {
611  $new_node = $succ_node->parentNode->insertBefore($new_node, $succ_node);
612  } else {
613  //echo "movin doin append_child";
614  $new_node = $parent_node->appendChild($new_node);
615  }
616  $a_cont_obj->setDomNode($new_node);
617  break;
618 
619  case IL_INSERT_BEFORE:
620  //echo "INSERT_BEF";
621  $new_node = $a_cont_obj->getDomNode();
622  $succ_node = $this->getContentDomNode($a_pos);
623  $new_node = $succ_node->parentNode->insertBefore($new_node, $succ_node);
624  $a_cont_obj->setDomNode($new_node);
625  break;
626 
627  // insert new node as first child of parent $a_pos (= $a_parent)
628  case IL_INSERT_CHILD:
629  //echo "insert as child:parent_childs:$cnt_parent_childs:<br>";
630  $new_node = $a_cont_obj->getDomNode();
631  if ($cnt_parent_childs == 0) {
632  $new_node = $parent_node->appendChild($new_node);
633  } else {
634  $new_node = $parent_childs[0]->parentNode->insertBefore($new_node, $parent_childs[0]);
635  }
636  $a_cont_obj->setDomNode($new_node);
637  //echo "PP";
638  break;
639  }
640 
641  //check for PlaceHolder to remove in EditMode-keep in Layout Mode
642  if ($remove_placeholder && !$placeholder_enabled) {
643  foreach ($curr_node->childNodes as $sub_node) {
644  if ($sub_node->nodeName == "PlaceHolder") {
645  $curr_node->parentNode->removeChild($curr_node);
646  }
647  }
648  }
649  }
const IL_INSERT_AFTER
const IL_INSERT_CHILD
const IL_INSERT_BEFORE
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:

◆ insertContentNode()

ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager::insertContentNode ( \DOMNode  $a_cont_node,
string  $a_pos,
int  $a_mode = IL_INSERT_AFTER,
string  $a_pcid = "" 
)

Definition at line 479 of file class.PageContentManager.php.

References ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager\getContentDomNode(), ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager\getPageObjectNode(), IL_INSERT_AFTER, IL_INSERT_BEFORE, and IL_INSERT_CHILD.

Referenced by ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager\pasteContents().

484  : void {
485  // move mode into container elements is always INSERT_CHILD
486  $curr_node = $this->getContentDomNode($a_pos, $a_pcid);
487  $curr_name = $curr_node->nodeName;
488  // @todo: try to generalize
489  if (($curr_name == "TableData") || ($curr_name == "PageObject") ||
490  ($curr_name == "ListItem") || ($curr_name == "Section")
491  || ($curr_name == "Tab") || ($curr_name == "ContentPopup")
492  || ($curr_name == "GridCell")) {
493  $a_mode = IL_INSERT_CHILD;
494  }
495 
496  $hid = $curr_node->getAttribute("HierId");
497  if ($hid != "") {
498  $a_pos = $hid;
499  }
500 
501  if ($a_mode != IL_INSERT_CHILD) { // determine parent hierarchical id
502  // of sibling at $a_pos
503  $pos = explode("_", $a_pos);
504  $target_pos = array_pop($pos);
505  $parent_pos = implode("_", $pos);
506  } else { // if we should insert a child, $a_pos is alreade the hierarchical id
507  // of the parent node
508  $parent_pos = $a_pos;
509  }
510 
511  // get the parent node
512  if ($parent_pos != "") {
513  $parent_node = $this->getContentDomNode($parent_pos);
514  } else {
515  $parent_node = $this->getPageObjectNode();
516  }
517 
518  // count the parent children
519  $parent_childs = $parent_node->childNodes;
520  $cnt_parent_childs = count($parent_childs);
521  switch ($a_mode) {
522  // insert new node after sibling at $a_pos
523  case IL_INSERT_AFTER:
524  //$new_node = $a_cont_obj->getNode();
525  if ($succ_node = $curr_node->nextSibling) {
526  $a_cont_node = $succ_node->parentNode->insertBefore($a_cont_node, $succ_node);
527  } else {
528  $a_cont_node = $parent_node->appendChild($a_cont_node);
529  }
530  //$a_cont_obj->setNode($new_node);
531  break;
532 
533  case IL_INSERT_BEFORE:
534  //$new_node = $a_cont_obj->getNode();
535  $succ_node = $this->getContentDomNode($a_pos);
536  $a_cont_node = $succ_node->parentNode->insertBefore($a_cont_node, $succ_node);
537  //$a_cont_obj->setNode($new_node);
538  break;
539 
540  // insert new node as first child of parent $a_pos (= $a_parent)
541  case IL_INSERT_CHILD:
542  //$new_node = $a_cont_obj->getNode();
543  if ($cnt_parent_childs == 0) {
544  $a_cont_node = $parent_node->appendChild($a_cont_node);
545  } else {
546  $a_cont_node = $parent_childs->item(0)->parentNode->insertBefore($a_cont_node, $parent_childs->item(0));
547  }
548  //$a_cont_obj->setNode($new_node);
549  break;
550  }
551  }
const IL_INSERT_AFTER
const IL_INSERT_CHILD
const IL_INSERT_BEFORE
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:

◆ insertInstIntoIDs()

ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager::insertInstIntoIDs ( string  $a_inst,
bool  $a_res_ref_to_obj_id = true 
)

inserts installation id into ids (e.g.

il__pg_4 -> il_23_pg_4) this is needed for xml export of page

Parameters
string$a_instinstallation id
bool$a_res_ref_to_obj_idconvert repository links obj_<ref_id> to <type>_<obj_id>

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

References ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager\$dom, $id, $path, $ref_id, ilObject\_lookupObjId(), and ilObject\_lookupType().

313  : void {
314  $dom = $this->dom;
315  // insert inst id into internal links
316  $path = "//IntLink";
317  $nodes = $this->dom_util->path($dom, $path);
318  foreach ($nodes as $node) {
319  $target = $node->getAttribute("Target");
320  $type = $node->getAttribute("Type");
321 
322  if (substr($target, 0, 4) == "il__") {
323  $id = substr($target, 4, strlen($target) - 4);
324 
325  // convert repository links obj_<ref_id> to <type>_<obj_id>
326  // this leads to bug 6685.
327  if ($a_res_ref_to_obj_id && $type == "RepositoryItem") {
328  $id_arr = explode("_", $id);
329 
330  // changed due to bug 6685
331  $ref_id = $id_arr[1];
332  $obj_id = \ilObject::_lookupObjId((int) $id_arr[1]);
333 
334  $otype = \ilObject::_lookupType($obj_id);
335  if ($obj_id > 0) {
336  // changed due to bug 6685
337  // the ref_id should be used, if the content is
338  // imported on the same installation
339  // the obj_id should be used, if a different
340  // installation imports, but has an import_id for
341  // the object id.
342  $id = $otype . "_" . $obj_id . "_" . $ref_id;
343  //$id = $otype."_".$ref_id;
344  }
345  }
346  $new_target = "il_" . $a_inst . "_" . $id;
347  $node->setAttribute("Target", $new_target);
348  }
349  }
350 
351  // insert inst id into media aliases
352  $path = "//MediaAlias";
353  $nodes = $this->dom_util->path($dom, $path);
354  foreach ($nodes as $node) {
355  $origin_id = $node->getAttribute("OriginId");
356  if (substr($origin_id, 0, 4) == "il__") {
357  $new_id = "il_" . $a_inst . "_" . substr($origin_id, 4, strlen($origin_id) - 4);
358  $node->setAttribute("OriginId", $new_id);
359  }
360  }
361 
362  // insert inst id file item identifier entries
363  $path = "//FileItem/Identifier";
364  $nodes = $this->dom_util->path($dom, $path);
365  foreach ($nodes as $node) {
366  $origin_id = $node->getAttribute("Entry");
367  if (substr($origin_id, 0, 4) == "il__") {
368  $new_id = "il_" . $a_inst . "_" . substr($origin_id, 4, strlen($origin_id) - 4);
369  $node->setAttribute("Entry", $new_id);
370  }
371  }
372 
373  // insert inst id into question references
374  $path = "//Question";
375  $nodes = $this->dom_util->path($dom, $path);
376  foreach ($nodes as $node) {
377  $qref = $node->getAttribute("QRef");
378  //echo "<br>setted:".$qref;
379  if (substr($qref, 0, 4) == "il__") {
380  $new_id = "il_" . $a_inst . "_" . substr($qref, 4, strlen($qref) - 4);
381  //echo "<br>setting:".$new_id;
382  $node->setAttribute("QRef", $new_id);
383  }
384  }
385 
386  // insert inst id into content snippets
387  $path = "//ContentInclude";
388  $nodes = $this->dom_util->path($dom, $path);
389  foreach ($nodes as $node) {
390  $ci = $node->getAttribute("InstId");
391  if ($ci == "") {
392  $node->setAttribute("InstId", $a_inst);
393  }
394  }
395  }
$path
Definition: ltiservices.php:29
static _lookupObjId(int $ref_id)
$ref_id
Definition: ltiauth.php:65
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
static _lookupType(int $id, bool $reference=false)
+ Here is the call graph for this function:

◆ moveContentAfter()

ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager::moveContentAfter ( \ilPageObject  $page,
string  $a_source,
string  $a_target,
string  $a_spcid = "",
string  $a_tpcid = "" 
)

move content object from position $a_source before position $a_target (both hierarchical content ids)

Parameters
string$a_source
string$a_target
string$a_spcid
string$a_tpcid
Returns
array|bool
Exceptions
ilCOPagePCEditException
ilCOPageUnknownPCTypeException
ilDateTimeException

Definition at line 663 of file class.PageContentManager.php.

References ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager\deleteContent(), ilPageObject\getContentObject(), IL_INSERT_AFTER, and ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager\insertContent().

669  : void {
670  // nothing to do...
671  if ($a_source === $a_target) {
672  return;
673  }
674 
675  // clone the node
676  $content = $page->getContentObject($a_source, $a_spcid);
677  $source_node = $content?->getDomNode();
678  $clone_node = $source_node?->cloneNode(true);
679 
680  // delete source node
681  $this->deleteContent($page, $a_source, $a_spcid, true);
682 
683  // insert cloned node at target
684  if ($content) {
685  $content->setDomNode($clone_node);
686  $this->insertContent($content, $a_target, IL_INSERT_AFTER, $a_tpcid);
687  }
688  }
deleteContent(\ilPageObject $page, string $a_hid, string $a_pcid="", bool $move_operation=false)
const IL_INSERT_AFTER
insertContent(\ilPageContent $a_cont_obj, string $a_pos, int $a_mode=IL_INSERT_AFTER, string $a_pcid="", bool $remove_placeholder=true, bool $placeholder_enabled=false)
+ Here is the call graph for this function:

◆ pasteContents()

ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager::pasteContents ( \ilObjUser  $user,
string  $a_hier_id,
\ilPageObject  $page,
bool  $a_self_ass = false 
)

Definition at line 397 of file class.PageContentManager.php.

References $c, ILIAS\$error, $path, ilObjUser\getPCClipboardContent(), ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager\handleCopiedContent(), IL_INSERT_AFTER, ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager\insertContentNode(), and null.

402  {
403  $a_hid = explode(":", $a_hier_id);
404  $content = $user->getPCClipboardContent();
405  // we insert from last to first, because we insert all at the
406  // same hier_id
407  for ($i = count($content) - 1; $i >= 0; $i--) {
408  $c = $content[$i];
409  $error = null;
410  $temp_dom = $this->dom_util->docFromString(
411  '<?xml version="1.0" encoding="UTF-8"?>' . $c,
412  $error
413  );
414  if (empty($error)) {
415  $this->handleCopiedContent($page, $temp_dom, $a_self_ass);
416  $path = "/PageContent";
417  $nodes = $this->dom_util->path($temp_dom, $path);
418  foreach ($nodes as $node) {
419  $new_pc_node = $node;
420  $cloned_pc_node = $new_pc_node->cloneNode(true);
421  $cloned_pc_node = $this->dom->importNode($cloned_pc_node, true);
422  $this->insertContentNode(
423  $cloned_pc_node,
424  $a_hid[0],
426  $a_hid[1]
427  );
428  }
429  } else {
430  //var_dump($error);
431  }
432  }
433  }
handleCopiedContent(\ilPageObject $page, \DOMDocument $dom, bool $a_self_ass=true, bool $a_clone_mobs=false, int $new_parent_id=0, int $obj_copy_id=0)
Handle copied content This function copies items, that must be copied, if page content is duplicated...
$c
Definition: deliver.php:25
$path
Definition: ltiservices.php:29
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
const IL_INSERT_AFTER
ilErrorHandling $error
Definition: class.ilias.php:69
insertContentNode(\DOMNode $a_cont_node, string $a_pos, int $a_mode=IL_INSERT_AFTER, string $a_pcid="")
+ Here is the call graph for this function:

◆ setInitialOpenedContent()

ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager::setInitialOpenedContent ( string  $a_type = "",
int  $a_id = 0,
string  $a_target = "" 
)

Definition at line 174 of file class.PageContentManager.php.

References $c, $path, and null.

178  : void {
179  $il_node = null;
180  $link_type = "";
181  switch ($a_type) {
182  case "media":
183  $link_type = "MediaObject";
184  $a_id = "il__mob_" . $a_id;
185  break;
186 
187  case "page":
188  $link_type = "PageObject";
189  $a_id = "il__pg_" . $a_id;
190  break;
191 
192  case "term":
193  $link_type = "GlossaryItem";
194  $a_id = "il__git_" . $a_id;
195  $a_target = "Glossary";
196  break;
197  }
198 
199  $path = "//PageObject/InitOpenedContent";
200  $nodes = $this->dom_util->path($this->dom, $path);
201  if ($link_type == "" || $a_id == "") {
202  if (count($nodes) > 0) {
203  $c = $nodes->item(0);
204  $c->parentNode->removeChild($c);
205  }
206  } else {
207  if (count($nodes) > 0) {
208  $init_node = $nodes->item(0);
209  foreach ($init_node->childNodes as $child) {
210  if ($child->nodeName === "IntLink") {
211  $il_node = $child;
212  }
213  }
214  } else {
215  $path = "//PageObject";
216  $nodes = $this->dom_util->path($this->dom, $path);
217  $page_node = $nodes->item(0);
218  $init_node = $this->dom->createElement("InitOpenedContent");
219  $init_node = $page_node->appendChild($init_node);
220  $il_node = $this->dom->createElement("IntLink");
221  $il_node = $init_node->appendChild($il_node);
222  }
223  $il_node->setAttribute("Target", $a_id);
224  $il_node->setAttribute("Type", $link_type);
225  $il_node->setAttribute("TargetFrame", $a_target);
226  }
227  }
$c
Definition: deliver.php:25
$path
Definition: ltiservices.php:29
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null

◆ switchEnableMultiple()

ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager::switchEnableMultiple ( \ilPageObject  $page,
array  $a_hids,
bool  $a_self_ass = false 
)

Definition at line 150 of file class.PageContentManager.php.

References ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager\checkForTag(), and ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager\getContentDomNode().

154  {
155  foreach ($a_hids as $a_hid) {
156  $a_hid = explode(":", $a_hid);
157  $curr_node = $this->getContentDomNode($a_hid[0], $a_hid[1] ?? "");
158  if (is_object($curr_node)) {
159  if ($curr_node->nodeName == "PageContent") {
160  $cont_obj = $this->pc_service->getByNode($curr_node, $page);
161  if ($cont_obj->isEnabled()) {
162  // do not deactivate question nodes in assessment pages
163  if (!$this->checkForTag("Question", $a_hid[0], (string) ($a_hid[1] ?? "")) || $a_self_ass) {
164  $cont_obj->disable();
165  }
166  } else {
167  $cont_obj->enable();
168  }
169  }
170  }
171  }
172  }
checkForTag(string $a_content_tag, string $a_hier_id, string $a_pc_id="")
+ Here is the call graph for this function:

Field Documentation

◆ $dom

DOMDocument ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager::$dom
protected

◆ $dom_util

ILIAS COPage Dom DomUtil ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager::$dom_util
protected

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

◆ $link

ILIAS COPage Link LinkManager ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager::$link
protected

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

◆ $page_object_node

DOMNode ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager::$page_object_node
protected

◆ $pc_service

ILIAS COPage PC DomainService ILIAS\UI\Implementation\Component\Layout\Page\PageContentManager::$pc_service
protected

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


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