ILIAS  release_8 Revision v8.24
class.ilPageContent.php
Go to the documentation of this file.
1<?php
2
25abstract class ilPageContent
26{
27 protected string $pcid;
28 protected string $type = "";
30 public string $hier_id = "";
31 public ?php4DOMElement $node = null;
32 public ?php4DOMDocument $dom = null;
33 public string $page_lang = "";
34 // needed for post processing (e.g. content includes)
35 protected string $file_download_link;
36 // needed for post processing (e.g. content includes)
37 protected string $fullscreen_link;
38 // needed for post processing (e.g. content includes)
40 protected ilLogger $log;
41 protected string $profile_back_url = "";
42
43 final public function __construct(ilPageObject $a_pg_obj)
44 {
45 $this->log = ilLoggerFactory::getLogger('copg');
46 $this->setPage($a_pg_obj);
47 $this->dom = $a_pg_obj->getDom();
48 $this->init();
49 if ($this->getType() == "") {
50 die("Error: ilPageContent::init() did not set type");
51 }
52 }
53
54 public function setPage(ilPageObject $a_val): void
55 {
56 $this->pg_obj = $a_val;
57 }
58
59 public function getPage(): ilPageObject
60 {
61 return $this->pg_obj;
62 }
63
68 abstract public function init(): void;
69
74 final protected function setType(string $a_type): void
75 {
76 $this->type = $a_type;
77 }
78
79 public function getType(): string
80 {
81 return $this->type;
82 }
83
88 public function setNode(php4DOMElement $a_node): void
89 {
90 $this->node = $a_node;
91 }
92
93 // Get PageContent node
94 public function getNode(): ?php4DOMElement
95 {
96 return $this->node;
97 }
98
99 public function getJavascriptFiles(string $a_mode): array
100 {
101 return array();
102 }
103
104 public function getCssFiles(string $a_mode): array
105 {
106 return [];
107 }
108
109 public function getOnloadCode(string $a_mode): array
110 {
111 return array();
112 }
113
114 public function setHierId(string $a_hier_id): void
115 {
116 $this->hier_id = $a_hier_id;
117 }
118
119 public function getHierId(): string
120 {
121 return $this->hier_id;
122 }
123
124 // Get hierarchical id from dom
125 public function lookupHierId(): string
126 {
127 return $this->node->get_attribute("HierId");
128 }
129
130 public function readHierId(): string
131 {
132 if (is_object($this->node)) {
133 return $this->node->get_attribute("HierId");
134 }
135 return "";
136 }
137
138 public function setPcId(string $a_pcid): void
139 {
140 $this->pcid = $a_pcid;
141 }
142
143 public function getPCId(): string
144 {
145 return $this->pcid;
146 }
147
148 public function setFileDownloadLink(string $a_download_link): void
149 {
150 $this->file_download_link = $a_download_link;
151 }
152
153 public function getFileDownloadLink(): string
154 {
156 }
157
158 public function setProfileBackUrl(string $url) : void
159 {
160 $this->profile_back_url = $url;
161 }
162
163 public function getProfileBackUrl() : string
164 {
166 }
167
168 public function setFullscreenLink(string $a_fullscreen_link): void
169 {
170 $this->fullscreen_link = $a_fullscreen_link;
171 }
172
173 public function getFullscreenLink(): string
174 {
176 }
177
178 public function setSourcecodeDownloadScript(string $script_name): void
179 {
180 $this->sourcecode_download_script = $script_name;
181 }
182
183 public function getSourcecodeDownloadScript(): string
184 {
186 }
187
188 public function readPCId(): string
189 {
190 if (is_object($this->node)) {
191 return $this->node->get_attribute("PCID");
192 }
193 return "";
194 }
195
196 public function writePCId(string $a_pc_id): void
197 {
198 if (is_object($this->node)) {
199 $this->node->set_attribute("PCID", $a_pc_id);
200 }
201 }
202
208 final public static function incEdId(string $ed_id): string
209 {
210 $id = explode("_", $ed_id);
211 $id[count($id) - 1]++;
212 return implode("_", $id);
213 }
214
220 final public static function decEdId(string $ed_id): string
221 {
222 $id = explode("_", $ed_id);
223 $id[count($id) - 1]--;
224 return implode("_", $id);
225 }
226
230 public static function sortHierIds(array $a_array): array
231 {
232 uasort($a_array, array("ilPageContent", "isGreaterHierId"));
233 return $a_array;
234 }
235
239 public static function isGreaterHierId(string $a, string $b): int
240 {
241 $a_arr = explode("_", $a);
242 $b_arr = explode("_", $b);
243 for ($i = 0; $i < count($a_arr); $i++) {
244 if ((int) $a_arr[$i] > (int) $b_arr[$i]) {
245 return +1;
246 } elseif ((int) $a_arr[$i] < (int) $b_arr[$i]) {
247 return -1;
248 }
249 }
250 return 0;
251 }
252
257 public function setEnabled(string $value): void
258 {
259 if (is_object($this->node)) {
260 $this->node->set_attribute("Enabled", $value);
261 }
262 }
263
264 public function enable(): void
265 {
266 $this->setEnabled("True");
267 }
268
269 public function disable(): void
270 {
271 $this->setEnabled("False");
272 }
273
274 final public function isEnabled(): bool
275 {
276 if (is_object($this->node) && $this->node->has_attribute("Enabled")) {
277 $compare = $this->node->get_attribute("Enabled");
278 } else {
279 $compare = "True";
280 }
281
282 return strcasecmp($compare, "true") == 0;
283 }
284
288 public function createPageContentNode(bool $a_set_this_node = true): php4DOMElement
289 {
290 $node = $this->dom->create_element("PageContent");
291 if ($a_set_this_node) {
292 $this->node = $node;
293 }
294 return $node;
295 }
296
301 public static function getLangVars(): array
302 {
303 return array();
304 }
305
315 public static function handleCopiedContent(
316 DOMDocument $a_domdoc,
317 bool $a_self_ass = true,
318 bool $a_clone_mobs = false,
319 int $new_parent_id = 0,
320 int $obj_copy_id = 0
321 ): void {
322 }
323
328 string $a_output,
329 string $a_mode,
330 bool $a_abstract_only = false
331 ): string {
332 return $a_output;
333 }
334
338 public static function afterPageUpdate(
339 ilPageObject $a_page,
340 DOMDocument $a_domdoc,
341 string $a_xml,
342 bool $a_creation
343 ): void {
344 }
345
350 public static function beforePageDelete(
351 ilPageObject $a_page
352 ): void {
353 }
354
358 public static function afterRepositoryCopy(ilPageObject $page, array $mapping, int $source_ref_id): void
359 {
360 }
361
365 public static function afterPageHistoryEntry(
366 ilPageObject $a_page,
367 DOMDocument $a_old_domdoc,
368 string $a_old_xml,
369 int $a_old_nr
370 ): void {
371 }
372
376 public function getModel(): ?stdClass
377 {
378 return null;
379 }
380
384 public static function deleteHistoryLowerEqualThan(
385 string $parent_type,
386 int $page_id,
387 string $lang,
388 int $delete_lower_than_nr
389 ): void {
390 }
391}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
static return function(ContainerConfigurator $containerConfigurator)
Definition: basic_rector.php:9
static getLogger(string $a_component_id)
Get component logger.
Component logger with individual log levels by component id.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilPageObject $pg_obj
php4DOMElement $node
getCssFiles(string $a_mode)
setHierId(string $a_hier_id)
setSourcecodeDownloadScript(string $script_name)
static incEdId(string $ed_id)
Increases an hierarchical editing id at lowest level (last number)
writePCId(string $a_pc_id)
static afterPageHistoryEntry(ilPageObject $a_page, DOMDocument $a_old_domdoc, string $a_old_xml, int $a_old_nr)
After page history entry has been created.
getJavascriptFiles(string $a_mode)
setFileDownloadLink(string $a_download_link)
setProfileBackUrl(string $url)
init()
Init object.
static afterPageUpdate(ilPageObject $a_page, DOMDocument $a_domdoc, string $a_xml, bool $a_creation)
After page has been updated (or created)
static sortHierIds(array $a_array)
Sort an array of Hier IDS in ascending order.
static deleteHistoryLowerEqualThan(string $parent_type, int $page_id, string $lang, int $delete_lower_than_nr)
Overwrite in derived classes, if old history entries are being deleted.
createPageContentNode(bool $a_set_this_node=true)
Create page content node (always use this method first when adding a new element)
__construct(ilPageObject $a_pg_obj)
setPage(ilPageObject $a_val)
setPcId(string $a_pcid)
static decEdId(string $ed_id)
Decreases an hierarchical editing id at lowest level (last number)
setFullscreenLink(string $a_fullscreen_link)
setNode(php4DOMElement $a_node)
Set xml node of page content.
string $sourcecode_download_script
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.
static isGreaterHierId(string $a, string $b)
Check whether Hier ID $a is greater than Hier ID $b.
modifyPageContentPostXsl(string $a_output, string $a_mode, bool $a_abstract_only=false)
Modify page content after xsl.
php4DOMDocument $dom
setEnabled(string $value)
Set Enabled value for page content component.
getOnloadCode(string $a_mode)
setType(string $a_type)
Set Type.
static getLangVars()
Get lang vars needed for editing.
Class ilPageObject Handles PageObjects of ILIAS Learning Modules (see ILIAS DTD)
getDom()
@depracated
return['3gp', '7z', 'ai', 'aif', 'aifc', 'aiff', 'au', 'arw', 'avi', 'backup', 'bak', 'bas', 'bpmn', 'bpmn2', 'bmp', 'bib', 'bibtex', 'bz', 'bz2', 'c', 'c++', 'cc', 'cct', 'cdf', 'cer', 'class', 'cls', 'conf', 'cpp', 'crt', 'crs', 'crw', 'cr2', 'css', 'cst', 'csv', 'cur', 'db', 'dcr', 'des', 'dng', 'doc', 'docx', 'dot', 'dotx', 'dtd', 'dvi', 'el', 'eps', 'epub', 'f', 'f77', 'f90', 'flv', 'for', 'g3', 'gif', 'gl', 'gan', 'ggb', 'gsd', 'gsm', 'gtar', 'gz', 'gzip', 'h', 'hpp', 'htm', 'html', 'htmls', 'ibooks', 'ico', 'ics', 'ini', 'ipynb', 'java', 'jbf', 'jpeg', 'jpg', 'js', 'jsf', 'jso', 'json', 'latex', 'lang', 'less', 'log', 'lsp', 'ltx', 'm1v', 'm2a', 'm2v', 'm3u', 'm4a', 'm4v', 'markdown', 'm', 'mat', 'md', 'mdl', 'mdown', 'mid', 'min', 'midi', 'mobi', 'mod', 'mov', 'movie', 'mp2', 'mp3', 'mp4', 'mpa', 'mpeg', 'mpg', 'mph', 'mpga', 'mpp', 'mpt', 'mpv', 'mpx', 'mv', 'mw', 'mv4', 'nb', 'nbp', 'nef', 'nif', 'niff', 'obj', 'obm', 'odt', 'ods', 'odp', 'odg', 'odf', 'oga', 'ogg', 'ogv', 'old', 'p', 'pas', 'pbm', 'pcl', 'pct', 'pcx', 'pdf', 'pgm', 'pic', 'pict', 'png', 'por', 'pov', 'project', 'properties', 'ppa', 'ppm', 'pps', 'ppsx', 'ppt', 'pptx', 'ppz', 'ps', 'psd', 'pwz', 'qt', 'qtc', 'qti', 'qtif', 'r', 'ra', 'ram', 'rar', 'rast', 'rda', 'rev', 'rexx', 'ris', 'rf', 'rgb', 'rm', 'rmd', 'rmi', 'rmm', 'rmp', 'rt', 'rtf', 'rtx', 'rv', 's', 's3m', 'sav', 'sbs', 'sec', 'sdml', 'sgm', 'sgml', 'smi', 'smil', 'srt', 'sps', 'spv', 'stl', 'svg', 'swa', 'swf', 'swz', 'tar', 'tex', 'texi', 'texinfo', 'text', 'tgz', 'tif', 'tiff', 'ttf', 'txt', 'tmp', 'uvproj', 'vdf', 'vimeo', 'viv', 'vivo', 'vrml', 'vsdx', 'wav', 'webm', 'wmv', 'wmx', 'wmz', 'woff', 'wwd', 'xhtml', 'xif', 'xls', 'xlsx', 'xmind', 'xml', 'xsl', 'xsd', 'zip']
$i
Definition: metadata.php:41
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
$url
$lang
Definition: xapiexit.php:26