ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
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 
22 {
23  use \ILIAS\Modules\OrgUnit\ARHelper\DIC;
24  const P_ENTRY_ID = 'entry_id';
25  const CMD_SHOW_CONTENT = 'showContent';
26  const CMD_SEND_FILE = "sendFile";
27  const TAB_CONTENT = "content";
28  const SUB_TAB_FILTER = "filter";
29  const CMD_VIEW = "view";
30  const TAB_EXPORT = "export";
31  const TAB_SETTINGS = self::SUBTAB_SETTINGS;
32  const TAB_ID_RECORDS = "id_records";
33  const TAB_ID_PERMISSIONS = "id_permissions";
34  const TAB_ID_INFO = "id_info";
35  const CMD_SHOW_DETAILS = "showDetails";
36  const CMD_EDIT = "edit";
37  const SUBTAB_SETTINGS = "settings";
38  const CMD_EDIT_OBJECT = 'editObject';
39  const CMD_UPDATE_OBJECT = 'updateObject';
43  public $object;
47  protected $facade;
55  protected $field_factory;
59  protected $filter_factory;
63  protected $type_factory;
67  protected $cmd = self::CMD_SHOW_CONTENT;
68 
69 
75  public function __construct($a_id = 0, $a_id_type = self::REPOSITORY_NODE_ID, $a_parent_node_id = 0)
76  {
77  global $DIC;
78 
79  parent::__construct($a_id, $a_id_type, $a_parent_node_id);
80  $DIC->language()->loadLanguageModule('bibl');
81  $DIC->language()->loadLanguageModule('content');
82  $DIC->language()->loadLanguageModule('obj');
83  $DIC->language()->loadLanguageModule('cntr');
84 
85  if (is_object($this->object)) {
86  $this->facade = new ilBiblFactoryFacade($this->object);
87  }
88  }
89 
90 
96  public function getStandardCmd()
97  {
98  return self::CMD_VIEW;
99  }
100 
101 
109  public function getType()
110  {
111  return "bibl";
112  }
113 
114 
118  public function executeCommand()
119  {
120  global $DIC;
121  $ilNavigationHistory = $DIC['ilNavigationHistory'];
122 
123  // Navigation History
124  $link = $this->dic()->ctrl()->getLinkTarget($this, $this->getStandardCmd());
125  if ($this->object != null) {
126  $ilNavigationHistory->addItem($this->object->getRefId(), $link, "bibl");
127  $this->addHeaderAction();
128  }
129 
130  // general Access Check, especially for single entries not matching the object
131  if ($this->object instanceof ilObjBibliographic && !$DIC->access()->checkAccess('read', "", $this->object->getRefId())) {
132  $this->handleNonAccess();
133  }
134 
135  $next_class = $this->dic()->ctrl()->getNextClass($this);
136  $this->cmd = $this->dic()->ctrl()->getCmd();
137  switch ($next_class) {
138  case strtolower(ilInfoScreenGUI::class):
139  $this->prepareOutput();
140  $this->dic()->tabs()->activateTab(self::TAB_ID_INFO);
141  $this->infoScreenForward();
142  break;
143  case strtolower(ilCommonActionDispatcherGUI::class):
144  $this->prepareOutput();
146  $this->ctrl->forwardCommand($gui);
147  break;
148  case strtolower(ilPermissionGUI::class):
149  $this->prepareOutput();
150  $this->dic()->tabs()->activateTab(self::TAB_ID_PERMISSIONS);
151  $this->ctrl->forwardCommand(new ilPermissionGUI($this));
152  break;
153  case strtolower(ilObjectCopyGUI::class):
154  $cp = new ilObjectCopyGUI($this);
155  $cp->setType('bibl');
156  $this->dic()['tpl']->loadStandardTemplate();
157  $this->ctrl->forwardCommand($cp);
158  break;
159  case strtolower(ilObjFileGUI::class):
160  $this->prepareOutput();
161  $this->dic()->tabs()->setTabActive(self::TAB_ID_RECORDS);
162  $this->ctrl->forwardCommand(new ilObjFile($this));
163  break;
164  case strtolower(ilExportGUI::class):
165  $this->prepareOutput();
166  $this->dic()->tabs()->setTabActive(self::TAB_EXPORT);
167  $exp_gui = new ilExportGUI($this);
168  $exp_gui->addFormat("xml");
169  $this->ctrl->forwardCommand($exp_gui);
170  break;
171  case strtolower(ilBiblFieldFilterGUI::class):
172  $this->prepareOutput();
173  $this->dic()->tabs()->setTabActive(self::TAB_SETTINGS);
174  $this->initSubTabs();
175  $this->tabs_gui->activateSubTab(self::SUB_TAB_FILTER);
176  $this->ctrl->forwardCommand(new ilBiblFieldFilterGUI($this->facade));
177  break;
178  default:
179  $this->prepareOutput();
180  $cmd = $this->ctrl->getCmd(self::CMD_SHOW_CONTENT);
181  switch ($cmd) {
182  case 'edit':
183  case 'update':
184  case self::CMD_EDIT_OBJECT:
185  case self::CMD_UPDATE_OBJECT:
186  $this->initSubTabs();
187  $this->tabs_gui->activateSubTab(self::SUBTAB_SETTINGS);
188  $this->{$cmd}();
189  break;
190  default:
191  $this->{$cmd}();
192  break;
193  }
194  break;
195  }
196 
197  return true;
198  }
199 
200 
206  public function infoScreen()
207  {
208  $this->ctrl->setCmd("showSummary");
209  $this->ctrl->setCmdClass(ilInfoScreenGUI::class);
210  $this->infoScreenForward();
211  }
212 
213 
217  public function infoScreenForward()
218  {
219  global $DIC;
220 
221  if (!$this->checkPermissionBoolAndReturn("visible") && !$this->checkPermissionBoolAndReturn('read')) {
222  ilUtil::sendFailure($DIC['lng']->txt("msg_no_perm_read"), true);
223  $this->ctrl->redirectByClass('ilDashboardGUI', '');
224  }
225  $DIC->tabs()->activateTab(self::TAB_ID_INFO);
226  $info = new ilInfoScreenGUI($this);
227  $info->enablePrivateNotes();
228  $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
229  $this->ctrl->forwardCommand($info);
230  }
231 
232 
233  /*
234  * addLocatorItems
235  */
236  public function addLocatorItems()
237  {
238  global $DIC;
239  $ilLocator = $DIC['ilLocator'];
240  if (is_object($this->object)) {
241  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ""), "", $this->node_id);
242  }
243  }
244 
245 
252  public static function _goto($a_target)
253  {
254  global $DIC;
255 
256  $id = explode("_", $a_target);
257  $DIC->ctrl()->initBaseClass(ilRepositoryGUI::class);
258  $DIC->ctrl()->setParameterByClass(ilObjBibliographicGUI::class, "ref_id", $id[0]);
259  // Detail-View
260  if ($id[1]) {
261  $DIC->ctrl()
262  ->setParameterByClass(ilObjBibliographicGUI::class, ilObjBibliographicGUI::P_ENTRY_ID, $id[1]);
263  $DIC->ctrl()->redirectByClass(
264  array(
265  ilRepositoryGUI::class,
266  ilObjBibliographicGUI::class,
267  ),
268  self::CMD_SHOW_DETAILS
269  );
270  } else {
271  $DIC->ctrl()->redirectByClass(
272  array(
273  ilRepositoryGUI::class,
274  ilObjBibliographicGUI::class,
275  ),
276  self::CMD_VIEW
277  );
278  }
279  }
280 
281 
287  protected function initCreationForms($a_new_type)
288  {
289  global $DIC;
290 
291  $forms = parent::initCreationForms($a_new_type);
292  // Add File-Upload
293  $in_file = new ilFileInputGUI($DIC->language()->txt("bibliography_file"), "bibliographic_file");
294  $in_file->setSuffixes(array("ris", "bib", "bibtex"));
295  $in_file->setRequired(true);
296  $forms[self::CFORM_NEW]->addItem($in_file);
297  $this->ctrl->saveParameterByClass('ilobjrootfoldergui', 'new_type');
298  $forms[self::CFORM_NEW]->setFormAction($this->ctrl->getFormActionByClass('ilobjrootfoldergui', "save"));
299 
300  return $forms;
301  }
302 
303 
304  public function save()
305  {
306  global $DIC;
307 
308  $form = $this->initCreationForms($this->getType());
309  if ($form[self::CFORM_NEW]->checkInput()) {
310  parent::save();
311  } else {
312  $form = $form[self::CFORM_NEW];
313  $form->setValuesByPost();
314  $DIC->ui()->mainTemplate()->setContent($form->getHtml());
315  }
316  }
317 
318 
322  protected function afterSave(ilObject $a_new_object)
323  {
327  assert($a_new_object instanceof ilObjBibliographic);
328  $a_new_object->doUpdate();
329  $this->addNews($a_new_object->getId(), 'created');
330  $this->ctrl->redirect($this, self::CMD_EDIT);
331  }
332 
333 
340  public function setTabs()
341  {
342  global $DIC;
343 
344  $ilHelp = $DIC['ilHelp'];
348  $ilHelp->setScreenIdComponent('bibl');
349  // info screen
350  if ($DIC->access()->checkAccess('read', "", $this->object->getRefId())) {
351  $DIC->tabs()->addTab(
352  self::TAB_CONTENT,
353  $DIC->language()
354  ->txt(self::TAB_CONTENT),
355  $this->ctrl->getLinkTarget($this, self::CMD_SHOW_CONTENT)
356  );
357  }
358  // info screen
359  if ($DIC->access()->checkAccess('visible', "", $this->object->getRefId())
360  || $DIC->access()->checkAccess('read', "", $this->object->getRefId())
361  ) {
362  $DIC->tabs()->addTab(
363  self::TAB_ID_INFO,
364  $DIC->language()
365  ->txt("info_short"),
366  $this->ctrl->getLinkTargetByClass("ilinfoscreengui", "showSummary")
367  );
368  }
369  // settings
370  if ($DIC->access()->checkAccess('write', "", $this->object->getRefId())) {
371  $DIC->tabs()->addTab(
372  self::SUBTAB_SETTINGS,
373  $DIC->language()
374  ->txt(self::SUBTAB_SETTINGS),
375  $this->ctrl->getLinkTarget($this, self::CMD_EDIT_OBJECT)
376  );
377  }
378  // export
379  if ($DIC->access()->checkAccess("write", "", $this->object->getRefId())) {
380  $DIC->tabs()->addTab(
381  self::TAB_EXPORT,
382  $DIC->language()
383  ->txt(self::TAB_EXPORT),
384  $this->ctrl->getLinkTargetByClass("ilexportgui", "")
385  );
386  }
387  // edit permissions
388  if ($DIC->access()->checkAccess('edit_permission', "", $this->object->getRefId())) {
389  $DIC->tabs()->addTab(
390  self::TAB_ID_PERMISSIONS,
391  $DIC->language()
392  ->txt("perm_settings"),
393  $this->ctrl->getLinkTargetByClass("ilpermissiongui", "perm")
394  );
395  }
396  }
397 
398 
399  protected function initSubTabs()
400  {
401  global $DIC;
402  $DIC->tabs()->addSubTab(
403  self::SUBTAB_SETTINGS,
404  $DIC->language()
405  ->txt(self::SUBTAB_SETTINGS),
406  $this->ctrl->getLinkTarget($this, self::CMD_EDIT_OBJECT)
407  );
408  $DIC->tabs()->addSubTab(
409  self::SUB_TAB_FILTER,
410  $DIC->language()
411  ->txt("bibl_filter"),
412  $this->ctrl->getLinkTargetByClass(ilBiblFieldFilterGUI::class, ilBiblFieldFilterGUI::CMD_STANDARD)
413  );
414  }
415 
416 
422  public function editObject()
423  {
424  $tpl = $this->tpl;
425  $ilTabs = $this->tabs_gui;
427 
428  if (!$this->checkPermissionBool("write")) {
429  $ilErr->raiseError($this->lng->txt("msg_no_perm_write"), $ilErr->MESSAGE);
430  }
431 
432  $ilTabs->activateTab("settings");
433 
434  $form = $this->initEditForm();
435  $values = $this->getEditFormValues();
436  if ($values) {
437  $form->setValuesByArray($values, true);
438  }
439 
440  $this->addExternalEditFormCustom($form);
441 
442  $tpl->setContent($form->getHTML());
443  }
444 
445 
446  public function initEditForm()
447  {
448  global $DIC;
449 
450  $form = parent::initEditForm();
451  // Add File-Upload
452  $in_file = new ilFileInputGUI(
453  $DIC->language()
454  ->txt("bibliography_file"),
455  "bibliographic_file"
456  );
457  $in_file->setSuffixes(array("ris", "bib", "bibtex"));
458  $in_file->setRequired(false);
459  $cb_override = new ilCheckboxInputGUI(
460  $DIC->language()
461  ->txt("override_entries"),
462  "override_entries"
463  );
464  $cb_override->addSubItem($in_file);
465 
466  $form->addItem($cb_override);
467 
468  $section_appearance = new ilFormSectionHeaderGUI();
469  $section_appearance->setTitle($this->lng->txt('cont_presentation'));
470  $form->addItem($section_appearance);
471  $DIC->object()->commonSettings()->legacyForm($form, $this->object)->addTileImage();
472 
473  $form->setFormAction($DIC->ctrl()->getFormAction($this, "save"));
474 
475  return $form;
476  }
477 
478 
482  protected function initEditCustomForm(ilPropertyFormGUI $a_form)
483  {
484  global $DIC;
485 
486  $DIC->tabs()->activateTab(self::SUBTAB_SETTINGS);
487  // is_online
488  $cb = new ilCheckboxInputGUI($DIC->language()->txt("online"), "is_online");
489  $a_form->addItem($cb);
490  }
491 
492 
498  public function getEditFormCustomValues(array &$a_values)
499  {
500  $a_values["is_online"] = $this->object->getOnline();
501 
502  return $a_values;
503  }
504 
505 
506  public function render()
507  {
508  $this->showContent();
509  }
510 
511 
515  public function showContent()
516  {
517  global $DIC;
518 
519  // if user has read permission and object is online OR user has write permissions
520  $read_access = $DIC->access()->checkAccess('read', "", $this->object->getRefId());
521  $online = $this->object->getOnline();
522  $write_access = $DIC->access()->checkAccess('write', "", $this->object->getRefId());
523  if (($read_access && $online) || $write_access) {
524  $DIC->tabs()->activateTab(self::TAB_CONTENT);
525 
527  $b->setCaption('download_original_file');
528  $b->setUrl($DIC->ctrl()->getLinkTargetByClass(self::class, self::CMD_SEND_FILE));
529  $b->setPrimary(true);
530  $DIC->toolbar()->addButtonInstance($b);
531 
532  $table = new ilBiblEntryTableGUI($this, $this->facade);
533  $html = $table->getHTML();
534  $DIC->ui()->mainTemplate()->setContent($html);
535 
536  //Permanent Link
537  $DIC->ui()->mainTemplate()->setPermanentLink("bibl", $this->object->getRefId());
538  } else {
539  $object_title = ilObject::_lookupTitle(ilObject::_lookupObjId($_GET["ref_id"]));
541  sprintf(
542  $DIC->language()
543  ->txt("msg_no_perm_read_item"),
544  $object_title
545  ),
546  true
547  );
548  //redirect to repository without any parameters
549  $this->handleNonAccess();
550  }
551  }
552 
553 
554  protected function applyFilter()
555  {
556  $table = new ilBiblEntryTableGUI($this, $this->facade);
557  $table->writeFilterToSession();
558  $table->resetOffset();
559  $this->ctrl->redirect($this, self::CMD_SHOW_CONTENT);
560  }
561 
562 
563  protected function resetFilter()
564  {
565  $table = new ilBiblEntryTableGUI($this, $this->facade);
566  $table->resetFilter();
567  $table->resetOffset();
568  $this->ctrl->redirect($this, self::CMD_SHOW_CONTENT);
569  }
570 
571 
575  public function sendFile()
576  {
577  global $DIC;
578 
579  if ($DIC['ilAccess']->checkAccess('read', "", $this->object->getRefId())) {
580  $file_path = $this->object->getLegacyAbsolutePath();
581  if ($file_path) {
582  if (is_file($file_path)) {
583  ilFileDelivery::deliverFileAttached($file_path, $this->object->getFilename(), 'application/octet-stream');
584  } else {
585  ilUtil::sendFailure($DIC['lng']->txt("file_not_found"));
586  $this->showContent();
587  }
588  }
589  } else {
590  $this->handleNonAccess();
591  }
592  }
593 
594 
595  public function showDetails()
596  {
597  global $DIC;
598 
599  if ($DIC->access()->checkAccess('read', "", $this->object->getRefId())) {
600  $id = $DIC->http()->request()->getQueryParams()[self::P_ENTRY_ID];
601  $entry = $this->facade->entryFactory()
602  ->findByIdAndTypeString($id, $this->object->getFileTypeAsString());
603  $bibGUI = new ilBiblEntryDetailPresentationGUI($entry, $this->facade);
604 
605  $DIC->ui()->mainTemplate()->setContent($bibGUI->getHTML());
606  } else {
607  $this->handleNonAccess();
608  }
609  }
610 
611 
612  public function view()
613  {
614  $this->showContent();
615  }
616 
617 
621  public function updateCustom(ilPropertyFormGUI $a_form)
622  {
623  global $DIC;
624 
625  if ($DIC->access()->checkAccess('write', "", $this->object->getRefId())) {
626  if ($this->object->getOnline() != $a_form->getInput("is_online")) {
627  $this->object->setOnline($a_form->getInput("is_online"));
628  }
629 
630  if (!empty($_FILES['bibliographic_file']['name'])) {
631  $this->addNews($this->object->getId(), 'updated');
632  }
633 
634  $DIC->object()->commonSettings()->legacyForm($a_form, $this->object)->saveTileImage();
635  } else {
636  $this->handleNonAccess();
637  }
638  }
639 
640 
641  public function toggleNotification()
642  {
643  global $DIC;
644 
645  switch ($_GET["ntf"]) {
646  case 1:
649  $DIC->user()
650  ->getId(),
652  false
653  );
654  break;
655  case 2:
658  $DIC->user()
659  ->getId(),
661  true
662  );
663  break;
664  }
665  $DIC->ctrl()->redirect($this, "");
666  }
667 
668 
672  public function addNews($obj_id, $change = 'created')
673  {
674  global $DIC;
675 
676  $ilNewsItem = new ilNewsItem();
677  $ilNewsItem->setTitle($DIC->language()->txt('news_title_' . $change));
678  $ilNewsItem->setPriority(NEWS_NOTICE);
679  $ilNewsItem->setContext($obj_id, $this->getType());
680  $ilNewsItem->setUserId($DIC->user()->getId());
681  $ilNewsItem->setVisibility(NEWS_USERS);
682  $ilNewsItem->setContentTextIsLangVar(false);
683  $ilNewsItem->create();
684  }
685 
686 
687 
693  public function addToDesk()
694  {
695  $this->addToDeskObject();
696  }
697 
698 
704  public function removeFromDesk()
705  {
706  $this->removeFromDeskObject();
707  }
708 
709 
713  protected function afterImport(ilObject $a_new_object)
714  {
718  $a_new_object->parseFileToDatabase();
719 
720  parent::afterImport($a_new_object);
721  }
722 
723 
724  private function handleNonAccess()
725  {
726  global $DIC;
727 
728  unset($_GET);
729  ilUtil::sendFailure($DIC->language()->txt("no_permission"), true);
731  }
732 }
infoScreenForward()
show information screen
Class ilObjBibliographicGUI.
Class ilInfoScreenGUI.
removeFromDesk()
Remove from desktop.
This class represents a property form user interface.
checkPermissionBool($a_perm, $a_cmd="", $a_type="", $a_node_id=null)
Check permission.
New implementation of ilObjectGUI.
GUI class for the workflow of copying objects.
$_GET["client_id"]
This class represents a section header in a property form.
This class represents a file property in a property form.
updateCustom(ilPropertyFormGUI $a_form)
updateSettings
static _gotoRepositoryRoot($a_raise_error=false)
Goto repository root.
This class represents a checkbox property in a property form.
static _lookupTitle($a_id)
lookup object title
addItem($a_item)
Add Item (Property, SectionHeader).
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
afterSave(ilObject $a_new_object)
Post (successful) object creation hook.
sendFile()
provide file as a download
addExternalEditFormCustom(ilPropertyFormGUI $a_form)
Export User Interface Class.
static deliverFileAttached($path_to_file, $download_file_name='', $mime_type='', $delete_file=false)
void
getId()
get object id public
Class ilBiblFieldFilterGUI.
static _lookupObjId($a_id)
const NEWS_NOTICE
global $DIC
Definition: goto.php:24
static setNotification($type, $user_id, $id, $status=true)
Set notification status for object and user.
__construct($a_id=0, $a_id_type=self::REPOSITORY_NODE_ID, $a_parent_node_id=0)
getInput($a_post_var, $ensureValidation=true)
Returns the value of a HTTP-POST variable, identified by the passed id.
removeFromDeskObject()
Remove from desktop public.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
setTabs()
create tabs (repository/workspace switch)
addNews($obj_id, $change='created')
getEditFormValues()
Get values for edit form.
initEditCustomForm(ilPropertyFormGUI $a_form)
Interface for gui classes (e.g ilLuceneSearchGUI) that offer add/remove to/from desktop.
__construct(Container $dic, ilPlugin $plugin)
showContent()
shows the overview page with all entries in a table
addToDeskObject()
Add desktop item public.
prepareOutput($a_show_subobjects=true)
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
const NEWS_USERS
Class ilObjBibliographic.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilBiblFactoryFacade.
addHeaderAction()
Add header action menu.
setSuffixes($a_suffixes)
Set Accepted Suffixes.
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
afterImport(ilObject $a_new_object)
Post (successful) object import hook.
static _goto($a_target)
_goto Deep link
infoScreen()
this one is called from the info button in the repository not very nice to set cmdClass/Cmd manually...