ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
class.ilEditClipboardGUI.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2010 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5require_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
6
19{
23 protected $lng;
24
28 protected $ctrl;
29
33 protected $user;
34
38 protected $tabs;
39
43 protected $tree;
44
48 protected $tpl;
49
53 protected $toolbar;
54
58 protected $error;
59
64 public function __construct()
65 {
66 global $DIC;
67
68 $this->lng = $DIC->language();
69 $this->ctrl = $DIC->ctrl();
70 $this->user = $DIC->user();
71 $this->tabs = $DIC->tabs();
72 $this->tree = $DIC->repositoryTree();
73 $this->tpl = $DIC["tpl"];
74 $this->toolbar = $DIC->toolbar();
75 $this->error = $DIC["ilErr"];
76 $lng = $DIC->language();
77 $ilCtrl = $DIC->ctrl();
78
79 $this->multiple = false;
80 $this->page_back_title = $lng->txt("cont_back");
81 if ($_GET["returnCommand"] != "") {
82 $this->mode = "getObject";
83 } else {
84 $this->mode = "";
85 }
86
87 $ilCtrl->setParameter(
88 $this,
89 "returnCommand",
90 rawurlencode($_GET["returnCommand"])
91 );
92
93 $ilCtrl->saveParameter($this, array("clip_item_id"));
94 }
95
99 public function executeCommand()
100 {
103 $ilTabs = $this->tabs;
105
106 $next_class = $ilCtrl->getNextClass($this);
107 $cmd = $ilCtrl->getCmd();
108
109 switch ($next_class) {
110 case "ilobjmediaobjectgui":
111 $ilCtrl->setReturn($this, "view");
112 $ilTabs->clearTargets();
113 $ilTabs->setBackTarget(
114 $lng->txt("back"),
115 $ilCtrl->getLinkTarget($this, "view")
116 );
117 $mob_gui = new ilObjMediaObjectGUI("", $_GET["clip_item_id"], false, false);
118 $mob_gui->setTabs();
119 $ret = $ilCtrl->forwardCommand($mob_gui);
120 switch ($cmd) {
121 case "save":
122 $ilUser->addObjectToClipboard($ret->getId(), "mob", $ret->getTitle());
123 $ilCtrl->redirect($this, "view");
124 break;
125 }
126 break;
127
128 default:
129 $ret = $this->$cmd();
130 break;
131 }
132
133 return $ret;
134 }
135
139 public function setMultipleSelections($a_multiple = true)
140 {
141 $this->multiple = $a_multiple;
142 }
143
147 public function getMultipleSelections()
148 {
149 return $this->multiple;
150 }
151
157 public function setInsertButtonTitle($a_insertbuttontitle)
158 {
159 $this->insertbuttontitle = $a_insertbuttontitle;
160 }
161
167 public function getInsertButtonTitle()
168 {
170
171 if ($this->insertbuttontitle == "") {
172 return $lng->txt("insert");
173 }
174
175 return $this->insertbuttontitle;
176 }
177
178 /*
179 * display clipboard content
180 */
181 public function view()
182 {
188 $ilToolbar = $this->toolbar;
189
190 include_once("./Services/UIComponent/Button/classes/class.ilLinkButton.php");
192 $but->setUrl($ilCtrl->getLinkTargetByClass("ilobjmediaobjectgui", "create"));
193 $but->setCaption("cont_create_mob");
194 $ilToolbar->addButtonInstance($but);
195
196 include_once("./Services/Clipboard/classes/class.ilClipboardTableGUI.php");
197 $table_gui = new ilClipboardTableGUI($this, "view");
198 $tpl->setContent($table_gui->getHTML());
199 }
200
201
205 public function getObject()
206 {
207 $this->mode = "getObject";
208 $this->view();
209 }
210
211
215 public function remove()
216 {
221
222 // check number of objects
223 if (!isset($_POST["id"])) {
224 $ilErr->raiseError($lng->txt("no_checkbox"), $ilErr->MESSAGE);
225 }
226
227 foreach ($_POST["id"] as $obj_id) {
228 $id = explode(":", $obj_id);
229 if ($id[0] == "mob") {
230 $ilUser->removeObjectFromClipboard($id[1], "mob");
231 include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
232 $mob = new ilObjMediaObject($id[1]);
233 $mob->delete(); // this method don't delete, if mob is used elsewhere
234 }
235 if ($id[0] == "incl") {
236 $ilUser->removeObjectFromClipboard($id[1], "incl");
237 }
238 }
239 $ilCtrl->redirect($this, "view");
240 }
241
245 public function insert()
246 {
249
250 // check number of objects
251 if (!isset($_POST["id"])) {
252 $ilErr->raiseError($lng->txt("no_checkbox"), $ilErr->MESSAGE);
253 }
254
255 if (!$this->getMultipleSelections()) {
256 if (count($_POST["id"]) > 1) {
257 $ilErr->raiseError($lng->txt("cont_select_max_one_item"), $ilErr->MESSAGE);
258 }
259 }
260
261 $_SESSION["ilEditClipboard_mob_id"] = $_POST["id"];
262 ilUtil::redirect($_GET["returnCommand"]);
263 }
264
265 public static function _getSelectedIDs()
266 {
267 return $_SESSION["ilEditClipboard_mob_id"];
268 }
269
273 public function setTabs()
274 {
275 $ilTabs = $this->tabs;
278
279 $tpl->setTitle($lng->txt("clipboard"));
280 $this->getTabs($ilTabs);
281 }
282
286 public function setPageBackTitle($a_title)
287 {
288 $this->page_back_title = $a_title;
289 }
290
296 public function getTabs(&$tabs_gui)
297 {
299
300 // back to upper context
301 $tabs_gui->setBackTarget(
302 $this->page_back_title,
303 $ilCtrl->getParentReturn($this)
304 );
305 }
306}
user()
Definition: user.php:4
$_GET["client_id"]
$_POST["username"]
$_SESSION["AccountId"]
An exception for terminatinating execution or to throw for unit testing.
error($a_errmsg)
set error message @access public
TableGUI clipboard items.
Class ilEditClipboardGUI.
getTabs(&$tabs_gui)
adds tabs to tab gui object
__construct()
Constructor @access public.
setInsertButtonTitle($a_insertbuttontitle)
Set Insert Button Title.
getMultipleSelections()
check wether multiple selections are enabled
getInsertButtonTitle()
Get Insert Button Title.
setMultipleSelections($a_multiple=true)
set, if multiple selections are enabled
setPageBackTitle($a_title)
Set title for back link.
executeCommand()
execute command
static getInstance()
Factory.
Class ilObjMediaObjectGUI.
Class ilObjMediaObject.
static redirect($a_script)
global $ilCtrl
Definition: ilias.php:18
$ret
Definition: parser.php:6
$ilErr
Definition: raiseError.php:18
$ilUser
Definition: imgupload.php:18
$DIC
Definition: xapitoken.php:46