ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilContainerPage.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
27{
32 public function getParentType(): string
33 {
34 return "cont";
35 }
36
37
38 public function addMissingContainerBlocks(?\ILIAS\Container\Content\ItemPresentationManager $manager): void
39 {
40 if ($manager !== null) {
41 foreach ($manager->getItemBlockSequence()->getBlocks() as $block) {
42 if (!$block->getPageEmbedded()) {
43 $this->buildDom();
44 $this->addRepositoryBlockToPage($block->getId(), $block->getBlock());
45 }
46 }
47 $this->removeUnsupportedBlockIds($manager);
48 }
49 }
50
51 public function removeUnsupportedBlockIds(\ILIAS\Container\Content\ItemPresentationManager $manager): void
52 {
53 $ids = $manager->getPageEmbeddedBlockIds();
54 $block_ids = [];
55 foreach ($manager->getItemBlockSequence()->getBlocks() as $block) {
56 $block_ids[] = $block->getId();
57 }
58 foreach ($ids as $id) {
59 if (!in_array($id, $block_ids)) {
60 $this->buildDom();
61 $doc = $this->getDomDoc();
62 $xpath_temp = new DOMXPath($doc);
63 if (is_numeric($id)) {
64 $igs = $xpath_temp->query("//Resources/ItemGroup");
65 foreach ($igs as $ig_node) {
66 $ref_id = $ig_node->getAttribute("RefId");
67 if ((int) $ref_id === (int) $id) {
68 $pc_node = $ig_node->parentNode->parentNode;
69 $node = $pc_node->parentNode->removeChild($pc_node);
70 }
71 }
72 } else {
73 $igs = $xpath_temp->query("//Resources/ResourceList");
74 foreach ($igs as $ig_node) {
75 $type = $ig_node->getAttribute("Type");
76 if ($type == $id) {
77 $pc_node = $ig_node->parentNode->parentNode;
78 $node = $pc_node->parentNode->removeChild($pc_node);
79 }
80 }
81 }
82 }
83 }
84 $this->update();
85 }
86
87 protected function addRepositoryBlockToPage(string $id, \ILIAS\Container\Content\Block $block): void
88 {
89 $pc_resources = new ilPCResources($this);
90 $this->addHierIDs();
91 $doc = $this->getDomDoc();
92 $xpath = new DOMXPath($doc);
93 $parent_hier_id = "pg";
94 $parent_pc_id = "";
95 $nodes = $xpath->query("//PageObject/PageContent[last()]");
96 foreach ($nodes as $node) {
97 $parent_hier_id = $node->getAttribute("HierId");
98 $parent_pc_id = $node->getAttribute("PCID");
99 }
100
101 $pc_resources->create($this, $parent_hier_id, $parent_pc_id);
102
103 if ($block instanceof \ILIAS\Container\Content\TypeBlock) {
104 $pc_resources->setResourceListType($id);
105 } elseif ($block instanceof \ILIAS\Container\Content\ItemGroupBlock) {
106 $pc_resources->setItemGroupRefId((int) $id);
107 } elseif ($block instanceof \ILIAS\Container\Content\OtherBlock) {
108 $pc_resources->setResourceListType("_other");
109 } elseif ($block instanceof \ILIAS\Container\Content\SessionBlock) {
110 $pc_resources->setResourceListType("sess");
111 } elseif ($block instanceof \ILIAS\Container\Content\ObjectivesBlock) {
112 $pc_resources->setResourceListType("_lobj");
113 } else {
114 throw new ilException("unknown type " . get_class($block));
115 }
116 $this->update();
117 }
118}
Container page object.
removeUnsupportedBlockIds(\ILIAS\Container\Content\ItemPresentationManager $manager)
addMissingContainerBlocks(?\ILIAS\Container\Content\ItemPresentationManager $manager)
addRepositoryBlockToPage(string $id, \ILIAS\Container\Content\Block $block)
getParentType()
Get parent type.
Base class for ILIAS Exception handling.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilPageObject Handles PageObjects of ILIAS Learning Modules (see ILIAS DTD)
update(bool $a_validate=true, bool $a_no_history=false)
update complete page content in db (dom xml content is used)
getDomDoc()
Get dom doc (DOMDocument)
addHierIDs()
Add hierarchical ID (e.g.
buildDom(bool $a_force=false)
$ref_id
Definition: ltiauth.php:66
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.