ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilPCCurriculum.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
25 {
26  public const PCTYPE = 'lsocurriculum';
27  public const PCELEMENT = 'Curriculum';
28  public const PLACEHOLDER = '[[[CURRICULUM]]]';
29  public const PROVIDING_TYPES = ['lso'];
30 
31  public function init(): void
32  {
33  $this->setType(self::PCTYPE);
34  }
35 
36  public function create(
37  ilPageObject $a_pg_obj,
38  string $a_hier_id,
39  string $a_pc_id = ""
40  ): void {
41  $this->createPageContentNode();
42  $a_pg_obj->insertContent($this, $a_hier_id, IL_INSERT_AFTER, $a_pc_id);
43  $cach_node = $this->dom_doc->createElement(self::PCELEMENT);
44  $this->getDomNode()->appendChild($cach_node);
45  }
46 
50  public function modifyPageContentPostXsl(
51  string $a_output,
52  string $a_mode,
53  bool $a_abstract_only = false
54  ): string {
55  if ($a_mode == 'edit') {
56  return $a_output;
57  }
58 
59  $parent_obj_id = (int) $this->getPage()->getParentId();
60  if ($this->supportsCurriculum($parent_obj_id)) {
61  $a_output = $this->replaceWithRenderedCurriculum($parent_obj_id, $a_output);
62  }
63 
64  return $a_output;
65  }
66 
67  protected function supportsCurriculum(int $parent_obj_id): bool
68  {
69  $parent_obj_type = \ilObject::_lookupType($parent_obj_id);
70  return in_array($parent_obj_type, self::PROVIDING_TYPES);
71  }
72 
73  protected function replaceWithRenderedCurriculum(int $obj_id, string $html): string
74  {
76  $rendered_curriculum = $lso->getCurrentUserCurriculum();
77  return str_replace(self::PLACEHOLDER, $rendered_curriculum, $html);
78  }
79 }
setType(string $a_type)
Set Type.
modifyPageContentPostXsl(string $a_output, string $a_mode, bool $a_abstract_only=false)
Curriculum for PageEditor.
Content object of ilPageObject (see ILIAS DTD).
replaceWithRenderedCurriculum(int $obj_id, string $html)
create(ilPageObject $a_pg_obj, string $a_hier_id, string $a_pc_id="")
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
Class ilPageObject Handles PageObjects of ILIAS Learning Modules (see ILIAS DTD)
const IL_INSERT_AFTER
createPageContentNode(bool $a_set_this_node=true)
Create page content node (always use this method first when adding a new element) ...
static getInstanceByObjId(?int $obj_id, bool $stop_on_error=true)
get an instance of an Ilias object by object id
supportsCurriculum(int $parent_obj_id)
static _lookupType(int $id, bool $reference=false)