ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
class.ilObjBibliographicAdminLibrariesFormGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
15{
16
20 protected $bibl_setting;
24 protected $parent_gui;
28 protected $ctrl;
32 protected $lng;
36 protected $action;
37
38
44 {
45 global $DIC;
46 $ilCtrl = $DIC['ilCtrl'];
47 $lng = $DIC['lng'];
48 $this->ctrl = $ilCtrl;
49 $this->lng = $lng;
50 $this->parent_gui = $parent_gui;
51 $this->bibl_setting = $bibl_setting;
52 if ($bibl_setting->getId() > 0) {
53 $this->action = 'update';
54 } else {
55 $this->action = 'create';
56 }
57 $this->ctrl->saveParameter($parent_gui, 'lib_id');
58 $this->initForm();
59 }
60
61
67 private function initForm()
68 {
69 $this->setFormAction($this->ctrl->getFormAction($this->parent_gui));
70 $name = new ilTextInputGUI($this->lng->txt("bibl_library_name"), 'name');
71 $name->setRequired(true);
72 $name->setValue('');
73 $this->addItem($name);
74 $url = new ilTextInputGUI($this->lng->txt("bibl_library_url"), 'url');
75 $url->setRequired(true);
76 $url->setValue('');
77 $this->addItem($url);
78 $img = new ilTextInputGUI($this->lng->txt("bibl_library_img"), 'img');
79 $img->setValue('');
80 $this->addItem($img);
81 $show_in_list = new ilCheckboxInputGUI($this->lng->txt("bibl_library_show_in_list"), 'show_in_list');
82 $show_in_list->setValue(1);
83 $this->addItem($show_in_list);
84 switch ($this->action) {
85 case 'create':
86 $this->setTitle($this->lng->txt("bibl_settings_new"));
87 $this->addCommandButton('create', $this->lng->txt('save'));
88 break;
89 case 'update':
90 $this->addCommandButton('update', $this->lng->txt('save'));
91 $this->fillForm();
92 $this->setTitle($this->lng->txt("bibl_settings_edit"));
93 break;
94 }
95 $this->addCommandButton('cancel', $this->lng->txt("cancel"));
96 }
97
98
99 private function fillForm()
100 {
101 $this->setValuesByArray(array(
102 'name' => $this->bibl_setting->getName(),
103 'url' => $this->bibl_setting->getUrl(),
104 'img' => $this->bibl_setting->getImg(),
105 'show_in_list' => $this->bibl_setting->getShowInList(),
106 ));
107 }
108
109
110 public function saveObject()
111 {
112 if (!$this->checkInput()) {
113 return false;
114 }
115 $this->bibl_setting->setName($this->getInput("name"));
116 $this->bibl_setting->setUrl($this->getInput("url"));
117 $this->bibl_setting->setImg($this->getInput("img"));
118 $this->bibl_setting->setShowInList($this->getInput("show_in_list"));
119 switch ($this->action) {
120 case 'create':
121 $this->bibl_setting->create();
122 break;
123 case 'update':
124 $this->bibl_setting->update();
125 break;
126 }
127
128 return true;
129 }
130}
An exception for terminatinating execution or to throw for unit testing.
This class represents a checkbox property in a property form.
setFormAction($a_formaction)
Set FormAction.
This class represents a property form user interface.
addItem($a_item)
Add Item (Property, SectionHeader).
addCommandButton($a_cmd, $a_text, $a_id="")
Add Command button.
setValuesByArray($a_values, $a_restrict_to_value_keys=false)
Set form values from an array.
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
checkInput()
Check Post Input.
setTitle($a_title)
Set Title.
This class represents a text property in a property form.
global $ilCtrl
Definition: ilias.php:18
$url
global $DIC
Definition: saml.php:7