ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilADTExternalLinkFormBridge.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
6 
13 {
14  protected ilLogger $logger;
15 
16  public function __construct(ilADT $a_adt)
17  {
18  global $DIC;
19  parent::__construct($a_adt);
20 
21  $this->logger = $DIC->logger()->amet();
22  }
23 
29  protected function isValidADT(ilADT $a_adt): bool
30  {
31  return $a_adt instanceof ilADTExternalLink;
32  }
33 
37  public function addToForm(): void
38  {
39  $def = $this->getADT()->getCopyOfDefinition();
40 
41  $both = new ilCombinationInputGUI($this->getTitle(), $this->getElementId());
42  $this->addBasicFieldProperties($both, $def);
43 
44  $title = new ilTextInputGUI('', $this->getElementId() . '_title');
45  $title->setMaxLength(250);
46  $title->setValue($this->getADT()->getTitle());
47  $both->addCombinationItem('title', $title, $this->lng->txt('title'));
48 
49  $url = new ilTextInputGUI('', $this->getElementId() . '_url');
50  $url->setMaxLength(1000);
51  $url->setValue($this->getADT()->getUrl());
52  $both->addCombinationItem('url', $url, $this->lng->txt('url'));
53 
54  $this->addToParentElement($both);
55  }
56 
60  public function importFromPost(): void
61  {
62  $this->getADT()->setUrl($this->getForm()->getInput($this->getElementId() . '_url'));
63  $this->getADT()->setTitle($this->getForm()->getInput($this->getElementId() . '_title'));
64 
65  $combination = $this->getForm()->getItemByPostVar($this->getElementId());
66  if (!$combination instanceof ilCombinationInputGUI) {
67  $this->logger->warning('Cannot find combination input gui');
68  return;
69  }
70 
71  $combination->getCombinationItem('url')->setValue($this->getADT()->getUrl());
72  $combination->getCombinationItem('title')->setValue($this->getADT()->getTitle());
73  }
74 }
addToParentElement(ilFormPropertyGUI $a_field)
ADT form bridge base class.
ADT base class.
Definition: class.ilADT.php:11
addBasicFieldProperties(ilFormPropertyGUI $a_field, ilADTDefinition $a_def)
Helper method to handle generic properties like setRequired(), setInfo()
global $DIC
Definition: feed.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
$url