ILIAS  release_8 Revision v8.24
class.ilPCPlaceHolder.php
Go to the documentation of this file.
1<?php
2
25{
26 protected ilCtrl $ctrl;
27 protected ilLanguage $lng;
28 public php4DOMElement $q_node; // node of Paragraph element
29 public string $content_class;
30 public string $height;
31
32 public function init(): void
33 {
34 global $DIC;
35
36 $this->ctrl = $DIC->ctrl();
37 $this->lng = $DIC->language();
38 $this->setType("plach");
39 }
40
41 public function setNode(php4DOMElement $a_node): void
42 {
43 parent::setNode($a_node); // this is the PageContent node
44 $this->q_node = $a_node->first_child(); //... and this the PlaceHolder
45 }
46
47 public function create(
48 ilPageObject $a_pg_obj,
49 string $a_hier_id,
50 string $a_pc_id = ""
51 ): void {
52 $this->createPageContentNode();
53 $a_pg_obj->insertContent($this, $a_hier_id, IL_INSERT_AFTER, $a_pc_id);
54 $this->q_node = $this->dom->create_element("PlaceHolder");
55 $this->q_node = $this->node->append_child($this->q_node);
56 }
57
58 public function setContentClass(string $a_class): void
59 {
60 if (is_object($this->q_node)) {
61 $this->q_node->set_attribute("ContentClass", $a_class);
62 }
63 }
64
65 public function getContentClass(): string
66 {
67 if (is_object($this->q_node)) {
68 return $this->q_node->get_attribute("ContentClass");
69 }
70 return "";
71 }
72
73 public function setHeight(string $a_height): void
74 {
75 if (is_object($this->q_node)) {
76 $this->q_node->set_attribute("Height", $a_height);
77 }
78 }
79
80 public function getHeight(): string
81 {
82 if (is_object($this->q_node)) {
83 return $this->q_node->get_attribute("Height");
84 }
85 return "";
86 }
87
88 public function getClass(): string
89 {
90 return "";
91 }
92
93 public static function getLangVars(): array
94 {
95 return array("question_placeh","media_placeh","text_placeh",
96 "ed_insert_plach","question_placehl","media_placehl","text_placehl",
97 "verification_placeh", "verification_placehl");
98 }
99
101 string $a_output,
102 string $a_mode,
103 bool $a_abstract_only = false
104 ): string {
105 $lng = $this->lng;
106
107 //
108 // Note: this standard output is "overwritten", e.g. by ilPortfolioPageGUI::postOutputProcessing
109 //
110
111 $end = 0;
112 $start = strpos($a_output, "{{{{{PlaceHolder#");
113 if (is_int($start)) {
114 $end = strpos($a_output, "}}}}}", $start);
115 }
116 $i = 1;
117 while ($end > 0) {
118 $param = substr($a_output, $start + 17, $end - $start - 17);
119 $param = explode("#", $param);
120
121 $html = $param[2];
122 switch ($param[2]) {
123 case "Text":
124 $html = $lng->txt("cont_text_placeh");
125 break;
126
127 case "Media":
128 $html = $lng->txt("cont_media_placeh");
129 break;
130
131 case "Question":
132 $html = $lng->txt("cont_question_placeh");
133 break;
134
135 case "Verification":
136 $html = $lng->txt("cont_verification_placeh");
137 break;
138 }
139
140 $h2 = substr($a_output, 0, $start) .
141 $html .
142 substr($a_output, $end + 5);
143 $a_output = $h2;
144 $i++;
145
146 $start = strpos($a_output, "{{{{{PlaceHolder#", $start + 5);
147 $end = 0;
148 if (is_int($start)) {
149 $end = strpos($a_output, "}}}}}", $start);
150 }
151 }
152 return $a_output;
153 }
154
158 public function getModel(): ?stdClass
159 {
160 $model = new \stdClass();
161 $model->contentClass = $this->getContentClass();
162 return $model;
163 }
164
165 public function getCssFiles(string $a_mode): array
166 {
168 }
169
170 public static function handleCopiedContent(
171 DOMDocument $a_domdoc,
172 bool $a_self_ass = true,
173 bool $a_clone_mobs = false,
174 int $new_parent_id = 0,
175 int $obj_copy_id = 0
176 ): void {
177 // remove question placholders
178 if (!$a_self_ass) {
179 // Get question IDs
180 $path = "//PlaceHolder[@ContentClass = 'Question']";
181 $xpath = new DOMXPath($a_domdoc);
182 $nodes = $xpath->query($path);
183
184 foreach ($nodes as $node) {
185 $parent = $node->parentNode;
186 $parent->parentNode->removeChild($parent);
187 }
188 }
189 }
190}
const IL_INSERT_AFTER
Class ilCtrl provides processing control methods.
language handling
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getLangVars()
Get lang vars needed for editing.
setHeight(string $a_height)
setContentClass(string $a_class)
php4DOMElement $q_node
create(ilPageObject $a_pg_obj, string $a_hier_id, string $a_pc_id="")
modifyPageContentPostXsl(string $a_output, string $a_mode, bool $a_abstract_only=false)
Modify page content after xsl.
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.
setNode(php4DOMElement $a_node)
Set xml node of page content.
getCssFiles(string $a_mode)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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
if(!file_exists(getcwd() . '/ilias.ini.php'))
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: confirmReg.php:20
global $DIC
Definition: feed.php:28
$path
Definition: ltiservices.php:32
$i
Definition: metadata.php:41
$lng
$param
Definition: xapitoken.php:46