ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilBiblLibraryGUI.php
Go to the documentation of this file.
1 <?php
2 
9 {
10  const F_LIB_ID = 'lib_id';
11  use \ILIAS\Modules\OrgUnit\ARHelper\DIC;
12  const CMD_DELETE = 'delete';
13  const CMD_EDIT = 'edit';
14  const CMD_INDEX = 'index';
15  const CMD_ADD = 'add';
19  protected $facade;
20 
21 
28  {
29  $this->facade = $facade;
30  }
31 
32 
39  public function executeCommand()
40  {
41  switch ($this->ctrl()->getNextClass()) {
42  case null:
43  $cmd = $this->ctrl()->getCmd(self::CMD_INDEX);
44  $this->{$cmd}();
45  break;
46  }
47  }
48 
49 
55  public function index()
56  {
57  if ($this->checkPermissionBoolAndReturn('write')) {
59  $b->setCaption(self::CMD_ADD);
60  $b->setUrl($this->ctrl()->getLinkTarget($this, self::CMD_ADD));
61  $b->setPrimary(true);
62 
63  $this->toolbar()->addButtonInstance($b);
64  }
65 
66  $a_table = $this->initTable();
67  $this->tpl()->setContent($a_table->getHTML());
68 
69  return true;
70  }
71 
72 
76  protected function initTable()
77  {
78  $table = new ilBiblLibraryTableGUI($this, $this->checkPermissionBoolAndReturn('write'));
79  $settings = $this->facade->libraryFactory()->getAll();
80  $result = array();
81  foreach ($settings as $set) {
82  $result[] = array(
83  "id" => $set->getId(),
84  "name" => $set->getName(),
85  "url" => $set->getUrl(),
86  "img" => $set->getImg(),
87  );
88  }
89  $table->setData($result);
90 
91  return $table;
92  }
93 
94 
98  public function add()
99  {
100  $this->checkPermissionAndFail('write');
101  $form = new ilBiblLibraryFormGUI($this->facade->libraryFactory()->getEmptyInstance());
102  $this->tpl()->setContent($form->getHTML());
103  }
104 
105 
109  public function delete()
110  {
111  $this->checkPermissionAndFail('write');
112  $ilBibliographicSetting = $this->getInstanceFromRequest();
113  $ilBibliographicSetting->delete();
114  $this->ctrl()->redirect($this, self::CMD_INDEX);
115  }
116 
117 
121  public function cancel()
122  {
123  $this->ctrl()->redirect($this, self::CMD_INDEX);
124  }
125 
126 
130  public function update()
131  {
132  $this->checkPermissionAndFail('write');
133  $ilBibliographicSetting = $this->getInstanceFromRequest();
134  $form = new ilBiblLibraryFormGUI($ilBibliographicSetting);
135  $form->setValuesByPost();
136  if ($form->saveObject()) {
137  ilUtil::sendSuccess($this->lng()->txt("settings_saved"), true);
138  $this->ctrl()->redirect($this, self::CMD_INDEX);
139  }
140  $this->tpl()->setContent($form->getHTML());
141  }
142 
143 
147  public function create()
148  {
149  $this->checkPermissionAndFail('write');
150  $form = new ilBiblLibraryFormGUI($this->facade->libraryFactory()->getEmptyInstance());
151  $form->setValuesByPost();
152  if ($form->saveObject()) {
153  ilUtil::sendSuccess($this->lng()->txt("settings_saved"), true);
154  $this->ctrl()->redirect($this, self::CMD_INDEX);
155  }
156  $this->tpl()->setContent($form->getHTML());
157  }
158 
159 
163  public function edit()
164  {
165  $this->checkPermissionAndFail('write');
166  $this->ctrl()->saveParameter($this, self::F_LIB_ID);
167  $ilBibliographicSetting = $this->getInstanceFromRequest();
168  $form = new ilBiblLibraryFormGUI($ilBibliographicSetting);
169  $this->tpl()->setContent($form->getHTML());
170  }
171 
172 
176  private function getInstanceFromRequest()
177  {
178  $ilBibliographicSetting = $this->facade->libraryFactory()
179  ->findById($_REQUEST[self::F_LIB_ID]);
180 
181  return $ilBibliographicSetting;
182  }
183 }
Class ilBiblLibraryGUI.
Interface ilBiblAdminLibraryFacadeInterface.
$result
index()
$ilToolbar ilToolbarGUI;
executeCommand()
Execute command.
__construct(ilBiblAdminLibraryFacadeInterface $facade)
ilBiblLibraryGUI constructor.
Bibliographic Libraries Form.
if(isset($_POST['submit'])) $form
Bibliographic ilBiblLibraryTableGUI.
update()
save changes in library
if(empty($password)) $table
Definition: pwgen.php:24