ILIAS  trunk Revision v11.0_alpha-1713-gd8962da2f67
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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;
97  $lng = $this->lng;
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  {
147  $lng = $this->lng;
148 
149  if ($this->insertbuttontitle === "") {
150  return $lng->txt("insert");
151  }
152 
154  }
155 
156  public function view(): void
157  {
158  $ilCtrl = $this->ctrl;
159  $tpl = $this->tpl;
160  $ilToolbar = $this->toolbar;
161 
162  $this->gui->button(
163  $this->lng->txt("cont_create_mob"),
164  $ilCtrl->getLinkTargetByClass("ilobjmediaobjectgui", "create")
165  )->toToolbar();
166 
167  $table_gui = new ilClipboardTableGUI($this, "view");
168  $tpl->setContent($table_gui->getHTML());
169  }
170 
171 
172  public function getObject(): void
173  {
174  $this->mode = "getObject";
175  $this->view();
176  }
177 
178 
182  public function remove(): void
183  {
184  $ilUser = $this->user;
185  $lng = $this->lng;
186  $ilCtrl = $this->ctrl;
187 
188  // check number of objects
189  $ids = $this->request->getItemIds();
190 
191  if (count($ids) === 0) {
192  $this->tpl->setOnScreenMessage('failure', $lng->txt("no_checkbox"), true);
193  $ilCtrl->redirect($this, "view");
194  }
195 
196  foreach ($ids as $obj_id) {
197  $id = explode(":", $obj_id);
198  if ($id[0] === "mob") {
199  $ilUser->removeObjectFromClipboard($id[1], "mob");
200  $mob = new ilObjMediaObject($id[1]);
201  $mob->delete(); // this method don't delete, if mob is used elsewhere
202  }
203  if ($id[0] === "incl") {
204  $ilUser->removeObjectFromClipboard($id[1], "incl");
205  }
206  }
207  $ilCtrl->redirect($this, "view");
208  }
209 
210  public function insert(): void
211  {
212  $lng = $this->lng;
213 
214  $return = $this->requested_return_cmd;
215  if ($this->requested_pcid !== "") {
216  $return .= "&pc_id=" . $this->requested_pcid;
217  }
218 
219  $ids = $this->request->getItemIds();
220 
221  // check number of objects
222  if (count($ids) === 0) {
223  $this->tpl->setOnScreenMessage('failure', $lng->txt("no_checkbox"), true);
224  ilUtil::redirect($return);
225  }
226 
227  if (!$this->getMultipleSelections() && count($ids) > 1) {
228  $this->tpl->setOnScreenMessage('failure', $lng->txt("cont_select_max_one_item"), true);
229  ilUtil::redirect($return);
230  }
231 
232  $this->clipboard_manager->setIds($ids);
233  ilUtil::redirect($return);
234  }
235 
236  public static function _getSelectedIDs(): array
237  {
238  global $DIC;
239  $clipboard_manager = $DIC->mediaPool()
240  ->internal()
241  ->domain()
242  ->clipboard();
243 
244  return $clipboard_manager->getIds();
245  }
246 
247  public function setTabs(): void
248  {
249  $ilTabs = $this->tabs;
250  $lng = $this->lng;
251  $tpl = $this->tpl;
252 
253  $tpl->setTitle($lng->txt("clipboard"));
254  $this->getTabs($ilTabs);
255  }
256 
257  public function setPageBackTitle(string $a_title): void
258  {
259  $this->page_back_title = $a_title;
260  }
261 
262  public function getTabs($tabs_gui): void
263  {
264  $ilCtrl = $this->ctrl;
265 
266  // back to upper context
267  $tabs_gui->setBackTarget(
268  $this->page_back_title,
269  $ilCtrl->getParentReturn($this)
270  );
271  }
272 }
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...
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...
setInsertButtonTitle(string $a_insertbuttontitle)
setContent(string $a_html)
Sets content for standard template.
setTitle(string $a_title, bool $hidden=false)
Sets title in standard template.
setMultipleSelections(bool $a_multiple=true)
multiple()
description: > This example show how the UI-Elements itself looks like.
Definition: multiple.php:36
ILIAS MediaPool Clipboard ClipboardGUIRequest $request
redirect(object $a_gui_obj, ?string $a_cmd=null, ?string $a_anchor=null, bool $is_async=false)
global $DIC
Definition: shib_login.php:22
ilGlobalTemplateInterface $tpl
setPageBackTitle(string $a_title)
static redirect(string $a_script)
Editing User Interface for MediaObjects within LMs (see ILIAS DTD)
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
ILIAS MediaPool InternalGUIService $gui
ILIAS MediaPool Clipboard ClipboardManager $clipboard_manager