ILIAS  release_8 Revision v8.25-1-g13de6a5eca6
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 string $return_cmd = ""
47 )
48 {
49 global $DIC;
50
51 $this->lng = $DIC->language();
52 $this->ctrl = $DIC->ctrl();
53 $this->user = $DIC->user();
54 $this->tabs = $DIC->tabs();
55 $this->tree = $DIC->repositoryTree();
56 $this->tpl = $DIC["tpl"];
57 $this->toolbar = $DIC->toolbar();
58 $lng = $DIC->language();
59 $ilCtrl = $DIC->ctrl();
60
61 $this->request = $DIC->mediaPool()
62 ->internal()
63 ->gui()
64 ->clipboard()
65 ->request();
66
67 $this->multiple = false;
68 $this->page_back_title = $lng->txt("cont_back");
69 $this->requested_return_cmd = $return_cmd;
70 $this->requested_clip_item_id = $this->request->getItemId();
71 $this->requested_pcid = $this->request->getPCId();
72 $this->clipboard_manager = $DIC->mediaPool()
73 ->internal()
74 ->domain()
75 ->clipboard();
76
77 if ($this->requested_return_cmd !== "") {
78 $this->mode = "getObject";
79 } else {
80 $this->mode = "";
81 }
82
83 $ilCtrl->saveParameter($this, array("clip_item_id", "pcid"));
84 }
85
86 public function executeCommand(): void
87 {
89 $ilCtrl = $this->ctrl;
90 $ilTabs = $this->tabs;
92
93 $next_class = $ilCtrl->getNextClass($this);
94 $cmd = $ilCtrl->getCmd();
95 switch ($next_class) {
96 case "ilobjmediaobjectgui":
97 $ilCtrl->setReturn($this, "view");
98 $ilTabs->clearTargets();
99 $ilTabs->setBackTarget(
100 $lng->txt("back"),
101 $ilCtrl->getLinkTarget($this, "view")
102 );
103 $mob_gui = new ilObjMediaObjectGUI("", $this->requested_clip_item_id, false, false);
104 $mob_gui->setTabs();
105 $ilCtrl->forwardCommand($mob_gui);
106 switch ($cmd) {
107 case "save":
108 $ilUser->addObjectToClipboard(
109 $mob_gui->getObject()->getId(),
110 "mob",
111 $mob_gui->getObject()->getTitle()
112 );
113 $ilCtrl->redirect($this, "view");
114 break;
115 }
116 break;
117
118 default:
119 $this->$cmd();
120 break;
121 }
122 }
123
124 public function setMultipleSelections(bool $a_multiple = true): void
125 {
126 $this->multiple = $a_multiple;
127 }
128
129 public function getMultipleSelections(): bool
130 {
131 return $this->multiple;
132 }
133
134 public function setInsertButtonTitle(string $a_insertbuttontitle): void
135 {
136 $this->insertbuttontitle = $a_insertbuttontitle;
137 }
138
139 public function getInsertButtonTitle(): string
140 {
142
143 if ($this->insertbuttontitle === "") {
144 return $lng->txt("insert");
145 }
146
148 }
149
150 public function view(): void
151 {
152 $ilCtrl = $this->ctrl;
154 $ilToolbar = $this->toolbar;
155
157 $but->setUrl($ilCtrl->getLinkTargetByClass("ilobjmediaobjectgui", "create"));
158 $but->setCaption("cont_create_mob");
159 $ilToolbar->addButtonInstance($but);
160
161 $table_gui = new ilClipboardTableGUI($this, "view");
162 $tpl->setContent($table_gui->getHTML());
163 }
164
165
166 public function getObject(): void
167 {
168 $this->mode = "getObject";
169 $this->view();
170 }
171
172
176 public function remove(): void
177 {
179 $lng = $this->lng;
180 $ilCtrl = $this->ctrl;
181
182 // check number of objects
183 $ids = $this->request->getItemIds();
184
185 if (count($ids) === 0) {
186 $this->tpl->setOnScreenMessage('failure', $lng->txt("no_checkbox"), true);
187 $ilCtrl->redirect($this, "view");
188 }
189
190 foreach ($ids as $obj_id) {
191 $id = explode(":", $obj_id);
192 if ($id[0] === "mob") {
193 $ilUser->removeObjectFromClipboard($id[1], "mob");
194 include_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
195 $mob = new ilObjMediaObject($id[1]);
196 $mob->delete(); // this method don't delete, if mob is used elsewhere
197 }
198 if ($id[0] === "incl") {
199 $ilUser->removeObjectFromClipboard($id[1], "incl");
200 }
201 }
202 $ilCtrl->redirect($this, "view");
203 }
204
205 public function insert(): void
206 {
208
210 if ($this->requested_pcid !== "") {
211 $return .= "&pc_id=" . $this->requested_pcid;
212 }
213
214 $ids = $this->request->getItemIds();
215
216 // check number of objects
217 if (count($ids) === 0) {
218 $this->tpl->setOnScreenMessage('failure', $lng->txt("no_checkbox"), true);
219 ilUtil::redirect($return);
220 }
221
222 if (!$this->getMultipleSelections() && count($ids) > 1) {
223 $this->tpl->setOnScreenMessage('failure', $lng->txt("cont_select_max_one_item"), true);
224 ilUtil::redirect($return);
225 }
226
227 $this->clipboard_manager->setIds($ids);
228 ilUtil::redirect($return);
229 }
230
231 public static function _getSelectedIDs(): array
232 {
233 global $DIC;
234 $clipboard_manager = $DIC->mediaPool()
235 ->internal()
236 ->domain()
237 ->clipboard();
238
239 return $clipboard_manager->getIds();
240 }
241
242 public function setTabs(): void
243 {
244 $ilTabs = $this->tabs;
247
248 $tpl->setTitle($lng->txt("clipboard"));
249 $this->getTabs($ilTabs);
250 }
251
252 public function setPageBackTitle(string $a_title): void
253 {
254 $this->page_back_title = $a_title;
255 }
256
257 public function getTabs($tabs_gui): void
258 {
259 $ilCtrl = $this->ctrl;
260
261 // back to upper context
262 $tabs_gui->setBackTarget(
263 $this->page_back_title,
264 $ilCtrl->getParentReturn($this)
265 );
266 }
267}
$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
__construct(string $return_cmd="")
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.