ILIAS  release_8 Revision v8.24
class.ilPCCurriculum.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
26{
27 public const PCTYPE = 'lsocurriculum';
28 public const PCELEMENT = 'Curriculum';
29 public const PLACEHOLDER = '[[[CURRICULUM]]]';
30 public const PROVIDING_TYPES = ['lso'];
31
32 public function init(): void
33 {
34 $this->setType(self::PCTYPE);
35 }
36
37 public function create(
38 ilPageObject $a_pg_obj,
39 string $a_hier_id,
40 string $a_pc_id = ""
41 ): void {
42 $this->node = $this->createPageContentNode();
43 $a_pg_obj->insertContent($this, $a_hier_id, IL_INSERT_AFTER, $a_pc_id);
44 $this->cach_node = $this->dom->create_element(self::PCELEMENT);
45 $this->cach_node = $this->node->append_child($this->cach_node);
46 }
47
51 public function modifyPageContentPostXsl(
52 string $a_output,
53 string $a_mode,
54 bool $a_abstract_only = false
55 ): string {
56 if ($a_mode == 'edit') {
57 return $a_output;
58 }
59
60 $parent_obj_id = (int) $this->getPage()->getParentId();
61 if ($this->supportsCurriculum($parent_obj_id)) {
62 $a_output = $this->replaceWithRenderedCurriculum($parent_obj_id, $a_output);
63 }
64
65 return $a_output;
66 }
67
68 protected function supportsCurriculum(int $parent_obj_id): bool
69 {
70 $parent_obj_type = \ilObject::_lookupType($parent_obj_id);
71 return in_array($parent_obj_type, self::PROVIDING_TYPES);
72 }
73
74 protected function replaceWithRenderedCurriculum(int $obj_id, string $html): string
75 {
77 $rendered_curriculum = $lso->getCurrentUserCurriculum();
78 return str_replace(self::PLACEHOLDER, $rendered_curriculum, $html);
79 }
80}
const IL_INSERT_AFTER
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
static _lookupType(int $id, bool $reference=false)
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.
supportsCurriculum(int $parent_obj_id)
replaceWithRenderedCurriculum(int $obj_id, string $html)
create(ilPageObject $a_pg_obj, string $a_hier_id, string $a_pc_id="")
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