ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
class.ilGlossaryForeignTermCollectorGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2016 ILIAS open source, Extended GPL, see docs/LICENSE */
4
13{
17 protected $glossary_gui;
18
22 protected $glossary;
23
27 protected $fglo_ref_id;
28
32 protected $ctrl;
33
37 protected $lng;
38
42 protected $tpl;
43
47 protected $user;
48
54 protected function __construct(ilObjGlossaryGUI $a_glossary_gui)
55 {
56 global $DIC;
57
58 $this->tpl = $DIC["tpl"];
59 $this->ctrl = $DIC->ctrl();
60 $this->lng = $DIC->language();
61 $this->user = $DIC->user();
62
63 $this->glossary_gui = $a_glossary_gui;
64 $this->glossary = $a_glossary_gui->object;
65
66 $this->fglo_ref_id = (int) $_GET["fglo_ref_id"];
67 if ($this->fglo_ref_id > 0 && ilObject::_lookupType($this->fglo_ref_id, true) == "glo")
68 {
69 $this->foreign_glossary = new ilObjGlossary($this->fglo_ref_id, true);
70 }
71
72 $this->ctrl->saveParameter($this, "fglo_ref_id");
73 }
74
81 public static function getInstance(ilObjGlossaryGUI $a_glossary_gui)
82 {
83 return new self($a_glossary_gui);
84 }
85
89 function executeCommand()
90 {
91 $next_class = $this->ctrl->getNextClass($this);
92 $cmd = $this->ctrl->getCmd("showGlossarySelector");
93
94 switch ($next_class)
95 {
96 default:
97 if (in_array($cmd, array("showGlossarySelector", "setForeignGlossary", "showTerms", "copyTerms", "referenceTerms")))
98 {
99 $this->$cmd();
100 }
101 }
102 }
103
108 {
109 ilUtil::sendInfo($this->lng->txt("glo_select_source_glo"));
110 include_once("./Services/Repository/classes/class.ilRepositorySelectorExplorerGUI.php");
111 $exp = new ilRepositorySelectorExplorerGUI($this, "showGlossarySelector",
112 $this, "setForeignGlossary", "fglo_ref_id");
113 $exp->setTypeWhiteList(array("root", "cat", "grp", "crs", "glo", "fold"));
114 $exp->setClickableTypes(array("glo"));
115 if (!$exp->handleCommand())
116 {
117 $this->tpl->setContent($exp->getHTML());
118 }
119 }
120
125 {
126 global $ilCtrl, $lng;
127
128 $ref_id = (int) $_GET["fglo_ref_id"];
129
130 if ($ref_id == $this->glossary->getRefId())
131 {
132 ilUtil::sendFailure($lng->txt("glo_please_select_other_glo"), true);
133 $ilCtrl->redirect($this, "showGlossarySelector");
134 }
135
136 $ilCtrl->redirect($this, "showTerms");
137 }
138
145 function showTerms()
146 {
147 include_once("./Modules/Glossary/classes/class.ilGlossaryForeignTermTableGUI.php");
148 $t = new ilGlossaryForeignTermTableGUI($this, "showTerms", $this->foreign_glossary);
149
150 $this->tpl->setContent($t->getHTML());
151 }
152
159 function copyTerms()
160 {
161 if(!is_array($_POST["term_id"]))
162 {
163 ilUtil::sendFailure($this->lng->txt("no_checkbox"), true);
164 $this->ctrl->redirect($this, "showTerms");
165 }
166 include_once("./Modules/Glossary/classes/class.ilGlossaryAct.php");
167 $act = ilGlossaryAct::getInstance($this->glossary, $this->user);
168 foreach ($_POST["term_id"] as $id)
169 {
170 $act->copyTerm($this->foreign_glossary, (int) $id);
171 }
172 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
173 $this->ctrl->returnToParent($this);
174 }
175
182 function referenceTerms()
183 {
184 if(!is_array($_POST["term_id"]))
185 {
186 ilUtil::sendFailure($this->lng->txt("no_checkbox"), true);
187 $this->ctrl->redirect($this, "showTerms");
188 }
189 include_once("./Modules/Glossary/classes/class.ilGlossaryAct.php");
190 $act = ilGlossaryAct::getInstance($this->glossary, $this->user);
191 $terms = array();
192 foreach ($_POST["term_id"] as $id)
193 {
194 $terms[] = (int) $id;
195
196 }
197 $act->referenceTerms($this->foreign_glossary, $terms);
198
199 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
200 $this->ctrl->returnToParent($this);
201 }
202
203}
204
205?>
user()
Definition: user.php:4
$_GET["client_id"]
$_POST["username"]
An exception for terminatinating execution or to throw for unit testing.
static getInstance(ilObjGlossary $a_glossary, ilObjUser $a_user)
Get instance.
Collects terms (reference or copy) from other glossaries.
static getInstance(ilObjGlossaryGUI $a_glossary_gui)
Get instance.
__construct(ilObjGlossaryGUI $a_glossary_gui)
Constructor.
TableGUI class for collecting foreign terms.
Class ilGlossaryGUI.
Class ilObjGlossary.
static _lookupType($a_id, $a_reference=false)
lookup object type
Explorer for selecting repository items.
static sendSuccess($a_info="", $a_keep=false)
Send Success Message to Screen.
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
global $ilCtrl
Definition: ilias.php:18
$cmd
Definition: sahs_server.php:35
$ref_id
Definition: sahs_server.php:39
global $DIC