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