ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilBiblLibraryFormGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
13 {
14  use \ILIAS\Modules\OrgUnit\ARHelper\DIC;
18  protected $object;
19 
20 
26  public function __construct(ilBiblLibraryInterface $library)
27  {
28  $this->object = $library;
29  $this->ctrl()->saveParameterByClass(ilBiblLibraryGUI::class, ilBiblLibraryGUI::F_LIB_ID);
30  $this->initForm();
31 
32  if ($this->object->getId()) {
33  $this->fillForm();
34  }
35  parent::__construct();
36  }
37 
38 
44  private function initForm()
45  {
46  $this->setFormAction($this->ctrl()->getFormActionByClass(ilBiblLibraryGUI::class));
47  $name = new ilTextInputGUI($this->lng()->txt("bibl_library_name"), 'name');
48  $name->setRequired(true);
49  $name->setValue('');
50  $this->addItem($name);
51  $url = new ilTextInputGUI($this->lng()->txt("bibl_library_url"), 'url');
52  $url->setRequired(true);
53  $url->setValue('');
54  $this->addItem($url);
55  $img = new ilTextInputGUI($this->lng()->txt("bibl_library_img"), 'img');
56  $img->setValue('');
57  $this->addItem($img);
58  $show_in_list = new ilCheckboxInputGUI($this->lng()
59  ->txt("bibl_library_show_in_list"), 'show_in_list');
60  $show_in_list->setValue(1);
61  $this->addItem($show_in_list);
62  if ($this->object->getId()) {
63  $this->addCommandButton('update', $this->lng()->txt('save'));
64  $this->fillForm();
65  $this->setTitle($this->lng()->txt("bibl_settings_edit"));
66  } else {
67  $this->setTitle($this->lng()->txt("bibl_settings_new"));
68  $this->addCommandButton('create', $this->lng()->txt('save'));
69  }
70  $this->addCommandButton('cancel', $this->lng()->txt("cancel"));
71  }
72 
73 
74  private function fillForm()
75  {
76  $this->setValuesByArray(array(
77  'name' => $this->object->getName(),
78  'url' => $this->object->getUrl(),
79  'img' => $this->object->getImg(),
80  'show_in_list' => $this->object->getShowInList(),
81  ));
82  }
83 
84 
85  public function saveObject()
86  {
87  if (!$this->checkInput()) {
88  return false;
89  }
90  $this->object->setName($this->getInput("name"));
91  $this->object->setUrl($this->getInput("url"));
92  $this->object->setImg($this->getInput("img"));
93  $this->object->setShowInList((bool) $this->getInput("show_in_list"));
94  $this->object->store();
95 
96  return true;
97  }
98 }
This class represents a property form user interface.
initForm()
Init settings property form.
This class represents a checkbox property in a property form.
setFormAction($a_formaction)
Set FormAction.
addItem($a_item)
Add Item (Property, SectionHeader).
__construct(ilBiblLibraryInterface $library)
ilBiblLibraryFormGUI constructor.
Bibliographic Libraries Form.
setTitle($a_title)
Set Title.
Interface ilBiblLibraryInterface.
This class represents a text property in a property form.
addCommandButton($a_cmd, $a_text, $a_id="")
Add Command button.
checkInput()
Check Post Input.
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
$url
setValuesByArray($a_values, $a_restrict_to_value_keys=false)
Set form values from an array.