ILIAS  release_8 Revision v8.24
class.ilEditClipboardGUI.php
Go to the documentation of this file.
1<?php
2
26{
27 public string $mode = "";
28 protected string $page_back_title = "";
29 protected bool $multiple = false;
30 protected \ILIAS\MediaPool\Clipboard\ClipboardGUIRequest $request;
31 protected \ILIAS\MediaPool\Clipboard\ClipboardManager $clipboard_manager;
32 protected string $insertbuttontitle = "";
33 protected ilLanguage $lng;
34 protected ilCtrl $ctrl;
35 protected ilObjUser $user;
36 protected ilTabsGUI $tabs;
37 protected ilTree $tree;
40
41 protected string $requested_return_cmd = "";
42 protected int $requested_clip_item_id = 0;
43 protected string $requested_pcid = "";
44
45 public function __construct()
46 {
47 global $DIC;
48
49 $this->lng = $DIC->language();
50 $this->ctrl = $DIC->ctrl();
51 $this->user = $DIC->user();
52 $this->tabs = $DIC->tabs();
53 $this->tree = $DIC->repositoryTree();
54 $this->tpl = $DIC["tpl"];
55 $this->toolbar = $DIC->toolbar();
56 $lng = $DIC->language();
57 $ilCtrl = $DIC->ctrl();
58
59 $this->request = $DIC->mediaPool()
60 ->internal()
61 ->gui()
62 ->clipboard()
63 ->request();
64
65 $this->multiple = false;
66 $this->page_back_title = $lng->txt("cont_back");
67 $this->requested_return_cmd = $this->request->getReturnCmd();
68 $this->requested_clip_item_id = $this->request->getItemId();
69 $this->requested_pcid = $this->request->getPCId();
70 $this->clipboard_manager = $DIC->mediaPool()
71 ->internal()
72 ->domain()
73 ->clipboard();
74
75 if ($this->requested_return_cmd !== "") {
76 $this->mode = "getObject";
77 } else {
78 $this->mode = "";
79 }
80
81 $ilCtrl->setParameter(
82 $this,
83 "returnCommand",
84 rawurlencode($this->requested_return_cmd)
85 );
86
87 $ilCtrl->saveParameter($this, array("clip_item_id", "pcid"));
88 }
89
90 public function executeCommand(): void
91 {
93 $ilCtrl = $this->ctrl;
94 $ilTabs = $this->tabs;
96
97 $next_class = $ilCtrl->getNextClass($this);
98 $cmd = $ilCtrl->getCmd();
99 switch ($next_class) {
100 case "ilobjmediaobjectgui":
101 $ilCtrl->setReturn($this, "view");
102 $ilTabs->clearTargets();
103 $ilTabs->setBackTarget(
104 $lng->txt("back"),
105 $ilCtrl->getLinkTarget($this, "view")
106 );
107 $mob_gui = new ilObjMediaObjectGUI("", $this->requested_clip_item_id, false, false);
108 $mob_gui->setTabs();
109 $ilCtrl->forwardCommand($mob_gui);
110 switch ($cmd) {
111 case "save":
112 $ilUser->addObjectToClipboard(
113 $mob_gui->getObject()->getId(),
114 "mob",
115 $mob_gui->getObject()->getTitle()
116 );
117 $ilCtrl->redirect($this, "view");
118 break;
119 }
120 break;
121
122 default:
123 $this->$cmd();
124 break;
125 }
126 }
127
128 public function setMultipleSelections(bool $a_multiple = true): void
129 {
130 $this->multiple = $a_multiple;
131 }
132
133 public function getMultipleSelections(): bool
134 {
135 return $this->multiple;
136 }
137
138 public function setInsertButtonTitle(string $a_insertbuttontitle): void
139 {
140 $this->insertbuttontitle = $a_insertbuttontitle;
141 }
142
143 public function getInsertButtonTitle(): string
144 {
146
147 if ($this->insertbuttontitle === "") {
148 return $lng->txt("insert");
149 }
150
152 }
153
154 public function view(): void
155 {
156 $ilCtrl = $this->ctrl;
158 $ilToolbar = $this->toolbar;
159
161 $but->setUrl($ilCtrl->getLinkTargetByClass("ilobjmediaobjectgui", "create"));
162 $but->setCaption("cont_create_mob");
163 $ilToolbar->addButtonInstance($but);
164
165 $table_gui = new ilClipboardTableGUI($this, "view");
166 $tpl->setContent($table_gui->getHTML());
167 }
168
169
170 public function getObject(): void
171 {
172 $this->mode = "getObject";
173 $this->view();
174 }
175
176
180 public function remove(): void
181 {
183 $lng = $this->lng;
184 $ilCtrl = $this->ctrl;
185
186 // check number of objects
187 $ids = $this->request->getItemIds();
188
189 if (count($ids) === 0) {
190 $this->tpl->setOnScreenMessage('failure', $lng->txt("no_checkbox"), true);
191 $ilCtrl->redirect($this, "view");
192 }
193
194 foreach ($ids as $obj_id) {
195 $id = explode(":", $obj_id);
196 if ($id[0] === "mob") {
197 $ilUser->removeObjectFromClipboard($id[1], "mob");
198 include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
199 $mob = new ilObjMediaObject($id[1]);
200 $mob->delete(); // this method don't delete, if mob is used elsewhere
201 }
202 if ($id[0] === "incl") {
203 $ilUser->removeObjectFromClipboard($id[1], "incl");
204 }
205 }
206 $ilCtrl->redirect($this, "view");
207 }
208
209 public function insert(): void
210 {
212
214 if ($this->requested_pcid !== "") {
215 $return .= "&pc_id=" . $this->requested_pcid;
216 }
217
218 $ids = $this->request->getItemIds();
219
220 // check number of objects
221 if (count($ids) === 0) {
222 $this->tpl->setOnScreenMessage('failure', $lng->txt("no_checkbox"), true);
223 ilUtil::redirect($return);
224 }
225
226 if (!$this->getMultipleSelections() && count($ids) > 1) {
227 $this->tpl->setOnScreenMessage('failure', $lng->txt("cont_select_max_one_item"), true);
228 ilUtil::redirect($return);
229 }
230
231 $this->clipboard_manager->setIds($ids);
232 ilUtil::redirect($return);
233 }
234
235 public static function _getSelectedIDs(): array
236 {
237 global $DIC;
238 $clipboard_manager = $DIC->mediaPool()
239 ->internal()
240 ->domain()
241 ->clipboard();
242
243 return $clipboard_manager->getIds();
244 }
245
246 public function setTabs(): void
247 {
248 $ilTabs = $this->tabs;
251
252 $tpl->setTitle($lng->txt("clipboard"));
253 $this->getTabs($ilTabs);
254 }
255
256 public function setPageBackTitle(string $a_title): void
257 {
258 $this->page_back_title = $a_title;
259 }
260
261 public function getTabs($tabs_gui): void
262 {
263 $ilCtrl = $this->ctrl;
264
265 // back to upper context
266 $tabs_gui->setBackTarget(
267 $this->page_back_title,
268 $ilCtrl->getParentReturn($this)
269 );
270 }
271}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilCtrl provides processing control methods.
redirect(object $a_gui_obj, string $a_cmd=null, string $a_anchor=null, bool $is_async=false)
@inheritDoc
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
ilGlobalTemplateInterface $tpl
ILIAS MediaPool Clipboard ClipboardGUIRequest $request
ILIAS MediaPool Clipboard ClipboardManager $clipboard_manager
setInsertButtonTitle(string $a_insertbuttontitle)
setPageBackTitle(string $a_title)
setMultipleSelections(bool $a_multiple=true)
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...
Editing User Interface for MediaObjects within LMs (see ILIAS DTD)
User class.
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...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static redirect(string $a_script)
global $DIC
Definition: feed.php:28
$ilUser
Definition: imgupload.php:34
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
setContent(string $a_html)
Sets content for standard template.
setTitle(string $a_title, bool $hidden=false)
Sets title in standard template.