ILIAS  release_8 Revision v8.25
class.ilGlossaryForeignTermCollectorGUI.php
Go to the documentation of this file.
1<?php
2
24{
26 protected \ILIAS\Glossary\Editing\EditingGUIRequest $request;
27 protected \ILIAS\Glossary\Term\TermManager $term_manager;
30 protected int $fglo_ref_id;
31 protected ilCtrl $ctrl;
32 protected ilLanguage $lng;
34 protected ilObjUser $user;
35
36 protected function __construct(
37 ilObjGlossaryGUI $a_glossary_gui
38 ) {
39 global $DIC;
40
41 $this->tpl = $DIC["tpl"];
42 $this->ctrl = $DIC->ctrl();
43 $this->lng = $DIC->language();
44 $this->user = $DIC->user();
45
46 $this->glossary_gui = $a_glossary_gui;
48 $glossary = $a_glossary_gui->getObject();
49 $this->glossary = $glossary;
50
51 $this->term_manager = $DIC->glossary()
52 ->internal()
53 ->domain()
54 ->term(
55 $this->glossary,
56 $this->user->getId()
57 );
58 $this->request = $DIC->glossary()
59 ->internal()
60 ->gui()
61 ->editing()
62 ->request();
63
64 $this->fglo_ref_id = $this->request->getForeignGlossaryRefId();
65 if ($this->fglo_ref_id > 0 && ilObject::_lookupType($this->fglo_ref_id, true) == "glo") {
66 $this->foreign_glossary = new ilObjGlossary($this->fglo_ref_id, true);
67 }
68
69 $this->ctrl->saveParameter($this, "fglo_ref_id");
70 }
71
72 public static function getInstance(ilObjGlossaryGUI $a_glossary_gui): self
73 {
74 return new self($a_glossary_gui);
75 }
76
77 public function executeCommand(): void
78 {
79 $next_class = $this->ctrl->getNextClass($this);
80 $cmd = $this->ctrl->getCmd("showGlossarySelector");
81
82 switch ($next_class) {
83 default:
84 if (in_array($cmd, array("showGlossarySelector", "setForeignGlossary", "showTerms", "copyTerms", "referenceTerms"))) {
85 $this->$cmd();
86 }
87 }
88 }
89
90 public function showGlossarySelector(): void
91 {
92 $this->tpl->setOnScreenMessage('info', $this->lng->txt("glo_select_source_glo"));
94 $this,
95 "showGlossarySelector",
96 $this,
97 "setForeignGlossary",
98 "fglo_ref_id"
99 );
100 $exp->setTypeWhiteList(array("root", "cat", "grp", "crs", "glo", "fold"));
101 $exp->setClickableTypes(array("glo"));
102 if (!$exp->handleCommand()) {
103 $this->tpl->setContent($exp->getHTML());
104 }
105 }
106
107 public function setForeignGlossary(): void
108 {
109 $ilCtrl = $this->ctrl;
111
112 $ref_id = $this->request->getForeignGlossaryRefId();
113
114 if ($ref_id == $this->glossary->getRefId()) {
115 $this->tpl->setOnScreenMessage('failure', $lng->txt("glo_please_select_other_glo"), true);
116 $ilCtrl->redirect($this, "showGlossarySelector");
117 }
118
119 $ilCtrl->redirect($this, "showTerms");
120 }
121
122 public function showTerms(): void
123 {
124 $t = new ilGlossaryForeignTermTableGUI($this, "showTerms", $this->foreign_glossary);
125
126 $this->tpl->setContent($t->getHTML());
127 }
128
129 public function copyTerms(): void
130 {
131 $term_ids = $this->request->getTermIds();
132 if (count($term_ids) == 0) {
133 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("no_checkbox"), true);
134 $this->ctrl->redirect($this, "showTerms");
135 }
136 foreach ($term_ids as $id) {
137 $this->term_manager->copyTermFromOtherGlossary(
138 $this->foreign_glossary->getRefId(),
139 $id
140 );
141 }
142 $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
143 $this->ctrl->returnToParent($this);
144 }
145
146 public function referenceTerms(): void
147 {
148 $term_ids = $this->request->getTermIds();
149 if (count($term_ids) == 0) {
150 $this->tpl->setOnScreenMessage('failure', $this->lng->txt("no_checkbox"), true);
151 $this->ctrl->redirect($this, "showTerms");
152 }
153 $terms = array();
154 foreach ($term_ids as $id) {
155 $terms[] = $id;
156 }
157 $this->term_manager->referenceTermsFromOtherGlossary(
158 $this->foreign_glossary->getRefId(),
159 $terms
160 );
161
162 $this->tpl->setOnScreenMessage('success', $this->lng->txt("msg_obj_modified"), true);
163 $this->ctrl->returnToParent($this);
164 }
165}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
Class ilCtrl provides processing control methods.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ILIAS Glossary Editing EditingGUIRequest $request
static getInstance(ilObjGlossaryGUI $a_glossary_gui)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
language handling
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...
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...
User class.
static _lookupType(int $id, bool $reference=false)
Explorer for selecting repository items.
global $DIC
Definition: feed.php:28
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$ref_id
Definition: ltiauth.php:67
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc