ILIAS  release_10 Revision v10.1-43-ga1241a92c2f
class.ilObjBibliographicGUI.php
Go to the documentation of this file.
1 <?php
2 
25 
42 {
43  use DIC;
44 
45  public const P_ENTRY_ID = 'entry_id';
46  public const CMD_SHOW_CONTENT = 'showContent';
47  public const CMD_SEND_FILE = "sendFile";
48  public const TAB_CONTENT = "content";
49  public const SUB_TAB_FILTER = "filter";
50  public const CMD_VIEW = "view";
51  public const TAB_EXPORT = "export";
52  public const TAB_SETTINGS = self::SUBTAB_SETTINGS;
53  public const TAB_ID_RECORDS = "id_records";
54  public const TAB_ID_PERMISSIONS = "id_permissions";
55  public const TAB_ID_INFO = "id_info";
56  public const CMD_SHOW_DETAILS = "showDetails";
57  public const SUBTAB_SETTINGS = "settings";
58  public const CMD_EDIT_OBJECT = 'editObject';
59  public const CMD_UPDATE_OBJECT = "updateObject";
60  public const CMD_SETTINGS = "settings";
61  public const CMD_OVERWRITE_BIBLIOGRAPHIC_FILE = "overwriteBibliographicFile";
62  public const CMD_REPLACE_BIBLIOGRAPHIC_FILE = "replaceBibliographicFile";
63  public const SECTION_REPLACE_BIBLIOGRAPHIC_FILE = 'section_replace_bibliographic_file';
64  public const PROP_BIBLIOGRAPHIC_FILE = "bibliographic_file";
65  public const SECTION_EDIT_BIBLIOGRAPHY = 'section_edit_bibliography';
66  public const PROP_TITLE_AND_DESC = 'title_and_desc';
67  public const SECTION_AVAILABILITY = 'section_availability';
68  public const PROP_ONLINE_STATUS = 'online_status';
69  public const SECTION_PRESENTATION = 'section_presentation';
70  public const PROP_TILE_IMAGE = 'tile_image';
72 
73  public ?ilObject $object = null;
74  protected ?ilBiblFactoryFacade $facade = null;
79 
80  protected ilHelpGUI $help;
81  protected Services $storage;
83  protected \ILIAS\HTTP\Services $http;
84  protected Factory $ui_factory;
85  protected \ILIAS\Refinery\Factory $refinery;
86  protected ?string $cmd = self::CMD_SHOW_CONTENT;
87 
88  public function __construct(int $a_id = 0, int $a_id_type = self::REPOSITORY_NODE_ID, int $a_parent_node_id = 0)
89  {
90  global $DIC;
91 
92  $this->help = $DIC['ilHelp'];
93  $this->storage = $DIC['resource_storage'];
94  $this->stakeholder = new ilObjBibliographicStakeholder();
95  $this->http = $DIC->http();
96  $this->ui_factory = $DIC->ui()->factory();
97  $this->refinery = $DIC->refinery();
98  $this->upload_limit = $DIC["ui.upload_limit_resolver"];
99 
100  parent::__construct($a_id, $a_id_type, $a_parent_node_id);
101  $DIC->language()->loadLanguageModule('bibl');
102  $DIC->language()->loadLanguageModule('content');
103  $DIC->language()->loadLanguageModule('obj');
104  $DIC->language()->loadLanguageModule('cntr');
105 
106  if ($this->object instanceof ilObjBibliographic) {
108  $obj = $this->object;
109  $this->facade = new ilBiblFactoryFacade($obj);
110  }
111  }
112 
116  public function getStandardCmd(): string
117  {
118  return self::CMD_VIEW;
119  }
120 
125  public function getType(): string
126  {
127  return "bibl";
128  }
129 
133  public function executeCommand(): void
134  {
135  global $DIC;
136  $ilNavigationHistory = $DIC['ilNavigationHistory'];
137 
138  // Navigation History
139  $link = $this->dic()->ctrl()->getLinkTarget($this, $this->getStandardCmd());
140  if ($this->object != null) {
141  $ilNavigationHistory->addItem($this->object->getRefId(), $link, "bibl");
142  $this->addHeaderAction();
143  }
144 
145  // general Access Check, especially for single entries not matching the object
146  if ($this->object instanceof ilObjBibliographic && !$DIC->access()->checkAccess(
147  'read',
148  "",
149  $this->object->getRefId()
150  )) {
151  $this->handleNonAccess();
152  }
153 
154  $next_class = $this->dic()->ctrl()->getNextClass($this);
155  $this->cmd = $this->dic()->ctrl()->getCmd();
156  switch ($next_class) {
157  case strtolower(ilInfoScreenGUI::class):
158  $this->prepareOutput();
159  $this->dic()->tabs()->activateTab(self::TAB_ID_INFO);
160  $this->infoScreenForward();
161  break;
162  case strtolower(ilCommonActionDispatcherGUI::class):
163  $this->prepareOutput();
165  $this->ctrl->forwardCommand($gui);
166  break;
167  case strtolower(ilPermissionGUI::class):
168  $this->prepareOutput();
169  $this->dic()->tabs()->activateTab(self::TAB_ID_PERMISSIONS);
170  $this->ctrl->forwardCommand(new ilPermissionGUI($this));
171  break;
172  case strtolower(ilObjectCopyGUI::class):
173  $cp = new ilObjectCopyGUI($this);
174  $cp->setType('bibl');
175  $this->dic()['tpl']->loadStandardTemplate();
176  $this->ctrl->forwardCommand($cp);
177  break;
178  case strtolower(ilExportGUI::class):
179  $this->prepareOutput();
180  $this->dic()->tabs()->setTabActive(self::TAB_EXPORT);
181  $exp_gui = new ilExportGUI($this);
182  $exp_gui->addFormat("xml");
183  $this->ctrl->forwardCommand($exp_gui);
184  break;
185  case strtolower(ilBiblFieldFilterGUI::class):
186  $this->prepareOutput();
187  $this->dic()->tabs()->setTabActive(self::TAB_SETTINGS);
188  $this->initSubTabs();
189  $this->tabs_gui->activateSubTab(self::SUB_TAB_FILTER);
190  $this->ctrl->forwardCommand(new ilBiblFieldFilterGUI($this->facade));
191  break;
192  case strtolower(ilObjBibliographicUploadHandlerGUI::class):
193  $rid = "";
194  if ($this->object && $this->object->getResourceId()) {
195  $rid = $this->object->getResourceId()->serialize();
196  }
197  $this->ctrl->forwardCommand(new ilObjBibliographicUploadHandlerGUI($rid));
198  break;
199  default:
200  $this->prepareOutput();
201  $cmd = $this->ctrl->getCmd(self::CMD_SHOW_CONTENT);
202  switch ($cmd) {
203  case self::CMD_SETTINGS:
204  case self::CMD_EDIT_OBJECT:
205  case self::CMD_UPDATE_OBJECT:
206  $this->initSubTabs();
207  $this->tabs_gui->activateSubTab(self::SUBTAB_SETTINGS);
208  $this->{$cmd}();
209  break;
210  default:
211  $this->{$cmd}();
212  break;
213  }
214  break;
215  }
216  }
217 
223  public function infoScreen(): void
224  {
225  $this->ctrl->redirectByClass(ilInfoScreenGUI::class, "showSummary");
226  }
227 
231  public function infoScreenForward(): void
232  {
233  global $DIC;
238  if (!$this->checkPermissionBoolAndReturn("visible") && !$this->checkPermissionBoolAndReturn('read')) {
239  $this->tpl->setOnScreenMessage('failure', $DIC['lng']->txt("msg_no_perm_read"), true);
240  $this->ctrl->redirectByClass('ilDashboardGUI', '');
241  }
242  $DIC->tabs()->activateTab(self::TAB_ID_INFO);
243  $info = new ilInfoScreenGUI($this);
244 
245  $info->enablePrivateNotes();
246  $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
247 
248  // Storage Info
249  $irss = new ilResourceStorageInfoGUI($this->object->getResourceId());
250  $irss->append($info);
251 
252  $this->ctrl->forwardCommand($info);
253  }
254 
255  /*
256  * addLocatorItems
257  */
258  public function addLocatorItems(): void
259  {
260  global $DIC;
261  $ilLocator = $DIC['ilLocator'];
262  if (is_object($this->object)) {
263  $ilLocator->addItem($this->object->getTitle(), $this->ctrl->getLinkTarget($this, ""), "", $this->node_id);
264  }
265  }
266 
271  public static function _goto(string $a_target): void
272  {
273  global $DIC;
274 
275  $id = explode("_", $a_target);
276  $DIC->ctrl()->setTargetScript('ilias.php');
277  $DIC->ctrl()->setParameterByClass(ilObjBibliographicGUI::class, "ref_id", (int) ($id[0] ?? 1));
278  // Detail-View
279  if (isset($id[1]) && $id[1] !== '') {
280  $DIC->ctrl()
281  ->setParameterByClass(ilObjBibliographicGUI::class, ilObjBibliographicGUI::P_ENTRY_ID, $id[1]);
282  $DIC->ctrl()->redirectByClass(
283  [
284  ilRepositoryGUI::class,
285  ilObjBibliographicGUI::class,
286  ],
287  self::CMD_SHOW_DETAILS
288  );
289  } else {
290  $DIC->ctrl()->redirectByClass(
291  [
292  ilRepositoryGUI::class,
293  ilObjBibliographicGUI::class,
294  ],
295  self::CMD_VIEW
296  );
297  }
298  }
299 
303  protected function initCreateForm(string $new_type): ilPropertyFormGUI
304  {
305  $form = new ilPropertyFormGUI();
306  $form->setTarget('_top');
307  $form->setFormAction($this->ctrl->getFormAction($this, 'save'));
308  $form->setTitle($this->lng->txt($new_type . '_new'));
309 
310  $ti = new ilTextInputGUI($this->lng->txt('title'), 'title');
311  $ti->setSize(min(40, ilObject::TITLE_LENGTH));
312  $ti->setMaxLength(ilObject::TITLE_LENGTH);
313  $ti->setRequired(true);
314  $form->addItem($ti);
315 
316  $ta = new ilTextAreaInputGUI($this->lng->txt('description'), 'desc');
317  $ta->setCols(40);
318  $ta->setRows(2);
319  $ta->setMaxNumOfChars(ilObject::LONG_DESC_LENGTH);
320  $form->addItem($ta);
321 
322  $in_file = new ilFileInputGUI($this->lng->txt('bibliography_file'), 'bibliographic_file');
323  $in_file->setSuffixes(['ris', 'bib', 'bibtex']);
324  $in_file->setRequired(true);
325  $form->addItem($in_file);
326 
327  $form = $this->initDidacticTemplate($form);
328 
329  $form->addCommandButton('save', $this->lng->txt($new_type . '_add'));
330  $form->addCommandButton('cancel', $this->lng->txt('cancel'));
331 
332  return $form;
333  }
334 
335  public function save(): void
336  {
337  $form = $this->initCreateForm($this->getType());
338  if ($form->checkInput()) {
339  $this->saveObject();
340  } else {
341  $form->setValuesByPost();
342  $this->ui()->mainTemplate()->setContent($form->getHtml());
343  }
344  }
345 
346  public function saveObject(): void
347  {
348  // create permission is already checked in createObject. This check here is done to prevent hacking attempts
349  if (!$this->checkPermissionBool('create', '', $this->requested_new_type)) {
350  $this->error->raiseError($this->lng->txt('no_create_permission'), $this->error->MESSAGE);
351  }
352 
353  $this->lng->loadLanguageModule($this->requested_new_type);
354  $this->ctrl->setParameter($this, 'new_type', $this->requested_new_type);
355 
356  $form = $this->initCreateForm($this->requested_new_type);
357  if ($form->checkInput()) {
358  $this->ctrl->setParameter($this, 'new_type', '');
359 
360  $newObj = new ilObjBibliographic();
361  $newObj->setTitle($form->getInput('title'));
362  $newObj->setDescription($form->getInput('desc'));
363  $newObj->processAutoRating();
364  $newObj->create();
365 
366  $this->putObjectInTree($newObj);
367 
368  $dtpl = $this->getDidacticTemplateVar('dtpl');
369  if ($dtpl !== 0) {
370  $newObj->applyDidacticTemplate($dtpl);
371  }
372 
373  $this->afterSave($newObj);
374  }
375 
376  $form->setValuesByPost();
377  $this->tpl->setContent($form->getHTML());
378  }
379 
380  public function updateObject(): void
381  {
382  $form = $this->getSettingsForm();
383  $form = $form->withRequest($this->http->request());
384  $result = $form->getInputGroup()->getContent();
385 
386  if (!$result->isOK()) {
387  $this->tpl->setOnScreenMessage('failure', $result->error(), true);
388  $this->tpl->setContent(
389  $this->ui()->renderer()->render([$form])
390  );
391  } else {
392  $values = $result->value();
393 
394  $this->object->getObjectProperties()->storePropertyTitleAndDescription(
395  $values[self::SECTION_EDIT_BIBLIOGRAPHY][self::PROP_TITLE_AND_DESC]
396  );
397  $this->object->getObjectProperties()->storePropertyIsOnline(
398  $values[self::SECTION_AVAILABILITY][self::PROP_ONLINE_STATUS]
399  );
400  $this->object->getObjectProperties()->storePropertyTileImage(
401  $values[self::SECTION_PRESENTATION][self::PROP_TILE_IMAGE]
402  );
403 
404  $this->tpl->setOnScreenMessage('success', $this->lng->txt('changes_saved'), true);
405  $this->ctrl->redirect($this, self::CMD_SETTINGS);
406  }
407  }
408 
409  protected function afterSave(ilObject $a_new_object): void
410  {
411  $this->addNews($a_new_object->getId(), 'created');
412  $this->ctrl->redirect($this, self::CMD_EDIT_OBJECT);
413  }
414 
415  protected function settings(): void
416  {
417  $this->tpl->setContent($this->ui()->renderer()->render($this->getSettingsForm()));
418  }
419 
420  private function replaceBibliograficFileInit(): void
421  {
422  if (!$this->access->checkAccess('write', "", $this->object->getRefId())) {
423  $this->ctrl->redirect($this, self::CMD_SHOW_CONTENT);
424  return;
425  }
426  $this->tabs()->clearTargets();
427  $this->tabs()->setBackTarget(
428  $this->lng->txt('back'),
429  $this->ctrl->getLinkTarget($this, self::CMD_SHOW_CONTENT)
430  );
431 
432  $this->tpl->setOnScreenMessage(
433  'info',
434  $this->lng->txt('replace_bibliography_file_info')
435  );
436  }
437 
438  public function overwriteBibliographicFile(): void
439  {
441 
442  $this->tpl->setContent($this->ui()->renderer()->render($this->getReplaceBibliographicFileForm()));
443  }
444 
445  public function replaceBibliographicFile(): void
446  {
448 
449  $form = $this->getReplaceBibliographicFileForm();
450  $form = $form->withRequest($this->http->request());
451  $data = $form->getData();
452  if ($data !== null && $bibl_file_rid = $this->storage->manage()->find(
453  $data[self::SECTION_REPLACE_BIBLIOGRAPHIC_FILE][self::PROP_BIBLIOGRAPHIC_FILE][0]
454  )) {
458  $bibl_obj = $this->getObject();
459  $bibl_filename = $this->storage->manage()->getResource($bibl_file_rid)->getCurrentRevision()->getTitle();
460  $bibl_filetype = $bibl_obj->determineFileTypeByFileName($bibl_filename);
461 
462  $bibl_obj->setResourceId($bibl_file_rid);
463  $bibl_obj->setFilename($bibl_filename);
464  $bibl_obj->setFileType($bibl_filetype);
465  $bibl_obj->update();
466  $bibl_obj->parseFileToDatabase();
467 
468  $this->tpl->setOnScreenMessage('success', $this->lng->txt('changes_saved'), true);
469  $this->ctrl->redirect($this, self::CMD_SHOW_CONTENT);
470  }
471 
472  $this->tpl->setContent(
473  $this->ui()->renderer()->render([$form])
474  );
475  }
476 
477  protected function getReplaceBibliographicFileForm(): Standard
478  {
483  $bibl_obj = $this->getObject();
484  $rid = $bibl_obj->getResourceId() ? $bibl_obj->getResourceId()->serialize() : "";
485  $bibl_upload_handler = new ilObjBibliographicUploadHandlerGUI($rid);
486 
487  $max_filesize_bytes = $this->upload_limit->getPhpUploadLimitInBytes();
488  $max_filesize_mb = round($max_filesize_bytes / 1024 / 1024, 1);
489  $info_file_limitations = $this->lng->txt('file_notice') . " " . number_format($max_filesize_mb, 1) . " MB <br>"
490  . $this->lng->txt('file_allowed_suffixes') . " .bib, .bibtex, .ris";
491  $section_replace_bibliographic_file = $this->ui_factory
492  ->input()
493  ->field()
494  ->section(
495  [
496  self::PROP_BIBLIOGRAPHIC_FILE => $this->ui_factory
497  ->input()
498  ->field()
499  ->file(
500  $bibl_upload_handler,
501  $this->lng->txt('bibliography_file'),
502  $info_file_limitations
503  )
504  ->withMaxFileSize($max_filesize_bytes)
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  public function setTabs(): void
547  {
548  global $DIC;
549 
550  $ilHelp = $DIC['ilHelp'];
554  $ilHelp->setScreenIdComponent('bibl');
555  // info screen
556  if ($DIC->access()->checkAccess('read', "", $this->object->getRefId())) {
557  $DIC->tabs()->addTab(
558  self::TAB_CONTENT,
559  $DIC->language()
560  ->txt(self::TAB_CONTENT),
561  $this->ctrl->getLinkTarget($this, self::CMD_SHOW_CONTENT)
562  );
563  }
564  // info screen
565  if ($DIC->access()->checkAccess('visible', "", $this->object->getRefId())
566  || $DIC->access()->checkAccess('read', "", $this->object->getRefId())
567  ) {
568  $DIC->tabs()->addTab(
569  self::TAB_ID_INFO,
570  $DIC->language()
571  ->txt("info_short"),
572  $this->ctrl->getLinkTargetByClass("ilinfoscreengui", "showSummary")
573  );
574  }
575  // settings
576  if ($DIC->access()->checkAccess('write', "", $this->object->getRefId())) {
577  $DIC->tabs()->addTab(
578  self::SUBTAB_SETTINGS,
579  $DIC->language()
580  ->txt(self::SUBTAB_SETTINGS),
581  $this->ctrl->getLinkTarget($this, self::CMD_EDIT_OBJECT)
582  );
583  }
584  // export
585  if ($DIC->access()->checkAccess("write", "", $this->object->getRefId())) {
586  $DIC->tabs()->addTab(
587  self::TAB_EXPORT,
588  $DIC->language()
589  ->txt(self::TAB_EXPORT),
590  $this->ctrl->getLinkTargetByClass("ilexportgui", "")
591  );
592  }
593  // edit permissions
594  if ($DIC->access()->checkAccess('edit_permission', "", $this->object->getRefId())) {
595  $DIC->tabs()->addTab(
596  self::TAB_ID_PERMISSIONS,
597  $DIC->language()
598  ->txt("perm_settings"),
599  $this->ctrl->getLinkTargetByClass("ilpermissiongui", "perm")
600  );
601  }
602  }
603 
604  protected function initSubTabs(): void
605  {
606  global $DIC;
607  $DIC->tabs()->addSubTab(
608  self::SUBTAB_SETTINGS,
609  $DIC->language()
610  ->txt(self::SUBTAB_SETTINGS),
611  $this->ctrl->getLinkTarget($this, self::CMD_EDIT_OBJECT)
612  );
613  $DIC->tabs()->addSubTab(
614  self::SUB_TAB_FILTER,
615  $DIC->language()
616  ->txt("bibl_filter"),
617  $this->ctrl->getLinkTargetByClass(ilBiblFieldFilterGUI::class, ilBiblFieldFilterGUI::CMD_STANDARD)
618  );
619  }
620 
625  public function editObject(): void
626  {
627  if (!$this->checkPermissionBool("write")) {
628  $this->error->raiseError($this->lng->txt("msg_no_perm_write"), $this->error->MESSAGE);
629  }
630 
631  $this->tabs_gui->activateTab("settings");
632  $form = $this->getSettingsForm();
633  $this->tpl->setContent($this->ui()->renderer()->render($form));
634  }
635 
636  public function getSettingsForm(): Standard
637  {
638  $field_factory = $this->ui_factory->input()->field();
639 
640  $section_edit_bibliography = $field_factory->section(
641  [
642  self::PROP_TITLE_AND_DESC => $this->object->getObjectProperties()->getPropertyTitleAndDescription(
643  )->toForm(
644  $this->lng,
645  $field_factory,
646  $this->refinery
647  )
648  ],
649  $this->lng->txt('bibl_edit'),
650  ''
651  );
652  $section_availability = $field_factory->section(
653  [
654  self::PROP_ONLINE_STATUS => $this->object->getObjectProperties()->getPropertyIsOnline()->toForm(
655  $this->lng,
656  $field_factory,
657  $this->refinery
658  )
659  ],
660  $this->lng->txt('rep_activation_availability'),
661  ''
662  );
663  $section_presentation = $field_factory->section(
664  [
665  self::PROP_TILE_IMAGE => $this->object->getObjectProperties()->getPropertyTileImage()->toForm(
666  $this->lng,
667  $field_factory,
668  $this->refinery
669  )
670  ],
671  $this->lng->txt('settings_presentation_header'),
672  ''
673  );
674 
675  return $this->ui_factory->input()->container()->form()->standard(
676  $this->ctrl->getFormAction($this, self::CMD_UPDATE_OBJECT),
677  [
678  self::SECTION_EDIT_BIBLIOGRAPHY => $section_edit_bibliography,
679  self::SECTION_AVAILABILITY => $section_availability,
680  self::SECTION_PRESENTATION => $section_presentation
681  ]
682  );
683  }
684 
685  public function render(): void
686  {
687  $this->showContent();
688  }
689 
693  public function showContent(): void
694  {
695  // if user has read permission and object is online OR user has write permissions
696  $read_access = $this->access->checkAccess('read', "", $this->object->getRefId());
697  $online = $this->object->getObjectProperties()->getPropertyIsOnline()->getIsOnline();
698  $write_access = $this->access->checkAccess('write', "", $this->object->getRefId());
699  if (($read_access && $online) || $write_access) {
700  $this->tabs_gui->activateTab(self::TAB_CONTENT);
701 
702  $btn_download_original_file = $this->ui()->factory()->button()->primary(
703  $this->lng->txt('download_original_file'),
704  $this->ctrl->getLinkTargetByClass(self::class, self::CMD_SEND_FILE)
705  );
706  $this->toolbar->addComponent($btn_download_original_file);
707 
708  if ($write_access) {
709  $btn_overwrite_bibliographic_file = $this->ui()->factory()->button()->standard(
710  $this->lng->txt('replace_bibliography_file'),
711  $this->ctrl->getLinkTargetByClass(self::class, self::CMD_OVERWRITE_BIBLIOGRAPHIC_FILE)
712  );
713  $this->toolbar->addComponent($btn_overwrite_bibliographic_file);
714  }
715 
716  $table_gui = new ilBiblEntryTableGUI($this, $this->facade, $this->ui());
717  $this->tpl->setContent($table_gui->getRenderedTableAndExistingFilters());
718 
719  //Permanent Link
720  $this->tpl->setPermanentLink("bibl", $this->object->getRefId());
721  } else {
722  $object_title = ilObject::_lookupTitle(ilObject::_lookupObjId($this->ref_id));
723  $this->tpl->setOnScreenMessage(
724  'failure',
725  sprintf(
726  $DIC->language()
727  ->txt("msg_no_perm_read_item"),
728  $object_title
729  ),
730  true
731  );
732  //redirect to repository without any parameters
733  $this->handleNonAccess();
734  }
735  }
736 
737  protected function applyFilter(): void
738  {
739  $table = new ilBiblEntryTableGUI($this, $this->facade, $this->ui());
740  $table->writeFilterToSession();
741  $table->resetOffset();
742  $this->ctrl->redirect($this, self::CMD_SHOW_CONTENT);
743  }
744 
745  protected function resetFilter(): void
746  {
747  $table = new ilBiblEntryTableGUI($this, $this->facade, $this->ui());
748  $table->resetFilter();
749  $table->resetOffset();
750  $this->ctrl->redirect($this, self::CMD_SHOW_CONTENT);
751  }
752 
756  public function sendFile(): void
757  {
758  global $DIC;
759 
760  if ($DIC['ilAccess']->checkAccess('read', "", $this->object->getRefId())) {
761  if (!$this->object->isMigrated()) {
762  $file_path = $this->object->getLegacyAbsolutePath();
763  if ($file_path) {
764  if (is_file($file_path)) {
766  $file_path,
767  $this->object->getFilename(),
768  'application/octet-stream'
769  );
770  } else {
771  $this->tpl->setOnScreenMessage('failure', $DIC['lng']->txt("file_not_found"));
772  $this->showContent();
773  }
774  }
775  } else {
776  $this->storage->consume()->download($this->object->getResourceId())->run();
777  }
778  } else {
779  $this->handleNonAccess();
780  }
781  }
782 
783  public function showDetails(): void
784  {
785  global $DIC;
786 
787  if ($DIC->access()->checkAccess('read', "", $this->object->getRefId())) {
788  $id = $DIC->http()->request()->getQueryParams()[self::P_ENTRY_ID];
789  $entry = $this->facade->entryFactory()
790  ->findByIdAndTypeString($id, $this->object->getFileTypeAsString());
791  $bibGUI = new ilBiblEntryDetailPresentationGUI(
792  $entry,
793  $this->facade,
794  $this->ctrl(),
795  $this->help,
796  $this->lng(),
797  $this->tpl(),
798  $this->tabs(),
799  $this->ui()
800  );
801 
802  $DIC->ui()->mainTemplate()->setContent($bibGUI->getHTML());
803  } else {
804  $this->handleNonAccess();
805  }
806  }
807 
808  public function view(): void
809  {
810  $this->showContent();
811  }
812 
813  public function toggleNotification(): void
814  {
815  global $DIC;
816  $ntf = $DIC->http()->wrapper()->query()->retrieve(
817  "ntf",
818  $DIC->refinery()->to()->int()
819  );
820 
821  switch ($ntf) {
822  case 1:
825  $DIC->user()
826  ->getId(),
828  false
829  );
830  break;
831  case 2:
834  $DIC->user()
835  ->getId(),
837  true
838  );
839  break;
840  }
841  $DIC->ctrl()->redirect($this, "");
842  }
843 
844  public function addNews(int $obj_id, string $change = 'created'): void
845  {
846  global $DIC;
847 
848  $ilNewsItem = new ilNewsItem();
849  $ilNewsItem->setTitle($DIC->language()->txt('news_title_' . $change));
850  $ilNewsItem->setPriority(NEWS_NOTICE);
851  $ilNewsItem->setContext($obj_id, $this->getType());
852  $ilNewsItem->setUserId($DIC->user()->getId());
853  $ilNewsItem->setVisibility(NEWS_USERS);
854  $ilNewsItem->setContentTextIsLangVar(false);
855  $ilNewsItem->create();
856  }
857 
862  public function addToDesk(): void
863  {
864  $this->addToDeskObject();
865  }
866 
871  public function removeFromDesk(): void
872  {
873  $this->removeFromDeskObject();
874  }
875 
876  protected function afterImport(ilObject $a_new_object): void
877  {
881  $a_new_object->parseFileToDatabase();
882 
883  parent::afterImport($a_new_object);
884  }
885 
886  private function handleNonAccess(): void
887  {
888  global $DIC;
889 
890  $this->tpl->setOnScreenMessage('failure', $DIC->language()->txt("no_permission"), true);
892  }
893 }
afterSave(ilObject $a_new_object)
Class ilObjBibliographicGUI.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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.
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)
putObjectInTree(ilObject $obj, int $parent_node_id=null)
Add object to tree at given position.
ilObjBibliographicStakeholder $stakeholder
sendFile()
provide file as a download
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilResourceStorageInfoGUI.
static _lookupObjId(int $ref_id)
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.
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.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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:25
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.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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...