ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilPublicSectionExplorerGUI.php
Go to the documentation of this file.
1 <?php
2 
24 {
26  public string $exp_id = "public_section";
27  public string $requested_transl = "";
28 
29  public function __construct(
30  object $a_parent_obj,
31  string $a_parent_cmd,
32  ilObjLearningModule $a_lm,
33  string $requested_transl = ""
34  ) {
35  $this->lm = $a_lm;
36  $this->requested_transl = $requested_transl;
37 
38  $tree = ilLMTree::getInstance($this->lm->getId());
39 
40  parent::__construct("lm_public_section_" . $this->lm->getId(), $a_parent_obj, $a_parent_cmd, $tree);
41  }
42 
46  public function getNodeContent($a_node): string
47  {
48  $lang = ($this->requested_transl != "")
49  ? $this->requested_transl
50  : "-";
52  $a_node,
54  $this->lm->isActiveNumbering(),
55  false,
56  false,
57  $this->lm->getId(),
58  $lang
59  );
60  }
61 
65  public function getNodeIcon($a_node): string
66  {
67  if ($a_node["child"] == $this->getNodeId($this->getRootNode())) {
68  $icon = ilUtil::getImagePath("icon_lm.svg");
69  } else {
70  $a_name = "icon_" . $a_node["type"] . ".svg";
71  if ($a_node["type"] == "pg") {
72  $lm_set = new ilSetting("lm");
73  $active = ilLMPage::_lookupActive(
74  $a_node["child"],
75  $this->lm->getType(),
76  $lm_set->get("time_scheduled_page_activation")
77  );
78 
79  // is page scheduled?
80  $img_sc = ($lm_set->get("time_scheduled_page_activation") &&
81  ilLMPage::_isScheduledActivation($a_node["child"], $this->lm->getType()))
82  ? "_sc"
83  : "";
84 
85  $a_name = "icon_pg" . $img_sc . ".svg";
86 
87  if (!$active) {
88  $a_name = "icon_pg_d" . $img_sc . ".svg";
89  } else {
91  $a_node["child"],
92  $this->lm->getType()
93  );
94  if ($contains_dis) {
95  $a_name = "icon_pg_del" . $img_sc . ".svg";
96  }
97  }
98  }
99  $icon = ilUtil::getImagePath($a_name);
100  }
101 
102  return $icon;
103  }
104 
105  public function beforeRendering(): void
106  {
107  //select public pages and open public chapters
108  foreach ($this->getAllNodes() as $node) {
109  if ($node["public_access"] == "y" && $node["type"] == "pg") {
110  $this->setNodeSelected($node["obj_id"]);
111  }
112  if ($node["public_access"] == "y" && $node["type"] == "st") {
113  $this->setNodeOpen($node["obj_id"]);
114  }
115  }
116  }
117 
118  protected function getAllNodes(?int $from_id = null): array
119  {
120  $nodes = array();
121 
122  if ($from_id === null) {
123  $from_id = $this->getNodeId($this->getRootNode());
124  }
125 
126  foreach ($this->getChildsOfNode($from_id) as $node) {
127  $nodes[] = $node;
128 
129  if ($node["type"] == "st") {
130  $nodes = array_merge($nodes, $this->getAllNodes($node["obj_id"]));
131  }
132  }
133  return $nodes;
134  }
135 
140  public function isNodeClickable($a_node): bool
141  {
142  if ($a_node["type"] == "pg") {
143  return true;
144  }
145  return false;
146  }
147 }
static _lookupActive(int $a_id, string $a_parent_type, bool $a_check_scheduled_activation=false, string $a_lang="-")
lookup activation status
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _isScheduledActivation(int $a_id, string $a_parent_type, string $a_lang="-")
Check whether page is activated by time schedule.
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
setNodeOpen($a_id)
Set node to be opened (additional custom opened node, not standard expand behaviour) ...
static getInstance(int $a_tree_id)
setNodeSelected($a_id)
Set node to be opened (additional custom opened node, not standard expand behaviour) ...
static _lookupContainsDeactivatedElements(int $a_id, string $a_parent_type, string $a_lang="-")
lookup whether page contains deactivated elements
getNodeId($a_node)
Get id for node.
$lang
Definition: xapiexit.php:26
getRootNode()
Get root node.
$lm_set
Explorer class that works on tree objects (Services/Tree)
__construct(Container $dic, ilPlugin $plugin)
__construct(object $a_parent_obj, string $a_parent_cmd, ilObjLearningModule $a_lm, string $requested_transl="")
getChildsOfNode($a_parent_node_id)
Get childs of node.
static _getNodePresentationTitle(array $a_node, string $a_mode=self::PAGE_TITLE, bool $a_include_numbers=false, bool $a_time_scheduled_activation=false, bool $a_force_content=false, int $a_lm_id=0, string $a_lang="-")
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...