ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
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 */
3require_once('./Services/Form/classes/class.ilPropertyFormGUI.php');
4require_once('./Modules/Bibliographic/classes/class.ilObjBibliographicAdminGUI.php');
16
20 protected $bibl_setting;
24 protected $parent_gui;
28 protected $ctrl;
32 protected $lng;
36 protected $action;
37
38
44 global $ilCtrl, $lng;
45 $this->ctrl = $ilCtrl;
46 $this->lng = $lng;
47 $this->parent_gui = $parent_gui;
48 $this->bibl_setting = $bibl_setting;
49 if ($bibl_setting->getId() > 0) {
50 $this->action = 'update';
51 } else {
52 $this->action = 'create';
53 }
54 $this->ctrl->saveParameter($parent_gui, 'lib_id');
55 $this->initForm();
56 }
57
58
64 private function initForm() {
65 $this->setFormAction($this->ctrl->getFormAction($this->parent_gui));
66 $name = new ilTextInputGUI($this->lng->txt("bibl_library_name"), 'name');
67 $name->setRequired(true);
68 $name->setValue('');
69 $this->addItem($name);
70 $url = new ilTextInputGUI($this->lng->txt("bibl_library_url"), 'url');
71 $url->setRequired(true);
72 $url->setValue('');
73 $this->addItem($url);
74 $img = new ilTextInputGUI($this->lng->txt("bibl_library_img"), 'img');
75 $img->setValue('');
76 $this->addItem($img);
77 $show_in_list = new ilCheckboxInputGUI($this->lng->txt("bibl_library_show_in_list"), 'show_in_list');
78 $show_in_list->setValue(1);
79 $this->addItem($show_in_list);
80 switch ($this->action) {
81 case 'create':
82 $this->setTitle($this->lng->txt("bibl_settings_new"));
83 $this->addCommandButton('create', $this->lng->txt('save'));
84 break;
85 case 'update':
86 $this->addCommandButton('update', $this->lng->txt('save'));
87 $this->fillForm();
88 $this->setTitle($this->lng->txt("bibl_settings_edit"));
89 break;
90 }
91 $this->addCommandButton('cancel', $this->lng->txt("cancel"));
92 }
93
94
95 private function fillForm() {
96 $this->setValuesByArray(array(
97 'name' => $this->bibl_setting->getName(),
98 'url' => $this->bibl_setting->getUrl(),
99 'img' => $this->bibl_setting->getImg(),
100 'show_in_list' => $this->bibl_setting->getShowInList()
101 ));
102 }
103
104
105 public function saveObject() {
106 if (! $this->checkInput()) {
107 return false;
108 }
109 $this->bibl_setting->setName($this->getInput("name"));
110 $this->bibl_setting->setUrl($this->getInput("url"));
111 $this->bibl_setting->setImg($this->getInput("img"));
112 $this->bibl_setting->setShowInList($this->getInput("show_in_list"));
113 switch ($this->action) {
114 case 'create':
115 $this->bibl_setting->create();
116 break;
117 case 'update':
118 $this->bibl_setting->update();
119 break;
120 }
121
122 return true;
123 }
124}
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).
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.
addCommandButton($a_cmd, $a_text)
Add Command button.
setTitle($a_title)
Set Title.
This class represents a text property in a property form.
global $ilCtrl
Definition: ilias.php:18
$url
Definition: shib_logout.php:72