ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilObjBibliographicGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5require_once "./Services/Object/classes/class.ilObject2GUI.php";
6require_once "./Modules/Bibliographic/classes/class.ilBibliographicDetailsGUI.php";
7require_once("./Services/Export/classes/class.ilExportGUI.php");
8require_once('./Services/News/classes/class.ilNewsItem.php');
9require_once('./Services/PersonalDesktop/interfaces/interface.ilDesktopItemHandling.php');
10require_once("Services/Form/classes/class.ilPropertyFormGUI.php");
11
28
29 const P_ENTRY_ID = 'entry_id';
30 const CMD_SHOW_CONTENT = 'showContent';
31 const CMD_SEND_FILE = "sendFile";
32 const TAB_CONTENT = "content";
33 const CMD_VIEW = "view";
34 const TAB_EXPORT = "export";
35 const TAB_ID_RECORDS = "id_records";
36 const TAB_ID_PERMISSIONS = "id_permissions";
37 const TAB_ID_INFO = "id_info";
38 const CMD_SHOW_DETAILS = "showDetails";
39 const CMD_EDIT = "edit";
43 protected $bibl_obj;
48
49
55 public function __construct($a_id = 0, $a_id_type = self::REPOSITORY_NODE_ID, $a_parent_node_id = 0) {
56 global $DIC;
57 $this->lng = $DIC['lng'];
58 parent::__construct($a_id, $a_id_type, $a_parent_node_id);
59 $this->lng->loadLanguageModule('bibl');
60 if ($a_id > 0) {
61 $this->bibl_obj = $this->object;
62 }
63 }
64
65
71 public function getStandardCmd() {
72 return self::CMD_VIEW;
73 }
74
75
81 public function getType() {
82 return "bibl";
83 }
84
85
89 public function executeCommand() {
90 global $DIC;
91 $ilCtrl = $DIC['ilCtrl'];
92 $ilTabs = $DIC['ilTabs'];
93 $ilNavigationHistory = $DIC['ilNavigationHistory'];
94 $tpl = $DIC['tpl'];
95
96 // Navigation History
97 $link = $ilCtrl->getLinkTarget($this, $this->getStandardCmd());
98 if ($this->object != null) {
99 $ilNavigationHistory->addItem($this->object->getRefId(), $link, "bibl");
100 $this->addHeaderAction();
101 }
102
103 // general Access Check, especially for single entries not matching the object
104 if ($this->object instanceof ilObjBibliographic && !$DIC['ilAccess']->checkAccess('visible', "", $this->object->getRefId())) {
105 $this->handleNonAccess();
106 }
107
108 $next_class = $ilCtrl->getNextClass($this);
109 $this->cmd = $ilCtrl->getCmd();
110 switch ($next_class) {
111 case "ilinfoscreengui":
112 $this->prepareOutput();
113 $ilTabs->activateTab(self::TAB_ID_INFO);
114 $this->infoScreenForward();
115 break;
116 case "ilcommonactiondispatchergui":
117 include_once("Services/Object/classes/class.ilCommonActionDispatcherGUI.php");
119 $this->ctrl->forwardCommand($gui);
120 break;
121 case "ilpermissiongui":
122 $this->prepareOutput();
123 $ilTabs->activateTab(self::TAB_ID_PERMISSIONS);
124 include_once("Services/AccessControl/classes/class.ilPermissionGUI.php");
125 $perm_gui = new ilPermissionGUI($this);
126 $this->ctrl->forwardCommand($perm_gui);
127 break;
128 case "ilobjectcopygui":
129 include_once "./Services/Object/classes/class.ilObjectCopyGUI.php";
130 $cp = new ilObjectCopyGUI($this);
131 $cp->setType('bibl');
132 $tpl->getStandardTemplate();
133 $this->ctrl->forwardCommand($cp);
134 break;
135 case "ilobjfilegui":
136 $this->prepareOutput();
137 $ilTabs->setTabActive(self::TAB_ID_RECORDS);
138 include_once("./Modules/File/classes/class.ilObjFile.php");
139 $file_gui = new ilObjFile($this);
140 $this->ctrl->forwardCommand($file_gui);
141 break;
142 case "ilexportgui":
143 $this->prepareOutput();
144 $ilTabs->setTabActive(self::TAB_EXPORT);
145 $exp_gui = new ilExportGUI($this);
146 $exp_gui->addFormat("xml");
147 $this->ctrl->forwardCommand($exp_gui);
148 break;
149 default:
150 return parent::executeCommand();
151 }
152
153 return true;
154 }
155
156
162 public function infoScreen() {
163 $this->ctrl->setCmd("showSummary");
164 $this->ctrl->setCmdClass("ilinfoscreengui");
165 $this->infoScreenForward();
166 }
167
168
172 public function infoScreenForward() {
173 global $DIC;
174
175 if (!$this->checkPermissionBool("visible")) {
176 ilUtil::sendFailure($DIC['lng']->txt("msg_no_perm_read"), true);
177 $this->ctrl->redirectByClass('ilPersonalDesktopGUI', '');
178 }
179 $DIC['ilTabs']->activateTab(self::TAB_ID_INFO);
180 include_once("./Services/InfoScreen/classes/class.ilInfoScreenGUI.php");
181 $info = new ilInfoScreenGUI($this);
182 $info->enablePrivateNotes();
183 $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
184 $this->ctrl->forwardCommand($info);
185 }
186
187
188 /*
189 * addLocatorItems
190 */
191 public function addLocatorItems() {
192 global $DIC;
193 $ilLocator = $DIC['ilLocator'];
194 if (is_object($this->object)) {
195 $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ""), "", $this->node_id);
196 }
197 }
198
199
206 public static function _goto($a_target) {
207 global $DIC;
208
209 $id = explode("_", $a_target);
210 $DIC['ilCtrl']->setTargetScript("ilias.php");
211 $DIC['ilCtrl']->initBaseClass("ilRepositoryGUI");
212 $DIC['ilCtrl']->setParameterByClass("ilobjbibliographicgui", "ref_id", $id[0]);
213 // Detail-View
214 if ($id[1]) {
215 $DIC['ilCtrl']->setParameterByClass("ilobjbibliographicgui", ilObjBibliographicGUI::P_ENTRY_ID, $id[1]);
216 $DIC['ilCtrl']->redirectByClass(array( "ilRepositoryGUI", "ilobjbibliographicgui" ), self::CMD_SHOW_DETAILS);
217 } else {
218 $DIC['ilCtrl']->redirectByClass(array( "ilRepositoryGUI", "ilobjbibliographicgui" ), self::CMD_VIEW);
219 }
220 }
221
222
228 protected function initCreationForms($a_new_type) {
229 global $DIC;
230 $forms = parent::initCreationForms($a_new_type);
231 // Add File-Upload
232 $in_file = new ilFileInputGUI($this->lng->txt("bibliography file"), "bibliographic_file");
233 $in_file->setSuffixes(array( "ris", "bib", "bibtex" ));
234 $in_file->setRequired(true);
235 $forms[self::CFORM_NEW]->addItem($in_file);
236 $this->ctrl->saveParameterByClass('ilobjrootfoldergui', 'new_type');
237 $forms[self::CFORM_NEW]->setFormAction($this->ctrl->getFormActionByClass('ilobjrootfoldergui', "save"));
238
239 return $forms;
240 }
241
242
243 public function save() {
244 global $DIC;
245 $tpl = $DIC['tpl'];
246 $form = $this->initCreationForms($this->getType());
247 if ($form[self::CFORM_NEW]->checkInput()) {
248 parent::save();
249 } else {
250 $form = $form[self::CFORM_NEW];
251 $form->setValuesByPost();
252 $tpl->setContent($form->getHtml());
253 }
254 }
255
256
260 protected function afterSave(ilObject $a_new_object) {
264 assert($a_new_object instanceof ilObjBibliographic);
265 $a_new_object->doUpdate();
266 $this->addNews($a_new_object->getId(), 'created');
267 $this->ctrl->redirect($this, self::CMD_EDIT);
268 }
269
270
277 public function setTabs() {
278 global $DIC;
279 $ilAccess = $DIC['ilAccess'];
280 $ilTabs = $DIC['ilTabs'];
281 $lng = $DIC['lng'];
282 $ilHelp = $DIC['ilHelp'];
289 $ilHelp->setScreenIdComponent('bibl');
290 // info screen
291 if ($ilAccess->checkAccess('read', "", $this->object->getRefId())) {
292 $ilTabs->addTab(self::TAB_CONTENT, $lng->txt(self::TAB_CONTENT), $this->ctrl->getLinkTarget($this, self::CMD_SHOW_CONTENT));
293 }
294 // info screen
295 if ($ilAccess->checkAccess('visible', "", $this->object->getRefId())) {
296 $ilTabs->addTab(self::TAB_ID_INFO, $lng->txt("info_short"), $this->ctrl->getLinkTargetByClass("ilinfoscreengui", "showSummary"));
297 }
298 // settings
299 if ($ilAccess->checkAccess('write', "", $this->object->getRefId())) {
300 $ilTabs->addTab("settings", $lng->txt("settings"), $this->ctrl->getLinkTarget($this, "editObject"));
301 }
302 // export
303 if ($ilAccess->checkAccess("write", "", $this->object->getRefId())) {
304 $ilTabs->addTab(self::TAB_EXPORT, $lng->txt(self::TAB_EXPORT), $this->ctrl->getLinkTargetByClass("ilexportgui", ""));
305 }
306 // edit permissions
307 if ($ilAccess->checkAccess('edit_permission', "", $this->object->getRefId())) {
308 $ilTabs->addTab(self::TAB_ID_PERMISSIONS, $lng->txt("perm_settings"), $this->ctrl->getLinkTargetByClass("ilpermissiongui", "perm"));
309 }
310 }
311
312
313 public function initEditForm() {
314 global $DIC;
315 $lng = $DIC['lng'];
316 $form = parent::initEditForm();
317 // Add File-Upload
318 $in_file = new ilFileInputGUI($lng->txt("bibliography file"), "bibliographic_file");
319 $in_file->setSuffixes(array( "ris", "bib", "bibtex" ));
320 $in_file->setRequired(false);
321 $cb_override = new ilCheckboxInputGUI($this->lng->txt("override_entries"), "override_entries");
322 $cb_override->addSubItem($in_file);
323 $form->addItem($cb_override);
324 $form->setFormAction($this->ctrl->getFormAction($this, "save"));
325
326 return $form;
327 }
328
329
333 protected function initEditCustomForm(ilPropertyFormGUI $a_form) {
334 global $DIC;
335 $ilTabs = $DIC['ilTabs'];
336 $ilTabs->activateTab("settings");
337 // is_online
338 $cb = new ilCheckboxInputGUI($this->lng->txt("online"), "is_online");
339 $a_form->addItem($cb);
340 }
341
342
348 public function getEditFormCustomValues(array &$a_values) {
349 $a_values["is_online"] = $this->object->getOnline();
350
351 return $a_values;
352 }
353
354
355 public function render() {
356 $this->showContent();
357 }
358
359
363 public function showContent() {
364 global $DIC;
365 $ilAccess = $DIC['ilAccess'];
366 $ilCtrl = $DIC['ilCtrl'];
367 $ilTabs = $DIC['ilTabs'];
368 // if user has read permission and object is online OR user has write permissions
369 if (($ilAccess->checkAccess('read', "", $this->object->getRefId()) && $this->object->getOnline())
370 || $ilAccess->checkAccess('write', "", $this->object->getRefId())
371 ) {
372 $ilTabs->setTabActive(self::TAB_CONTENT);
373
374 // With new UI service, currently not supported by ilToolbar
375 // $f = $DIC->ui()->factory()->button()
376 // ->primary($lng->txt("download_original_file"), $ilCtrl->getLinkTargetByClass("ilBibliographicDetailsGUI", "sendFile"));
377 // $ilToolbar->addText($DIC->ui()->renderer()->render($f));
378
380 $b->setCaption('download_original_file');
381 $b->setUrl($ilCtrl->getLinkTargetByClass("ilBibliographicDetailsGUI", self::CMD_SEND_FILE));
382 $b->setPrimary(true);
383 $DIC['ilToolbar']->addButtonInstance($b);
384
385 include_once "./Modules/Bibliographic/classes/class.ilBibliographicRecordListTableGUI.php";
386 $table = new ilDataBibliographicRecordListTableGUI($this, self::CMD_SHOW_CONTENT);
387 $html = $table->getHTML();
388 $DIC['tpl']->setContent($html);
389
390 //Permanent Link
391 $DIC['tpl']->setPermanentLink("bibl", $this->object->getRefId());
392 } else {
393 //redirect to repository without any parameters
394 $this->handleNonAccess();
395 }
396 }
397
398
402 public function sendFile() {
403 global $DIC;
404
405 if ($DIC['ilAccess']->checkAccess('read', "", $this->object->getRefId())) {
406 $file_path = $this->bibl_obj->getFileAbsolutePath();
407 if ($file_path) {
408 if (is_file($file_path)) {
409 require_once('./Services/FileDelivery/classes/class.ilFileDelivery.php');
410 ilFileDelivery::deliverFileAttached($file_path, null, 'application/octet-stream');
411 } else {
412 ilUtil::sendFailure($DIC['lng']->txt("file_not_found"));
413 $this->showContent();
414 }
415 }
416 } else {
417 $this->handleNonAccess();
418 }
419 }
420
421
422 public function showDetails() {
423 global $DIC;
424
425 if ($DIC['ilAccess']->checkAccess('read', "", $this->object->getRefId())) {
426 $bibGUI = ilBibliographicDetailsGUI::getInstance($this->bibl_obj, $_GET[self::P_ENTRY_ID]);
427 $this->tpl->setContent($bibGUI->getHTML());
428 } else {
429 $this->handleNonAccess();
430 }
431 }
432
433
434 public function view() {
435 $this->showContent();
436 }
437
438
442 public function updateCustom(ilPropertyFormGUI $a_form) {
443 global $DIC;
444 $ilAccess = $DIC['ilAccess'];
445 if ($ilAccess->checkAccess('write', "", $this->object->getRefId())) {
446 if ($this->object->getOnline() != $a_form->getInput("is_online")) {
447 $this->object->setOnline($a_form->getInput("is_online"));
448 }
449
450 if (!empty($_FILES['bibliographic_file']['name'])) {
451 $this->addNews($this->bibl_obj->getId(), 'updated');
452 }
453 } else {
454 $this->handleNonAccess();
455 }
456 }
457
458
459 public function toggleNotification() {
460 global $DIC;
461 $ilCtrl = $DIC['ilCtrl'];
462 $ilUser = $DIC['ilUser'];
463 include_once "./Services/Notification/classes/class.ilNotification.php";
464 switch ($_GET["ntf"]) {
465 case 1:
467 break;
468 case 2:
470 break;
471 }
472 $ilCtrl->redirect($this, "");
473 }
474
475
479 public function addNews($obj_id, $change = 'created') {
480 global $DIC;
481 $lng = $DIC['lng'];
482 $ilUser = $DIC['ilUser'];
483
484 $ilNewsItem = new ilNewsItem();
485 $ilNewsItem->setTitle($lng->txt('news_title_' . $change));
486 $ilNewsItem->setPriority(NEWS_NOTICE);
487 $ilNewsItem->setContext($obj_id, $this->getType());
488 $ilNewsItem->setUserId($ilUser->getId());
489 $ilNewsItem->setVisibility(NEWS_USERS);
490 $ilNewsItem->setContentTextIsLangVar(false);
491 $ilNewsItem->create();
492 }
493
494
500 public function addToDeskObject() {
501 include_once './Services/PersonalDesktop/classes/class.ilDesktopItemGUI.php';
503 ilUtil::sendSuccess($this->lng->txt("added_to_desktop"), true);
504 $this->ctrl->redirect($this, self::CMD_VIEW);
505 }
506
507
513 public function removeFromDeskObject() {
514 include_once './Services/PersonalDesktop/classes/class.ilDesktopItemGUI.php';
516 ilUtil::sendSuccess($this->lng->txt("removed_from_desktop"), true);
517 $this->ctrl->redirect($this, self::CMD_VIEW);
518 }
519
520
526 public function addToDesk() {
527 $this->addToDeskObject();
528 }
529
530
536 public function removeFromDesk() {
537 $this->removeFromDeskObject();
538 }
539
540
544 protected function afterImport(ilObject $a_new_object) {
548 $a_new_object->writeSourcefileEntriesToDb();
549 parent::afterImport($a_new_object); // TODO: Change the autogenerated stub
550 }
551
552
553 private function handleNonAccess() {
554 global $DIC;
555
556 unset($_GET);
557 ilUtil::sendFailure($DIC->language()->txt("no_permission"), true);
559 }
560}
$_GET["client_id"]
An exception for terminatinating execution or to throw for unit testing.
const NEWS_USERS
const NEWS_NOTICE
static getInstance(ilObjBibliographic $bibl_obj, $entry_id)
This class represents a checkbox property in a property form.
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
static addToDesktop()
Add desktop item @access public.
static removeFromDesktop()
Remove item from personal desktop @access public.
Export User Interface Class.
static deliverFileAttached($path_to_file, $download_file_name=null, $mime_type=null, $delete_file=false)
This class represents a file property in a property form.
Class ilInfoScreenGUI.
static getInstance()
Factory.
static setNotification($type, $user_id, $id, $status=true)
Set notification status for object and user.
Class ilObjBibliographicGUI.
initEditCustomForm(ilPropertyFormGUI $a_form)
addNews($obj_id, $change='created')
initEditForm()
Init object edit form.
infoScreen()
this one is called from the info button in the repository not very nice to set cmdClass/Cmd manually,...
static _goto($a_target)
_goto Deep link
__construct($a_id=0, $a_id_type=self::REPOSITORY_NODE_ID, $a_parent_node_id=0)
addLocatorItems()
Functions to be overwritten.
infoScreenForward()
show information screen
removeFromDesk()
Remove from desktop.
sendFile()
provide file as a download
showContent()
shows the overview page with all entries in a table
updateCustom(ilPropertyFormGUI $a_form)
updateSettings
removeFromDeskObject()
Remove from desktop.
view()
view object content (repository/workspace switch)
Class ilObjBibliographic.
Class ilObjFile.
New implementation of ilObjectGUI.
setTabs()
create tabs (repository/workspace switch)
prepareOutput($a_show_subobjects=true)
prepare output
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_node_id=null)
Check permission.
GUI class for the workflow of copying objects.
afterImport(ilObject $a_new_object)
Post (successful) object import hook.
static _gotoRepositoryRoot($a_raise_error=false)
Goto repository root.
afterSave(ilObject $a_new_object)
Post (successful) object creation hook.
addHeaderAction()
Add header action menu.
Class ilObject Basic functions for all objects.
getId()
get object id @access public
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
This class represents a property form user interface.
addItem($a_item)
Add Item (Property, SectionHeader).
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
$html
Definition: example_001.php:87
$info
Definition: example_052.php:80
global $ilCtrl
Definition: ilias.php:18
Interface for gui classes (e.g ilLuceneSearchGUI) that offer add/remove to/from desktop.
global $DIC
$ilUser
Definition: imgupload.php:18