ILIAS  release_8 Revision v8.24
class.ilPCTab.php
Go to the documentation of this file.
1<?php
2
25{
26 protected int $user_id = 0;
27
28 public function init(): void
29 {
30 global $DIC;
31 $this->user_id = $DIC->user()->getId();
32 $this->setType("tabstab");
33 }
34
35 public function newItemAfter(): void
36 {
37 $tab = $this->getNode();
38 $new_tab = $this->dom->create_element("Tab");
39 if ($next_tab = $tab->next_sibling()) {
40 $new_tab = $next_tab->insert_before($new_tab, $next_tab);
41 } else {
42 $parent_tabs = $tab->parent_node();
43 $new_tab = $parent_tabs->append_child($new_tab);
44 }
45 }
46
47 public function newItemBefore(): void
48 {
49 $tab = $this->getNode();
50 $new_tab = $this->dom->create_element("Tab");
51 $new_tab = $tab->insert_before($new_tab, $tab);
52 }
53
54 public function deleteItem(): void
55 {
56 $tab = $this->getNode();
57 $tab->unlink($tab);
58 }
59
60 public function moveItemDown(): void
61 {
62 $tab = $this->getNode();
63 $next = $tab->next_sibling();
64 $next_copy = $next->clone_node(true);
65 $next_copy = $tab->insert_before($next_copy, $tab);
66 $next->unlink($next);
67 }
68
69 public function moveItemUp(): void
70 {
71 $tab = $this->getNode();
72 $prev = $tab->previous_sibling();
73 $tab_copy = $tab->clone_node(true);
74 $tab_copy = $prev->insert_before($tab_copy, $prev);
75 $tab->unlink($tab);
76 }
77
81 public function modifyPageContentPostXsl(
82 string $a_output,
83 string $a_mode,
84 bool $a_abstract_only = false
85 ): string {
86
87 // get opened accordions
88 $storage = new ilAccordionPropertiesStorageGUI();
89 $opened = $storage->getPropertyForIdStartsWith("ilc_accordion_" .
90 $this->getPage()->getId() . "_", $this->user_id, "opened");
91 $script = "";
92 if (!$a_abstract_only) {
93 $script = "<script>";
94 foreach ($opened as $id => $open) {
95 $script .= <<<EOT
96 if (typeof ilAccordionsInits !== 'undefined') {
97 for (var i = 0; i < ilAccordionsInits.length; i++) {
98 if (ilAccordionsInits[i].id === '$id') {
99 ilAccordionsInits[i].initial_opened = '$open';
100 }
101 }
102 }
103EOT;
104 }
105 $script .= "</script>";
106 }
107
108
109
110 return $a_output . $script;
111 }
112}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getPropertyForIdStartsWith(string $id_starts_with, int $user_id, string $property)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
int $user_id
modifyPageContentPostXsl(string $a_output, string $a_mode, bool $a_abstract_only=false)
Modify page content after xsl.
init()
Init object.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setType(string $a_type)
Set Type.
global $DIC
Definition: feed.php:28