ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilTRBLBorderStyleInputGUI.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
27{
28 protected string $rightvalue = "";
29 protected string $leftvalue = "";
30 protected string $bottomvalue = "";
31 protected string $topvalue = "";
32 protected string $allvalue = "";
36 protected array $dirs = [];
37 protected ilObjUser $user;
38 protected string $value = "";
39
40 public function __construct(string $a_title = "", string $a_postvar = "")
41 {
42 global $DIC;
43
44 $this->lng = $DIC->language();
45 $this->user = $DIC->user();
46 parent::__construct($a_title, $a_postvar);
47 $this->setType("border_style");
48 $this->dirs = array("all", "top", "bottom", "left", "right");
49 }
50
51 public function setAllValue(string $a_allvalue): void
52 {
53 $this->allvalue = $a_allvalue;
54 }
55
56 public function getAllValue(): string
57 {
58 return $this->allvalue;
59 }
60
61 public function setTopValue(string $a_topvalue): void
62 {
63 $this->topvalue = $a_topvalue;
64 }
65
66 public function getTopValue(): string
67 {
68 return $this->topvalue;
69 }
70
71 public function setBottomValue(string $a_bottomvalue): void
72 {
73 $this->bottomvalue = $a_bottomvalue;
74 }
75
76 public function getBottomValue(): string
77 {
78 return $this->bottomvalue;
79 }
80
81 public function setLeftValue(string $a_leftvalue): void
82 {
83 $this->leftvalue = $a_leftvalue;
84 }
85
86 public function getLeftValue(): string
87 {
88 return $this->leftvalue;
89 }
90
91 public function setRightValue(string $a_rightvalue): void
92 {
93 $this->rightvalue = $a_rightvalue;
94 }
95
96 public function getRightValue(): string
97 {
98 return $this->rightvalue;
99 }
100
101 public function checkInput(): bool
102 {
103 $input = $this->getInput();
104
105 foreach ($this->dirs as $dir) {
106 $pre_value = $input[$dir]["pre_value"];
107
108 /*
109 if ($this->getRequired() && trim($num_value) == "")
110 {
111 $this->setAlert($lng->txt("msg_input_is_required"));
112
113 return false;
114 }*/
115
116 $value = $pre_value;
117
118 if (trim($value) != "") {
119 switch ($dir) {
120 case "all": $this->setAllValue($value);
121 break;
122 case "top": $this->setTopValue($value);
123 break;
124 case "bottom": $this->setBottomValue($value);
125 break;
126 case "left": $this->setLeftValue($value);
127 break;
128 case "right": $this->setRightValue($value);
129 break;
130 }
131 }
132 }
133
134 return true;
135 }
136
137 public function getInput(): array
138 {
139 return $this->arrayArray($this->getPostVar());
140 }
141
142 public function insert(ilTemplate $a_tpl): void
143 {
145 $value = "";
146 $layout_tpl = new ilTemplate("tpl.prop_trbl_layout.html", true, true, "components/ILIAS/Style/Content");
147
148 foreach ($this->dirs as $dir) {
149 $tpl = new ilTemplate("tpl.prop_trbl_select.html", true, true, "components/ILIAS/Style/Content");
150 $pre_options = array_merge(
151 array("" => ""),
153 );
154
155 switch ($dir) {
156 case "all": $value = strtolower(trim($this->getAllValue()));
157 break;
158 case "top": $value = strtolower(trim($this->getTopValue()));
159 break;
160 case "bottom": $value = strtolower(trim($this->getBottomValue()));
161 break;
162 case "left": $value = strtolower(trim($this->getLeftValue()));
163 break;
164 case "right": $value = strtolower(trim($this->getRightValue()));
165 break;
166 }
167
168 foreach ($pre_options as $option) {
169 $tpl->setCurrentBlock("pre_option");
170 $tpl->setVariable("VAL_PRE", $option);
171 $tpl->setVariable("TXT_PRE", $option);
172 if ($value == $option) {
173 $tpl->setVariable("PRE_SELECTED", 'selected="selected"');
174 }
175 $tpl->parseCurrentBlock();
176 }
177
178 $tpl->setVariable("POSTVAR", $this->getPostVar());
179 $tpl->setVariable("TXT_DIR", $lng->txt("sty_$dir"));
180 $tpl->setVariable("DIR", $dir);
181
182 $layout_tpl->setVariable(strtoupper($dir), $tpl->get());
183 }
184
185 $a_tpl->setCurrentBlock("prop_generic");
186 $a_tpl->setVariable("PROP_GENERIC", $layout_tpl->get());
187 $a_tpl->parseCurrentBlock();
188 }
189
190 public function setValueByArray(array $a_values): void
191 {
192 $this->setAllValue($a_values[$this->getPostVar()]["all"]["pre_value"]);
193 $this->setBottomValue($a_values[$this->getPostVar()]["bottom"]["pre_value"]);
194 $this->setTopValue($a_values[$this->getPostVar()]["top"]["pre_value"]);
195 $this->setLeftValue($a_values[$this->getPostVar()]["left"]["pre_value"]);
196 $this->setRightValue($a_values[$this->getPostVar()]["right"]["pre_value"]);
197 }
198}
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544
This class represents a property in a property form.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
static _getStyleParameterValues(string $par)
User class.
This class represents a border style with all/top/right/bottom/left in a property form.
checkInput()
Check input, strip slashes etc.
__construct(string $a_title="", string $a_postvar="")
special template class to simplify handling of ITX/PEAR
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26