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