ILIAS  release_7 Revision v7.30-3-g800a261c036
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"));
108 $this,
109 "showGlossarySelector",
110 $this,
111 "setForeignGlossary",
112 "fglo_ref_id"
113 );
114 $exp->setTypeWhiteList(array("root", "cat", "grp", "crs", "glo", "fold"));
115 $exp->setClickableTypes(array("glo"));
116 if (!$exp->handleCommand()) {
117 $this->tpl->setContent($exp->getHTML());
118 }
119 }
120
124 public function setForeignGlossary()
125 {
126 $ilCtrl = $this->ctrl;
128
129 $ref_id = (int) $_GET["fglo_ref_id"];
130
131 if ($ref_id == $this->glossary->getRefId()) {
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 public function showTerms()
146 {
147 $t = new ilGlossaryForeignTermTableGUI($this, "showTerms", $this->foreign_glossary);
148
149 $this->tpl->setContent($t->getHTML());
150 }
151
158 public function copyTerms()
159 {
160 if (!is_array($_POST["term_id"])) {
161 ilUtil::sendFailure($this->lng->txt("no_checkbox"), true);
162 $this->ctrl->redirect($this, "showTerms");
163 }
164 $act = ilGlossaryAct::getInstance($this->glossary, $this->user);
165 foreach ($_POST["term_id"] as $id) {
166 $act->copyTerm($this->foreign_glossary, (int) $id);
167 }
168 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
169 $this->ctrl->returnToParent($this);
170 }
171
178 public function referenceTerms()
179 {
180 if (!is_array($_POST["term_id"])) {
181 ilUtil::sendFailure($this->lng->txt("no_checkbox"), true);
182 $this->ctrl->redirect($this, "showTerms");
183 }
184 $act = ilGlossaryAct::getInstance($this->glossary, $this->user);
185 $terms = array();
186 foreach ($_POST["term_id"] as $id) {
187 $terms[] = (int) $id;
188 }
189 $act->referenceTerms($this->foreign_glossary, $terms);
190
191 ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"), true);
192 $this->ctrl->returnToParent($this);
193 }
194}
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.
global $DIC
Definition: goto.php:24