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