ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilObjBibliographicAdminLibrariesGUI.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/Object/classes/class.ilObjectGUI.php");
4 require_once("./Modules/Bibliographic/classes/Admin/class.ilObjBibliographicAdminLibrariesFormGUI.php");
5 require_once("./Modules/Bibliographic/classes/Admin/class.ilObjBibliographicAdminTableGUI.php");
6 require_once("./Modules/Bibliographic/classes/Admin/class.ilBibliographicSetting.php");
7 require_once("./Services/UIComponent/Button/classes/class.ilLinkButton.php");
8 
18 
22  protected $parent_gui;
26  protected $ctrl;
30  protected $lng;
31 
32 
38  public function __construct($parent_gui) {
39  global $lng, $ilCtrl;
40  $this->lng = $lng;
41  $this->ctrl = $ilCtrl;
42  $this->parent_gui = $parent_gui;
43  }
44 
45 
52  public function executeCommand() {
53  global $ilCtrl;
54  $cmd = $ilCtrl->getCmd();
55  switch ($cmd) {
56  case 'view':
57  $this->view();
58  break;
59  case 'add':
60  $this->add();
61  break;
62  case 'edit':
63  $this->edit();
64  break;
65  case 'delete':
66  $this->delete();
67  break;
68  case 'create':
69  $this->create();
70  break;
71  case 'update':
72  $this->update();
73  break;
74  case 'cancel':
75  $this->cancel();
76  break;
77  }
78  }
79 
80 
86  public function view() {
87  global $ilToolbar;
92  $b->setCaption('add');
93  $b->setUrl($this->ctrl->getLinkTarget($this, 'add'));
94  $b->setPrimary(true);
95  $ilToolbar->addButtonInstance($b);
96  $a_table = $this->initTable();
97  $this->parent_gui->tpl->setContent($a_table->getHTML());
98 
99  return true;
100  }
101 
102 
109  protected function initTable() {
110  $table = new ilObjBibliographicAdminTableGUI($this, 'library');
111  $settings = ilBibliographicSetting::getAll();
112  $result = array();
113  foreach ($settings as $set) {
114  $result[] = array(
115  "id" => $set->getId(),
116  "name" => $set->getName(),
117  "url" => $set->getUrl(),
118  "img" => $set->getImg()
119  );
120  }
121  $table->setData($result);
122 
123  return $table;
124  }
125 
126 
130  public function add() {
132  $this->parent_gui->tpl->setContent($form->getHTML());
133  $this->parent_gui->tabs_gui->setTabActive('settings');
134  }
135 
136 
140  public function delete() {
141  global $ilDB;
142  $ilDB->manipulate("DELETE FROM il_bibl_settings WHERE id = " . $ilDB->quote($_REQUEST["lib_id"], "integer"));
143  $this->ctrl->redirect($this, 'view');
144  }
145 
146 
150  public function cancel() {
151  $this->ctrl->redirect($this, 'view');
152  }
153 
154 
158  public function update() {
160  $form->setValuesByPost();
161  if ($form->saveObject()) {
162  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
163  $this->ctrl->redirect($this, 'view');
164  }
165  $this->parent_gui->tpl->setContent($form->getHTML());
166  }
167 
168 
172  public function create() {
174  $form->setValuesByPost();
175  if ($form->saveObject()) {
176  ilUtil::sendSuccess($this->lng->txt("settings_saved"), true);
177  $this->ctrl->redirect($this, 'view');
178  }
179  $this->parent_gui->tpl->setContent($form->getHTML());
180  }
181 
182 
186  public function edit() {
187  $this->ctrl->saveParameter($this, 'lib_id');
189  $this->parent_gui->tpl->setContent($form->getHTML());
190  }
191 }
192 
193 ?>