ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
class.ilCustomInputGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
29 {
30  protected bool $skip_required_check = false;
31  protected string $html = "";
32 
33  public function __construct(
34  string $a_title = "",
35  string $a_postvar = ""
36  ) {
37  global $DIC;
38  $this->lng = $DIC->language();
39  parent::__construct($a_title, $a_postvar);
40  $this->setType("custom");
41  }
42 
43  public function setHtml(string $a_html): void
44  {
45  $this->html = $a_html;
46  }
47 
48  public function getHtml(): string
49  {
50  return $this->html;
51  }
52 
53  public function setValueByArray(array $a_values): void
54  {
55  foreach ($this->getSubItems() as $item) {
56  $item->setValueByArray($a_values);
57  }
58  }
59 
60  public function insert(ilTemplate $a_tpl): void
61  {
62  $a_tpl->setCurrentBlock("prop_custom");
63  $a_tpl->setVariable("CUSTOM_CONTENT", $this->getHtml());
64  $a_tpl->parseCurrentBlock();
65  }
66 
67  public function setSkipRequiredCheck(bool $skip): void
68  {
69  $this->skip_required_check = $skip;
70  }
71 
72  public function checkInput(): bool
73  {
74  $lng = $this->lng;
75 
76  if ($this->getPostVar()) {
77  if (!$this->skip_required_check && $this->getRequired() && $this->getInput() == "") {
78  $this->setAlert($lng->txt("msg_input_is_required"));
79  return false;
80  }
81  }
82  return $this->checkSubItemsInput();
83  }
84 
85  public function getInput(): string
86  {
87  return trim($this->str($this->getPostVar()));
88  }
89 }
parseCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
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...
__construct(string $a_title="", string $a_postvar="")
setSkipRequiredCheck(bool $skip)
setVariable($variable, $value='')
Sets a variable value.
Definition: IT.php:544
insert(ilTemplate $a_tpl)
global $DIC
Definition: shib_login.php:26
setValueByArray(array $a_values)
setCurrentBlock(string $part=ilGlobalTemplateInterface::DEFAULT_BLOCK)
__construct(Container $dic, ilPlugin $plugin)
This class represents a property that may include a sub form.