ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilADTExternalLinkFormBridge.php
Go to the documentation of this file.
1<?php
2
19declare(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}
ADT form bridge base class.
addBasicFieldProperties(ilFormPropertyGUI $a_field, ilADTDefinition $a_def)
Helper method to handle generic properties like setRequired(), setInfo()
addToParentElement(ilFormPropertyGUI $a_field)
ADT base class.
Definition: class.ilADT.php:26
This class represents a number property in a property form.
Component logger with individual log levels by component id.
This class represents a text property in a property form.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
global $DIC
Definition: shib_login.php:26
$url
Definition: shib_logout.php:68