ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
class.ilBiblLibraryFormGUI.php
Go to the documentation of this file.
1 <?php
2 
20 
30 {
31  use DIC;
32 
33 
37  public function __construct(protected ilBiblLibraryInterface $object)
38  {
39  $this->ctrl()->setParameterByClass(ilBiblLibraryGUI::class, ilBiblLibraryGUI::F_LIB_ID, $this->object->getId());
40  $this->initForm();
41 
42  if ($this->object->getId()) {
43  $this->fillForm();
44  }
46  }
47 
48 
54  private function initForm(): void
55  {
56  $this->setFormAction($this->ctrl()->getFormActionByClass(ilBiblLibraryGUI::class));
57  $name = new ilTextInputGUI($this->lng()->txt("bibl_library_name"), 'name');
58  $name->setRequired(true);
59  $name->setValue('');
60  $this->addItem($name);
61  $url = new ilTextInputGUI($this->lng()->txt("bibl_library_url"), 'url');
62  $url->setRequired(true);
63  $url->setValue('');
64  $this->addItem($url);
65  $img = new ilTextInputGUI($this->lng()->txt("bibl_library_img"), 'img');
66  $img->setValue('');
67  $this->addItem($img);
68  $show_in_list = new ilCheckboxInputGUI($this->lng()
69  ->txt("bibl_library_show_in_list"), 'show_in_list');
70  $show_in_list->setValue('1');
71  $this->addItem($show_in_list);
72  if ($this->object->getId()) {
73  $this->addCommandButton('update', $this->lng()->txt('save'));
74  $this->fillForm();
75  $this->setTitle($this->lng()->txt("bibl_settings_edit"));
76  } else {
77  $this->setTitle($this->lng()->txt("bibl_settings_new"));
78  $this->addCommandButton('create', $this->lng()->txt('save'));
79  }
80  $this->addCommandButton('cancel', $this->lng()->txt("cancel"));
81  }
82 
83 
84  private function fillForm(): void
85  {
86  $this->setValuesByArray([
87  'name' => $this->object->getName(),
88  'url' => $this->object->getUrl(),
89  'img' => $this->object->getImg(),
90  'show_in_list' => $this->object->isShownInList(),
91  ]);
92  }
93 
94 
95  public function saveObject(): bool
96  {
97  if (!$this->checkInput()) {
98  return false;
99  }
100  $this->object->setName($this->getInput("name"));
101  $this->object->setUrl($this->getInput("url"));
102  $this->object->setImg($this->getInput("img"));
103  $this->object->setShowInList((bool) $this->getInput("show_in_list"));
104  $this->object->store();
105 
106  return true;
107  }
108 }
initForm()
Init settings property form.
$url
Definition: shib_logout.php:68
getInput(string $a_post_var, bool $ensureValidation=true)
Returns the input of an item, if item provides getInput method and as fallback the value of the HTTP-...
Bibliographic Libraries Form.
setFormAction(string $a_formaction)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setValuesByArray(array $a_values, bool $a_restrict_to_value_keys=false)
addCommandButton(string $a_cmd, string $a_text, string $a_id="")
__construct(protected ilBiblLibraryInterface $object)
ilBiblLibraryFormGUI constructor.
__construct(Container $dic, ilPlugin $plugin)