ILIAS  release_8 Revision v8.25-1-g13de6a5eca6
class.ilBiblLibraryFormGUI.php
Go to the documentation of this file.
1<?php
27{
28 use \ILIAS\Modules\OrgUnit\ARHelper\DIC;
29 protected \ilBiblLibraryInterface $object;
30
31
35 public function __construct(ilBiblLibraryInterface $library)
36 {
37 $this->object = $library;
38 $this->ctrl()->saveParameterByClass(ilBiblLibraryGUI::class, ilBiblLibraryGUI::F_LIB_ID);
39 $this->initForm();
40
41 if ($this->object->getId()) {
42 $this->fillForm();
43 }
45 }
46
47
53 private function initForm(): void
54 {
55 $this->setFormAction($this->ctrl()->getFormActionByClass(ilBiblLibraryGUI::class));
56 $name = new ilTextInputGUI($this->lng()->txt("bibl_library_name"), 'name');
57 $name->setRequired(true);
58 $name->setValue('');
59 $this->addItem($name);
60 $url = new ilTextInputGUI($this->lng()->txt("bibl_library_url"), 'url');
61 $url->setRequired(true);
62 $url->setValue('');
63 $this->addItem($url);
64 $img = new ilTextInputGUI($this->lng()->txt("bibl_library_img"), 'img');
65 $img->setValue('');
66 $this->addItem($img);
67 $show_in_list = new ilCheckboxInputGUI($this->lng()
68 ->txt("bibl_library_show_in_list"), 'show_in_list');
69 $show_in_list->setValue('1');
70 $this->addItem($show_in_list);
71 if ($this->object->getId()) {
72 $this->addCommandButton('update', $this->lng()->txt('save'));
73 $this->fillForm();
74 $this->setTitle($this->lng()->txt("bibl_settings_edit"));
75 } else {
76 $this->setTitle($this->lng()->txt("bibl_settings_new"));
77 $this->addCommandButton('create', $this->lng()->txt('save'));
78 }
79 $this->addCommandButton('cancel', $this->lng()->txt("cancel"));
80 }
81
82
83 private function fillForm(): void
84 {
85 $this->setValuesByArray(array(
86 'name' => $this->object->getName(),
87 'url' => $this->object->getUrl(),
88 'img' => $this->object->getImg(),
89 'show_in_list' => $this->object->isShownInList(),
90 ));
91 }
92
93
94 public function saveObject(): bool
95 {
96 if (!$this->checkInput()) {
97 return false;
98 }
99 $this->object->setName($this->getInput("name"));
100 $this->object->setUrl($this->getInput("url"));
101 $this->object->setImg($this->getInput("img"));
102 $this->object->setShowInList((bool) $this->getInput("show_in_list"));
103 $this->object->store();
104
105 return true;
106 }
107}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(ilBiblLibraryInterface $library)
ilBiblLibraryFormGUI constructor.
initForm()
Init settings property form.
ilBiblLibraryInterface $object
This class represents a checkbox property in a property form.
setFormAction(string $a_formaction)
This class represents a property form user interface.
setValuesByArray(array $a_values, bool $a_restrict_to_value_keys=false)
addCommandButton(string $a_cmd, string $a_text, string $a_id="")
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-...
This class represents a text property in a property form.
$img
Definition: imgupload.php:83
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
$url