ILIAS  trunk Revision v11.0_alpha-1713-gd8962da2f67
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
class.ilObjBibliographicGUI.php
Go to the documentation of this file.
1 <?php
2 
24 
41 {
42  use DIC;
43 
44  public const P_ENTRY_ID = 'entry_id';
45  public const CMD_SHOW_CONTENT = 'showContent';
46  public const CMD_SEND_FILE = "sendFile";
47  public const TAB_CONTENT = "content";
48  public const SUB_TAB_FILTER = "filter";
49  public const CMD_VIEW = "view";
50  public const TAB_EXPORT = "export";
51  public const TAB_SETTINGS = self::SUBTAB_SETTINGS;
52  public const TAB_ID_RECORDS = "id_records";
53  public const TAB_ID_PERMISSIONS = "id_permissions";
54  public const TAB_ID_INFO = "id_info";
55  public const CMD_SHOW_DETAILS = "showDetails";
56  public const SUBTAB_SETTINGS = "settings";
57  public const CMD_EDIT_OBJECT = 'editObject';
58  public const CMD_UPDATE_OBJECT = "updateObject";
59  public const CMD_SETTINGS = "settings";
60  public const CMD_OVERWRITE_BIBLIOGRAPHIC_FILE = "overwriteBibliographicFile";
61  public const CMD_REPLACE_BIBLIOGRAPHIC_FILE = "replaceBibliographicFile";
62  public const SECTION_REPLACE_BIBLIOGRAPHIC_FILE = 'section_replace_bibliographic_file';
63  public const PROP_BIBLIOGRAPHIC_FILE = "bibliographic_file";
64  public const SECTION_EDIT_BIBLIOGRAPHY = 'section_edit_bibliography';
65  public const PROP_TITLE_AND_DESC = 'title_and_desc';
66  public const SECTION_AVAILABILITY = 'section_availability';
67  public const PROP_ONLINE_STATUS = 'online_status';
68  public const SECTION_PRESENTATION = 'section_presentation';
69  public const PROP_TILE_IMAGE = 'tile_image';
70 
71  public ?ilObject $object = null;
73  protected \ilBiblTranslationFactory $translation_factory;
74  protected \ilBiblFieldFactory $field_factory;
75  protected \ilBiblFieldFilterFactory $filter_factory;
76  protected \ilBiblTypeFactory $type_factory;
77 
78  protected ilHelpGUI $help;
79  protected Services $storage;
80  protected \ilObjBibliographicStakeholder $stakeholder;
81  protected \ILIAS\HTTP\Services $http;
82  protected Factory $ui_factory;
83  protected \ILIAS\Refinery\Factory $refinery;
84  protected ?string $cmd = self::CMD_SHOW_CONTENT;
85 
86  public function __construct(int $a_id = 0, int $a_id_type = self::REPOSITORY_NODE_ID, int $a_parent_node_id = 0)
87  {
88  global $DIC;
89 
90  $this->help = $DIC['ilHelp'];
91  $this->storage = $DIC['resource_storage'];
92  $this->stakeholder = new ilObjBibliographicStakeholder();
93  $this->http = $DIC->http();
94  $this->ui_factory = $DIC->ui()->factory();
95  $this->refinery = $DIC->refinery();
96 
97  parent::__construct($a_id, $a_id_type, $a_parent_node_id);
98  $DIC->language()->loadLanguageModule('bibl');
99  $DIC->language()->loadLanguageModule('content');
100  $DIC->language()->loadLanguageModule('obj');
101  $DIC->language()->loadLanguageModule('cntr');
102 
103  if ($this->object instanceof ilObjBibliographic) {
105  $obj = $this->object;
106  $this->facade = new ilBiblFactoryFacade($obj);
107  }
108  }
109 
113  public function getStandardCmd(): string
114  {
115  return self::CMD_VIEW;
116  }
117 
122  public function getType(): string
123  {
124  return "bibl";
125  }
126 
130  #[\Override]
131  public function executeCommand(): void
132  {
133  global $DIC;
134  $ilNavigationHistory = $DIC['ilNavigationHistory'];
135 
136  // Navigation History
137  $link = $this->dic()->ctrl()->getLinkTarget($this, $this->getStandardCmd());
138  if ($this->object != null) {
139  $ilNavigationHistory->addItem($this->object->getRefId(), $link, "bibl");
140  $this->addHeaderAction();
141  }
142 
143  // general Access Check, especially for single entries not matching the object
144  if ($this->object instanceof ilObjBibliographic && !$DIC->access()->checkAccess(
145  'read',
146  "",
147  $this->object->getRefId()
148  )) {
149  $this->handleNonAccess();
150  }
151 
152  $next_class = $this->dic()->ctrl()->getNextClass($this);
153  $this->cmd = $this->dic()->ctrl()->getCmd();
154  switch ($next_class) {
155  case strtolower(ilInfoScreenGUI::class):
156  $this->prepareOutput();
157  $this->dic()->tabs()->activateTab(self::TAB_ID_INFO);
158  $this->infoScreenForward();
159  break;
160  case strtolower(ilCommonActionDispatcherGUI::class):
161  $this->prepareOutput();
163  $this->ctrl->forwardCommand($gui);
164  break;
165  case strtolower(ilPermissionGUI::class):
166  $this->prepareOutput();
167  $this->dic()->tabs()->activateTab(self::TAB_ID_PERMISSIONS);
168  $this->ctrl->forwardCommand(new ilPermissionGUI($this));
169  break;
170  case strtolower(ilObjectCopyGUI::class):
171  $cp = new ilObjectCopyGUI($this);
172  $cp->setType('bibl');
173  $this->dic()['tpl']->loadStandardTemplate();
174  $this->ctrl->forwardCommand($cp);
175  break;
176  case strtolower(ilExportGUI::class):
177  $this->prepareOutput();
178  $this->dic()->tabs()->setTabActive(self::TAB_EXPORT);
179  $exp_gui = new ilExportGUI($this);
180  $exp_gui->addFormat();
181  $this->ctrl->forwardCommand($exp_gui);
182  break;
183  case strtolower(ilBiblFieldFilterGUI::class):
184  $this->prepareOutput();
185  $this->dic()->tabs()->setTabActive(self::TAB_SETTINGS);
186  $this->initSubTabs();
187  $this->tabs_gui->activateSubTab(self::SUB_TAB_FILTER);
188  $this->ctrl->forwardCommand(new ilBiblFieldFilterGUI($this->facade));
189  break;
190  case strtolower(ilObjBibliographicUploadHandlerGUI::class):
191  $rid = "";
192  if ($this->object && $this->object->getResourceId()) {
193  $rid = $this->object->getResourceId()->serialize();
194  }
195  $this->ctrl->forwardCommand(new ilObjBibliographicUploadHandlerGUI($rid));
196  break;
197  default:
198  $this->prepareOutput();
199  $cmd = $this->ctrl->getCmd(self::CMD_SHOW_CONTENT);
200  switch ($cmd) {
201  case self::CMD_SETTINGS:
202  case self::CMD_EDIT_OBJECT:
203  case self::CMD_UPDATE_OBJECT:
204  $this->initSubTabs();
205  $this->tabs_gui->activateSubTab(self::SUBTAB_SETTINGS);
206  $this->{$cmd}();
207  break;
208  default:
209  $this->{$cmd}();
210  break;
211  }
212  break;
213  }
214  }
215 
221  public function infoScreen(): void
222  {
223  // @todo: removed deprecated ilCtrl methods, this needs inspection by a maintainer.
224  // $this->ctrl->setCmd("showSummary");
225  // $this->ctrl->setCmdClass(ilInfoScreenGUI::class);
226  $this->infoScreenForward();
227  }
228 
232  public function infoScreenForward(): void
233  {
234  global $DIC;
239  if (!$this->checkPermissionBoolAndReturn("visible") && !$this->checkPermissionBoolAndReturn('read')) {
240  $this->tpl->setOnScreenMessage('failure', $DIC['lng']->txt("msg_no_perm_read"), true);
241  $this->ctrl->redirectByClass('ilDashboardGUI', '');
242  }
243  $DIC->tabs()->activateTab(self::TAB_ID_INFO);
244  $info = new ilInfoScreenGUI($this);
245 
246  $info->enablePrivateNotes();
247  $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
248 
249  // Storage Info
250  $irss = new ilResourceStorageInfoGUI($this->object->getResourceId());
251  $irss->append($info);
252 
253  $this->ctrl->forwardCommand($info);
254  }
255 
256  /*
257  * addLocatorItems
258  */
259  public function addLocatorItems(): void
260  {
261  global $DIC;
262  $ilLocator = $DIC['ilLocator'];
263  if (is_object($this->object)) {
264  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ""), "", $this->node_id);
265  }
266  }
267 
272  public static function _goto(string $a_target): void
273  {
274  global $DIC;
275 
276  $id = explode("_", $a_target);
277  $DIC->ctrl()->setTargetScript('ilias.php');
278  $DIC->ctrl()->setParameterByClass(ilObjBibliographicGUI::class, "ref_id", (int) ($id[0] ?? 1));
279  // Detail-View
280  if (isset($id[1]) && $id[1] !== '') {
281  $DIC->ctrl()
282  ->setParameterByClass(ilObjBibliographicGUI::class, ilObjBibliographicGUI::P_ENTRY_ID, $id[1]);
283  $DIC->ctrl()->redirectByClass(
284  [
285  ilRepositoryGUI::class,
286  ilObjBibliographicGUI::class,
287  ],
288  self::CMD_SHOW_DETAILS
289  );
290  } else {
291  $DIC->ctrl()->redirectByClass(
292  [
293  ilRepositoryGUI::class,
294  ilObjBibliographicGUI::class,
295  ],
296  self::CMD_VIEW
297  );
298  }
299  }
300 
304  #[\Override]
305  protected function initCreateForm(string $new_type): ilPropertyFormGUI
306  {
307  $form = new ilPropertyFormGUI();
308  $form->setTarget('_top');
309  $form->setFormAction($this->ctrl->getFormAction($this, 'save'));
310  $form->setTitle($this->lng->txt($new_type . '_new'));
311 
312  $ti = new ilTextInputGUI($this->lng->txt('title'), 'title');
313  $ti->setSize(min(40, ilObject::TITLE_LENGTH));
314  $ti->setMaxLength(ilObject::TITLE_LENGTH);
315  $ti->setRequired(true);
316  $form->addItem($ti);
317 
318  $ta = new ilTextAreaInputGUI($this->lng->txt('description'), 'desc');
319  $ta->setCols(40);
320  $ta->setRows(2);
321  $ta->setMaxNumOfChars(ilObject::LONG_DESC_LENGTH);
322  $form->addItem($ta);
323 
324  $in_file = new ilFileInputGUI($this->lng->txt('bibliography_file'), 'bibliographic_file');
325  $in_file->setSuffixes(['ris', 'bib', 'bibtex']);
326  $in_file->setRequired(true);
327  $form->addItem($in_file);
328 
329  $form = $this->initDidacticTemplate($form);
330 
331  $form->addCommandButton('save', $this->lng->txt($new_type . '_add'));
332  $form->addCommandButton('cancel', $this->lng->txt('cancel'));
333 
334  return $form;
335  }
336 
337  #[\Override]
338  public function save(): void
339  {
340  $form = $this->initCreateForm($this->getType());
341  if ($form->checkInput()) {
342  $this->saveObject();
343  } else {
344  $form->setValuesByPost();
345  $this->ui()->mainTemplate()->setContent($form->getHtml());
346  }
347  }
348 
349  #[\Override]
350  public function saveObject(): void
351  {
352  // create permission is already checked in createObject. This check here is done to prevent hacking attempts
353  if (!$this->checkPermissionBool('create', '', $this->requested_new_type)) {
354  $this->error->raiseError($this->lng->txt('no_create_permission'), $this->error->MESSAGE);
355  }
356 
357  $this->lng->loadLanguageModule($this->requested_new_type);
358  $this->ctrl->setParameter($this, 'new_type', $this->requested_new_type);
359 
360  $form = $this->initCreateForm($this->requested_new_type);
361  if ($form->checkInput()) {
362  $this->ctrl->setParameter($this, 'new_type', '');
363 
364  $newObj = new ilObjBibliographic();
365  $newObj->setTitle($form->getInput('title'));
366  $newObj->setDescription($form->getInput('desc'));
367  $newObj->processAutoRating();
368  $newObj->create();
369 
370  $this->putObjectInTree($newObj);
371 
372  $dtpl = $this->getDidacticTemplateVar('dtpl');
373  if ($dtpl !== 0) {
374  $newObj->applyDidacticTemplate($dtpl);
375  }
376 
377  $this->afterSave($newObj);
378  }
379 
380  $form->setValuesByPost();
381  $this->tpl->setContent($form->getHTML());
382  }
383 
384  #[\Override]
385  public function updateObject(): void
386  {
387  $form = $this->getSettingsForm();
388  $form = $form->withRequest($this->http->request());
389  $result = $form->getInputGroup()->getContent();
390 
391  if (!$result->isOK()) {
392  $this->tpl->setOnScreenMessage('failure', $result->error(), true);
393  $this->tpl->setContent(
394  $this->ui()->renderer()->render([$form])
395  );
396  } else {
397  $values = $result->value();
398 
399  $this->object->getObjectProperties()->storePropertyTitleAndDescription(
400  $values[self::SECTION_EDIT_BIBLIOGRAPHY][self::PROP_TITLE_AND_DESC]
401  );
402  $this->object->getObjectProperties()->storePropertyIsOnline(
403  $values[self::SECTION_AVAILABILITY][self::PROP_ONLINE_STATUS]
404  );
405  $this->object->getObjectProperties()->storePropertyTileImage(
406  $values[self::SECTION_PRESENTATION][self::PROP_TILE_IMAGE]
407  );
408 
409  $this->tpl->setOnScreenMessage('success', $this->lng->txt('changes_saved'), true);
410  $this->ctrl->redirect($this, self::CMD_SETTINGS);
411  }
412  }
413 
414  #[\Override]
415  protected function afterSave(ilObject $a_new_object): void
416  {
417  $this->addNews($a_new_object->getId(), 'created');
418  $this->ctrl->redirect($this, self::CMD_EDIT_OBJECT);
419  }
420 
421  protected function settings(): void
422  {
423  $this->tpl->setContent($this->ui()->renderer()->render($this->getSettingsForm()));
424  }
425 
426  private function replaceBibliograficFileInit(): void
427  {
428  if (!$DIC->access()->checkAccess('write', "", $this->object->getRefId())) {
429  $this->ctrl->redirect($this, self::CMD_SHOW_CONTENT);
430  return;
431  }
432  $this->tabs()->clearTargets();
433  $this->tabs()->setBackTarget(
434  $this->lng->txt('back'),
435  $this->ctrl->getLinkTarget($this, self::CMD_SHOW_CONTENT)
436  );
437 
438  $this->tpl->setOnScreenMessage(
439  'info',
440  $this->lng->txt('replace_bibliography_file_info')
441  );
442  }
443 
444  public function overwriteBibliographicFile(): void
445  {
447 
448  $this->tpl->setContent($this->ui()->renderer()->render($this->getReplaceBibliographicFileForm()));
449  }
450 
451  public function replaceBibliographicFile(): void
452  {
454 
455  $form = $this->getReplaceBibliographicFileForm();
456  $form = $form->withRequest($this->http->request());
457  $data = $form->getData();
458  if ($data !== null && $bibl_file_rid = $this->storage->manage()->find(
459  $data[self::SECTION_REPLACE_BIBLIOGRAPHIC_FILE][self::PROP_BIBLIOGRAPHIC_FILE][0]
460  )) {
464  $bibl_obj = $this->getObject();
465  $bibl_filename = $this->storage->manage()->getResource($bibl_file_rid)->getCurrentRevision()->getTitle();
466  $bibl_filetype = $bibl_obj->determineFileTypeByFileName($bibl_filename);
467 
468  $bibl_obj->setResourceId($bibl_file_rid);
469  $bibl_obj->setFilename($bibl_filename);
470  $bibl_obj->setFileType($bibl_filetype);
471  $bibl_obj->update();
472  $bibl_obj->parseFileToDatabase();
473 
474  $this->tpl->setOnScreenMessage('success', $this->lng->txt('changes_saved'), true);
475  $this->ctrl->redirect($this, self::CMD_SHOW_CONTENT);
476  }
477 
478  $this->tpl->setContent(
479  $this->ui()->renderer()->render([$form])
480  );
481  }
482 
483  protected function getReplaceBibliographicFileForm(): Standard
484  {
489  $bibl_obj = $this->getObject();
490  $rid = $bibl_obj->getResourceId() ? $bibl_obj->getResourceId()->serialize() : "";
491  $bibl_upload_handler = new ilObjBibliographicUploadHandlerGUI($rid);
492 
493  $section_replace_bibliographic_file = $this->ui_factory
494  ->input()
495  ->field()
496  ->section(
497  [
498  self::PROP_BIBLIOGRAPHIC_FILE => $this->ui_factory
499  ->input()
500  ->field()
501  ->file(
502  $bibl_upload_handler,
503  $this->lng->txt('bibliography_file')
504  )
505  ->withRequired(true)
506  ->withAdditionalTransformation(
508  )
509  ],
510  $this->lng->txt('replace_bibliography_file')
511  );
512 
513  return $this->ui_factory->input()->container()->form()->standard(
514  $this->ctrl->getFormAction($this, self::CMD_REPLACE_BIBLIOGRAPHIC_FILE),
515  [
516  self::SECTION_REPLACE_BIBLIOGRAPHIC_FILE => $section_replace_bibliographic_file
517  ]
518  );
519  }
520 
522  {
523  return $this->refinery->custom()->constraint(
524  function ($bibl_file_input): bool {
525  global $DIC;
526  $rid = $bibl_file_input[0];
527  $resource_identifier = $DIC->resourceStorage()->manage()->find($rid);
528  if ($resource_identifier !== null) {
529  $bibl_file = $DIC->resourceStorage()->manage()->getCurrentRevision($resource_identifier);
530  $bibl_file_suffix = $bibl_file->getInformation()->getSuffix();
531  if (in_array($bibl_file_suffix, ['ris', 'bib', 'bibtex'])) {
532  return true;
533  }
534  }
535  return false;
536  },
537  $this->lng->txt('msg_error_invalid_bibl_file_suffix')
538  );
539  }
540 
546  #[\Override]
547  public function setTabs(): void
548  {
549  global $DIC;
550 
551  $ilHelp = $DIC['ilHelp'];
555  $ilHelp->setScreenIdComponent('bibl');
556  // info screen
557  if ($DIC->access()->checkAccess('read', "", $this->object->getRefId())) {
558  $DIC->tabs()->addTab(
559  self::TAB_CONTENT,
560  $DIC->language()
561  ->txt(self::TAB_CONTENT),
562  $this->ctrl->getLinkTarget($this, self::CMD_SHOW_CONTENT)
563  );
564  }
565  // info screen
566  if ($DIC->access()->checkAccess('visible', "", $this->object->getRefId())
567  || $DIC->access()->checkAccess('read', "", $this->object->getRefId())
568  ) {
569  $DIC->tabs()->addTab(
570  self::TAB_ID_INFO,
571  $DIC->language()
572  ->txt("info_short"),
573  $this->ctrl->getLinkTargetByClass("ilinfoscreengui", "showSummary")
574  );
575  }
576  // settings
577  if ($DIC->access()->checkAccess('write', "", $this->object->getRefId())) {
578  $DIC->tabs()->addTab(
579  self::SUBTAB_SETTINGS,
580  $DIC->language()
581  ->txt(self::SUBTAB_SETTINGS),
582  $this->ctrl->getLinkTarget($this, self::CMD_EDIT_OBJECT)
583  );
584  }
585  // export
586  if ($DIC->access()->checkAccess("write", "", $this->object->getRefId())) {
587  $DIC->tabs()->addTab(
588  self::TAB_EXPORT,
589  $DIC->language()
590  ->txt(self::TAB_EXPORT),
591  $this->ctrl->getLinkTargetByClass("ilexportgui", "")
592  );
593  }
594  // edit permissions
595  if ($DIC->access()->checkAccess('edit_permission', "", $this->object->getRefId())) {
596  $DIC->tabs()->addTab(
597  self::TAB_ID_PERMISSIONS,
598  $DIC->language()
599  ->txt("perm_settings"),
600  $this->ctrl->getLinkTargetByClass("ilpermissiongui", "perm")
601  );
602  }
603  }
604 
605  protected function initSubTabs(): void
606  {
607  global $DIC;
608  $DIC->tabs()->addSubTab(
609  self::SUBTAB_SETTINGS,
610  $DIC->language()
611  ->txt(self::SUBTAB_SETTINGS),
612  $this->ctrl->getLinkTarget($this, self::CMD_EDIT_OBJECT)
613  );
614  $DIC->tabs()->addSubTab(
615  self::SUB_TAB_FILTER,
616  $DIC->language()
617  ->txt("bibl_filter"),
618  $this->ctrl->getLinkTargetByClass(ilBiblFieldFilterGUI::class, ilBiblFieldFilterGUI::CMD_STANDARD)
619  );
620  }
621 
626  #[\Override]
627  public function editObject(): void
628  {
629  if (!$this->checkPermissionBool("write")) {
630  $this->error->raiseError($this->lng->txt("msg_no_perm_write"), $this->error->MESSAGE);
631  }
632 
633  $this->tabs_gui->activateTab("settings");
634  $form = $this->getSettingsForm();
635  $this->tpl->setContent($this->ui()->renderer()->render($form));
636  }
637 
638  public function getSettingsForm(): Standard
639  {
640  $field_factory = $this->ui_factory->input()->field();
641 
642  $section_edit_bibliography = $field_factory->section(
643  [
644  self::PROP_TITLE_AND_DESC => $this->object->getObjectProperties()->getPropertyTitleAndDescription(
645  )->toForm(
646  $this->lng,
647  $field_factory,
648  $this->refinery
649  )
650  ],
651  $this->lng->txt('bibl_edit'),
652  ''
653  );
654  $section_availability = $field_factory->section(
655  [
656  self::PROP_ONLINE_STATUS => $this->object->getObjectProperties()->getPropertyIsOnline()->toForm(
657  $this->lng,
658  $field_factory,
659  $this->refinery
660  )
661  ],
662  $this->lng->txt('rep_activation_availability'),
663  ''
664  );
665  $section_presentation = $field_factory->section(
666  [
667  self::PROP_TILE_IMAGE => $this->object->getObjectProperties()->getPropertyTileImage()->toForm(
668  $this->lng,
669  $field_factory,
670  $this->refinery
671  )
672  ],
673  $this->lng->txt('settings_presentation_header'),
674  ''
675  );
676 
677  return $this->ui_factory->input()->container()->form()->standard(
678  $this->ctrl->getFormAction($this, self::CMD_UPDATE_OBJECT),
679  [
680  self::SECTION_EDIT_BIBLIOGRAPHY => $section_edit_bibliography,
681  self::SECTION_AVAILABILITY => $section_availability,
682  self::SECTION_PRESENTATION => $section_presentation
683  ]
684  );
685  }
686 
687  public function render(): void
688  {
689  $this->showContent();
690  }
691 
695  public function showContent(): void
696  {
697  global $DIC;
698 
699  // if user has read permission and object is online OR user has write permissions
700  $read_access = $DIC->access()->checkAccess('read', "", $this->object->getRefId());
701  $online = $this->object->getObjectProperties()->getPropertyIsOnline()->getIsOnline();
702  $write_access = $DIC->access()->checkAccess('write', "", $this->object->getRefId());
703  if (($read_access && $online) || $write_access) {
704  $DIC->tabs()->activateTab(self::TAB_CONTENT);
705 
706  $btn_download_original_file = $this->ui()->factory()->button()->primary(
707  $this->lng->txt('download_original_file'),
708  $this->ctrl()->getLinkTargetByClass(self::class, self::CMD_SEND_FILE)
709  );
710  $this->toolbar->addComponent($btn_download_original_file);
711 
712  if ($write_access) {
713  $btn_overwrite_bibliographic_file = $this->ui()->factory()->button()->standard(
714  $this->lng->txt('replace_bibliography_file'),
715  $this->ctrl()->getLinkTargetByClass(self::class, self::CMD_OVERWRITE_BIBLIOGRAPHIC_FILE)
716  );
717  $this->toolbar->addComponent($btn_overwrite_bibliographic_file);
718  }
719 
720  $table_gui = new ilBiblEntryTableGUI($this, $this->facade, $this->ui());
721  $DIC->ui()->mainTemplate()->setContent($table_gui->getRenderedTableAndExistingFilters());
722 
723  //Permanent Link
724  $DIC->ui()->mainTemplate()->setPermanentLink("bibl", $this->object->getRefId());
725  } else {
726  $object_title = ilObject::_lookupTitle(ilObject::_lookupObjId($this->ref_id));
727  $this->tpl->setOnScreenMessage(
728  'failure',
729  sprintf(
730  $DIC->language()
731  ->txt("msg_no_perm_read_item"),
732  $object_title
733  ),
734  true
735  );
736  //redirect to repository without any parameters
737  $this->handleNonAccess();
738  }
739  }
740 
741  protected function applyFilter(): void
742  {
743  $table = new ilBiblEntryTableGUI($this, $this->facade, $this->ui());
744  $table->writeFilterToSession();
745  $table->resetOffset();
746  $this->ctrl->redirect($this, self::CMD_SHOW_CONTENT);
747  }
748 
749  protected function resetFilter(): void
750  {
751  $table = new ilBiblEntryTableGUI($this, $this->facade, $this->ui());
752  $table->resetFilter();
753  $table->resetOffset();
754  $this->ctrl->redirect($this, self::CMD_SHOW_CONTENT);
755  }
756 
760  public function sendFile(): void
761  {
762  global $DIC;
763 
764  if ($DIC['ilAccess']->checkAccess('read', "", $this->object->getRefId())) {
765  if (!$this->object->isMigrated()) {
766  $file_path = $this->object->getLegacyAbsolutePath();
767  if ($file_path) {
768  if (is_file($file_path)) {
770  $file_path,
771  $this->object->getFilename(),
772  'application/octet-stream'
773  );
774  } else {
775  $this->tpl->setOnScreenMessage('failure', $DIC['lng']->txt("file_not_found"));
776  $this->showContent();
777  }
778  }
779  } else {
780  $this->storage->consume()->download($this->object->getResourceId())->run();
781  }
782  } else {
783  $this->handleNonAccess();
784  }
785  }
786 
787  public function showDetails(): void
788  {
789  global $DIC;
790 
791  if ($DIC->access()->checkAccess('read', "", $this->object->getRefId())) {
792  $id = $DIC->http()->request()->getQueryParams()[self::P_ENTRY_ID];
793  $entry = $this->facade->entryFactory()
794  ->findByIdAndTypeString($id, $this->object->getFileTypeAsString());
795  $bibGUI = new ilBiblEntryDetailPresentationGUI(
796  $entry,
797  $this->facade,
798  $this->ctrl(),
799  $this->help,
800  $this->lng(),
801  $this->tpl(),
802  $this->tabs(),
803  $this->ui()
804  );
805 
806  $DIC->ui()->mainTemplate()->setContent($bibGUI->getHTML());
807  } else {
808  $this->handleNonAccess();
809  }
810  }
811 
812  #[\Override]
813  public function view(): void
814  {
815  $this->showContent();
816  }
817 
818  public function toggleNotification(): void
819  {
820  global $DIC;
821  $ntf = $DIC->http()->wrapper()->query()->retrieve(
822  "ntf",
823  $DIC->refinery()->to()->int()
824  );
825 
826  switch ($ntf) {
827  case 1:
830  $DIC->user()
831  ->getId(),
833  false
834  );
835  break;
836  case 2:
839  $DIC->user()
840  ->getId(),
842  true
843  );
844  break;
845  }
846  $DIC->ctrl()->redirect($this, "");
847  }
848 
849  public function addNews(int $obj_id, string $change = 'created'): void
850  {
851  global $DIC;
852 
853  $ilNewsItem = new ilNewsItem();
854  $ilNewsItem->setTitle($DIC->language()->txt('news_title_' . $change));
855  $ilNewsItem->setPriority(NEWS_NOTICE);
856  $ilNewsItem->setContext($obj_id, $this->getType());
857  $ilNewsItem->setUserId($DIC->user()->getId());
858  $ilNewsItem->setVisibility(NEWS_USERS);
859  $ilNewsItem->setContentTextIsLangVar(false);
860  $ilNewsItem->create();
861  }
862 
867  public function addToDesk(): void
868  {
869  $this->addToDeskObject();
870  }
871 
876  public function removeFromDesk(): void
877  {
878  $this->removeFromDeskObject();
879  }
880 
881  #[\Override]
882  protected function afterImport(ilObject $a_new_object): void
883  {
887  $a_new_object->parseFileToDatabase();
888 
889  parent::afterImport($a_new_object);
890  }
891 
892  private function handleNonAccess(): void
893  {
894  global $DIC;
895 
896  $this->tpl->setOnScreenMessage('failure', $DIC->language()->txt("no_permission"), true);
898  }
899 }
afterSave(ilObject $a_new_object)
Class ilObjBibliographicGUI.
removeFromDesk()
Remove from desktop.
New implementation of ilObjectGUI.
GUI class for the workflow of copying objects.
const TITLE_LENGTH
ilBiblFieldFilterFactory $filter_factory
This class represents a file property in a property form.
Help GUI class.
renderer()
getDidacticTemplateVar(string $type)
Get didactic template setting from creation screen.
A constraint encodes some resrtictions on values.
Definition: Constraint.php:31
prepareOutput(bool $show_sub_objects=true)
setSuffixes(array $a_suffixes)
ilObjBibliographicStakeholder $stakeholder
sendFile()
provide file as a download
Class ilResourceStorageInfoGUI.
static _lookupObjId(int $ref_id)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
const LONG_DESC_LENGTH
static http()
Fetches the global http state from ILIAS.
checkPermissionBool(string $perm, string $cmd="", string $type="", ?int $node_id=null)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _lookupTitle(int $obj_id)
static setNotification(int $type, int $user_id, int $id, bool $status=true)
Set notification status for object and user.
Class ilBiblFieldFilterGUI.
static deliverFileAttached(string $path_to_file, ?string $download_file_name=null, ?string $mime_type=null, bool $delete_file=false)
This is how the factory for UI elements looks.
Definition: Factory.php:37
Class ilObjBibliographicStakeholder.
initDidacticTemplate(ilPropertyFormGUI $form)
const NEWS_NOTICE
__construct(int $id=0, int $id_type=self::REPOSITORY_NODE_ID, int $parent_node_id=0)
global $DIC
Definition: shib_login.php:22
putObjectInTree(ilObject $obj, ?int $parent_node_id=null)
Add object to tree at given position.
afterImport(ilObject $new_object)
Post (successful) object import hook.
ilBiblTranslationFactory $translation_factory
This describes a standard form.
Definition: Standard.php:28
setTabs()
create tabs (repository/workspace switch)
A news item can be created by different sources.
addNews(int $obj_id, string $change='created')
__construct(Container $dic, ilPlugin $plugin)
This class represents a text area property in a property form.
showContent()
shows the overview page with all entries in a table
ILIAS Refinery Factory $refinery
const NEWS_USERS
static _goto(string $a_target)
_goto Deep link
Class ilObjBibliographic.
Class ilBiblEntryDetailPresentationGUI.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
addHeaderAction()
Add header action menu.
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
static _gotoRepositoryRoot(bool $raise_error=false)
Goto repository root.
infoScreen()
this one is called from the info button in the repository not very nice to set cmdClass/Cmd manually...