ILIAS  trunk Revision v12.0_alpha-1227-g7ff6d300864
class.ilEditClipboardGUI.php
Go to the documentation of this file.
1<?php
2
26{
27 protected \ILIAS\MediaPool\InternalGUIService $gui;
28 public string $mode = "";
29 protected string $page_back_title = "";
30 protected bool $multiple = false;
31 protected \ILIAS\MediaPool\Clipboard\ClipboardGUIRequest $request;
32 protected \ILIAS\MediaPool\Clipboard\ClipboardManager $clipboard_manager;
33 protected string $insertbuttontitle = "";
34 protected ilLanguage $lng;
35 protected ilCtrl $ctrl;
36 protected ilObjUser $user;
37 protected ilTabsGUI $tabs;
38 protected ilTree $tree;
41
42 protected string $requested_return_cmd = "";
43 protected int $requested_clip_item_id = 0;
44 protected string $requested_pcid = "";
45
46 public function __construct()
47 {
48 global $DIC;
49
50 $this->lng = $DIC->language();
51 $this->ctrl = $DIC->ctrl();
52 $this->user = $DIC->user();
53 $this->tabs = $DIC->tabs();
54 $this->tree = $DIC->repositoryTree();
55 $this->tpl = $DIC["tpl"];
56 $this->toolbar = $DIC->toolbar();
57 $lng = $DIC->language();
58 $ilCtrl = $DIC->ctrl();
59
60 $this->request = $DIC->mediaPool()
61 ->internal()
62 ->gui()
63 ->clipboard()
64 ->request();
65
66 $this->multiple = false;
67 $this->page_back_title = $lng->txt("cont_back");
68 $this->requested_return_cmd = $this->request->getReturnCmd();
69 $this->requested_clip_item_id = $this->request->getItemId();
70 $this->requested_pcid = $this->request->getPCId();
71 $this->clipboard_manager = $DIC->mediaPool()
72 ->internal()
73 ->domain()
74 ->clipboard();
75
76 if ($this->requested_return_cmd !== "") {
77 $this->mode = "getObject";
78 } else {
79 $this->mode = "";
80 }
81
82 $ilCtrl->setParameter(
83 $this,
84 "returnCommand",
85 rawurlencode($this->requested_return_cmd)
86 );
87
88 $ilCtrl->saveParameter($this, array("clip_item_id", "pcid"));
89 $this->gui = $DIC->mediaPool()->internal()->gui();
90 }
91
92 public function executeCommand(): void
93 {
94 $ilUser = $this->user;
95 $ilCtrl = $this->ctrl;
96 $ilTabs = $this->tabs;
98
99 $next_class = $ilCtrl->getNextClass($this);
100 $cmd = $ilCtrl->getCmd();
101 switch ($next_class) {
102 case "ilobjmediaobjectgui":
103 $ilCtrl->setReturn($this, "view");
104 $ilTabs->clearTargets();
105 $ilTabs->setBackTarget(
106 $lng->txt("back"),
107 $ilCtrl->getLinkTarget($this, "view")
108 );
109 $mob_gui = new ilObjMediaObjectGUI("", $this->requested_clip_item_id, false, false);
110 $mob_gui->setTabs();
111 $ilCtrl->forwardCommand($mob_gui);
112 switch ($cmd) {
113 case "save":
114 $ilUser->addObjectToClipboard(
115 $mob_gui->getObject()->getId(),
116 "mob",
117 $mob_gui->getObject()->getTitle()
118 );
119 $ilCtrl->redirect($this, "view");
120 break;
121 }
122 break;
123
124 default:
125 $this->$cmd();
126 break;
127 }
128 }
129
130 public function setMultipleSelections(bool $a_multiple = true): void
131 {
132 $this->multiple = $a_multiple;
133 }
134
135 public function getMultipleSelections(): bool
136 {
137 return $this->multiple;
138 }
139
140 public function setInsertButtonTitle(string $a_insertbuttontitle): void
141 {
142 $this->insertbuttontitle = $a_insertbuttontitle;
143 }
144
145 public function getInsertButtonTitle(): string
146 {
148
149 if ($this->insertbuttontitle === "") {
150 return $lng->txt("insert");
151 }
152
154 }
155
156 public function view(): void
157 {
158 $ilCtrl = $this->ctrl;
160 $ilToolbar = $this->toolbar;
161
162 $this->lng->loadLanguageModule("mep");
163 $tpl->setOnScreenMessage("info", $this->lng->txt("mep_clipboard_info"));
164
165 $this->gui->button(
166 $this->lng->txt("cont_create_mob"),
167 $ilCtrl->getLinkTargetByClass("ilobjmediaobjectgui", "create")
168 )->toToolbar();
169
170 $table_gui = new ilClipboardTableGUI($this, "view");
171 $tpl->setContent($table_gui->getHTML());
172 }
173
174
175 public function getObject(): void
176 {
177 $this->mode = "getObject";
178 $this->view();
179 }
180
181
185 public function remove(): void
186 {
187 $ilUser = $this->user;
189 $ilCtrl = $this->ctrl;
190
191 // check number of objects
192 $ids = $this->request->getItemIds();
193
194 if (count($ids) === 0) {
195 $this->tpl->setOnScreenMessage('failure', $lng->txt("no_checkbox"), true);
196 $ilCtrl->redirect($this, "view");
197 }
198
199 foreach ($ids as $obj_id) {
200 $id = explode(":", $obj_id);
201 if ($id[0] === "mob") {
202 $ilUser->removeObjectFromClipboard($id[1], "mob");
203 $mob = new ilObjMediaObject($id[1]);
204 $mob->delete(); // this method don't delete, if mob is used elsewhere
205 }
206 if ($id[0] === "incl") {
207 $ilUser->removeObjectFromClipboard($id[1], "incl");
208 }
209 }
210 $ilCtrl->redirect($this, "view");
211 }
212
213 public function insert(): void
214 {
216
218 if ($this->requested_pcid !== "") {
219 $return .= "&pc_id=" . $this->requested_pcid;
220 }
221
222 $ids = $this->request->getItemIds();
223
224 // check number of objects
225 if (count($ids) === 0) {
226 $this->tpl->setOnScreenMessage('failure', $lng->txt("no_checkbox"), true);
227 ilUtil::redirect($return);
228 }
229
230 if (!$this->getMultipleSelections() && count($ids) > 1) {
231 $this->tpl->setOnScreenMessage('failure', $lng->txt("cont_select_max_one_item"), true);
232 ilUtil::redirect($return);
233 }
234
235 $this->clipboard_manager->setIds($ids);
236 ilUtil::redirect($return);
237 }
238
239 public static function _getSelectedIDs(): array
240 {
241 global $DIC;
242 $clipboard_manager = $DIC->mediaPool()
243 ->internal()
244 ->domain()
245 ->clipboard();
246
247 return $clipboard_manager->getIds();
248 }
249
250 public function setTabs(): void
251 {
252 $ilTabs = $this->tabs;
255
256 $tpl->setTitle($lng->txt("clipboard"));
257 $this->getTabs($ilTabs);
258 }
259
260 public function setPageBackTitle(string $a_title): void
261 {
262 $this->page_back_title = $a_title;
263 }
264
265 public function getTabs($tabs_gui): void
266 {
267 $ilCtrl = $this->ctrl;
268
269 // back to upper context
270 $tabs_gui->setBackTarget(
271 $this->page_back_title,
272 $ilCtrl->getParentReturn($this)
273 );
274 }
275}
$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 InternalGUIService $gui
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...
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
static redirect(string $a_script)
setOnScreenMessage(string $type, string $a_txt, bool $a_keep=false)
Set a message to be displayed to the user.
setTitle(string $a_title, bool $hidden=false)
Sets title in standard template.
setContent(string $a_html)
Sets content for standard template.
global $DIC
Definition: shib_login.php:26