ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilObjGlossaryGUI.php
Go to the documentation of this file.
1 <?php
2 
29 {
30  protected \ILIAS\GlobalScreen\Services $global_screen;
32  protected \ILIAS\Glossary\InternalDomainService $domain;
33  protected \ILIAS\Glossary\InternalGUIService $gui;
34  protected \ILIAS\DI\UIServices $ui;
35  protected \ILIAS\Taxonomy\Service $taxonomy;
38  protected int $tax_node = 0;
39  protected ilObjTaxonomy $tax;
40  protected $tax_id;
41  protected bool $in_administration = false;
42  protected \ILIAS\Glossary\Presentation\GUIService $gui_presentation_service;
44  protected \ILIAS\Glossary\Editing\EditingGUIRequest $edit_request;
46  public ?ilGlossaryTerm $term = null;
47  protected int $term_id = 0;
48  protected ilTabsGUI $tabs;
49  protected ilSetting $setting;
50  protected ilHelpGUI $help;
52  protected ilLogger $log;
53  protected \ILIAS\Style\Content\GUIService $content_style_gui;
54  protected \ILIAS\Style\Content\Object\ObjectFacade $content_style_domain;
55  protected \ILIAS\UI\Factory $ui_fac;
56  protected \ILIAS\UI\Renderer $ui_ren;
57  protected array $modals_to_render = [];
58 
59  public function __construct(
60  $a_data,
61  int $a_id = 0,
62  bool $a_call_by_reference = true,
63  bool $a_prepare_output = true
64  ) {
65  global $DIC;
66 
67  $service = $DIC->glossary()->internal();
68  $this->gui = $gui = $service->gui();
69  $this->domain = $domain = $service->domain();
70 
71  $this->lng = $domain->lng();
72  $this->user = $domain->user();
73  $this->setting = $domain->settings();
74  $this->access = $domain->access();
75  $this->rbacsystem = $domain->rbac()->system();
76  $this->log = $domain->log();
77 
78  $this->ctrl = $gui->ctrl();
79  $this->toolbar = $gui->toolbar();
80  $this->tabs = $gui->tabs();
81  $this->help = $gui->help();
82  $this->ui = $gui->ui();
83  $this->ui_fac = $gui->ui()->factory();
84  $this->ui_ren = $gui->ui()->renderer();
85  $this->global_screen = $gui->globalScreen();
86  $this->gui_presentation_service = $gui->presentation();
87 
88  $this->edit_request = $gui->editing()->request();
89  $this->term_perm = ilGlossaryTermPermission::getInstance();
90 
91  $this->ctrl->saveParameter($this, array("ref_id"));
92  $this->lng->loadLanguageModule("content");
93  $this->lng->loadLanguageModule("glo");
94 
95  $this->type = "glo";
96  parent::__construct($a_data, $a_id, $a_call_by_reference, false);
97 
98  // determine term id and check whether it is valid (belongs to
99  // current glossary)
100  $this->term_id = $this->edit_request->getTermId();
101  $term_glo_id = ilGlossaryTerm::_lookGlossaryID($this->term_id);
102  if ($this->term_id > 0 && $term_glo_id != $this->object->getId()
104  $this->term_id = 0;
105  }
106 
107  $this->tax_id = $this->object->getTaxonomyId();
108  if ($this->tax_id > 0) {
109  $this->ctrl->saveParameter($this, array("tax_node"));
110 
111  $this->tax = new ilObjTaxonomy($this->tax_id);
112  }
113  $tax_node = $this->edit_request->getTaxNode();
114  if ($tax_node > 1 && $this->tax->getTree()->readRootId() != $tax_node) {
115  $this->tax_node = $tax_node;
116  }
117 
118  if ($this->getGlossary()) {
119  $this->term_manager = $domain->term(
120  $this->getGlossary(),
121  $this->user->getId()
122  );
123  $this->tax_manager = $domain->taxonomy(
124  $this->getGlossary()
125  );
126  }
127 
128  $this->term_def_bulk_gui = $this->gui_presentation_service
129  ->TermDefinitionBulkCreationGUI($this->getGlossary());
130 
131  $this->in_administration =
132  (strtolower($this->edit_request->getBaseClass()) == "iladministrationgui");
133  $cs = $DIC->contentStyle();
134  $this->content_style_gui = $cs->gui();
135  if (is_object($this->object)) {
136  $this->content_style_domain = $cs->domain()->styleForRefId($this->object->getRefId());
137  $this->taxonomy = $DIC->taxonomy();
138  }
139  }
140 
141  public function executeCommand(): void
142  {
143  $cmd = $this->ctrl->getCmd();
144  $next_class = $this->ctrl->getNextClass($this);
145 
146  $this->log->debug("glossary term, next class " . $next_class . ", cmd: " . $cmd);
147 
148  switch ($next_class) {
149  case 'ilobjectmetadatagui':
150  $this->checkPermission("write");
151 
152  $this->getTemplate();
153  $this->setTabs();
154  $this->setLocator();
155  $this->addHeaderAction();
156 
157  $this->tabs_gui->activateTab('meta_data');
158  $md_gui = new ilObjectMetaDataGUI($this->object, 'term');
159  $this->ctrl->forwardCommand($md_gui);
160  break;
161 
162  case "ilglossarytermgui":
163  if (!$this->term_perm->checkPermission("edit_content", $this->term_id) &&
164  !$this->term_perm->checkPermission("write", $this->term_id)) {
165  throw new ilGlossaryException("No permission.");
166  }
167  $this->getTemplate();
168  // $this->quickList();
169  $this->ctrl->setReturn($this, "listTerms");
170  $term_gui = new ilGlossaryTermGUI($this->term_id);
171  $term_gui->setGlossary($this->getGlossary());
172  $this->ctrl->forwardCommand($term_gui);
173  break;
174 
175  case "ilinfoscreengui":
176  $this->addHeaderAction();
177  $this->showInfoScreen();
178  break;
179 
180  case "ilobjectcontentstylesettingsgui":
181  $this->checkPermission("write");
182  $this->prepareOutput();
183  $this->addHeaderAction();
184  $this->tabs_gui->activateTab("settings");
185  $this->setSettingsSubTabs("style");
186  $settings_gui = $this->content_style_gui
187  ->objectSettingsGUIForRefId(
188  null,
189  $this->object->getRefId()
190  );
191  $this->ctrl->forwardCommand($settings_gui);
192  break;
193 
194 
195  case 'ilpermissiongui':
196  if ($this->in_administration) {
197  $this->prepareOutput();
198  } else {
199  $this->getTemplate();
200  $this->setTabs();
201  $this->setLocator();
202  $this->addHeaderAction();
203  }
204  $perm_gui = new ilPermissionGUI($this);
205  $ret = $this->ctrl->forwardCommand($perm_gui);
206  break;
207 
208  case "ilcommonactiondispatchergui":
210  $this->prepareOutput();
211  $this->ctrl->forwardCommand($gui);
212  break;
213 
214  case strtolower(ilTaxonomySettingsGUI::class):
215  $this->checkPermission("write");
216  $this->getTemplate();
217  $this->setTabs();
218  $this->setLocator();
219  $this->addHeaderAction();
220  $this->tabs->activateTab("settings");
221  $this->setSettingsSubTabs("taxonomy");
222 
223  $this->ctrl->setReturn($this, "properties");
224  $tax_gui = $this->taxonomy->gui()->getSettingsGUI(
225  $this->object->getId(),
226  $this->lng->txt("glo_tax_info"),
227  false,
228  $this
229  );
230  $ret = $this->ctrl->forwardCommand($tax_gui);
231  break;
232 
233  case "ilexportgui":
234  $this->checkPermission("write");
235  $this->getTemplate();
236  $this->setTabs();
237  $this->tabs->activateTab("export");
238  $this->setLocator();
239  $exp_gui = new ilExportGUI($this);
240  //$exp_gui->addFormat("xml", "", $this, "export");
241  $exp_gui->addFormat("xml");
242  $exp_gui->addFormat("html", "", $this, "exportHTML");
243  $exp_gui->addCustomColumn(
244  $this->lng->txt("cont_public_access"),
245  $this,
246  "getPublicAccessColValue"
247  );
248  $exp_gui->addCustomMultiCommand(
249  $this->lng->txt("cont_public_access"),
250  $this,
251  "publishExportFile"
252  );
253  $ret = $this->ctrl->forwardCommand($exp_gui);
254  break;
255 
256  case 'ilobjectcopygui':
257  $this->prepareOutput();
258  $cp = new ilObjectCopyGUI($this);
259  $cp->setType('glo');
260  $this->ctrl->forwardCommand($cp);
261  break;
262 
263  case "ilglossaryforeigntermcollectorgui":
264  $this->checkPermission("write");
265  $this->ctrl->setReturn($this, "");
266  $this->getTemplate();
267  $this->setTabs();
268  $this->setLocator();
269  $this->addHeaderAction();
271  $this->ctrl->forwardCommand($coll);
272  break;
273 
274  case "iltermdefinitionbulkcreationgui":
275  $this->checkPermission("write");
276  $this->ctrl->setReturn($this, "listTerms");
277  $this->ctrl->forwardCommand($this->term_def_bulk_gui);
278  break;
279 
280  default:
281  $cmd = $this->ctrl->getCmd("listTerms");
282 
283  if (($cmd == "create") && ($this->edit_request->getNewType() == "term")) {
284  $this->ctrl->setCmd("create");
285  $this->ctrl->setCmdClass("ilGlossaryTermGUI");
286  $this->executeCommand();
287  return;
288  } else {
289  if ($cmd != "quickList") {
290  if ($this->in_administration ||
291  $this->getCreationMode() == true) {
292  $this->prepareOutput();
293  $cmd .= "Object";
294  } else {
295  $this->getTemplate();
296  $this->setTabs();
297  $this->setLocator();
298  $this->addHeaderAction();
299 
300  if ($cmd == "redrawHeaderAction") {
301  $cmd = "redrawHeaderActionObject";
302  }
303  }
304  }
305  if (in_array($cmd, [
306  "redrawHeaderActionObject"
307  ])) {
308  $this->checkPermission("read");
309  } elseif (in_array($cmd, [
310  "showInfoScreen"
311  ])) {
312  $this->checkPermission("visible");
313  } else {
314  if (!$this->getCreationMode()) {
315  $this->checkPermission("write");
316  }
317  }
318  $this->$cmd();
319  }
320  break;
321  }
322 
323  if ($cmd != "quickList") {
324  if (!$this->in_administration && !$this->getCreationMode()) {
325  $this->tpl->printToStdout();
326  }
327  } else {
328  $this->tpl->printToStdout(false);
329  }
330  }
331 
335  public function getGlossary(): ?ilObjGlossary
336  {
338  $glossary = $this->object;
339  if (isset($glossary) && $glossary->getType() == "glo") {
340  return $glossary;
341  }
342  return null;
343  }
344 
345  protected function assignObject(): void
346  {
347  $this->object = new ilObjGlossary($this->id, true);
348  }
349 
350  protected function initCreateForm(string $new_type): ilPropertyFormGUI
351  {
352  $form = new ilPropertyFormGUI();
353  $form->setTarget("_top");
354  $form->setFormAction($this->ctrl->getFormAction($this));
355  $form->setTitle($this->lng->txt($new_type . "_new"));
356 
357  // title
358  $ti = new ilTextInputGUI($this->lng->txt("title"), "title");
359  $ti->setSize(min(40, ilObject::TITLE_LENGTH));
360  $ti->setMaxLength(ilObject::TITLE_LENGTH);
361  $ti->setRequired(true);
362  $form->addItem($ti);
363 
364  // description
365  $ta = new ilTextAreaInputGUI($this->lng->txt("description"), "desc");
366  $ta->setCols(40);
367  $ta->setRows(2);
368  $form->addItem($ta);
369 
370  // didactic template
371  $form = $this->initDidacticTemplate($form);
372 
373  $form->addCommandButton("save", $this->lng->txt($new_type . "_add"));
374  $form->addCommandButton("cancel", $this->lng->txt("cancel"));
375 
376  return $form;
377  }
378 
379  public function importObject(): void
380  {
381  $this->createObject();
382  }
383 
384  public function saveObject(): void
385  {
386  $new_type = $this->edit_request->getNewType();
387 
388  // create permission is already checked in createObject. This check here is done to prevent hacking attempts
389  if (!$this->checkPermissionBool("create", "", $new_type)) {
390  throw new ilPermissionException($this->lng->txt("no_create_permission"));
391  }
392 
393  $this->lng->loadLanguageModule($new_type);
394  $this->ctrl->setParameter($this, "new_type", $new_type);
395 
396  $form = $this->initCreateForm($new_type);
397  if ($form->checkInput()) {
398  $this->ctrl->setParameter($this, "new_type", "");
399 
400  $newObj = new ilObjGlossary();
401  $newObj->setType($new_type);
402  $newObj->setTitle($form->getInput("title"));
403  $newObj->setDescription($form->getInput("desc"));
404  $newObj->setVirtualMode("none");
405  $newObj->create();
406 
407  $this->putObjectInTree($newObj);
408 
409  // apply didactic template?
410  $dtpl = $this->getDidacticTemplateVar("dtpl");
411  if ($dtpl) {
412  $newObj->applyDidacticTemplate($dtpl);
413  }
414 
415  // always send a message
416  $this->tpl->setOnScreenMessage('success', $this->lng->txt("glo_added"), true);
417  $this->ctrl->setParameterByClass(
418  ilObjGlossaryGUI::class,
419  "ref_id",
420  $newObj->getRefId()
421  );
422  $this->ctrl->redirectByClass(
423  [ilGlossaryEditorGUI::class, ilObjGlossaryGUI::class],
424  "properties"
425  );
426  }
427 
428  // display only this form to correct input
429  $form->setValuesByPost();
430  $this->tpl->setContent($form->getHTML());
431  }
432 
433  public function showInfoScreen(): void
434  {
435  $this->getTemplate();
436  $this->setTabs();
437  $this->setLocator();
438  $this->lng->loadLanguageModule("meta");
439 
440  $info = new ilInfoScreenGUI($this);
441  $info->enablePrivateNotes();
442  $info->enableNews();
443  if ($this->access->checkAccess("write", "", $this->requested_ref_id)) {
444  $info->enableNewsEditing();
445  $news_set = new ilSetting("news");
446  $enable_internal_rss = $news_set->get("enable_rss_for_internal");
447  if ($enable_internal_rss) {
448  $info->setBlockProperty("news", "settings", true);
449  }
450  }
451  $info->addMetaDataSections($this->object->getId(), 0, $this->object->getType());
452 
453  self::addUsagesToInfo($info, $this->object->getId());
454 
455  $this->ctrl->forwardCommand($info);
456  }
457 
461  public static function addUsagesToInfo(
462  ilInfoScreenGUI $info,
463  int $glo_id
464  ): void {
465  global $DIC;
466 
467  $lng = $DIC->language();
468  $ilAccess = $DIC->access();
469 
470  $info->addSection($lng->txt("glo_usages"));
472  foreach ($sms as $sm) {
473  $link = false;
474  $refs = ilObject::_getAllReferences($sm);
475  foreach ($refs as $ref) {
476  if ($link === false && $ilAccess->checkAccess("write", "", $ref)) {
477  $link = ilLink::_getLink($ref, 'sahs');
478  }
479  }
480 
481  $entry = ilObject::_lookupTitle($sm);
482  if ($link !== false) {
483  $entry = "<a href='" . $link . "' target='_top'>" . $entry . "</a>";
484  }
485 
486  $info->addProperty($lng->txt("obj_sahs"), $entry);
487  }
488  }
489 
490 
491  public function viewObject(): void
492  {
493  if ($this->in_administration) {
494  parent::viewObject();
495  return;
496  }
497 
498  if (!$this->rbacsystem->checkAccess("visible,read", $this->object->getRefId())) {
499  throw new ilPermissionException($this->lng->txt("permission_denied"));
500  }
501  }
502 
503  public function properties(): void
504  {
505  $this->checkPermission("write");
506 
507  $this->setSettingsSubTabs("general_settings");
508 
509  $this->initSettingsForm();
510 
511  // Edit ecs export settings
512  $ecs = new ilECSGlossarySettings($this->object);
513  $ecs->addSettingsToForm($this->form, 'glo');
514 
515  $this->tpl->setContent($this->form->getHTML());
516  }
517 
518  public function initSettingsForm(
519  string $a_mode = "edit"
520  ): void {
521  $obj_service = $this->getObjectService();
522 
523  $this->form = new ilPropertyFormGUI();
524 
525  // title
526  $title = new ilTextInputGUI($this->lng->txt("title"), "title");
527  $title->setRequired(true);
528  $this->form->addItem($title);
529 
530  // description
531  $desc = new ilTextAreaInputGUI($this->lng->txt("desc"), "description");
532  $this->form->addItem($desc);
533 
534  // glossary mode
535  // for layout of this property see https://mantis.ilias.de/view.php?id=31833
536  $glo_mode = new ilRadioGroupInputGUI($this->lng->txt("glo_content_assembly"), "glo_mode");
537  //$glo_mode->setInfo($this->lng->txt("glo_mode_desc"));
538  $op1 = new ilRadioOption($this->lng->txt("glo_mode_normal"), "none", $this->lng->txt("glo_mode_normal_info"));
539  $op2 = new ilRadioOption($this->lng->txt("glo_collection"), "coll", $this->lng->txt("glo_collection_info"));
540  if (!empty($this->object->getGlossariesForCollection()) && $this->object->isVirtual()) {
541  $op1->setDisabled(true);
542  $op2->setDisabled(true);
543  $glo_mode->setInfo($this->lng->txt("glo_change_to_standard_unavailable_info"));
544  }
545  if (!empty(ilGlossaryTerm::getTermsOfGlossary($this->object->getId())) && !$this->object->isVirtual()) {
546  $op1->setDisabled(true);
547  $op2->setDisabled(true);
548  $glo_mode->setInfo($this->lng->txt("glo_change_to_collection_unavailable_info"));
549  }
550  $glo_mode->addOption($op1);
551  $glo_mode->addOption($op2);
552  $this->form->addItem($glo_mode);
553 
554 
555  $this->lng->loadLanguageModule("rep");
556  $section = new ilFormSectionHeaderGUI();
557  $section->setTitle($this->lng->txt('rep_activation_availability'));
558  $this->form->addItem($section);
559 
560  // online
561  $online = new ilCheckboxInputGUI($this->lng->txt("cont_online"), "cobj_online");
562  $online->setValue("y");
563  $online->setInfo($this->lng->txt("glo_online_info"));
564  $this->form->addItem($online);
565 
566  $section = new ilFormSectionHeaderGUI();
567  $section->setTitle($this->lng->txt('cont_presentation'));
568  $this->form->addItem($section);
569 
570  // tile image
571  $obj_service->commonSettings()->legacyForm($this->form, $this->object)->addTileImage();
572 
573  // presentation mode
574  $pres_mode = new ilRadioGroupInputGUI($this->lng->txt("glo_presentation_mode"), "pres_mode");
575  $pres_mode->setValue("table");
576  $op1 = new ilRadioOption($this->lng->txt("glo_table_form"), "table", $this->lng->txt("glo_table_form_info"));
577 
578  // short text length
579  $snl = new ilNumberInputGUI($this->lng->txt("glo_text_snippet_length"), "snippet_length");
580  $snl->setMaxValue(3000);
581  $snl->setMinValue(100);
582  $snl->setMaxLength(4);
583  $snl->setSize(4);
584  $snl->setInfo($this->lng->txt("glo_text_snippet_length_info"));
585  $snl->setValue(200);
586  $snl->setSuffix($this->lng->txt("characters"));
587  $op1->addSubItem($snl);
588 
589  $pres_mode->addOption($op1);
590  $op2 = new ilRadioOption($this->lng->txt("glo_full_definitions"), "full_def", $this->lng->txt("glo_full_definitions_info"));
591  $pres_mode->addOption($op2);
592  $this->form->addItem($pres_mode);
593 
594  // flashcard training
595  $flash_active = new ilCheckboxInputGUI($this->lng->txt("glo_flashcard_training"), "flash_active");
596  $flash_active->setValue("y");
597  $flash_active->setInfo($this->lng->txt("glo_flashcard_training_info"));
598 
599  //flashcard training mode
600  $flash_mode = new ilRadioGroupInputGUI($this->lng->txt("glo_mode"), "flash_mode");
601  $op1 = new ilRadioOption($this->lng->txt("glo_term_vs_def"), "term", $this->lng->txt("glo_term_vs_def_info"));
602  $flash_mode->addOption($op1);
603  $op2 = new ilRadioOption($this->lng->txt("glo_def_vs_term"), "def", $this->lng->txt("glo_def_vs_term_info"));
604  $flash_mode->addOption($op2);
605  $flash_active->addSubItem($flash_mode);
606  $this->form->addItem($flash_active);
607 
608  // downloads
609  $down = new ilCheckboxInputGUI($this->lng->txt("cont_downloads"), "glo_act_downloads");
610  $down->setValue("y");
611  $down->setInfo($this->lng->txt("cont_downloads_desc"));
612  $this->form->addItem($down);
613 
614  if ($a_mode == "edit") {
615  $title->setValue($this->object->getTitle());
616  $desc->setValue($this->object->getDescription());
617  $online->setChecked($this->object->getOnline());
618  $mode1 = $this->object->getVirtualMode() === "none"
619  ? "none"
620  : "coll";
621  $glo_mode->setValue($mode1);
622  $pres_mode->setValue($this->object->getPresentationMode());
623  $snl->setValue($this->object->getSnippetLength());
624 
625  $down->setChecked($this->object->isActiveDownloads());
626  $flash_active->setChecked($this->object->isActiveFlashcards());
627  $flash_mode->setValue($this->object->getFlashcardsMode());
628 
629  // additional features
630  $feat = new ilFormSectionHeaderGUI();
631  $feat->setTitle($this->lng->txt('obj_features'));
632  $this->form->addItem($feat);
633 
635  $this->object->getId(),
636  $this->form,
637  array(
640  )
641  );
642  }
643 
644  // sort columns, if adv fields are given
645  $adv_ap = new ilGlossaryAdvMetaDataAdapter($this->object->getRefId());
646  $cols = $adv_ap->getColumnOrder();
647  if (count($cols) > 1) {
648  $ti = new ilGloAdvColSortInputGUI($this->lng->txt("cont_col_ordering"), "field_order");
649  $this->form->addItem($ti);
650  $ti->setValue($cols);
651  $ti->setInfo($this->lng->txt("glo_col_ordering_info"));
652  }
653 
654  // save and cancel commands
655  $this->form->addCommandButton("saveProperties", $this->lng->txt("save"));
656 
657  $this->form->setTitle($this->lng->txt("cont_glo_properties"));
658  $this->form->setFormAction($this->ctrl->getFormAction($this));
659  }
660 
661 
662  public function saveProperties(): void
663  {
664  $obj_service = $this->getObjectService();
665  $this->initSettingsForm();
666  if ($this->form->checkInput()) {
667  $this->object->setTitle($this->form->getInput("title"));
668  $this->object->setDescription($this->form->getInput("description"));
669  $this->object->setOnline(ilUtil::yn2tf($this->form->getInput("cobj_online")));
670  $glo_mode = $this->form->getInput("glo_mode") ?: $this->object->getVirtualMode();
671  $this->object->setVirtualMode($glo_mode);
672  $this->object->setActiveDownloads(ilUtil::yn2tf($this->form->getInput("glo_act_downloads")));
673  $this->object->setPresentationMode($this->form->getInput("pres_mode"));
674  $this->object->setSnippetLength($this->form->getInput("snippet_length"));
675  $this->object->setActiveFlashcards(ilUtil::yn2tf($this->form->getInput("flash_active")));
676  $this->object->setFlashcardsMode($this->form->getInput("flash_mode"));
677  $this->object->update();
678 
679  // tile image
680  $obj_service->commonSettings()->legacyForm($this->form, $this->object)->saveTileImage();
681 
682  // field order of advanced metadata
683  $adv_ap = new ilGlossaryAdvMetaDataAdapter($this->object->getRefId());
684  $cols = $adv_ap->getColumnOrder();
685  if (count($cols) > 1) {
686  $adv_ap->saveColumnOrder($this->form->getInput("field_order"));
687  }
688 
689  // set definition short texts dirty
691 
693  $this->object->getId(),
694  $this->form,
695  array(
698  )
699  );
700 
701  // Update ecs export settings
702  $ecs = new ilECSGlossarySettings($this->object);
703  if ($ecs->handleSettingsUpdate($this->form)) {
704  $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
705  $this->ctrl->redirect($this, "properties");
706  }
707  }
708  $this->form->setValuesByPost();
709  $this->tpl->setContent($this->form->getHTML());
710  }
711 
712  public function getProperties(
713  int $tax_id
714  ): array {
715  $active = $this->object->getShowTaxonomy();
716  $value = $active
717  ? $this->lng->txt("yes")
718  : $this->lng->txt("no");
719 
720  return [
721  $this->lng->txt("glo_show_in_presentation") => $value
722  ];
723  }
724 
725  public function getActions(
726  int $tax_id
727  ): array {
728  $actions = [];
729  $this->ctrl->setParameterByClass(self::class, "glo_tax_id", $tax_id);
730  $active = $this->object->getShowTaxonomy();
731  if (!$active) {
732  $actions[] = $this->ui->factory()->button()->shy(
733  $this->lng->txt("glo_show_in_presentation_on"),
734  $this->ctrl->getLinkTargetByClass(
735  self::class,
736  "showTaxInPresentation"
737  )
738  );
739  } else {
740  $actions[] = $this->ui->factory()->button()->shy(
741  $this->lng->txt("glo_show_in_presentation_off"),
742  $this->ctrl->getLinkTargetByClass(
743  self::class,
744  "hideTaxInPresentation"
745  )
746  );
747  }
748  $this->ctrl->setParameterByClass(self::class, "glo_tax_id", null);
749 
750  return $actions;
751  }
752 
753  protected function showTaxInPresentation(): void
754  {
755  $this->object->setShowTaxonomy(true);
756  $this->object->update();
757  $this->ctrl->redirectByClass(ilTaxonomySettingsGUI::class);
758  }
759 
760  protected function hideTaxInPresentation(): void
761  {
762  $this->object->setShowTaxonomy(false);
763  $this->object->update();
764  $this->ctrl->redirectByClass(ilTaxonomySettingsGUI::class);
765  }
766 
767  public function listTerms(): void
768  {
769  $this->showTaxonomy();
770 
771  $panel_html = "";
772  $modals = "";
773  $tab_html = "";
774  if ($this->object->isVirtual()) {
775  $this->showToolbarForCollection();
776  $panel = $this->showSelectedGlossariesForCollection();
777  $panel_html = $this->ui_ren->render($panel);
778  $modals = $this->ui_ren->render($this->getModalsToRender());
779  } else {
780  $this->showToolbarForStandard();
781  $tab = new ilTermListTableGUI($this, "listTerms", $this->tax_node);
782  $tab_html = $tab->getHTML();
783  }
784 
785  $this->tabs->activateTab("content");
786 
787  $this->tpl->setContent($panel_html . $modals . $tab_html);
788  }
789 
793  protected function getModalsToRender(): array
794  {
796  }
797 
798  public function showToolbarForStandard(): void
799  {
800  // term
801  $ti = new ilTextInputGUI($this->lng->txt("cont_new_term"), "new_term");
802  $ti->setMaxLength(80);
803  $ti->setSize(20);
804  $this->toolbar->addInputItem($ti, true);
805 
806  // language
807  $this->lng->loadLanguageModule("meta");
809  $session_lang = $this->term_manager->getSessionLang();
810  if ($session_lang != "") {
811  $s_lang = $session_lang;
812  } else {
813  $s_lang = $this->user->getLanguage();
814  }
815  $si = new ilSelectInputGUI($this->lng->txt("language"), "term_language");
816  $si->setOptions($lang);
817  $si->setValue($s_lang);
818  $this->toolbar->addInputItem($si, true);
819 
820  $this->toolbar->setFormAction($this->ctrl->getFormAction($this));
821  $this->toolbar->addFormButton($this->lng->txt("glo_add_new_term"), "addTerm");
822 
823  $this->toolbar->addSeparator();
824 
825  //ilEditClipboard::getAction() == "copy"
826  if ($this->user->clipboardHasObjectsOfType("term")) {
827  $this->toolbar->addButton(
828  $this->lng->txt("paste"),
829  $this->ctrl->getLinkTarget($this, "pasteTerms")
830  );
831  $this->toolbar->addButton(
832  $this->lng->txt("clear_clipboard"),
833  $this->ctrl->getLinkTarget($this, "clearClipboard")
834  );
835  } else {
836  $this->toolbar->addButton(
837  $this->lng->txt("glo_add_from_other"),
838  $this->ctrl->getLinkTargetByClass("ilglossaryforeigntermcollectorgui", "")
839  );
840  }
841 
842  $this->term_def_bulk_gui->modifyToolbar($this->toolbar);
843  }
844 
845  public function showToolbarForCollection(): void
846  {
847  $modal = $this->showModalForCollection();
848  $button = $this->ui_fac->button()->standard($this->lng->txt("glo_add_glossary"), "")->withOnClick($modal->getShowSignal());
849  $this->modals_to_render[] = $modal;
850  $this->toolbar->addComponent($button);
851  }
852 
856  public function showSelectedGlossariesForCollection(): array
857  {
858  $items = [];
859  $glo_ids = $this->object->getAllGlossaryIds(true);
860  $at_least_one_glossary = false;
861  foreach ($glo_ids as $glo_id) {
862  if ($this->object->getId() === $glo_id) {
863  continue;
864  }
865  $glossary = new ilObjGlossary($glo_id, false);
866  $glo_ref_id = current(ilObject::_getAllReferences($glossary->getId()));
867  $glo_link = $this->ui_fac->link()->standard($glossary->getTitle(), ilLink::_getLink($glo_ref_id));
868  $glo_item = $this->ui_fac->item()->standard($glo_link);
869  $glo_item = $glo_item->withDescription($glossary->getDescription());
870  $form_action = $this->ctrl->getFormActionByClass(ilObjGlossaryGUI::class, "removeGlossaryFromCollection");
871  $delete_modal = $this->ui_fac->modal()->interruptive(
872  "",
873  $this->lng->txt("glo_really_remove_from_collection"),
875  )->withAffectedItems([
876  $this->ui_fac->modal()->interruptiveItem()->standard(
877  $glossary->getId(),
878  $glossary->getTitle(),
879  $this->ui_fac->image()->standard(
880  ilObject::_getIcon($glossary->getId(), "small", $glossary->getType()),
881  $this->lng->txt("icon") . " " . $this->lng->txt("obj_" . $glossary->getType())
882  )
883  )
884  ]);
885  $actions = $this->ui_fac->dropdown()->standard([
886  $this->ui_fac->button()->shy($this->lng->txt("remove"), "")->withOnClick($delete_modal->getShowSignal()),
887  ]);
888  $glo_item = $glo_item->withActions($actions);
889 
890  $items[] = $glo_item;
891  $this->modals_to_render[] = $delete_modal;
892  $at_least_one_glossary = true;
893  }
894 
895  $components = [];
896  if (!$at_least_one_glossary) {
897  $message_box = $this->ui_fac->messageBox()->info($this->lng->txt("glo_collection_empty_info"));
898  $components[] = $message_box;
899  }
900  if (!empty($items)) {
901  $item_group = $this->ui_fac->item()->group($this->lng->txt("glo_selected_glossaries_info"), $items);
902  $panel = $this->ui_fac->panel()->listing()->standard(
903  $this->lng->txt("glo_selected_glossaries"),
904  [$item_group]
905  );
906  $components[] = $panel;
907  }
908 
909  return $components;
910  }
911 
913  {
915  $this,
916  "showModalForCollection",
917  $this,
918  "saveGlossaryForCollection",
919  "sel_glo_ref_id"
920  );
921  $modal = $this->ui_fac->modal()->roundtrip(
922  $this->lng->txt("glo_add_to_collection"),
923  $this->ui_fac->legacy(!$exp->handleCommand() ? $exp->getHTML() : "")
924  );
925 
926  return $modal;
927  }
928 
929  public function saveGlossaryForCollection(): void
930  {
931  $selected_glo = new ilObjGlossary($this->edit_request->getSelectedGlossaryRefId(), true);
932  if ($selected_glo->getId() === $this->object->getId()) {
933  $this->tpl->setOnScreenMessage("info", $this->lng->txt("glo_selected_glossary_is_current_info"), true);
934  } else {
935  $this->object->addGlossaryForCollection($selected_glo->getId());
936  $this->tpl->setOnScreenMessage("success", $this->lng->txt("glo_added_to_collection_info"), true);
937  }
938  $this->ctrl->redirect($this, "listTerms");
939  }
940 
941  public function removeGlossaryFromCollection(): void
942  {
943  $glo_id = $this->edit_request->getInterruptiveItemIds()[0];
944  $this->object->removeGlossaryFromCollection($glo_id);
945  $this->tpl->setOnScreenMessage("success", $this->lng->txt("glo_removed_from_collection_info"), true);
946  $this->ctrl->redirect($this, "listTerms");
947  }
948 
952  public function addTerm(): void
953  {
954  $new_term = $this->edit_request->getNewTerm();
955  if ($new_term == "") {
956  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("cont_please_enter_a_term"), true);
957  $this->ctrl->redirect($this, "listTerms");
958  }
959 
960  // add term
961  $lang = $this->edit_request->getTermLanguage();
962  $term = new ilGlossaryTerm();
963  $term->setGlossary($this->getGlossary());
964  $term->setTerm($new_term);
965  $term->setLanguage($lang);
966  $term->create();
967 
968  $this->term_manager->setSessionLang($lang);
969 
970  $this->ctrl->setParameterByClass("ilglossarydefpagegui", "term_id", $term->getId());
971  $this->ctrl->redirectByClass(array("ilglossarytermgui",
972  "iltermdefinitioneditorgui", "ilglossarydefpagegui"), "edit");
973  }
974 
975  public function export(): void
976  {
977  $this->checkPermission("write");
978  $glo_exp = new ilGlossaryExport($this->getGlossary());
979  $glo_exp->buildExportFile();
980  $this->ctrl->redirectByClass("ilexportgui", "");
981  }
982 
986  public function exportHTML(): void
987  {
988  $glo_exp = new ilGlossaryExport($this->getGlossary(), "html");
989  $glo_exp->buildExportFile();
990  $this->ctrl->redirectByClass("ilexportgui", "");
991  }
992 
996  public function publishExportFile(): void
997  {
998  $files = $this->edit_request->getFiles();
999  if (count($files) == 0) {
1000  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("no_checkbox"), true);
1001  $this->ctrl->redirectByClass("ilexportgui", "");
1002  }
1003  if (count($files) > 1) {
1004  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("cont_select_max_one_item"), true);
1005  $this->ctrl->redirectByClass("ilexportgui", "");
1006  }
1007 
1008  $file = explode(":", $files[0]);
1009  $export_dir = $this->object->getExportDirectory($file[0]);
1010 
1011  if ($this->object->getPublicExportFile($file[0]) ==
1012  $file[1]) {
1013  $this->object->setPublicExportFile($file[0], "");
1014  } else {
1015  $this->object->setPublicExportFile($file[0], $file[1]);
1016  }
1017  $this->object->update();
1018  $this->ctrl->redirectByClass("ilexportgui", "");
1019  }
1020 
1021  public function confirmTermDeletion(): void
1022  {
1023  $ids = $this->edit_request->getIds();
1024  if (count($ids) == 0) {
1025  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("no_checkbox"), true);
1026  $this->ctrl->redirect($this, "listTerms");
1027  }
1028 
1029  // check ids
1030  foreach ($ids as $term_id) {
1031  $term_glo_id = ilGlossaryTerm::_lookGlossaryID($term_id);
1032  if ($term_glo_id != $this->object->getId() && !ilGlossaryTermReferences::isReferenced([$this->object->getId()], $term_id)) {
1033  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("glo_term_must_belong_to_glo"), true);
1034  $this->ctrl->redirect($this, "listTerms");
1035  }
1036  }
1037 
1038  // display confirmation message
1039  $cgui = new ilConfirmationGUI();
1040  $cgui->setFormAction($this->ctrl->getFormAction($this));
1041  $cgui->setHeaderText($this->lng->txt("info_delete_sure"));
1042  $cgui->setCancel($this->lng->txt("cancel"), "cancelTermDeletion");
1043  $cgui->setConfirm($this->lng->txt("confirm"), "deleteTerms");
1044 
1045  foreach ($ids as $id) {
1046  try {
1047  $term = new ilGlossaryTerm($id);
1048  } catch (Exception $e) {
1049  $cgui->addItem("id[]", $id, "Error: Page is missing.");
1050  continue;
1051  }
1052 
1053 
1054  $add = "";
1056  if ($nr > 0) {
1057  $this->ctrl->setParameterByClass(
1058  "ilglossarytermgui",
1059  "term_id",
1060  $id
1061  );
1062 
1063  if (ilGlossaryTermReferences::isReferenced([$this->object->getId()], $id)) {
1064  $add = " (" . $this->lng->txt("glo_term_reference") . ")";
1065  } else {
1066  $link = "[<a href='" .
1067  $this->ctrl->getLinkTargetByClass("ilglossarytermgui", "listUsages") .
1068  "'>" . $this->lng->txt("glo_list_usages") . "</a>]";
1069  $add = "<div class='small'>" .
1070  sprintf($this->lng->txt("glo_term_is_used_n_times"), $nr) . " " . $link . "</div>";
1071  }
1072  }
1073 
1074  $cgui->addItem("id[]", $id, $term->getTerm() . $add);
1075  }
1076 
1077  $this->tpl->setContent($cgui->getHTML());
1078  }
1079 
1080  public function cancelTermDeletion(): void
1081  {
1082  $this->ctrl->redirect($this, "listTerms");
1083  }
1084 
1085  public function deleteTerms(): void
1086  {
1087  $ids = $this->edit_request->getIds();
1088  foreach ($ids as $id) {
1089  if (ilGlossaryTermReferences::isReferenced([$this->object->getId()], $id)) {
1090  $refs = new ilGlossaryTermReferences($this->object->getId());
1091  $refs->deleteTerm($id);
1092  $refs->update();
1093  } else {
1094  $this->term_manager->deleteTerm($id);
1095  }
1096  }
1097  $this->ctrl->redirect($this, "listTerms");
1098  }
1099 
1100  protected function setLocator(): void
1101  {
1102  if (strtolower($this->edit_request->getBaseClass()) != "ilglossaryeditorgui") {
1103  parent::setLocator();
1104  } elseif (is_object($this->object)) {
1105  $gloss_loc = new ilGlossaryLocatorGUI();
1106  if (is_object($this->term)) {
1107  $gloss_loc->setTerm($this->term);
1108  }
1109  $gloss_loc->setGlossary($this->getGlossary());
1110  $gloss_loc->display();
1111  }
1112  }
1113 
1114  public function view(): void
1115  {
1116  $this->viewObject();
1117  }
1118 
1119  public function getTemplate(): void
1120  {
1121  $this->tpl->loadStandardTemplate();
1122 
1123  $title = $this->object->getTitle();
1124 
1125 
1126  if ($this->term_id > 0) {
1127  $this->tpl->setTitle($this->lng->txt("term") . ": " .
1128  ilGlossaryTerm::_lookGlossaryTerm($this->term_id));
1129  } else {
1130  parent::setTitleAndDescription();
1131  $this->tpl->setTitleIcon(ilUtil::getImagePath("standard/icon_glo.svg"));
1132  $this->tpl->setTitle($this->lng->txt("glo") . ": " . $title);
1133  }
1134  }
1135 
1136  protected function getTabs(): void
1137  {
1138  $this->help->setScreenIdComponent("glo");
1139 
1140  // list terms
1141  $cmd = $this->ctrl->getCmd();
1142  $force_active = ($cmd == "" || $cmd == "listTerms");
1143  $this->tabs_gui->addTarget(
1144  "content",
1145  $this->ctrl->getLinkTarget($this, "listTerms"),
1146  array("listTerms", ""),
1147  get_class($this),
1148  "",
1149  $force_active
1150  );
1151 
1152  $force_active = false;
1153  if ($this->ctrl->getCmd() == "showSummary" ||
1154  strtolower($this->ctrl->getNextClass()) == "ilinfoscreengui") {
1155  $force_active = true;
1156  }
1157  $this->tabs_gui->addTarget(
1158  "info_short",
1159  $this->ctrl->getLinkTargetByClass("ilinfoscreengui", "showSummary"),
1160  "",
1161  "ilInfoScreenGUI",
1162  "",
1163  $force_active
1164  );
1165 
1166  // properties
1167  if ($this->rbacsystem->checkAccess('write', $this->object->getRefId())) {
1168  $this->tabs_gui->addTarget(
1169  "settings",
1170  $this->ctrl->getLinkTarget($this, "properties"),
1171  "properties",
1172  get_class($this)
1173  );
1174 
1175  // meta data
1176  $mdgui = new ilObjectMetaDataGUI($this->object, "term");
1177  $mdtab = $mdgui->getTab();
1178  if ($mdtab) {
1179  $this->tabs_gui->addTarget(
1180  "meta_data",
1181  $mdtab,
1182  "",
1183  "ilobjectmetadatagui"
1184  );
1185  }
1186 
1187  // export
1188  /*$tabs_gui->addTarget("export",
1189  $this->ctrl->getLinkTarget($this, "exportList"),
1190  array("exportList", "viewExportLog"), get_class($this));*/
1191 
1192  // export
1193  $this->tabs_gui->addTarget(
1194  "export",
1195  $this->ctrl->getLinkTargetByClass("ilexportgui", ""),
1196  "",
1197  "ilexportgui"
1198  );
1199  }
1200 
1201  // permissions
1202  if ($this->rbacsystem->checkAccess('edit_permission', $this->object->getRefId())) {
1203  /*$tabs_gui->addTarget("permission_settings",
1204  $this->ctrl->getLinkTarget($this, "perm"),
1205  array("perm", "info"),
1206  get_class($this));
1207  */
1208  $this->tabs_gui->addTarget(
1209  "perm_settings",
1210  $this->ctrl->getLinkTargetByClass(array(get_class($this),'ilpermissiongui'), "perm"),
1211  array("perm","info","owner"),
1212  'ilpermissiongui'
1213  );
1214  }
1215 
1216  $this->tabs_gui->addNonTabbedLink(
1217  "presentation_view",
1218  $this->lng->txt("glo_presentation_view"),
1219  "ilias.php?baseClass=ilGlossaryPresentationGUI&amp;ref_id=" . $this->object->getRefId(),
1220  "_top"
1221  );
1222  }
1223 
1224  public function setSettingsSubTabs(string $a_active): void
1225  {
1226  if (in_array(
1227  $a_active,
1228  array("general_settings", "style", "taxonomy", "glossaries")
1229  )) {
1230  // general properties
1231  $this->tabs->addSubTab(
1232  "general_settings",
1233  $this->lng->txt("settings"),
1234  $this->ctrl->getLinkTarget($this, 'properties')
1235  );
1236 
1237  // style properties
1238  $this->tabs->addSubTab(
1239  "style",
1240  $this->lng->txt("obj_sty"),
1241  $this->ctrl->getLinkTargetByClass("ilobjectcontentstylesettingsgui", '')
1242  );
1243 
1244  $this->taxonomy->gui()->addSettingsSubTab($this->getObject()->getId());
1245 
1246  // style properties
1247  $this->tabs->addSubTab(
1248  "glossaries",
1249  $this->lng->txt("cont_auto_glossaries"),
1250  $this->ctrl->getLinkTarget($this, 'editGlossaries')
1251  );
1252 
1253  $this->tabs->activateSubTab($a_active);
1254  }
1255  }
1256 
1257 
1258  public static function _goto(string $a_target): void
1259  {
1260  global $DIC;
1261  $main_tpl = $DIC->ui()->mainTemplate();
1262 
1263  $lng = $DIC->language();
1264  $ilAccess = $DIC->access();
1265  $ctrl = $DIC->ctrl();
1266 
1267  if ($ilAccess->checkAccess("read", "", $a_target)) {
1268  $ctrl->setParameterByClass("ilGlossaryPresentationGUI", "ref_id", $a_target);
1269  $ctrl->redirectByClass("ilGlossaryPresentationGUI", "");
1270  } elseif ($ilAccess->checkAccess("visible", "", $a_target)) {
1271  $ctrl->setParameterByClass("ilGlossaryPresentationGUI", "ref_id", $a_target);
1272  $ctrl->redirectByClass("ilGlossaryPresentationGUI", "infoScreen");
1273  } elseif ($ilAccess->checkAccess("read", "", ROOT_FOLDER_ID)) {
1274  $main_tpl->setOnScreenMessage('failure', sprintf(
1275  $lng->txt("msg_no_perm_read_item"),
1277  ), true);
1279  }
1280 
1281  throw new ilPermissionException($lng->txt("no_permission"));
1282  }
1283 
1284  public function applyFilter(): void
1285  {
1286  $prtab = new ilTermListTableGUI($this, "listTerms", $this->tax_node);
1287  $prtab->resetOffset();
1288  $prtab->writeFilterToSession();
1289  $this->listTerms();
1290  }
1291 
1292  public function resetFilter(): void
1293  {
1294  $prtab = new ilTermListTableGUI($this, "listTerms", $this->tax_node);
1295  $prtab->resetOffset();
1296  $prtab->resetFilter();
1297  $this->listTerms();
1298  }
1299 
1300 
1304 
1305  public function setContentStyleSheet(
1306  ilGlobalTemplateInterface $a_tpl = null
1307  ): void {
1308  if ($a_tpl != null) {
1309  $ctpl = $a_tpl;
1310  } else {
1311  $ctpl = $this->tpl;
1312  }
1313 
1314  $this->content_style_gui->addCss($ctpl, $this->object->getRefId());
1315  }
1316 
1320  public function getPublicAccessColValue(
1321  string $a_type,
1322  string $a_file
1323  ): string {
1324  if ($this->object->getPublicExportFile($a_type) == $a_file) {
1325  return $this->lng->txt("yes");
1326  }
1327 
1328  return " ";
1329  }
1330 
1334  public function showTaxonomy(): void
1335  {
1336  $ctrl = $this->ctrl;
1337 
1338  if (is_null($this->tax_manager) || !$this->tax_manager->showInEditing()) {
1339  return;
1340  }
1341 
1342  $tool_context = $this->global_screen->tool()->context()->current();
1343 
1344  $tax_id = $this->tax_manager->getTaxonomyId();
1345 
1346  $tool_context->addAdditionalData(
1348  true
1349  );
1350  $tool_context->addAdditionalData(
1353  );
1354  $tool_context->addAdditionalData(
1356  $tax_id
1357  );
1358  $tool_context->addAdditionalData(
1360  "listTerms"
1361  );
1362  $tool_context->addAdditionalData(
1364  "showTaxonomy"
1365  );
1366  }
1367 
1368  //
1369  // Auto glossaries
1370  //
1371 
1375  public function editGlossaries(): void
1376  {
1377  $this->tabs->setTabActive("settings");
1378  $this->setSettingsSubTabs("glossaries");
1379 
1380  $this->toolbar->addButton(
1381  $this->lng->txt("add"),
1382  $this->ctrl->getLinkTarget($this, "showGlossarySelector")
1383  );
1384 
1385  $tab = new ilGlossaryAutoLinkTableGUI($this->getGlossary(), $this, "editGlossaries");
1386 
1387  $this->tpl->setContent($tab->getHTML());
1388  }
1389 
1393  public function showGlossarySelector(): void
1394  {
1395  $this->tabs->setTabActive("settings");
1396  $this->setSettingsSubTabs("glossaries");
1397 
1398  $exp = new ilSearchRootSelector($this->ctrl->getLinkTarget($this, 'showGlossarySelector'));
1399  $search_root_expand = $this->edit_request->getSearchRootExpand();
1400  $exp->setExpand($search_root_expand ?: $this->tree->readRootId());
1401  $exp->setExpandTarget($this->ctrl->getLinkTarget($this, 'showGlossarySelector'));
1402  $exp->setTargetClass(get_class($this));
1403  $exp->setCmd('confirmGlossarySelection');
1404  $exp->setClickableTypes(array("glo"));
1405  $exp->addFilter("glo");
1406 
1407  // build html-output
1408  $exp->setOutput(0);
1409  $this->tpl->setContent($exp->getOutput());
1410  }
1411 
1412  public function confirmGlossarySelection(): void
1413  {
1414  $cgui = new ilConfirmationGUI();
1415  $this->ctrl->setParameter($this, "glo_ref_id", $this->edit_request->getGlossaryRefId());
1416  $cgui->setFormAction($this->ctrl->getFormAction($this));
1417  $cgui->setHeaderText($this->lng->txt("glo_link_glo_in_glo"));
1418  $cgui->setCancel($this->lng->txt("no"), "selectGlossary");
1419  $cgui->setConfirm($this->lng->txt("yes"), "selectGlossaryLink");
1420  $this->tpl->setContent($cgui->getHTML());
1421  }
1422 
1426  public function selectGlossaryLink(): void
1427  {
1428  $glo_ref_id = $this->edit_request->getGlossaryRefId();
1429  $this->object->autoLinkGlossaryTerms($glo_ref_id);
1430  $this->selectGlossary();
1431  }
1432 
1433 
1437  public function selectGlossary(): void
1438  {
1439  $glos = $this->object->getAutoGlossaries();
1440  $glo_ref_id = $this->edit_request->getGlossaryRefId();
1441  $glo_id = ilObject::_lookupObjId($glo_ref_id);
1442  if (!in_array($glo_id, $glos)) {
1443  $glos[] = $glo_id;
1444  }
1445  $this->object->setAutoGlossaries($glos);
1446  $this->object->update();
1447 
1448  $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
1449  $this->ctrl->redirect($this, "editGlossaries");
1450  }
1451 
1452  public function removeGlossary(): void
1453  {
1454  $this->object->removeAutoGlossary($this->edit_request->getGlossaryId());
1455  $this->object->update();
1456 
1457  $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
1458  $this->ctrl->redirect($this, "editGlossaries");
1459  }
1460 
1464  public function copyTerms(): void
1465  {
1466  $items = $this->edit_request->getIds();
1467  if (count($items) == 0) {
1468  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("no_checkbox"), true);
1469  $this->ctrl->redirect($this, "listTerms");
1470  }
1471 
1472  $this->user->clipboardDeleteObjectsOfType("term");
1473 
1474  // put them into the clipboard
1475  $time = date("Y-m-d H:i:s");
1476  $order = 0;
1477  foreach ($items as $id) {
1478  $this->user->addObjectToClipboard(
1479  $id,
1480  "term",
1482  0,
1483  $time,
1484  $order
1485  );
1486  }
1487 
1489  $this->tpl->setOnScreenMessage('info', $this->lng->txt("glo_selected_terms_have_been_copied"), true);
1490  $this->ctrl->redirect($this, "listTerms");
1491  }
1492 
1496  public function referenceTerms(): void
1497  {
1498  $items = $this->edit_request->getIds();
1499  if (count($items) == 0) {
1500  $this->tpl->setOnScreenMessage('failure', $this->lng->txt("no_checkbox"), true);
1501  $this->ctrl->redirect($this, "listTerms");
1502  }
1503 
1504  $this->user->clipboardDeleteObjectsOfType("term");
1505 
1506  // put them into the clipboard
1507  $time = date("Y-m-d H:i:s");
1508  $order = 0;
1509  foreach ($items as $id) {
1510  $this->user->addObjectToClipboard(
1511  $id,
1512  "term",
1514  0,
1515  $time,
1516  $order
1517  );
1518  }
1519 
1521  $this->tpl->setOnScreenMessage('info', $this->lng->txt("glo_selected_terms_have_been_copied"), true);
1522  $this->ctrl->redirect($this, "listTerms");
1523  }
1524 
1525 
1526  public function clearClipboard(): void
1527  {
1528  $this->user->clipboardDeleteObjectsOfType("term");
1529  $this->ctrl->redirect($this, "listTerms");
1530  }
1531 
1532  public function pasteTerms(): void
1533  {
1534  if (ilEditClipboard::getAction() == "copy") {
1535  foreach ($this->user->getClipboardObjects("term") as $item) {
1536  ilGlossaryTerm::_copyTerm($item["id"], $this->object->getId());
1537  }
1538  }
1539  if (ilEditClipboard::getAction() == "link") {
1540  $refs = new ilGlossaryTermReferences($this->object->getId());
1541  foreach ($this->user->getClipboardObjects("term") as $item) {
1542  $refs->addTerm($item["id"]);
1543  }
1544  $refs->update();
1545  }
1546  $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
1547  $this->ctrl->redirect($this, "listTerms");
1548  }
1549 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct( $a_data, int $a_id=0, bool $a_call_by_reference=true, bool $a_prepare_output=true)
static getInstance(ilObjGlossaryGUI $a_glossary_gui)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static setAction(string $a_action)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ILIAS GlobalScreen Services $global_screen
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setContentStyleSheet(ilGlobalTemplateInterface $a_tpl=null)
Class ilInfoScreenGUI.
ilTermDefinitionBulkCreationGUI $term_def_bulk_gui
static addUsagesToInfo(ilInfoScreenGUI $info, int $glo_id)
Add usages to info screen.
redirectByClass( $a_class, string $a_cmd=null, string $a_anchor=null, bool $is_async=false)
static _getIcon(int $obj_id=0, string $size="big", string $type="", bool $offline=false)
Get icon for repository item.
This class represents a selection list property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
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...
addGlossaryForCollection(int $glo_id)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setDisabled(bool $a_disabled)
GUI class for the workflow of copying objects.
const ROOT_FOLDER_ID
Definition: constants.php:32
const TITLE_LENGTH
editGlossaries()
Edit automatically linked glossaries.
ILIAS Glossary Presentation GUIService $gui_presentation_service
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
prepareOutput(bool $show_sub_objects=true)
initCreateForm(string $new_type)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ChatMainBarProvider .
initSettingsForm(string $a_mode="edit")
setInfo(string $a_info)
static _getAllReferences(int $id)
get all reference ids for object ID
static getImagePath(string $img, string $module_path="", string $mode="output", bool $offline=false)
get image path (for images located in a template directory)
Help GUI class.
ILIAS Glossary Term TermManager $term_manager
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setTarget(string $a_target)
addProperty(string $a_name, string $a_value, string $a_link="")
add a property to current section
static getScormModulesForGlossary(int $a_glo_id)
Get SCORM modules that assign a certain glossary.
getDidacticTemplateVar(string $type)
Get didactic template setting from creation screen.
setParameterByClass(string $a_class, string $a_parameter, $a_value)
exportHTML()
create html package
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
getPublicAccessColValue(string $a_type, string $a_file)
Get public access value for export table.
createObject()
create new object form
setOptions(array $a_options)
static updateServiceSettingsForm(int $obj_id, ilPropertyFormGUI $form, array $services)
ILIAS DI UIServices $ui
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-...
setGlossary(ilObjGlossary $a_glossary)
static isReferenced(array $a_glo_id, int $a_term_id)
Is a term referenced by a set of glossaries.
static _lookupObjId(int $ref_id)
static _copyTerm(int $a_term_id, int $a_glossary_id)
Copy a term to a glossary.
ILIAS Glossary Taxonomy TaxonomyManager $tax_manager
showTaxonomy()
Show taxonomy.
global $DIC
Definition: feed.php:28
Export User Interface Class.
ilLanguage $lng
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ILIAS Style Content GUIService $content_style_gui
ILIAS UI Factory $ui_fac
This class represents a property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(VocabulariesInterface $vocabularies)
ilGlobalTemplateInterface $tpl
ILIAS Glossary Editing EditingGUIRequest $edit_request
ilGlossaryTermPermission $term_perm
static _lookupTitle(int $obj_id)
setTerm(string $a_term)
setFormAction(string $a_formaction)
create(bool $a_omit_page_creation=false)
selectGlossaryLink()
Select a glossary and link all its terms.
initDidacticTemplate(ilPropertyFormGUI $form)
Class ilObjectGUI Basic methods of all Output classes.
setValue(string $a_value)
static _lookGlossaryTerm(int $term_id)
get glossary term
static _goto(string $a_target)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getTermsOfGlossary(int $a_glo_id)
addSection(string $a_title)
ILIAS Style Content Object ObjectFacade $content_style_domain
copyTerms()
Copy terms to clipboard.
static initServiceSettingsForm(int $obj_id, ilPropertyFormGUI $form, array $services)
addCommandButton(string $a_cmd, string $a_text, string $a_id="")
checkPermissionBool(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
setLanguage(string $a_language)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$lang
Definition: xapiexit.php:26
putObjectInTree(ilObject $obj, int $parent_node_id=null)
Add object to tree at given position.
setSettingsSubTabs(string $a_active)
getCurrentClassPath()
form( $class_path, string $cmd, string $submit_caption="")
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.
selectGlossary()
Select auto glossary.
referenceTerms()
Add terms to be referenced to clipboard.
static setShortTextsDirty(int $a_glo_id)
Set all short texts of glossary dirty (e.g.
static yn2tf(string $a_yn)
New PermissionGUI (extends from old ilPermission2GUI) RBAC related output.
ilPropertyFormGUI $form
setTabs()
set admin tabs
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ILIAS Glossary InternalGUIService $gui
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getNumberOfUsages(int $a_term_id)
showGlossarySelector()
Show auto glossary selection.
publishExportFile()
download export file
addHeaderAction()
Add header action menu.
$service
Definition: ltiservices.php:43
ILIAS Glossary InternalDomainService $domain
setDisabled(bool $a_disabled)
ILIAS UI Renderer $ui_ren
checkPermission(string $perm, string $cmd="", string $type="", ?int $ref_id=null)
ILIAS Taxonomy Service $taxonomy
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getInstanceFromAjaxCall()
(Re-)Build instance from ajax call
setExpand($a_node_id)
set the expand option this value is stored in a SESSION variable to save it different view (lo view...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static _gotoRepositoryRoot(bool $raise_error=false)
Goto repository root.
addCss(string $a_css_file, string $media="screen")
Add a css file that should be included in the header.
static _lookGlossaryID(int $term_id)
get glossary id form term id