ILIAS  release_8 Revision v8.24
class.ilNonEditableValueGUI.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
27{
31 protected $value = null;
32 protected string $section_icon = "";
33 protected bool $disable_escaping = false;
34
35 public function __construct(
36 string $a_title = "",
37 string $a_id = "",
38 bool $a_disable_escaping = false
39 ) {
40 parent::__construct($a_title, $a_id);
41 $this->setTitle($a_title);
42 $this->setType("non_editable_value");
43 $this->disable_escaping = $a_disable_escaping;
44 }
45
46 public function checkInput(): bool
47 {
48 return $this->checkSubItemsInput();
49 }
50
54 public function getInput()
55 {
56 if ($this->isRequestParamArray($this->getPostVar())) {
57 return $this->strArray($this->getPostVar());
58 }
59 return $this->str($this->getPostVar());
60 }
61
62 protected function setType(string $a_type): void
63 {
64 $this->type = $a_type;
65 }
66
67 public function getType(): string
68 {
69 return $this->type;
70 }
71
72 public function setTitle(string $a_title): void
73 {
74 $this->title = $a_title;
75 }
76
77 public function getTitle(): string
78 {
79 return $this->title;
80 }
81
82 public function setInfo(string $a_info): void
83 {
84 $this->info = $a_info;
85 }
86
87 public function getInfo(): string
88 {
89 return $this->info;
90 }
91
95 public function setValue($a_value): void
96 {
97 if ($this->getMulti() && is_array($a_value)) {
98 $this->setMultiValues($a_value);
99 $a_value = array_shift($a_value);
100 }
101 $this->value = $a_value;
102 }
103
107 public function getValue()
108 {
109 return $this->value;
110 }
111
112 public function render(): string
113 {
114 $postvar = "";
115
116 $tpl = new ilTemplate("tpl.non_editable_value.html", true, true, "Services/Form");
117 if ($this->getPostVar() != "") {
118 $postvar = $this->getPostVar();
119 if ($this->getMulti() && substr($postvar, -2) != "[]") {
120 $postvar .= "[]";
121 }
122
123 $tpl->setCurrentBlock("hidden");
124 $tpl->setVariable('NON_EDITABLE_ID', $postvar);
125 $tpl->setVariable('MULTI_HIDDEN_ID', $this->getFieldId());
126 $tpl->setVariable("HVALUE", ilLegacyFormElementsUtil::prepareFormOutput((string) $this->getValue()));
127 $tpl->parseCurrentBlock();
128 }
129 $value = $this->getValue();
130 if (!$this->disable_escaping) {
132 }
133 $tpl->setVariable("VALUE", $value);
134 if ($this->getFieldId() != "") {
135 $tpl->setVariable("ID", ' id="' . $this->getFieldId() . '" ');
136 }
137 $tpl->parseCurrentBlock();
138
139 if ($this->getMulti() && $postvar != "" && !$this->getDisabled()) {
140 $tpl->setVariable("MULTI_ICONS", $this->getMultiIconsHTML());
141 }
142
143
144 return $tpl->get();
145 }
146
147 public function insert(ilTemplate $a_tpl): void
148 {
149 $a_tpl->setCurrentBlock("prop_generic");
150 $a_tpl->setVariable("PROP_GENERIC", $this->render());
151 $a_tpl->parseCurrentBlock();
152 }
153
154 public function setValueByArray(array $a_values): void
155 {
156 if ($this->getPostVar() && isset($a_values[$this->getPostVar()])) {
157 $this->setValue($a_values[$this->getPostVar()]);
158 }
159 foreach ($this->getSubItems() as $item) {
160 $item->setValueByArray($a_values);
161 }
162 }
163
164 public function getTableFilterHTML(): string
165 {
166 $html = $this->render();
167 return $html;
168 }
169}
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:514
setMultiValues(array $a_values)
static prepareFormOutput($a_str, bool $a_strip=false)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
checkInput()
Check input, strip slashes etc.
__construct(string $a_title="", string $a_id="", bool $a_disable_escaping=false)
getTableFilterHTML()
Get input item HTML to be inserted into table filters.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
special template class to simplify handling of ITX/PEAR
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if($DIC->http() ->request() ->getMethod()=="GET" &&isset($DIC->http() ->request() ->getQueryParams()['tex'])) $tpl
Definition: latex.php:41
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc