ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilPanelGUI.php
Go to the documentation of this file.
1 <?php
2 
27 {
28  public const PANEL_STYLE_PRIMARY = 0;
29  public const PANEL_STYLE_SECONDARY = 1;
30  public const HEADING_STYLE_SUBHEADING = 0;
31  public const HEADING_STYLE_BLOCK = 1;
32  public const FOOTER_STYLE_BLOCK = 0;
33 
34  protected string $heading = "";
35  protected string $body = "";
36  protected string $footer = "";
37  protected int $panel_style = 0;
38  protected int $heading_style = 0;
39  protected int $footer_style = 0;
40 
41  protected function __construct()
42  {
43  }
44 
45  public static function getInstance(): self
46  {
47  return new ilPanelGUI();
48  }
49 
50  public function setHeading(string $a_val): void
51  {
52  $this->heading = $a_val;
53  }
54 
55  public function getHeading(): string
56  {
57  return $this->heading;
58  }
59 
60  public function setBody(string $a_val): void
61  {
62  $this->body = $a_val;
63  }
64 
65  public function getBody(): string
66  {
67  return $this->body;
68  }
69 
70  public function setFooter(string $a_val): void
71  {
72  $this->footer = $a_val;
73  }
74 
75  public function getFooter(): string
76  {
77  return $this->footer;
78  }
79 
80  public function setPanelStyle(int $a_val): void
81  {
82  $this->panel_style = $a_val;
83  }
84 
85  public function getPanelStyle(): int
86  {
87  return $this->panel_style;
88  }
89 
90  public function setHeadingStyle(int $a_val): void
91  {
92  $this->heading_style = $a_val;
93  }
94 
95  public function getHeadingStyle(): int
96  {
97  return $this->heading_style;
98  }
99 
100  public function setFooterStyle(int $a_val): void
101  {
102  $this->footer_style = $a_val;
103  }
104 
105  public function getFooterStyle(): int
106  {
107  return $this->footer_style;
108  }
109 
110  public function getHTML(): string
111  {
112  $tpl = new ilTemplate("tpl.panel.html", true, true, "Services/UIComponent/Panel");
113 
114  $head_outer_div_style = "";
115  if ($this->getHeading() !== "") {
116  $tpl->setCurrentBlock("heading");
117  $tpl->setVariable("HEADING", $this->getHeading());
118 
119  switch ($this->getHeadingStyle()) {
120  case self::HEADING_STYLE_BLOCK:
121  $tpl->setVariable("HEAD_DIV_STYLE", "panel-heading ilBlockHeader");
122  $tpl->setVariable("HEAD_H3_STYLE", "ilBlockHeader");
123  $head_outer_div_style = "il_Block";
124  break;
125 
126  case self::HEADING_STYLE_SUBHEADING:
127  $tpl->setVariable("HEAD_DIV_STYLE", "panel-heading ilHeader");
128  $tpl->setVariable("HEAD_H3_STYLE", "ilHeader");
129  break;
130  }
131 
132  $tpl->parseCurrentBlock();
133  }
134 
135  $tpl->setVariable("BODY", $this->getBody());
136 
137  if ($this->getFooter() !== "") {
138  $tpl->setCurrentBlock("footer");
139  $tpl->setVariable("FOOTER", $this->getFooter());
140 
141  switch ($this->getFooterStyle()) {
142  case self::FOOTER_STYLE_BLOCK:
143  $tpl->setVariable("FOOT_DIV_STYLE", "panel-footer ilBlockInfo");
144  break;
145  }
146 
147  $tpl->parseCurrentBlock();
148  }
149 
150  switch ($this->getPanelStyle()) {
151  case self::PANEL_STYLE_SECONDARY:
152  $tpl->setVariable("PANEL_STYLE", "panel panel-default " . $head_outer_div_style);
153  break;
154 
155  default:
156  $tpl->setVariable("PANEL_STYLE", "panel panel-primary " . $head_outer_div_style);
157  break;
158  }
159 
160  return $tpl->get();
161  }
162 }
const PANEL_STYLE_PRIMARY
setFooter(string $a_val)
setPanelStyle(int $a_val)
setHeadingStyle(int $a_val)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setFooterStyle(int $a_val)
setHeading(string $a_val)
const HEADING_STYLE_SUBHEADING
static getInstance()
setBody(string $a_val)
const PANEL_STYLE_SECONDARY
const HEADING_STYLE_BLOCK
const FOOTER_STYLE_BLOCK