ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 $this->foreign_glossary = new ilObjGlossary($this->fglo_ref_id, true);
69 }
70
71 $this->ctrl->saveParameter($this, "fglo_ref_id");
72 }
73
80 public static function getInstance(ilObjGlossaryGUI $a_glossary_gui)
81 {
82 return new self($a_glossary_gui);
83 }
84
88 public function executeCommand()
89 {
90 $next_class = $this->ctrl->getNextClass($this);
91 $cmd = $this->ctrl->getCmd("showGlossarySelector");
92
93 switch ($next_class) {
94 default:
95 if (in_array($cmd, array("showGlossarySelector", "setForeignGlossary", "showTerms", "copyTerms", "referenceTerms"))) {
96 $this->$cmd();
97 }
98 }
99 }
100
104 public function showGlossarySelector()
105 {
106 ilUtil::sendInfo($this->lng->txt("glo_select_source_glo"));
107 include_once("./Services/Repository/classes/class.ilRepositorySelectorExplorerGUI.php");
109 $this,
110 "showGlossarySelector",
111 $this,
112 "setForeignGlossary",
113 "fglo_ref_id"
114 );
115 $exp->setTypeWhiteList(array("root", "cat", "grp", "crs", "glo", "fold"));
116 $exp->setClickableTypes(array("glo"));
117 if (!$exp->handleCommand()) {
118 $this->tpl->setContent($exp->getHTML());
119 }
120 }
121
125 public function setForeignGlossary()
126 {
129
130 $ref_id = (int) $_GET["fglo_ref_id"];
131
132 if ($ref_id == $this->glossary->getRefId()) {
133 ilUtil::sendFailure($lng->txt("glo_please_select_other_glo"), true);
134 $ilCtrl->redirect($this, "showGlossarySelector");
135 }
136
137 $ilCtrl->redirect($this, "showTerms");
138 }
139
146 public function showTerms()
147 {
148 include_once("./Modules/Glossary/classes/class.ilGlossaryForeignTermTableGUI.php");
149 $t = new ilGlossaryForeignTermTableGUI($this, "showTerms", $this->foreign_glossary);
150
151 $this->tpl->setContent($t->getHTML());
152 }
153
160 public function copyTerms()
161 {
162 if (!is_array($_POST["term_id"])) {
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 $act->copyTerm($this->foreign_glossary, (int) $id);
170 }
171 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
172 $this->ctrl->returnToParent($this);
173 }
174
181 public function referenceTerms()
182 {
183 if (!is_array($_POST["term_id"])) {
184 ilUtil::sendFailure($this->lng->txt("no_checkbox"), true);
185 $this->ctrl->redirect($this, "showTerms");
186 }
187 include_once("./Modules/Glossary/classes/class.ilGlossaryAct.php");
188 $act = ilGlossaryAct::getInstance($this->glossary, $this->user);
189 $terms = array();
190 foreach ($_POST["term_id"] as $id) {
191 $terms[] = (int) $id;
192 }
193 $act->referenceTerms($this->foreign_glossary, $terms);
194
195 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
196 $this->ctrl->returnToParent($this);
197 }
198}
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 sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
if(!array_key_exists('StateId', $_REQUEST)) $id
global $ilCtrl
Definition: ilias.php:18
global $DIC
Definition: saml.php:7