ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
class.ilUriInputGUI.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 use ILIAS\Data\URI;
22 
30 {
31  protected ?int $maxlength = 500;
32  protected int $size = 40;
33 
34  public function __construct(
35  string $a_title = "",
36  string $a_postvar = ""
37  ) {
38  global $DIC;
39 
40  $this->lng = $DIC->language();
41  parent::__construct($a_title, $a_postvar);
42  $this->setType("uri");
43  }
44 
45  public function checkInput(): bool
46  {
47  $lng = $this->lng;
48 
49  $uri_string = trim($this->getInput());
50 
51  // check required
52  if ($uri_string === "") {
53  if ($this->getRequired()) {
54  $this->setAlert($lng->txt("msg_input_is_required"));
55  return false;
56  }
57  return true;
58  }
59 
60  try {
61  new URI($uri_string);
62  } catch (Throwable $e) {
63  $this->setAlert($lng->txt("form_invalid_uri"));
64  return false;
65  }
66 
67  return true;
68  }
69 }
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...
global $DIC
Definition: shib_login.php:26
Legacy Uri input.
__construct(Container $dic, ilPlugin $plugin)
__construct(string $a_title="", string $a_postvar="")