ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilPCPlaceHolder.php
Go to the documentation of this file.
1<?php
2
25{
26 protected ilCtrl $ctrl;
27 protected ilLanguage $lng;
28 public string $content_class;
29 public string $height;
30
31 public function init(): void
32 {
33 global $DIC;
34
35 $this->ctrl = $DIC->ctrl();
36 $this->lng = $DIC->language();
37 $this->setType("plach");
38 }
39
40 public function create(
41 ilPageObject $a_pg_obj,
42 string $a_hier_id,
43 string $a_pc_id = ""
44 ): void {
45 $this->createInitialChildNode($a_hier_id, $a_pc_id, "PlaceHolder");
46 }
47
48 public function setContentClass(string $a_class): void
49 {
50 if (is_object($this->getChildNode())) {
51 $this->getChildNode()->setAttribute("ContentClass", $a_class);
52 }
53 }
54
55 public function getContentClass(): string
56 {
57 if (is_object($this->getChildNode())) {
58 return $this->getChildNode()->getAttribute("ContentClass");
59 }
60 return "";
61 }
62
63 public function setHeight(string $a_height): void
64 {
65 if (is_object($this->getChildNode())) {
66 $this->getChildNode()->setAttribute("Height", $a_height);
67 }
68 }
69
70 public function getHeight(): string
71 {
72 if (is_object($this->getChildNode())) {
73 return $this->getChildNode()->getAttribute("Height");
74 }
75 return "";
76 }
77
78 public function getClass(): string
79 {
80 return "";
81 }
82
83 public static function getLangVars(): array
84 {
85 return array("question_placeh","media_placeh","text_placeh",
86 "ed_insert_plach","question_placehl","media_placehl","text_placehl",
87 "verification_placeh", "verification_placehl");
88 }
89
90 public function modifyPageContentPostXsl(
91 string $a_output,
92 string $a_mode,
93 bool $a_abstract_only = false
94 ): string {
95 $lng = $this->lng;
96
97 //
98 // Note: this standard output is "overwritten", e.g. by ilPortfolioPageGUI::postOutputProcessing
99 //
100
101 $end = 0;
102 $start = strpos($a_output, "{{{{{PlaceHolder#");
103 if (is_int($start)) {
104 $end = strpos($a_output, "}}}}}", $start);
105 }
106 $i = 1;
107 while ($end > 0) {
108 $param = substr($a_output, $start + 17, $end - $start - 17);
109 $param = explode("#", $param);
110
111 $html = $param[2];
112 switch ($param[2]) {
113 case "Text":
114 $html = $lng->txt("cont_text_placeh");
115 break;
116
117 case "Media":
118 $html = $lng->txt("cont_media_placeh");
119 break;
120
121 case "Question":
122 $html = $lng->txt("cont_question_placeh");
123 break;
124
125 case "Verification":
126 $html = $lng->txt("cont_verification_placeh");
127 break;
128 }
129
130 $h2 = substr($a_output, 0, $start) .
131 $html .
132 substr($a_output, $end + 5);
133 $a_output = $h2;
134 $i++;
135
136 $start = strpos($a_output, "{{{{{PlaceHolder#", $start + 5);
137 $end = 0;
138 if (is_int($start)) {
139 $end = strpos($a_output, "}}}}}", $start);
140 }
141 }
142 return $a_output;
143 }
144
148 public function getModel(): ?stdClass
149 {
150 $model = new \stdClass();
151 $model->contentClass = $this->getContentClass();
152 return $model;
153 }
154
155 public function getCssFiles(string $a_mode): array
156 {
157 return [];
158 }
159
160 public static function handleCopiedContent(
161 DOMDocument $a_domdoc,
162 bool $a_self_ass = true,
163 bool $a_clone_mobs = false,
164 int $new_parent_id = 0,
165 int $obj_copy_id = 0
166 ): void {
167 // remove question placholders
168 if (!$a_self_ass) {
169 // Get question IDs
170 $path = "//PlaceHolder[@ContentClass = 'Question']";
171 $xpath = new DOMXPath($a_domdoc);
172 $nodes = $xpath->query($path);
173
174 foreach ($nodes as $node) {
175 $parent = $node->parentNode;
176 $parent->parentNode->removeChild($parent);
177 }
178 }
179 }
180}
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)
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.
getCssFiles(string $a_mode)
Content object of ilPageObject (see ILIAS DTD).
createInitialChildNode(string $hier_id, string $pc_id, string $child, array $child_attributes=[])
setType(string $a_type)
Set Type.
Class ilPageObject Handles PageObjects of ILIAS Learning Modules (see ILIAS DTD)
$path
Definition: ltiservices.php:30
global $lng
Definition: privfeed.php:31
if(!file_exists('../ilias.ini.php'))
global $DIC
Definition: shib_login.php:26
$param
Definition: xapitoken.php:46