ILIAS  trunk Revision v11.0_alpha-1769-g99a433fe2dc
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilPCTab.php
Go to the documentation of this file.
1 <?php
2 
24 class ilPCTab extends ilPageContent
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->getDomNode();
38  $new_tab = $this->dom_doc->createElement("Tab");
39  if ($next_tab = $tab->nextSibling) {
40  $new_tab = $next_tab->parentNode->insertBefore($new_tab, $next_tab);
41  } else {
42  $parent_tabs = $tab->parentNode;
43  $new_tab = $parent_tabs->appendChild($new_tab);
44  }
45  }
46 
47  public function newItemBefore(): void
48  {
49  $tab = $this->getDomNode();
50  $new_tab = $this->dom_doc->createElement("Tab");
51  $new_tab = $tab->parentNode->insertBefore($new_tab, $tab);
52  }
53 
54  public function deleteItem(): void
55  {
56  $tab = $this->getDomNode();
57  $tab->parentNode->removeChild($tab);
58  }
59 
60  public function moveItemDown(): void
61  {
62  $tab = $this->getDomNode();
63  $next = $tab->nextSibling;
64  $next_copy = $next->cloneNode(true);
65  $next_copy = $tab->parentNode->insertBefore($next_copy, $tab);
66  $next->parentNode->removeChild($next);
67  }
68 
69  public function moveItemUp(): void
70  {
71  $tab = $this->getDomNode();
72  $prev = $tab->previousSibling;
73  $tab_copy = $tab->cloneNode(true);
74  $tab_copy = $prev->parentNode->insertBefore($tab_copy, $prev);
75  $tab->parentNode->removeChild($tab);
76  }
77 
81  public function modifyPageContentPostXsl(
82  string $a_output,
83  string $a_mode,
84  bool $a_abstract_only = false
85  ): string {
86  // get opened accordions
87  $storage = new ilAccordionPropertiesStorageGUI();
88  $opened = $storage->getPropertyForIdStartsWith("ilc_accordion_" .
89  $this->getPage()->getId() . "_", $this->user_id, "opened");
90  $script = "";
91  if (!$a_abstract_only) {
92  $script = "<script>";
93  foreach ($opened as $id => $open) {
94  $script .= <<<EOT
95  if (typeof ilAccordionsInits !== 'undefined') {
96  for (var i = 0; i < ilAccordionsInits.length; i++) {
97  if (ilAccordionsInits[i].id === '$id') {
98  ilAccordionsInits[i].initial_opened = '$open';
99  }
100  }
101  }
102 EOT;
103  }
104  $script .= "</script>";
105  }
106 
107  return $a_output . $script;
108  }
109 }
setType(string $a_type)
Set Type.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Content object of ilPageObject (see ILIAS DTD).
global $DIC
Definition: shib_login.php:22
int $user_id
modifyPageContentPostXsl(string $a_output, string $a_mode, bool $a_abstract_only=false)
Modify page content after xsl.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23