ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 require_once('./Services/Form/classes/class.ilPropertyFormGUI.php');
4 require_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 $DIC;
45  $ilCtrl = $DIC['ilCtrl'];
46  $lng = $DIC['lng'];
47  $this->ctrl = $ilCtrl;
48  $this->lng = $lng;
49  $this->parent_gui = $parent_gui;
50  $this->bibl_setting = $bibl_setting;
51  if ($bibl_setting->getId() > 0) {
52  $this->action = 'update';
53  } else {
54  $this->action = 'create';
55  }
56  $this->ctrl->saveParameter($parent_gui, 'lib_id');
57  $this->initForm();
58  }
59 
60 
66  private function initForm() {
67  $this->setFormAction($this->ctrl->getFormAction($this->parent_gui));
68  $name = new ilTextInputGUI($this->lng->txt("bibl_library_name"), 'name');
69  $name->setRequired(true);
70  $name->setValue('');
71  $this->addItem($name);
72  $url = new ilTextInputGUI($this->lng->txt("bibl_library_url"), 'url');
73  $url->setRequired(true);
74  $url->setValue('');
75  $this->addItem($url);
76  $img = new ilTextInputGUI($this->lng->txt("bibl_library_img"), 'img');
77  $img->setValue('');
78  $this->addItem($img);
79  $show_in_list = new ilCheckboxInputGUI($this->lng->txt("bibl_library_show_in_list"), 'show_in_list');
80  $show_in_list->setValue(1);
81  $this->addItem($show_in_list);
82  switch ($this->action) {
83  case 'create':
84  $this->setTitle($this->lng->txt("bibl_settings_new"));
85  $this->addCommandButton('create', $this->lng->txt('save'));
86  break;
87  case 'update':
88  $this->addCommandButton('update', $this->lng->txt('save'));
89  $this->fillForm();
90  $this->setTitle($this->lng->txt("bibl_settings_edit"));
91  break;
92  }
93  $this->addCommandButton('cancel', $this->lng->txt("cancel"));
94  }
95 
96 
97  private function fillForm() {
98  $this->setValuesByArray(array(
99  'name' => $this->bibl_setting->getName(),
100  'url' => $this->bibl_setting->getUrl(),
101  'img' => $this->bibl_setting->getImg(),
102  'show_in_list' => $this->bibl_setting->getShowInList()
103  ));
104  }
105 
106 
107  public function saveObject() {
108  if (! $this->checkInput()) {
109  return false;
110  }
111  $this->bibl_setting->setName($this->getInput("name"));
112  $this->bibl_setting->setUrl($this->getInput("url"));
113  $this->bibl_setting->setImg($this->getInput("img"));
114  $this->bibl_setting->setShowInList($this->getInput("show_in_list"));
115  switch ($this->action) {
116  case 'create':
117  $this->bibl_setting->create();
118  break;
119  case 'update':
120  $this->bibl_setting->update();
121  break;
122  }
123 
124  return true;
125  }
126 }
This class represents a property form user interface.
This class represents a checkbox property in a property form.
setFormAction($a_formaction)
Set FormAction.
addItem($a_item)
Add Item (Property, SectionHeader).
$url
Definition: shib_logout.php:72
global $ilCtrl
Definition: ilias.php:18
setTitle($a_title)
Set Title.
setValue($a_value)
Set Value.
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.
Create styles array
The data for the language used.
global $DIC
setValuesByArray($a_values, $a_restrict_to_value_keys=false)
Set form values from an array.
setRequired($a_required)
Set Required.