ILIAS  trunk Revision v11.0_alpha-1723-g8e69f309bab
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilADTExternalLinkFormBridge.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
27 {
28  protected ilLogger $logger;
29 
30  public function __construct(ilADT $a_adt)
31  {
32  global $DIC;
33  parent::__construct($a_adt);
34 
35  $this->logger = $DIC->logger()->amet();
36  }
37 
43  protected function isValidADT(ilADT $a_adt): bool
44  {
45  return $a_adt instanceof ilADTExternalLink;
46  }
47 
51  public function addToForm(): void
52  {
53  $def = $this->getADT()->getCopyOfDefinition();
54 
55  $both = new ilCombinationInputGUI($this->getTitle(), $this->getElementId());
56  $this->addBasicFieldProperties($both, $def);
57 
58  $title = new ilTextInputGUI('', $this->getElementId() . '_title');
59  $title->setMaxLength(250);
60  $title->setValue($this->getADT()->getTitle());
61  $both->addCombinationItem('title', $title, $this->lng->txt('title'));
62 
63  $url = new ilTextInputGUI('', $this->getElementId() . '_url');
64  $url->setMaxLength(1000);
65  $url->setValue($this->getADT()->getUrl());
66  $both->addCombinationItem('url', $url, $this->lng->txt('url'));
67 
68  $this->addToParentElement($both);
69  }
70 
74  public function importFromPost(): void
75  {
76  $this->getADT()->setUrl($this->getForm()->getInput($this->getElementId() . '_url'));
77  $this->getADT()->setTitle($this->getForm()->getInput($this->getElementId() . '_title'));
78 
79  $combination = $this->getForm()->getItemByPostVar($this->getElementId());
80  if (!$combination instanceof ilCombinationInputGUI) {
81  $this->logger->warning('Cannot find combination input gui');
82  return;
83  }
84 
85  $combination->getCombinationItem('url')->setValue($this->getADT()->getUrl());
86  $combination->getCombinationItem('title')->setValue($this->getADT()->getTitle());
87  }
88 }
addToParentElement(ilFormPropertyGUI $a_field)
ADT form bridge base class.
$url
Definition: shib_logout.php:66
ADT base class.
Definition: class.ilADT.php:25
addBasicFieldProperties(ilFormPropertyGUI $a_field, ilADTDefinition $a_def)
Helper method to handle generic properties like setRequired(), setInfo()
global $DIC
Definition: shib_login.php:22
This class represents a number property in a property form.
__construct(Container $dic, ilPlugin $plugin)