ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilPCAMDForm.php
Go to the documentation of this file.
1<?php
2
24{
25 protected int $ref_id;
26 protected ilDBInterface $db;
27 protected ilLanguage $lng;
28
29 public function init(): void
30 {
31 global $DIC;
32
33 $this->db = $DIC->database();
34 $this->lng = $DIC->language();
35 $this->setType("amdfrm");
36
37 $request = $DIC->portfolio()
38 ->internal()
39 ->gui()
40 ->standardRequest();
41
42 $this->ref_id = $request->getRefId();
43 }
44
45 public static function getLangVars(): array
46 {
47 return array("ed_insert_amdfrm", "pc_amdfrm");
48 }
49
50 protected function isTemplate(): bool
51 {
52 return ($this->getPage()->getParentType() === "prtt");
53 }
54
55 public function create(
56 ilPageObject $a_pg_obj,
57 string $a_hier_id,
58 string $a_pc_id = ""
59 ): void {
60 $this->createPageContentNode();
61 $a_pg_obj->insertContent($this, $a_hier_id, IL_INSERT_AFTER, $a_pc_id);
62 $amdfrm_node = $this->dom_doc->createElement("AMDForm");
63 $this->getDomNode()->appendChild($amdfrm_node);
64 }
65
66 public function setRecordIds(array $record_ids): void
67 {
68 $this->getChildNode()->setAttribute("RecordIds", implode(",", $record_ids));
69 }
70
71 public function getRecordIds(): array
72 {
73 if (is_object($this->getChildNode())) {
74 return explode(",", $this->getChildNode()->getAttribute("RecordIds"));
75 }
76 return [];
77 }
78
79
80 public function modifyPageContentPostXsl(
81 string $a_output,
82 string $a_mode,
83 bool $a_abstract_only = false
84 ): string {
85 $end = 0;
86 $start = strpos($a_output, "[[[[[AMDForm;");
87 if (is_int($start)) {
88 $end = strpos($a_output, "]]]]]", $start);
89 }
90 while ($end > 0) {
91 $parts = explode(";", substr($a_output, $start + 13, $end - $start - 13));
92 if ($this->isTemplate()) {
93 $portfolio = new ilObjPortfolioTemplate($this->getPage()->getPortfolioId(), false);
94 } else {
95 $portfolio = new ilObjPortfolio($this->getPage()->getPortfolioId(), false);
96 }
97
98 $mdgui = new ilObjectMetaDataGUI($portfolio, "pfpg", $this->getPage()->getId(), false);
99 $mdgui->setRecordFilter(explode(",", $parts[0]));
100 $insert_html = $mdgui->getBlockHTML();
101
102 $a_output = substr($a_output, 0, $start) .
103 $insert_html .
104 substr($a_output, $end + 5);
105
106 $start = strpos($a_output, "[[[[[AMDForm;", $start + 5);
107 $end = 0;
108 if (is_int($start)) {
109 $end = strpos($a_output, "]]]]]", $start);
110 }
111 }
112
113 return $a_output;
114 }
115
116 public static function handleCopiedContent(
117 DOMDocument $a_domdoc,
118 bool $a_self_ass = true,
119 bool $a_clone_mobs = false,
120 int $new_parent_id = 0,
121 int $obj_copy_id = 0
122 ): void {
123 if ($obj_copy_id > 0) {
124 $cp_options = ilCopyWizardOptions::_getInstance($obj_copy_id);
125 $mappings = $cp_options->getMappings();
126 $key = $new_parent_id . "_adv_rec";
127 if (is_array($mappings) && isset($mappings[$key])) {
128 $xpath = new DOMXPath($a_domdoc);
129 $nodes = $xpath->query("//AMDForm");
130 foreach ($nodes as $node) {
131 $old_ids = explode(",", (string) $node->getAttribute("RecordIds"));
132 // 36565: do not overwrite RecordIds that are not mapped
133 $new_ids = array_map(static function ($i) use ($mappings, $key) {
134 return $mappings[$key][(int) $i] ?? $i;
135 }, $old_ids);
136 $new_ids = implode(",", $new_ids);
137 if ($new_ids !== "") {
138 $node->setAttribute("RecordIds", $new_ids);
139 }
140 }
141 }
142 }
143 }
144}
const IL_INSERT_AFTER
static _getInstance(int $a_copy_id)
language handling
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilObjectMetaDataGUI.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
modifyPageContentPostXsl(string $a_output, string $a_mode, bool $a_abstract_only=false)
Modify page content after xsl.
static getLangVars()
Get lang vars needed for editing.
setRecordIds(array $record_ids)
create(ilPageObject $a_pg_obj, string $a_hier_id, string $a_pc_id="")
init()
Init object.
ilDBInterface $db
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.
ilLanguage $lng
Content object of ilPageObject (see ILIAS DTD).
createPageContentNode(bool $a_set_this_node=true)
Create page content node (always use this method first when adding a new element)
setType(string $a_type)
Set Type.
Class ilPageObject Handles PageObjects of ILIAS Learning Modules (see ILIAS DTD)
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
Interface ilDBInterface.
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
Definition: ltitoken.php:61
if(!file_exists('../ilias.ini.php'))
global $DIC
Definition: shib_login.php:26