ILIAS  trunk Revision v12.0_alpha-1540-g00f839d5fa1
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 $info_file_limitations = $this->lng->txt('file_allowed_suffixes') . " .bib, .bibtex, .ris";
489 $section_replace_bibliographic_file = $this->ui_factory
490 ->input()
491 ->field()
492 ->section(
493 [
494 self::PROP_BIBLIOGRAPHIC_FILE => $this->ui_factory
495 ->input()
496 ->field()
497 ->file(
498 $bibl_upload_handler,
499 $this->lng->txt('bibliography_file'),
500 $info_file_limitations
501 )
502 ->withRequired(true)
503 ->withAdditionalTransformation(
504 $this->getValidBiblFileSuffixConstraint()
505 )
506 ],
507 $this->lng->txt('replace_bibliography_file')
508 );
509
510 return $this->ui_factory->input()->container()->form()->standard(
511 $this->ctrl->getFormAction($this, self::CMD_REPLACE_BIBLIOGRAPHIC_FILE),
512 [
513 self::SECTION_REPLACE_BIBLIOGRAPHIC_FILE => $section_replace_bibliographic_file
514 ]
515 );
516 }
517
519 {
520 return $this->refinery->custom()->constraint(
521 function ($bibl_file_input): bool {
522 global $DIC;
523 $rid = $bibl_file_input[0];
524 $resource_identifier = $DIC->resourceStorage()->manage()->find($rid);
525 if ($resource_identifier !== null) {
526 $bibl_file = $DIC->resourceStorage()->manage()->getCurrentRevision($resource_identifier);
527 $bibl_file_suffix = $bibl_file->getInformation()->getSuffix();
528 if (in_array($bibl_file_suffix, ['ris', 'bib', 'bibtex'])) {
529 return true;
530 }
531 }
532 return false;
533 },
534 $this->lng->txt('msg_error_invalid_bibl_file_suffix')
535 );
536 }
537
543 #[Override]
544 public function setTabs(): void
545 {
546 global $DIC;
547
548 $ilHelp = $DIC['ilHelp'];
552 $ilHelp->setScreenIdComponent('bibl');
553 // info screen
554 if ($DIC->access()->checkAccess('read', "", $this->object->getRefId())) {
555 $DIC->tabs()->addTab(
556 self::TAB_CONTENT,
557 $DIC->language()
558 ->txt(self::TAB_CONTENT),
559 $this->ctrl->getLinkTarget($this, self::CMD_SHOW_CONTENT)
560 );
561 }
562 // info screen
563 if ($DIC->access()->checkAccess('visible', "", $this->object->getRefId())
564 || $DIC->access()->checkAccess('read', "", $this->object->getRefId())
565 ) {
566 $DIC->tabs()->addTab(
567 self::TAB_ID_INFO,
568 $DIC->language()
569 ->txt("info_short"),
570 $this->ctrl->getLinkTargetByClass("ilinfoscreengui", "showSummary")
571 );
572 }
573 // settings
574 if ($DIC->access()->checkAccess('write', "", $this->object->getRefId())) {
575 $DIC->tabs()->addTab(
576 self::SUBTAB_SETTINGS,
577 $DIC->language()
578 ->txt(self::SUBTAB_SETTINGS),
579 $this->ctrl->getLinkTarget($this, self::CMD_EDIT_OBJECT)
580 );
581 }
582 // export
583 if ($DIC->access()->checkAccess("write", "", $this->object->getRefId())) {
584 $DIC->tabs()->addTab(
585 self::TAB_EXPORT,
586 $DIC->language()
587 ->txt(self::TAB_EXPORT),
588 $this->ctrl->getLinkTargetByClass("ilexportgui", "")
589 );
590 }
591 // edit permissions
592 if ($DIC->access()->checkAccess('edit_permission', "", $this->object->getRefId())) {
593 $DIC->tabs()->addTab(
594 self::TAB_ID_PERMISSIONS,
595 $DIC->language()
596 ->txt("perm_settings"),
597 $this->ctrl->getLinkTargetByClass("ilpermissiongui", "perm")
598 );
599 }
600 }
601
602 protected function initSubTabs(): void
603 {
604 global $DIC;
605 $DIC->tabs()->addSubTab(
606 self::SUBTAB_SETTINGS,
607 $DIC->language()
608 ->txt(self::SUBTAB_SETTINGS),
609 $this->ctrl->getLinkTarget($this, self::CMD_EDIT_OBJECT)
610 );
611 $DIC->tabs()->addSubTab(
612 self::SUB_TAB_FILTER,
613 $DIC->language()
614 ->txt("bibl_filter"),
615 $this->ctrl->getLinkTargetByClass(ilBiblFieldFilterGUI::class, ilBiblFieldFilterGUI::CMD_STANDARD)
616 );
617 }
618
623 #[Override]
624 public function editObject(): void
625 {
626 if (!$this->checkPermissionBool("write")) {
627 $this->error->raiseError($this->lng->txt("msg_no_perm_write"), $this->error->MESSAGE);
628 }
629
630 $this->tabs_gui->activateTab("settings");
631 $form = $this->getSettingsForm();
632 $this->tpl->setContent($this->ui()->renderer()->render($form));
633 }
634
635 public function getSettingsForm(): Standard
636 {
637 $field_factory = $this->ui_factory->input()->field();
638
639 $section_edit_bibliography = $field_factory->section(
640 [
641 self::PROP_TITLE_AND_DESC => $this->object->getObjectProperties()->getPropertyTitleAndDescription(
642 )->toForm(
643 $this->lng,
645 $this->refinery
646 )
647 ],
648 $this->lng->txt('bibl_edit'),
649 ''
650 );
651 $section_availability = $field_factory->section(
652 [
653 self::PROP_ONLINE_STATUS => $this->object->getObjectProperties()->getPropertyIsOnline()->toForm(
654 $this->lng,
656 $this->refinery
657 )
658 ],
659 $this->lng->txt('rep_activation_availability'),
660 ''
661 );
662 $section_presentation = $field_factory->section(
663 [
664 self::PROP_TILE_IMAGE => $this->object->getObjectProperties()->getPropertyTileImage()->toForm(
665 $this->lng,
667 $this->refinery
668 )
669 ],
670 $this->lng->txt('settings_presentation_header'),
671 ''
672 );
673
674 return $this->ui_factory->input()->container()->form()->standard(
675 $this->ctrl->getFormAction($this, self::CMD_UPDATE_OBJECT),
676 [
677 self::SECTION_EDIT_BIBLIOGRAPHY => $section_edit_bibliography,
678 self::SECTION_AVAILABILITY => $section_availability,
679 self::SECTION_PRESENTATION => $section_presentation
680 ]
681 );
682 }
683
684 public function render(): void
685 {
686 $this->showContent();
687 }
688
692 public function showContent(): void
693 {
694 // if user has read permission and object is online OR user has write permissions
695 $read_access = $this->access->checkAccess('read', "", $this->object->getRefId());
696 $online = $this->object->getObjectProperties()->getPropertyIsOnline()->getIsOnline();
697 $write_access = $this->access->checkAccess('write', "", $this->object->getRefId());
698 if (($read_access && $online) || $write_access) {
699 $this->tabs_gui->activateTab(self::TAB_CONTENT);
700
701 $btn_download_original_file = $this->ui()->factory()->button()->primary(
702 $this->lng->txt('download_original_file'),
703 $this->ctrl->getLinkTargetByClass(self::class, self::CMD_SEND_FILE)
704 );
705 $this->toolbar->addComponent($btn_download_original_file);
706
707 if ($write_access) {
708 $btn_overwrite_bibliographic_file = $this->ui()->factory()->button()->standard(
709 $this->lng->txt('replace_bibliography_file'),
710 $this->ctrl->getLinkTargetByClass(self::class, self::CMD_OVERWRITE_BIBLIOGRAPHIC_FILE)
711 );
712 $this->toolbar->addComponent($btn_overwrite_bibliographic_file);
713 }
714
715 $table_gui = new ilBiblEntryTableGUI($this, $this->facade, $this->ui());
716 $this->tpl->setContent($table_gui->getRenderedTableAndExistingFilters());
717
718 //Permanent Link
719 $this->tpl->setPermanentLink("bibl", $this->object->getRefId());
720 } else {
721 $object_title = ilObject::_lookupTitle(ilObject::_lookupObjId($this->ref_id));
722 $this->tpl->setOnScreenMessage(
723 'failure',
724 sprintf(
725 $DIC->language()
726 ->txt("msg_no_perm_read_item"),
727 $object_title
728 ),
729 true
730 );
731 //redirect to repository without any parameters
732 $this->handleNonAccess();
733 }
734 }
735
736 protected function applyFilter(): void
737 {
738 $table = new ilBiblEntryTableGUI($this, $this->facade, $this->ui());
739 $table->writeFilterToSession();
740 $table->resetOffset();
741 $this->ctrl->redirect($this, self::CMD_SHOW_CONTENT);
742 }
743
744 protected function resetFilter(): void
745 {
746 $table = new ilBiblEntryTableGUI($this, $this->facade, $this->ui());
747 $table->resetFilter();
748 $table->resetOffset();
749 $this->ctrl->redirect($this, self::CMD_SHOW_CONTENT);
750 }
751
755 public function sendFile(): void
756 {
757 global $DIC;
758
759 if ($DIC['ilAccess']->checkAccess('read', "", $this->object->getRefId())) {
760 if (!$this->object->isMigrated()) {
761 $file_path = $this->object->getLegacyAbsolutePath();
762 if ($file_path) {
763 if (is_file($file_path)) {
765 $file_path,
766 $this->object->getFilename(),
767 'application/octet-stream'
768 );
769 } else {
770 $this->tpl->setOnScreenMessage('failure', $DIC['lng']->txt("file_not_found"));
771 $this->showContent();
772 }
773 }
774 } else {
775 $this->storage->consume()->download($this->object->getResourceId())->run();
776 }
777 } else {
778 $this->handleNonAccess();
779 }
780 }
781
782 public function showDetails(): void
783 {
784 global $DIC;
785
786 if ($DIC->access()->checkAccess('read', "", $this->object->getRefId())) {
787 $id = $DIC->http()->request()->getQueryParams()[self::P_ENTRY_ID];
788 $entry = $this->facade->entryFactory()
789 ->findByIdAndTypeString($id, $this->object->getFileTypeAsString());
791 $entry,
792 $this->facade,
793 $this->ctrl(),
794 $this->help,
795 $this->lng(),
796 $this->tpl(),
797 $this->tabs(),
798 $this->ui()
799 );
800
801 $DIC->ui()->mainTemplate()->setContent($bibGUI->getHTML());
802 } else {
803 $this->handleNonAccess();
804 }
805 }
806
807 #[Override]
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(),
827 $this->obj_id,
828 false
829 );
830 break;
831 case 2:
834 $DIC->user()
835 ->getId(),
836 $this->obj_id,
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 #[Override]
877 protected function afterImport(ilObject $a_new_object): void
878 {
882 $a_new_object->parseFileToDatabase();
883
884 parent::afterImport($a_new_object);
885 }
886
887 private function handleNonAccess(): void
888 {
889 global $DIC;
890
891 $this->tpl->setOnScreenMessage('failure', $DIC->language()->txt("no_permission"), true);
893 }
894}
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:30
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