ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
class.ilObjGlossaryGUI.php
Go to the documentation of this file.
1<?php
2
21
34{
35 protected \ILIAS\GlobalScreen\Services $global_screen;
37 protected \ILIAS\Glossary\InternalDomainService $domain;
38 protected \ILIAS\Glossary\InternalGUIService $gui;
39 protected \ILIAS\DI\UIServices $ui;
40 protected \ILIAS\Taxonomy\Service $taxonomy;
43 protected int $tax_node = 0;
45 protected $tax_id;
46 protected bool $in_administration = false;
47 protected \ILIAS\Glossary\Presentation\GUIService $gui_presentation_service;
49 protected \ILIAS\Glossary\Editing\EditingGUIRequest $edit_request;
51 public ?ilGlossaryTerm $term = null;
52 protected int $term_id = 0;
53 protected ilTabsGUI $tabs;
55 protected ilHelpGUI $help;
57 protected ilLogger $log;
58 protected \ILIAS\Style\Content\GUIService $content_style_gui;
59 protected \ILIAS\Style\Content\Object\ObjectFacade $content_style_domain;
60 protected \ILIAS\UI\Factory $ui_fac;
61 protected \ILIAS\UI\Renderer $ui_ren;
62 protected array $modals_to_render = [];
68
69 public function __construct(
70 $a_data,
71 int $a_id = 0,
72 bool $a_call_by_reference = true,
73 bool $a_prepare_output = true
74 ) {
75 global $DIC;
76
77 $service = $DIC->glossary()->internal();
78 $this->gui = $gui = $service->gui();
79 $this->domain = $domain = $service->domain();
80
81 $this->lng = $domain->lng();
82 $this->user = $domain->user();
83 $this->setting = $domain->settings();
84 $this->access = $domain->access();
85 $this->rbacsystem = $domain->rbac()->system();
86 $this->log = $domain->log();
87
88 $this->ctrl = $gui->ctrl();
89 $this->toolbar = $gui->toolbar();
90 $this->tabs = $gui->tabs();
91 $this->help = $gui->help();
92 $this->ui = $gui->ui();
93 $this->ui_fac = $gui->ui()->factory();
94 $this->ui_ren = $gui->ui()->renderer();
95 $this->global_screen = $gui->globalScreen();
96 $this->gui_presentation_service = $gui->presentation();
97
98 $this->edit_request = $gui->editing()->request();
99 $this->term_perm = ilGlossaryTermPermission::getInstance();
100 $this->requested_table_glossary_term_list_action = $this->edit_request->getTableGlossaryTermListAction();
101 $this->requested_table_glossary_term_list_ids = $this->edit_request->getTableGlossaryTermListIds();
102
103 $this->ctrl->saveParameter($this, array("ref_id"));
104 $this->lng->loadLanguageModule("content");
105 $this->lng->loadLanguageModule("glo");
106
107 $this->type = "glo";
108 parent::__construct($a_data, $a_id, $a_call_by_reference, false);
109
110 // determine term id and check whether it is valid (belongs to
111 // current glossary)
112 if (($this->requested_table_glossary_term_list_action == "editTerm"
113 || $this->requested_table_glossary_term_list_action == "editDefinition")
114 && !empty($this->requested_table_glossary_term_list_ids)) {
115 $this->term_id = $this->requested_table_glossary_term_list_ids[0];
116 } else {
117 $this->term_id = $this->edit_request->getTermId();
118 }
119 $term_glo_id = ilGlossaryTerm::_lookGlossaryID($this->term_id);
120 if ($this->term_id > 0 && $term_glo_id != $this->object->getId()
121 && !ilGlossaryTermReferences::isReferenced([$this->object->getId()], $this->term_id)) {
122 $this->term_id = 0;
123 }
124 $this->ctrl->setParameterByClass("ilglossarytermgui", "term_id", $this->term_id);
125
126 $this->tax_id = $this->object->getTaxonomyId();
127 if ($this->tax_id > 0) {
128 $this->ctrl->saveParameter($this, array("show_tax", "tax_node"));
129
130 $this->tax = new ilObjTaxonomy($this->tax_id);
131 }
132 $tax_node = $this->edit_request->getTaxNode();
133 if ($tax_node > 1 && $this->tax->getTree()->readRootId() != $tax_node) {
134 $this->tax_node = $tax_node;
135 }
136
137 if ($this->getGlossary()) {
138 $this->term_manager = $domain->term(
139 $this->getGlossary(),
140 $this->user->getId()
141 );
142 $this->tax_manager = $domain->taxonomy(
143 $this->getGlossary()
144 );
145 }
146
147 $this->term_def_bulk_gui = $this->gui_presentation_service
148 ->TermDefinitionBulkCreationGUI($this->getGlossary());
149
150 $this->in_administration =
151 (strtolower($this->edit_request->getBaseClass()) == "iladministrationgui");
152 $cs = $DIC->contentStyle();
153 $this->content_style_gui = $cs->gui();
154 if (is_object($this->object)) {
155 $this->content_style_domain = $cs->domain()->styleForRefId($this->object->getRefId());
156 $this->taxonomy = $DIC->taxonomy();
157 }
158 }
159
160 public function executeCommand(): void
161 {
162 $cmd = $this->ctrl->getCmd();
163 $next_class = $this->ctrl->getNextClass($this);
164
165 $this->log->debug("glossary term, next class " . $next_class . ", cmd: " . $cmd);
166
167 switch ($next_class) {
168 case 'ilobjectmetadatagui':
169 $this->checkPermission("write");
170
171 $this->getTemplate();
172 $this->setTabs();
173 $this->setLocator();
174 $this->addHeaderAction();
175
176 $this->tabs_gui->activateTab('meta_data');
177 $md_gui = new ilObjectMetaDataGUI($this->object, 'term');
178 $this->ctrl->forwardCommand($md_gui);
179 break;
180
181 case "ilglossarytermgui":
182 if (!$this->term_perm->checkPermission("edit_content", $this->term_id) &&
183 !$this->term_perm->checkPermission("write", $this->term_id)) {
184 throw new ilGlossaryException("No permission.");
185 }
186 $this->getTemplate();
187 $this->ctrl->setReturn($this, "listTerms");
188 $term_gui = new ilGlossaryTermGUI($this->term_id);
189 $term_gui->setGlossary($this->getGlossary());
190 $this->ctrl->forwardCommand($term_gui);
191 break;
192
193 case "ilinfoscreengui":
194 $this->addHeaderAction();
195 $this->showInfoScreen();
196 $this->tabs->activateTab("info_short");
197 break;
198
199 case "ilobjectcontentstylesettingsgui":
200 $this->checkPermission("write");
201 $this->prepareOutput();
202 $this->addHeaderAction();
203 $this->tabs_gui->activateTab("settings");
204 $this->setSettingsSubTabs("style");
205 $settings_gui = $this->content_style_gui
206 ->objectSettingsGUIForRefId(
207 null,
208 $this->object->getRefId()
209 );
210 $this->ctrl->forwardCommand($settings_gui);
211 break;
212
213
214 case 'ilpermissiongui':
215 if ($this->in_administration) {
216 $this->prepareOutput();
217 } else {
218 $this->getTemplate();
219 $this->setTabs();
220 $this->setLocator();
221 $this->addHeaderAction();
222 }
223 $perm_gui = new ilPermissionGUI($this);
224 $ret = $this->ctrl->forwardCommand($perm_gui);
225 break;
226
227 case "ilcommonactiondispatchergui":
229 $this->prepareOutput();
230 $this->ctrl->forwardCommand($gui);
231 break;
232
233 case strtolower(ilTaxonomySettingsGUI::class):
234 $this->getTemplate();
235 $this->setTabs();
236 $this->setLocator();
237 $this->addHeaderAction();
238 $this->tabs->activateTab("settings");
239 $this->setSettingsSubTabs("taxonomy");
240
241 $this->ctrl->setReturn($this, "properties");
242 $tax_gui = $this->taxonomy->gui()->getSettingsGUI(
243 $this->object->getId(),
244 $this->lng->txt("glo_tax_info"),
245 false,
246 $this
247 );
248 $ret = $this->ctrl->forwardCommand($tax_gui);
249 break;
250
251 case "ilexportgui":
252 $this->checkPermission("write");
253 $this->getTemplate();
254 $this->setTabs();
255 $this->tabs->activateTab("export");
256 $this->setLocator();
257 $exp_gui = new ilExportGUI($this);
258 $ret = $this->ctrl->forwardCommand($exp_gui);
259 break;
260
261 case 'ilobjectcopygui':
262 $this->prepareOutput();
263 $cp = new ilObjectCopyGUI($this);
264 $cp->setType('glo');
265 $this->ctrl->forwardCommand($cp);
266 break;
267
268 case "ilglossaryforeigntermcollectorgui":
269 if (!$this->rbacsystem->checkAccess('write', $this->object->getRefId()) &&
270 !$this->rbacsystem->checkAccess('edit_content', $this->object->getRefId())) {
271 throw new ilGlossaryException("No permission.");
272 }
273 $this->ctrl->setReturn($this, "");
274 $this->getTemplate();
275 $this->setTabs();
276 $this->setLocator();
277 $this->addHeaderAction();
279 $this->ctrl->forwardCommand($coll);
280 break;
281
282 case "iltermdefinitionbulkcreationgui":
283 if (!$this->rbacsystem->checkAccess('write', $this->object->getRefId()) &&
284 !$this->rbacsystem->checkAccess('edit_content', $this->object->getRefId())) {
285 throw new ilGlossaryException("No permission.");
286 }
287 $this->ctrl->setReturn($this, "listTerms");
288 $this->ctrl->forwardCommand($this->term_def_bulk_gui);
289 break;
290
291 case strtolower(ilMediaObjectOverviewGUI::class):
292 if (!$this->rbacsystem->checkAccess('write', $this->object->getRefId()) &&
293 !$this->rbacsystem->checkAccess('edit_content', $this->object->getRefId())) {
294 throw new ilGlossaryException("No permission.");
295 }
296
297 $this->getTemplate();
298 $this->setTabs();
299 $this->tabs->activateTab("media");
300 $this->setLocator();
301
302 $retrieval = new TermPageRetrieval($this->getGlossary(), $this->ctrl);
303 $gui = new ilMediaObjectOverviewGUI($retrieval);
304 $this->ctrl->forwardCommand($gui);
305 break;
306
307 case strtolower(SettingsGUI::class):
308 $this->checkPermission("write");
309 $this->getTemplate();
310 $this->setTabs();
311 $this->tabs->activateTab("settings");
312 $this->setLocator();
313 $this->setSettingsSubTabs("general_settings");
314 $this->checkPermission("write");
315 $gui = $this->gui->settings()->settingsGUI(
316 $this->object->getId(),
317 $this->requested_ref_id,
318 $this->getCreationMode(),
319 $this,
320 $this->object
321 );
322 $this->ctrl->forwardCommand($gui);
323 break;
324
325 default:
326 if (!$this->rbacsystem->checkAccess('write', $this->object->getRefId()) &&
327 !$this->rbacsystem->checkAccess('edit_content', $this->object->getRefId())) {
328 throw new ilGlossaryException("No permission.");
329 }
330 $cmd = $this->ctrl->getCmd("listTerms");
331
332 if (($cmd == "create") && ($this->edit_request->getNewType() == "term")) {
333 $this->ctrl->redirectByClass(ilGlossaryTermGUI::class, "create");
334 } else {
335 if ($this->in_administration ||
336 $this->getCreationMode()) {
337 $this->prepareOutput();
338 $cmd .= "Object";
339 } else {
340 $this->getTemplate();
341 $this->setTabs();
342 $this->setLocator();
343 $this->addHeaderAction();
344
345 if ($cmd == "redrawHeaderAction") {
346 $cmd = "redrawHeaderActionObject";
347 }
348 }
349 $this->$cmd();
350 }
351 break;
352 }
353
354 if (!$this->in_administration && !$this->getCreationMode()) {
355 $this->tpl->printToStdout();
356 }
357 }
358
362 public function getGlossary(): ?ilObjGlossary
363 {
365 $glossary = $this->object;
366 if (isset($glossary) && $glossary->getType() == "glo") {
367 return $glossary;
368 }
369 return null;
370 }
371
372 protected function assignObject(): void
373 {
374 $this->object = new ilObjGlossary($this->id, true);
375 }
376
377 protected function initCreateForm(string $new_type): ilPropertyFormGUI
378 {
379 $form = new ilPropertyFormGUI();
380 $form->setTarget("_top");
381 $form->setFormAction($this->ctrl->getFormAction($this));
382 $form->setTitle($this->lng->txt($new_type . "_new"));
383
384 // title
385 $ti = new ilTextInputGUI($this->lng->txt("title"), "title");
386 $ti->setSize(min(40, ilObject::TITLE_LENGTH));
387 $ti->setMaxLength(ilObject::TITLE_LENGTH);
388 $ti->setRequired(true);
389 $form->addItem($ti);
390
391 // description
392 $ta = new ilTextAreaInputGUI($this->lng->txt("description"), "desc");
393 $ta->setCols(40);
394 $ta->setRows(2);
395 $form->addItem($ta);
396
397 // didactic template
398 $form = $this->initDidacticTemplate($form);
399
400 $form->addCommandButton("save", $this->lng->txt($new_type . "_add"));
401 $form->addCommandButton("cancel", $this->lng->txt("cancel"));
402
403 return $form;
404 }
405
406 public function importObject(): void
407 {
408 $this->createObject();
409 }
410
411 public function saveObject(): void
412 {
413 $new_type = $this->edit_request->getNewType();
414
415 // create permission is already checked in createObject. This check here is done to prevent hacking attempts
416 if (!$this->checkPermissionBool("create", "", $new_type)) {
417 throw new ilPermissionException($this->lng->txt("no_create_permission"));
418 }
419
420 $this->lng->loadLanguageModule($new_type);
421 $this->ctrl->setParameter($this, "new_type", $new_type);
422
423 $form = $this->initCreateForm($new_type);
424 if ($form->checkInput()) {
425 $this->ctrl->setParameter($this, "new_type", "");
426
427 $newObj = new ilObjGlossary();
428 $newObj->setType($new_type);
429 $newObj->setTitle($form->getInput("title"));
430 $newObj->setDescription($form->getInput("desc"));
431 $newObj->setVirtualMode("none");
432 $newObj->create();
433
434 $this->putObjectInTree($newObj);
435
436 // apply didactic template?
437 $dtpl = $this->getDidacticTemplateVar("dtpl");
438 if ($dtpl) {
439 $newObj->applyDidacticTemplate($dtpl);
440 }
441
442 // always send a message
443 $this->tpl->setOnScreenMessage('success', $this->lng->txt("glo_added"), true);
444 $this->ctrl->setParameterByClass(
445 ilObjGlossaryGUI::class,
446 "ref_id",
447 $newObj->getRefId()
448 );
449 $this->ctrl->redirectByClass(
450 [ilGlossaryEditorGUI::class, ilObjGlossaryGUI::class],
451 "properties"
452 );
453 }
454
455 // display only this form to correct input
457 $this->tpl->setContent($form->getHTML());
458 }
459
460 public function showInfoScreen(): void
461 {
462 $this->getTemplate();
463 $this->setTabs();
464 $this->setLocator();
465 $this->lng->loadLanguageModule("meta");
466
467 $info = new ilInfoScreenGUI($this);
468 $info->enablePrivateNotes();
469 $info->enableNews();
470 if ($this->access->checkAccess("write", "", $this->requested_ref_id)) {
471 $info->enableNewsEditing();
472 $news_set = new ilSetting("news");
473 $enable_internal_rss = $news_set->get("enable_rss_for_internal");
474 if ($enable_internal_rss) {
475 $info->setBlockProperty("news", "settings", true);
476 }
477 }
478 $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
479
480 self::addUsagesToInfo($info, $this->object->getId());
481
482 $this->ctrl->forwardCommand($info);
483 }
484
488 public static function addUsagesToInfo(
490 int $glo_id
491 ): void {
492 global $DIC;
493
494 $lng = $DIC->language();
495 $ilAccess = $DIC->access();
496
497 $info->addSection($lng->txt("glo_usages"));
499 foreach ($sms as $sm) {
500 $link = false;
501 $refs = ilObject::_getAllReferences($sm);
502 foreach ($refs as $ref) {
503 if ($link === false && $ilAccess->checkAccess("write", "", $ref)) {
504 $link = ilLink::_getLink($ref, 'sahs');
505 }
506 }
507
508 $entry = ilObject::_lookupTitle($sm);
509 if ($link !== false) {
510 $entry = "<a href='" . $link . "' target='_top'>" . $entry . "</a>";
511 }
512
513 $info->addProperty($lng->txt("obj_sahs"), $entry);
514 }
515 }
516
517
518 public function viewObject(): void
519 {
520 if ($this->in_administration) {
521 parent::viewObject();
522 return;
523 }
524
525 if (!$this->rbacsystem->checkAccess("visible,read", $this->object->getRefId())) {
526 throw new ilPermissionException($this->lng->txt("permission_denied"));
527 }
528 }
529
530 public function properties(): void
531 {
532 $this->ctrl->redirectByClass(SettingsGUI::class);
533 }
534
535 public function getProperties(
536 int $tax_id
537 ): array {
538 $active = $this->object->getShowTaxonomy();
539 $value = $active
540 ? $this->lng->txt("yes")
541 : $this->lng->txt("no");
542
543 return [
544 $this->lng->txt("glo_show_in_presentation") => $value
545 ];
546 }
547
548 public function getActions(
549 int $tax_id
550 ): array {
551 $actions = [];
552 $this->ctrl->setParameterByClass(self::class, "glo_tax_id", $tax_id);
553 $active = $this->object->getShowTaxonomy();
554 if (!$active) {
555 $actions[] = $this->ui->factory()->button()->shy(
556 $this->lng->txt("glo_show_in_presentation_on"),
557 $this->ctrl->getLinkTargetByClass(
558 self::class,
559 "showTaxInPresentation"
560 )
561 );
562 } else {
563 $actions[] = $this->ui->factory()->button()->shy(
564 $this->lng->txt("glo_show_in_presentation_off"),
565 $this->ctrl->getLinkTargetByClass(
566 self::class,
567 "hideTaxInPresentation"
568 )
569 );
570 }
571 $this->ctrl->setParameterByClass(self::class, "glo_tax_id", null);
572
573 return $actions;
574 }
575
576 protected function showTaxInPresentation(): void
577 {
578 $this->object->setShowTaxonomy(true);
579 $this->object->update();
580 $this->ctrl->redirectByClass(ilTaxonomySettingsGUI::class);
581 }
582
583 protected function hideTaxInPresentation(): void
584 {
585 $this->object->setShowTaxonomy(false);
586 $this->object->update();
587 $this->ctrl->redirectByClass(ilTaxonomySettingsGUI::class);
588 }
589
590 public function listTerms(): void
591 {
592 $this->tabs->activateTab("content");
593
594 $this->showTaxonomy();
595
596 $panel_html = "";
597 $modals = "";
598 $tab_html = "";
599 if ($this->object->isVirtual()) {
600 $this->showToolbarForCollection();
601 $panel = $this->showSelectedGlossariesForCollection();
602 $panel_html = $this->ui_ren->render($panel);
603 $modals = $this->ui_ren->render($this->getModalsToRender());
604 } else {
605 $this->showToolbarForStandard();
606 $table = $this->domain->table()->getTermListTable($this->getGlossary(), $this->tax_node)->getComponent();
607 $tab_html = $this->ui_ren->render($table);
608 }
609
610 $this->tabs->activateTab("content");
611
612 $this->tpl->setContent($panel_html . $modals . $tab_html);
613 }
614
618 protected function getModalsToRender(): array
619 {
620 return $this->modals_to_render;
621 }
622
623 public function showToolbarForStandard(): void
624 {
625 // term
626 $ti = new ilTextInputGUI($this->lng->txt("cont_new_term"), "new_term");
627 $ti->setMaxLength(80);
628 $ti->setSize(20);
629 $this->toolbar->addInputItem($ti, true);
630
631 // language
632 $this->lng->loadLanguageModule("meta");
633 $lang = $this->domain->metadata()->getLOMLanguagesForSelectInputs();
634 $session_lang = $this->term_manager->getSessionLang();
635 if ($session_lang != "") {
636 $s_lang = $session_lang;
637 } else {
638 $s_lang = $this->user->getLanguage();
639 }
640 $si = new ilSelectInputGUI($this->lng->txt("language"), "term_language");
641 $si->setOptions($lang);
642 $si->setValue($s_lang);
643 $this->toolbar->addInputItem($si, true);
644
645 $this->toolbar->setFormAction($this->ctrl->getFormAction($this));
646 $this->toolbar->addFormButton($this->lng->txt("glo_add_new_term"), "addTerm");
647
648 $this->toolbar->addSeparator();
649
650 //ilEditClipboard::getAction() == "copy"
651 if ($this->user->clipboardHasObjectsOfType("term")) {
652 $this->toolbar->addButton(
653 $this->lng->txt("paste"),
654 $this->ctrl->getLinkTarget($this, "pasteTerms")
655 );
656 $this->toolbar->addButton(
657 $this->lng->txt("clear_clipboard"),
658 $this->ctrl->getLinkTarget($this, "clearClipboard")
659 );
660 } else {
661 $this->toolbar->addButton(
662 $this->lng->txt("glo_add_from_other"),
663 $this->ctrl->getLinkTargetByClass("ilglossaryforeigntermcollectorgui", "")
664 );
665 }
666
667 $this->term_def_bulk_gui->modifyToolbar($this->toolbar);
668 }
669
670 public function showToolbarForCollection(): void
671 {
672 $modal = $this->showModalForCollection();
673 $button = $this->ui_fac->button()->standard($this->lng->txt("glo_add_glossary"), "")->withOnClick($modal->getShowSignal());
674 $this->modals_to_render[] = $modal;
675 $this->toolbar->addComponent($button);
676 }
677
681 public function showSelectedGlossariesForCollection(): array
682 {
683 $items = [];
684 $glo_ids = $this->object->getAllGlossaryIds(true);
685 $at_least_one_glossary = false;
686 foreach ($glo_ids as $glo_id) {
687 if ($this->object->getId() === $glo_id) {
688 continue;
689 }
690 $glossary = new ilObjGlossary($glo_id, false);
691 $glo_ref_id = current(ilObject::_getAllReferences($glossary->getId()));
692 $glo_link = $this->ui_fac->link()->standard($glossary->getTitle(), ilLink::_getLink($glo_ref_id));
693 $glo_item = $this->ui_fac->item()->standard($glo_link);
694 $glo_item = $glo_item->withDescription($glossary->getDescription());
695 $form_action = $this->ctrl->getFormActionByClass(ilObjGlossaryGUI::class, "removeGlossaryFromCollection");
696 $delete_modal = $this->ui_fac->modal()->interruptive(
697 "",
698 $this->lng->txt("glo_really_remove_from_collection"),
699 $form_action
700 )->withAffectedItems([
701 $this->ui_fac->modal()->interruptiveItem()->standard(
702 $glossary->getId(),
703 $glossary->getTitle(),
704 $this->ui_fac->image()->standard(
705 ilObject::_getIcon($glossary->getId(), "small", $glossary->getType()),
706 $this->lng->txt("icon") . " " . $this->lng->txt("obj_" . $glossary->getType())
707 )
708 )
709 ]);
710 $actions = $this->ui_fac->dropdown()->standard([
711 $this->ui_fac->button()->shy($this->lng->txt("remove"), "")->withOnClick($delete_modal->getShowSignal()),
712 ]);
713 $glo_item = $glo_item->withActions($actions);
714
715 $items[] = $glo_item;
716 $this->modals_to_render[] = $delete_modal;
717 $at_least_one_glossary = true;
718 }
719
720 $components = [];
721 if (!$at_least_one_glossary) {
722 $message_box = $this->ui_fac->messageBox()->info($this->lng->txt("glo_collection_empty_info"));
723 $components[] = $message_box;
724 }
725 if (!empty($items)) {
726 $item_group = $this->ui_fac->item()->group($this->lng->txt("glo_selected_glossaries_info"), $items);
727 $panel = $this->ui_fac->panel()->listing()->standard(
728 $this->lng->txt("glo_selected_glossaries"),
729 [$item_group]
730 );
731 $components[] = $panel;
732 }
733
734 return $components;
735 }
736
737 public function showModalForCollection(): ILIAS\UI\Component\Modal\RoundTrip
738 {
740 $this,
741 "showModalForCollection",
742 $this,
743 "saveGlossaryForCollection",
744 "sel_glo_ref_id"
745 );
746 $modal = $this->ui_fac->modal()->roundtrip(
747 $this->lng->txt("glo_add_to_collection"),
748 $this->ui_fac->legacy()->content(!$exp->handleCommand() ? $exp->getHTML(true) : "")
749 );
750
751 return $modal;
752 }
753
754 public function saveGlossaryForCollection(): void
755 {
756 $selected_glo = new ilObjGlossary($this->edit_request->getSelectedGlossaryRefId(), true);
757 if ($selected_glo->getId() === $this->object->getId()) {
758 $this->tpl->setOnScreenMessage("info", $this->lng->txt("glo_selected_glossary_is_current_info"), true);
759 } else {
760 $this->object->addGlossaryForCollection($selected_glo->getId());
761 $this->tpl->setOnScreenMessage("success", $this->lng->txt("glo_added_to_collection_info"), true);
762 }
763 $this->ctrl->redirect($this, "listTerms");
764 }
765
766 public function removeGlossaryFromCollection(): void
767 {
768 $glo_id = $this->edit_request->getGlossaryIdInModal();
769 $this->object->removeGlossaryFromCollection($glo_id);
770 $this->tpl->setOnScreenMessage("success", $this->lng->txt("glo_removed_from_collection_info"), true);
771 $this->ctrl->redirect($this, "listTerms");
772 }
773
774 public function actTaxonomy(): void
775 {
776 $this->ctrl->setParameter($this, "show_tax", 1);
777 $this->ctrl->redirect($this, "listTerms");
778 }
779
783 public function deactTaxonomy(): void
784 {
785 $this->ctrl->setParameter($this, "show_tax", "");
786 $this->ctrl->redirect($this, "listTerms");
787 }
788
789
793 public function addTerm(): void
794 {
795 $new_term = $this->edit_request->getNewTerm();
796 if ($new_term == "") {
797 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("cont_please_enter_a_term"), true);
798 $this->ctrl->redirect($this, "listTerms");
799 }
800
801 // add term
802 $lang = $this->edit_request->getTermLanguage();
803 $term = new ilGlossaryTerm();
804 $term->setGlossary($this->getGlossary());
805 $term->setTerm($new_term);
806 $term->setLanguage($lang);
807 $term->create();
808
809 $this->term_manager->setSessionLang($lang);
810
811 $this->ctrl->setParameterByClass("ilglossarydefpagegui", "term_id", $term->getId());
812 $this->ctrl->redirectByClass(array("ilglossarytermgui",
813 "iltermdefinitioneditorgui", "ilglossarydefpagegui"), "edit");
814 }
815
819 public function exportHTML(): void
820 {
821 $glo_exp = new ilGlossaryExport($this->getGlossary(), "html");
822 $glo_exp->buildExportFileHTML();
823 $this->ctrl->redirectByClass("ilexportgui", "");
824 }
825
826 public function deleteTerms(): void
827 {
828 if (!empty($this->edit_request->getTermIdsInModal())
829 && $ids = $this->edit_request->getTermIdsInModal()) {
830 foreach ($ids as $id) {
831 if (ilGlossaryTermReferences::isReferenced([$this->object->getId()], $id)) {
832 $refs = new ilGlossaryTermReferences($this->object->getId());
833 $refs->deleteTerm($id);
834 $refs->update();
835 } else {
836 $this->term_manager->deleteTerm($id);
837 }
838 }
839 }
840 $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
841 $this->ctrl->redirect($this, "listTerms");
842 }
843
844 protected function setLocator(): void
845 {
846 if (strtolower($this->edit_request->getBaseClass()) != "ilglossaryeditorgui") {
847 parent::setLocator();
848 } elseif (is_object($this->object)) {
849 $gloss_loc = new ilGlossaryLocatorGUI();
850 if (is_object($this->term)) {
851 $gloss_loc->setTerm($this->term);
852 }
853 $gloss_loc->setGlossary($this->getGlossary());
854 $gloss_loc->display();
855 }
856 }
857
858 public function view(): void
859 {
860 $this->viewObject();
861 }
862
863 public function getTemplate(): void
864 {
865 $this->tpl->loadStandardTemplate();
866
867 $title = $this->object->getTitle();
868
869
870 if ($this->term_id > 0) {
871 $this->tpl->setTitle($this->lng->txt("term") . ": " .
872 ilGlossaryTerm::_lookGlossaryTerm($this->term_id));
873 } else {
874 parent::setTitleAndDescription();
875 $this->tpl->setTitleIcon(ilUtil::getImagePath("standard/icon_glo.svg"));
876 $this->tpl->setTitle($this->lng->txt("glo") . ": " . $title);
877 }
878 }
879
880 protected function getTabs(): void
881 {
882 $this->help->setScreenIdComponent("glo");
883
884 // list terms
885 $cmd = $this->ctrl->getCmd();
886 $force_active = ($cmd == "" || $cmd == "listTerms");
887
888
889 if ($this->rbacsystem->checkAccess('write', $this->object->getRefId()) ||
890 $this->rbacsystem->checkAccess('edit_content', $this->object->getRefId())) {
891 $this->tabs_gui->addTab(
892 "content",
893 $this->lng->txt("content"),
894 $this->ctrl->getLinkTarget($this, "listTerms")
895 );
896
897 // media
898 $this->lng->loadLanguageModule('mob');
899 $this->tabs_gui->addTab(
900 "media",
901 $this->lng->txt("mob_media"),
902 $this->ctrl->getLinkTargetByClass(ilMediaObjectOverviewGUI::class, "show")
903 );
904 }
905
906 $this->tabs_gui->addTab(
907 "info_short",
908 $this->lng->txt("info_short"),
909 $this->ctrl->getLinkTargetByClass("ilinfoscreengui", "showSummary")
910 );
911
912 // properties
913 if ($this->rbacsystem->checkAccess('write', $this->object->getRefId())) {
914 $this->tabs_gui->addTab(
915 "settings",
916 $this->lng->txt("settings"),
917 $this->ctrl->getLinkTargetByClass(SettingsGUI::class)
918 );
919
920 // meta data
921 $mdgui = new ilObjectMetaDataGUI($this->object, "term");
922 $mdtab = $mdgui->getTab();
923 if ($mdtab) {
924 $this->tabs_gui->addTab(
925 "meta_data",
926 $this->lng->txt("meta_data"),
927 $mdtab
928 );
929 }
930
931 // export
932 $this->tabs_gui->addTab(
933 "export",
934 $this->lng->txt("export"),
935 $this->ctrl->getLinkTargetByClass("ilexportgui", "")
936 );
937 }
938
939 // permissions
940 if ($this->rbacsystem->checkAccess('edit_permission', $this->object->getRefId())) {
941 $this->tabs_gui->addTab(
942 "perm_settings",
943 $this->lng->txt("perm_settings"),
944 $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm")
945 );
946 }
947
948 $this->tabs_gui->addNonTabbedLink(
949 "presentation_view",
950 $this->lng->txt("glo_presentation_view"),
951 "ilias.php?baseClass=ilGlossaryPresentationGUI&amp;ref_id=" . $this->object->getRefId()
952 );
953 }
954
955 public function setSettingsSubTabs(string $a_active): void
956 {
957 if (in_array(
958 $a_active,
959 array("general_settings", "style", "taxonomy", "glossaries")
960 )) {
961 // general properties
962 $this->tabs->addSubTab(
963 "general_settings",
964 $this->lng->txt("settings"),
965 $this->ctrl->getLinkTarget($this, 'properties')
966 );
967
968 // style properties
969 $this->tabs->addSubTab(
970 "style",
971 $this->lng->txt("obj_sty"),
972 $this->ctrl->getLinkTargetByClass("ilobjectcontentstylesettingsgui", '')
973 );
974
975 $this->taxonomy->gui()->addSettingsSubTab($this->getObject()->getId());
976
977 // style properties
978 $this->tabs->addSubTab(
979 "glossaries",
980 $this->lng->txt("cont_auto_glossaries"),
981 $this->ctrl->getLinkTarget($this, 'editGlossaries')
982 );
983
984 $this->tabs->activateSubTab($a_active);
985 }
986 }
987
988
989 public static function _goto(string $a_target): void
990 {
991 global $DIC;
992 $main_tpl = $DIC->ui()->mainTemplate();
993
994 $lng = $DIC->language();
995 $ilAccess = $DIC->access();
996 $ctrl = $DIC->ctrl();
997
998 if ($ilAccess->checkAccess("read", "", $a_target)) {
999 $ctrl->setParameterByClass("ilGlossaryPresentationGUI", "ref_id", $a_target);
1000 $ctrl->redirectByClass("ilGlossaryPresentationGUI", "");
1001 } elseif ($ilAccess->checkAccess("visible", "", $a_target)) {
1002 $ctrl->setParameterByClass("ilGlossaryPresentationGUI", "ref_id", $a_target);
1003 $ctrl->redirectByClass("ilGlossaryPresentationGUI", "infoScreen");
1004 } elseif ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID)) {
1005 $main_tpl->setOnScreenMessage('failure', sprintf(
1006 $lng->txt("msg_no_perm_read_item"),
1008 ), true);
1010 }
1011
1012 throw new ilPermissionException($lng->txt("no_permission"));
1013 }
1014
1015
1019
1020 public function setContentStyleSheet(
1021 ?ilGlobalTemplateInterface $a_tpl = null
1022 ): void {
1023 if ($a_tpl != null) {
1024 $ctpl = $a_tpl;
1025 } else {
1026 $ctpl = $this->tpl;
1027 }
1028
1029 $this->content_style_gui->addCss($ctpl, $this->object->getRefId());
1030 }
1031
1035 public function showTaxonomy(): void
1036 {
1037 $ctrl = $this->ctrl;
1038
1039 if (is_null($this->tax_manager) || !$this->tax_manager->showInEditing()) {
1040 return;
1041 }
1042
1043 $tool_context = $this->global_screen->tool()->context()->current();
1044
1045 $tax_id = $this->tax_manager->getTaxonomyId();
1046
1047 $tool_context->addAdditionalData(
1049 true
1050 );
1051 $tool_context->addAdditionalData(
1053 $ctrl->getCurrentClassPath()
1054 );
1055 $tool_context->addAdditionalData(
1057 $tax_id
1058 );
1059 $tool_context->addAdditionalData(
1061 "listTerms"
1062 );
1063 $tool_context->addAdditionalData(
1065 "showTaxonomy"
1066 );
1067 }
1068
1069 //
1070 // Auto glossaries
1071 //
1072
1076 public function editGlossaries(): void
1077 {
1078 $this->tabs->setTabActive("settings");
1079 $this->setSettingsSubTabs("glossaries");
1080
1081 $this->toolbar->addButton(
1082 $this->lng->txt("add"),
1083 $this->ctrl->getLinkTarget($this, "showGlossarySelector")
1084 );
1085
1086 $table = $this->domain->table()->getGlossaryAutoLinkTable($this->getGlossary())->getComponent();
1087
1088 $this->tpl->setContent($this->ui_ren->render($table));
1089 }
1090
1094 public function showGlossarySelector(): void
1095 {
1096 $this->tabs->setTabActive("settings");
1097 $this->setSettingsSubTabs("glossaries");
1098
1099 $exp = new ilSearchRootSelector($this->ctrl->getLinkTarget($this, 'showGlossarySelector'));
1100 $search_root_expand = $this->edit_request->getSearchRootExpand();
1101 $exp->setExpand($search_root_expand ?: $this->tree->readRootId());
1102 $exp->setExpandTarget($this->ctrl->getLinkTarget($this, 'showGlossarySelector'));
1103 $exp->setTargetClass(get_class($this));
1104 $exp->setCmd('confirmGlossarySelection');
1105 $exp->setClickableTypes(array("glo"));
1106 $exp->addFilter("glo");
1107
1108 // build html-output
1109 $exp->setOutput(0);
1110 $this->tpl->setContent($exp->getOutput());
1111 }
1112
1113 public function confirmGlossarySelection(): void
1114 {
1115 $cgui = new ilConfirmationGUI();
1116 $this->ctrl->setParameter($this, "glo_ref_id", $this->edit_request->getGlossaryRefId());
1117 $cgui->setFormAction($this->ctrl->getFormAction($this));
1118 $cgui->setHeaderText($this->lng->txt("glo_link_glo_in_glo"));
1119 $cgui->setCancel($this->lng->txt("no"), "selectGlossary");
1120 $cgui->setConfirm($this->lng->txt("yes"), "selectGlossaryLink");
1121 $this->tpl->setContent($cgui->getHTML());
1122 }
1123
1127 public function selectGlossaryLink(): void
1128 {
1129 $glo_ref_id = $this->edit_request->getGlossaryRefId();
1130 $this->object->autoLinkGlossaryTerms($glo_ref_id);
1131 $this->selectGlossary();
1132 }
1133
1134
1138 public function selectGlossary(): void
1139 {
1140 $glos = $this->object->getAutoGlossaries();
1141 $glo_ref_id = $this->edit_request->getGlossaryRefId();
1142 $glo_id = ilObject::_lookupObjId($glo_ref_id);
1143 if (!in_array($glo_id, $glos)) {
1144 $glos[] = $glo_id;
1145 }
1146 $this->object->setAutoGlossaries($glos);
1147 $this->object->update();
1148
1149 $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
1150 $this->ctrl->redirect($this, "editGlossaries");
1151 }
1152
1153 public function removeGlossary(): void
1154 {
1155 $this->object->removeAutoGlossary($this->edit_request->getGlossaryIdInModal());
1156 $this->object->update();
1157
1158 $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
1159 $this->ctrl->redirect($this, "editGlossaries");
1160 }
1161
1165 public function copyTerms(): void
1166 {
1167 $this->putTermsIntoClipBoard();
1168
1170 $this->tpl->setOnScreenMessage('info', $this->lng->txt("glo_selected_terms_have_been_copied"), true);
1171 $this->ctrl->redirect($this, "listTerms");
1172 }
1173
1177 public function referenceTerms(): void
1178 {
1179 $this->putTermsIntoClipBoard();
1180
1182 $this->tpl->setOnScreenMessage('info', $this->lng->txt("glo_selected_terms_have_been_copied"), true);
1183 $this->ctrl->redirect($this, "listTerms");
1184 }
1185
1186 protected function putTermsIntoClipBoard(): void
1187 {
1188 $this->user->clipboardDeleteObjectsOfType("term");
1189 $time = date("Y-m-d H:i:s");
1190 $order = 0;
1191 if (($this->requested_table_glossary_term_list_action === "copyTerms"
1192 || $this->requested_table_glossary_term_list_action === "referenceTerms")
1193 && !empty($this->requested_table_glossary_term_list_ids)
1194 && $this->requested_table_glossary_term_list_ids[0] === "ALL_OBJECTS"
1195 ) {
1196 $terms = $this->object->getTermList(
1197 "",
1198 "",
1199 "",
1200 $this->tax_node,
1201 true,
1202 true,
1203 null,
1204 false,
1205 true
1206 );
1207 foreach ($terms as $term) {
1208 $this->user->addObjectToClipboard(
1209 (int) $term["id"],
1210 "term",
1211 ilGlossaryTerm::_lookGlossaryTerm((int) $term["id"]),
1212 0,
1213 $time,
1214 $order
1215 );
1216 }
1217 } elseif ($this->requested_table_glossary_term_list_action === "copyTerms"
1218 || $this->requested_table_glossary_term_list_action === "referenceTerms") {
1219 foreach ($this->requested_table_glossary_term_list_ids as $term_id) {
1220 $this->user->addObjectToClipboard(
1221 (int) $term_id,
1222 "term",
1223 ilGlossaryTerm::_lookGlossaryTerm((int) $term_id),
1224 0,
1225 $time,
1226 $order
1227 );
1228 }
1229 }
1230 if (empty($this->requested_table_glossary_term_list_ids)) {
1231 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("no_checkbox"), true);
1232 $this->ctrl->redirect($this, "listTerms");
1233 }
1234 }
1235
1236
1237 public function clearClipboard(): void
1238 {
1239 $this->user->clipboardDeleteObjectsOfType("term");
1240 $this->ctrl->redirect($this, "listTerms");
1241 }
1242
1243 public function pasteTerms(): void
1244 {
1245 if (ilEditClipboard::getAction() == "copy") {
1246 foreach ($this->user->getClipboardObjects("term") as $item) {
1247 ilGlossaryTerm::_copyTerm($item["id"], $this->object->getId());
1248 }
1249 }
1250 if (ilEditClipboard::getAction() == "link") {
1251 $refs = new ilGlossaryTermReferences($this->object->getId());
1252 foreach ($this->user->getClipboardObjects("term") as $item) {
1253 $refs->addTerm($item["id"]);
1254 }
1255 $refs->update();
1256 }
1257 $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
1258 $this->ctrl->redirect($this, "listTerms");
1259 }
1260}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
$components
@ilCtrl_Calls ILIAS\Glossary\Settings\SettingsGUI: ilDidacticTemplateGUI
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static setAction(string $a_action)
Export User Interface Class.
setFormAction(string $a_formaction)
setTarget(string $a_target)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstance(ilObjGlossaryGUI $a_glossary_gui)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static isReferenced(array $a_glo_id, int $a_term_id)
Is a term referenced by a set of glossaries.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setGlossary(ilObjGlossary $a_glossary)
setTerm(string $a_term)
static _lookGlossaryTerm(int $term_id)
get glossary term
setLanguage(string $a_language)
create(bool $a_omit_page_creation=false)
static _lookGlossaryID(int $term_id)
get glossary id form term id
static _copyTerm(int $a_term_id, int $a_glossary_id)
Copy a term to a glossary.
Help GUI class.
Class ilInfoScreenGUI.
txt(string $a_topic, string $a_default_lang_fallback_mod="")
gets the text for a given topic if the topic is not in the list, the topic itself with "-" will be re...
Component logger with individual log levels by component id.
GUI class for ilGlossary.
exportHTML()
create html package
referenceTerms()
Add terms to be referenced to clipboard.
setContentStyleSheet(?ilGlobalTemplateInterface $a_tpl=null)
ILIAS GlobalScreen Services $global_screen
ILIAS Glossary Editing EditingGUIRequest $edit_request
ilTermDefinitionBulkCreationGUI $term_def_bulk_gui
array $requested_table_glossary_term_list_ids
ILIAS Glossary Term TermManager $term_manager
copyTerms()
Copy terms to clipboard.
ILIAS UI Renderer $ui_ren
initCreateForm(string $new_type)
ILIAS Glossary Taxonomy TaxonomyManager $tax_manager
viewObject()
viewObject container presentation for "administration -> repository, trash, permissions"
getTabs()
@abstract overwrite in derived GUI class of your object type
showTaxonomy()
Show taxonomy.
ILIAS Style Content Object ObjectFacade $content_style_domain
ILIAS Taxonomy Service $taxonomy
selectGlossaryLink()
Select a glossary and link all its terms.
ilPropertyFormGUI $form
showGlossarySelector()
Show auto glossary selection.
ILIAS Glossary InternalGUIService $gui
ilGlossaryTermPermission $term_perm
ILIAS DI UIServices $ui
string $requested_table_glossary_term_list_action
selectGlossary()
Select auto glossary.
ILIAS Style Content GUIService $content_style_gui
__construct( $a_data, int $a_id=0, bool $a_call_by_reference=true, bool $a_prepare_output=true)
ILIAS Glossary InternalDomainService $domain
deactTaxonomy()
Hide Taxonomy.
static _goto(string $a_target)
ILIAS Glossary Presentation GUIService $gui_presentation_service
setSettingsSubTabs(string $a_active)
static addUsagesToInfo(ilInfoScreenGUI $info, int $glo_id)
Add usages to info screen.
editGlossaries()
Edit automatically linked glossaries.
ILIAS UI Factory $ui_fac
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getScormModulesForGlossary(int $a_glo_id)
Get SCORM modules that assign a certain glossary.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
GUI class for the workflow of copying objects.
Class ilObjectGUI Basic methods of all Output classes.
static _gotoRepositoryRoot(bool $raise_error=false)
Goto repository root.
checkPermission(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
checkPermissionBool(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
initDidacticTemplate(ilPropertyFormGUI $form)
addHeaderAction()
Add header action menu.
createObject()
create new object form
putObjectInTree(ilObject $obj, ?int $parent_node_id=null)
Add object to tree at given position.
setTabs()
set admin tabs
getDidacticTemplateVar(string $type)
Get didactic template setting from creation screen.
prepareOutput(bool $show_sub_objects=true)
ilLanguage $lng
Class ilObjectMetaDataGUI.
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
const TITLE_LENGTH
static _getAllReferences(int $id)
get all reference ids for object ID
static _lookupObjId(int $ref_id)
static _lookupTitle(int $obj_id)
This class represents a property form user interface.
addCommandButton(string $a_cmd, string $a_text, string $a_id="")
getInput(string $a_post_var, bool $ensureValidation=true)
Returns the input of an item, if item provides getInput method and as fallback the value of the HTTP-...
class ilRbacSystem system function like checkAccess, addActiveRole ... Supporting system functions ar...
This class represents a selection list property in a property form.
ILIAS Setting Class.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This class represents a text area property in a property form.
This class represents a text property in a property form.
static getImagePath(string $image_name, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
const ROOT_FOLDER_ID
Definition: constants.php:32
$info
Definition: entry_point.php:21
$service
Definition: ltiresult.php:36
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
global $lng
Definition: privfeed.php:31
if(!file_exists('../ilias.ini.php'))
global $DIC
Definition: shib_login.php:26