ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilPageEditorGUI.php
Go to the documentation of this file.
1<?php
2
21use Psr\Http\Message\ServerRequestInterface;
22
39{
40 protected \ILIAS\COPage\PC\PCDefinition $pc_definition;
41 protected ServerRequestInterface $http_request;
46 protected string $page_back_title = "";
48 protected string $int_link_return = "";
50 protected ilHelpGUI $help;
51 protected ilObjUser $user;
55 public ilCtrl $ctrl;
58 public string $target_script = "";
59 public string $return_location = "";
60 public string $header = "";
61 public ?ilPageContent $cont_obj = null;
62 public bool $enable_keywords = false;
63 public bool $enable_anchors = false;
64 protected ilLogger $log;
65 protected \ILIAS\DI\UIServices $ui;
66 protected \ILIAS\GlobalScreen\ScreenContext\ContextServices $tool_context;
67 protected string $requested_hier_id;
68 protected string $requested_pc_id;
69 protected string $requested_pcid; // one of these should go
70 protected string $requested_pl_pc_id; // placeholder pc id
71 protected string $requested_ctype;
72 protected string $requested_cname;
73 protected int $requested_mob_id;
74
75 public function __construct(
76 ilPageObject $a_page_object,
77 ilPageObjectGUI $a_page_object_gui
78 ) {
79 global $DIC;
80
81 $this->help = $DIC["ilHelp"];
82 $this->user = $DIC->user();
83 $this->access = $DIC->access();
84 $tpl = $DIC["tpl"];
85 $lng = $DIC->language();
86 $objDefinition = $DIC["objDefinition"];
87 $ilCtrl = $DIC->ctrl();
88 $ilTabs = $DIC->tabs();
89
90 $this->ui = $DIC->ui();
91
92 $this->request = $DIC->copage()->internal()->gui()->page()->editRequest();
93 $this->requested_hier_id = $this->request->getHierId();
94 $this->requested_pc_id = $this->request->getPCId();
95 $this->requested_pl_pc_id = $this->request->getPlaceholderPCId();
96 $this->requested_ctype = $this->request->getCType();
97 $this->requested_cname = $this->request->getCName();
98 $this->requested_mob_id = $this->request->getMobId();
99
100 $this->log = ilLoggerFactory::getLogger('copg');
101
102 $this->tool_context = $DIC->globalScreen()->tool()->context();
103
104 // initiate variables
105 $this->http_request = $DIC->http()->request();
106 $this->ctrl = $ilCtrl;
107 $this->tpl = $tpl;
108 $this->lng = $lng;
109 $this->objDefinition = $objDefinition;
110 $this->tabs_gui = $ilTabs;
111 $this->page = $a_page_object;
112 $this->page_gui = $a_page_object_gui;
113
114 $this->ctrl->saveParameter($this, array("hier_id", "pc_id"));
115
116 $this->edit_repo = $DIC
117 ->copage()
118 ->internal()
119 ->repo()
120 ->edit();
121 $this->pc_definition = $DIC
122 ->copage()
123 ->internal()
124 ->domain()
125 ->pc()
126 ->definition();
127 }
128
132 public function setHeader(string $a_header): void
133 {
134 $this->header = $a_header;
135 }
136
137 public function getHeader(): string
138 {
139 return $this->header;
140 }
141
142 public function returnToContext(): void
143 {
144 $this->ctrl->returnToParent($this);
145 }
146
147 public function setIntLinkReturn(string $a_return): void
148 {
149 $this->int_link_return = $a_return;
150 }
151
152 public function setPageBackTitle(string $a_title): void
153 {
154 $this->page_back_title = $a_title;
155 }
156
160 public function executeCommand(): string
161 {
162 $ilCtrl = $this->ctrl;
163 $ilHelp = $this->help;
164 $this->log->debug("begin =========================");
165 $ctype = "";
166 $cont_obj = null;
167
168 $ret = "";
169 $add_type = "";
170
171 // Step BC (basic command determination)
172 // determine cmd, cmdClass, hier_id and pc_id
173 $cmd = $this->ctrl->getCmd("displayPage");
174 $cmdClass = strtolower($this->ctrl->getCmdClass());
175
176 $hier_id = $this->requested_hier_id;
177 $pc_id = $this->requested_pc_id;
178 $new_hier_id = $this->request->getString("new_hier_id");
179 if ($new_hier_id != "") {
180 $hier_id = $new_hier_id;
181 }
182
183 $this->log->debug("step BC: cmd:$cmd, cmdClass:$cmdClass, hier_id: $hier_id, pc_id: $pc_id");
184
185 // Step EC (exec_ command handling)
186 // handle special exec_ commands, modify pc, hier_id
187 if (substr($cmd, 0, 5) == "exec_") {
188 // check whether pc id is given
189 $pca = explode(":", $this->ctrl->getCmd());
190 $pc_id = $pca[1];
191 $cmd = explode("_", $pca[0]);
192 unset($cmd[0]);
193 $hier_id = implode("_", $cmd);
194 $cmd = $this->request->getString("command" . $hier_id);
195 }
196 $this->log->debug("step EC: cmd:$cmd, hier_id: $hier_id, pc_id: $pc_id");
197
198 // Step CC (handle table container (and similar) commands
199 // ... strip "c" "r" of table ids from hierarchical id
200 $first_hier_character = substr($hier_id, 0, 1);
201 if ($first_hier_character == "c" ||
202 $first_hier_character == "r" ||
203 $first_hier_character == "g" ||
204 $first_hier_character == "i") {
205 $hier_id = substr($hier_id, 1);
206 }
207 $this->log->debug("step CC: cmd:$cmd, hier_id: $hier_id, pc_id: $pc_id");
208
209 // Step B (build dom, and ids in XML)
210 $this->page->buildDom();
211 $this->page->addHierIDs();
212
213
214 // Step CS (strip base command)
215 $com = null;
216 if ($cmdClass != "ilcontainerresourcegui") {
217 $com = explode("_", $cmd);
218 $cmd = $com[0];
219 }
220 $this->log->debug("step CS: cmd:$cmd");
221
222
223 // Step NC (determine next class)
224 $next_class = $this->ctrl->getNextClass($this);
225 $this->log->debug("step NC: next class: " . $next_class);
226
227 // Step PH (placeholder handling, placeholders from preview mode come without hier_id)
228 if ($next_class == "ilpcplaceholdergui" && $hier_id == "" && $this->requested_pl_pc_id != "") {
229 $hid = $this->page->getHierIdsForPCIds(array($this->requested_pl_pc_id));
230 $hier_id = $hid[$this->requested_pl_pc_id];
231 }
232 $this->log->debug("step PH: next class: " . $next_class);
233 if (!is_null($com) && ($com[0] == "insert" || $com[0] == "create")) {
234 // Step CM (creation mode handling)
235 $cmd = $com[0];
236 $ctype = $com[1] ?? ""; // note ctype holds type if cmdclass is empty, but also subcommands if not (e.g. applyFilter in ilpcmediaobjectgui)
237 $add_type = $this->request->getString("pluginName");
238 if ($ctype == "mob") {
239 $ctype = "media";
240 }
241
242 $this->log->debug("step CM: cmd: " . $cmd . ", ctype: " . $ctype . ", add_type: " . $add_type);
243 } else {
244 $this->log->debug("step LM: cmd: " . $cmd . ", cmdClass: " . $cmdClass);
245
246 // Step PR (get content object and return to parent)
247 $this->log->debug("before PR: cmdClass: $cmdClass, nextClass: $next_class" .
248 ", hier_id: " . $hier_id . ", pc_id: " . $pc_id . ")");
249 // note: ilinternallinkgui for page: no cont_obj is received
250 // ilinternallinkgui for mob: cont_obj is received
251 if ($this->requested_ctype == "" && $this->requested_cname == "" &&
252 $cmd != "insertFromClipboard" && $cmd != "pasteFromClipboard" &&
253 $cmd != "setMediaMode" && $cmd != "copyLinkedMediaToClipboard" &&
254 $cmd != "activatePage" && $cmd != "deactivatePage" &&
255 $cmd != "copyLinkedMediaToMediaPool" && $cmd != "showSnippetInfo" &&
256 $cmd != "delete" && $cmd != "paste" &&
257 $cmd != "cancelDeleteSelected" && $cmd != "confirmedDeleteSelected" &&
258 $cmd != "copy" && $cmd != "cut" &&
259 ($cmd != "displayPage" || $this->request->getString("editImagemapForward_x") != "" || $cmdClass == "ilcontainerresourcegui") &&
260 $cmd != "activate" && $cmd != "characteristic" &&
261 $cmd != "assignCharacteristic" &&
262 $cmdClass != "ilrepositoryselector2inputgui" &&
263 $cmdClass != "ilpageeditorserveradaptergui" &&
264 $cmd != "cancelCreate" && $cmd != "popup" &&
265 $cmdClass != "ileditclipboardgui" && $cmd != "addChangeComment" &&
266 ($cmdClass != "ilinternallinkgui" || ($next_class == "ilpcmediaobjectgui"))) {
267 $cont_obj = $this->page->getContentObject($hier_id, $pc_id);
268 if (!is_object($cont_obj)) {
269 $this->log->debug("returnToParent");
270 $ilCtrl->returnToParent($this);
271 }
272 $ctype = $cont_obj->getType();
273 }
274 }
275 // Step NC (handle empty next class)
276 if ($this->requested_ctype != "" || $this->requested_cname != "") {
277 $ctype = $this->requested_ctype;
278 if ($this->requested_cname != "") {
279 $pc_def = $this->pc_definition->getPCDefinitionByName($this->requested_cname);
280 $ctype = $pc_def["pc_type"];
281 }
282 $pc_id = $this->requested_pc_id;
283 $hier_id = $this->requested_hier_id;
284 if (!in_array($cmd, ["insert", "create", "upload"])) {
285 $cont_obj = $this->page->getContentObject($hier_id, $pc_id);
286 }
287 }
288 // this fixes e.g. #31214
289 if ($pc_id != "" && $hier_id == "") {
290 $hier_id = $this->page->getHierIdForPcId($pc_id);
291 }
292 if ($ctype != "media" || !is_object($cont_obj)) {
293 if ($this->getHeader() != "") {
294 $this->tpl->setTitle($this->getHeader());
295 }
296 }
297
298 $this->cont_obj = $cont_obj;
299
300 $this->ctrl->setParameter($this, "hier_id", $hier_id);
301 $this->ctrl->setParameter($this, "pc_id", $pc_id);
302
303 if ($next_class == "") {
304 $pc_def = $this->pc_definition->getPCDefinitionByType($ctype);
305 if (is_array($pc_def)) {
306 if ($ctype === "plug") {
307 $this->ctrl->setParameterByClass(
308 $pc_def["pc_gui_class"],
309 "pluginName",
310 $this->request->getString("pluginName")
311 );
312 }
313 $this->ctrl->redirectByClass($pc_def["pc_gui_class"], $this->ctrl->getCmd());
314 }
315 $next_class = $this->ctrl->getNextClass($this);
316 }
317 $this->log->debug("step NC2: next_class: $next_class");
318
319 // ... do not do this while imagemap editing is ongoing
320 // Step IM (handle image map editing)
321 if ($cmd == "displayPage" && $next_class !== "ilpcmediaobjectgui" &&
322 $this->request->getString("editImagemapForward_x") == ""
323 && $this->request->getString("imagemap_x") == "") {
324 $next_class = "";
325 }
326
327 switch ($next_class) {
328 case "ilinternallinkgui":
329 $link_gui = new ilInternalLinkGUI(
330 $this->page_gui->getPageConfig()->getIntLinkHelpDefaultType(),
331 $this->page_gui->getPageConfig()->getIntLinkHelpDefaultId(),
332 $this->page_gui->getPageConfig()->getIntLinkHelpDefaultIdIsRef()
333 );
334 $link_gui->setFilterWhiteList(
335 $this->page_gui->getPageConfig()->getIntLinkFilterWhiteList()
336 );
337 foreach ($this->page_gui->getPageConfig()->getIntLinkFilters() as $filter) {
338 $link_gui->filterLinkType($filter);
339 }
340 $link_gui->setReturn($this->int_link_return);
341
342 $ret = $this->ctrl->forwardCommand($link_gui);
343 break;
344
345 // PC Media Object
346 case "ilpcmediaobjectgui":
347 $this->tabs_gui->clearTargets();
348 $this->tabs_gui->setBackTarget(
349 $this->page_gui->page_back_title,
350 $ilCtrl->getLinkTarget($this->page_gui, "edit")
351 );
352 $pcmob_gui = new ilPCMediaObjectGUI($this->page, $cont_obj, $hier_id, $pc_id);
353 $pcmob_gui->setStyleId($this->page_gui->getStyleId());
354 $pcmob_gui->setSubCmd($ctype);
355 $pcmob_gui->setEnabledMapAreas($this->page_gui->getPageConfig()->getEnableInternalLinks());
356 $ret = $this->ctrl->forwardCommand($pcmob_gui);
357 $ilHelp->setScreenIdComponent("copg_media");
358 break;
359
360 // only for "linked" media
361 case "ilobjmediaobjectgui":
362 $this->tabs_gui->clearTargets();
363 $this->tabs_gui->setBackTarget(
364 $this->lng->txt("back"),
365 (string) $ilCtrl->getParentReturn($this)
366 );
367 $mob_gui = new ilObjMediaObjectGUI("", $this->requested_mob_id, false, false);
368 $mob_gui->getTabs();
369 $mob_gui->setEnabledMapAreas($this->page_gui->getPageConfig()->getEnableInternalLinks());
370 $this->tpl->setTitle($this->lng->txt("mob") . ": " .
371 ilObject::_lookupTitle($this->requested_mob_id));
372 $ret = $this->ctrl->forwardCommand($mob_gui);
373 break;
374
375 // Question
376 case "ilpcquestiongui":
377 $pc_question_gui = new ilPCQuestionGUI($this->page, $cont_obj, $hier_id, $pc_id);
378 $pc_question_gui->setSelfAssessmentMode($this->page_gui->getPageConfig()->getEnableSelfAssessment());
379 $pc_question_gui->setPageConfig($this->page_gui->getPageConfig());
380
381 if ($this->page_gui->getPageConfig()->getEnableSelfAssessment()) {
382 $this->tabs_gui->clearTargets();
383 $ilHelp->setScreenIdComponent("copg_pcqst");
384 $this->tabs_gui->setBackTarget(
385 $this->lng->txt("back"),
386 (string) $ilCtrl->getParentReturn($this)
387 );
388 $ret = $this->ctrl->forwardCommand($pc_question_gui);
389 } else {
390 $cmd = $this->ctrl->getCmd();
391 $pc_question_gui->$cmd();
392 $this->ctrl->redirectByClass(array("ilobjquestionpoolgui", get_class($cont_obj)), "editQuestion");
393 }
394 break;
395
396 // Plugged Component
397 case "ilpcpluggedgui":
398 $this->tabs_gui->clearTargets();
399 $plugged_gui = new ilPCPluggedGUI(
400 $this->page,
401 $cont_obj,
402 $hier_id,
403 $add_type,
404 $pc_id
405 );
406 $ret = $this->ctrl->forwardCommand($plugged_gui);
407 break;
408
409 case "ilpageeditorserveradaptergui":
410 $adapter = new ilPageEditorServerAdapterGUI(
411 $this->page_gui,
412 $this->ctrl,
413 $this->ui,
414 $this->http_request
415 );
416 $this->ctrl->forwardCommand($adapter);
417 break;
418
419 default:
420
421 // generic calls to gui classes
422 if ($this->pc_definition->isPCGUIClassName($next_class, true)) {
423 $this->log->debug("Generic Call");
424 $pc_def = $this->pc_definition->getPCDefinitionByGUIClassName($next_class);
425 $this->tabs_gui->clearTargets();
426 $this->tabs_gui->setBackTarget(
427 $this->page_gui->page_back_title,
428 $ilCtrl->getLinkTarget($this->page_gui, "edit")
429 );
430 $ilHelp->setScreenIdComponent("copg_" . $pc_def["pc_type"]);
431 $gui_class_name = $pc_def["pc_gui_class"];
432 $pc_gui = new $gui_class_name($this->page, $cont_obj, $hier_id, $pc_id);
433 if ($pc_def["style_classes"]) {
434 $pc_gui->setStyleId($this->page_gui->getStyleId());
435 }
436 $pc_gui->setPageConfig($this->page_gui->getPageConfig());
437 $ret = $this->ctrl->forwardCommand($pc_gui);
438 } else {
439 $this->log->debug("Call ilPageEditorGUI command.");
440 // cmd belongs to ilPageEditorGUI
441
442 if ($cmd == "pasteFromClipboard") {
443 //$ret = $this->pasteFromClipboard($hier_id);
444 $this->pasteFromClipboard($hier_id);
445 } elseif ($cmd == "paste") {
446 //$ret = $this->paste($hier_id);
447 $this->paste($hier_id);
448 } else {
449 $ret = $this->$cmd();
450 }
451 }
452 break;
453 }
454
455 $this->log->debug("end --------------------");
456
457 return (string) $ret;
458 }
459
460 public function activatePage(): void
461 {
462 $this->page_gui->activatePage();
463 }
464
465 public function deactivatePage(): void
466 {
467 $this->page_gui->deactivatePage();
468 }
469
473 public function setMediaMode(): void
474 {
475 $ilUser = $this->user;
476
477 $ilUser->writePref(
478 "ilPageEditor_MediaMode",
479 $this->request->getString("media_mode")
480 );
481 $ilUser->writePref(
482 "ilPageEditor_HTMLMode",
483 $this->request->getString("html_mode")
484 );
485 $js_mode = $this->request->getString("js_mode");
486 $ilUser->writePref("ilPageEditor_JavaScript", $js_mode);
487
488 // again not so nice...
489 if ($this->page->getParentType() == "lm") {
490 $this->ctrl->redirectByClass("illmpageobjectgui", "edit");
491 } else {
492 $this->ctrl->returnToParent($this);
493 }
494 }
495
499 public function copyLinkedMediaToClipboard(): void
500 {
501 $ilUser = $this->user;
502
503 $this->tpl->setOnScreenMessage('success', $this->lng->txt("copied_to_clipboard"), true);
504 $ilUser->addObjectToClipboard(
505 $this->requested_mob_id,
506 "mob",
507 ilObject::_lookupTitle($this->requested_mob_id)
508 );
509 $this->ctrl->returnToParent($this);
510 }
511
515 public function copyLinkedMediaToMediaPool(): void
516 {
517 $this->ctrl->setParameterByClass("ilmediapooltargetselector", "mob_id", $this->requested_mob_id);
518 $this->ctrl->redirectByClass("ilmediapooltargetselector", "listPools");
519 }
520
524 public function delete(): void
525 {
526 $ilCtrl = $this->ctrl;
529
530 $targets = $this->request->getIds();
531
532 if (count($targets) == 0) {
533 $this->tpl->setOnScreenMessage('info', $lng->txt("no_checkbox"), true);
534 $this->ctrl->returnToParent($this);
535 } else {
536 $cgui = new ilConfirmationGUI();
537 $cgui->setFormAction($ilCtrl->getFormAction($this));
538 $cgui->setHeaderText($lng->txt("copg_confirm_el_deletion"));
539 $cgui->setCancel($lng->txt("cancel"), "cancelDeleteSelected");
540 $cgui->setConfirm($lng->txt("confirm"), "confirmedDeleteSelected");
541 foreach ($targets as $t) {
542 $cgui->addHiddenItem("ids[]", $t);
543 }
544
545 $tpl->setContent($cgui->getHTML());
546 }
547 }
548
549 public function cancelDeleteSelected(): void
550 {
551 $this->ctrl->returnToParent($this);
552 }
553
554 public function confirmedDeleteSelected(): void
555 {
556 $targets = $this->request->getIds();
557 if (count($targets) > 0) {
558 $updated = $this->page->deleteContents(
559 $targets,
560 true,
561 $this->page_gui->getPageConfig()->getEnableSelfAssessment()
562 );
563 if ($updated !== true) {
564 $this->edit_repo->setPageError($updated);
565 } else {
566 $this->edit_repo->clearPageError();
567 }
568 }
569 $this->ctrl->returnToParent($this);
570 }
571
575 public function copy(): void
576 {
578
579 $ids = $this->request->getIds();
580 if (count($ids) > 0) {
581 $this->page->copyContents($ids);
582 $this->tpl->setOnScreenMessage('success', $lng->txt("cont_sel_el_copied_use_paste"), true);
583 }
584 $this->ctrl->returnToParent($this);
585 }
586
590 public function cut(): void
591 {
593
594 $ids = $this->request->getIds();
595 if (count($ids)) {
596 $updated = $this->page->cutContents($ids);
597 if ($updated !== true) {
598 $this->edit_repo->setPageError($updated);
599 } else {
600 $this->edit_repo->clearPageError();
601 }
602 $this->tpl->setOnScreenMessage('success', $lng->txt("cont_sel_el_cut_use_paste"), true);
603 }
604 $this->ctrl->returnToParent($this);
605 }
606
610 public function paste(string $a_hier_id): void
611 {
612 $this->page->pasteContents($a_hier_id, $this->page_gui->getPageConfig()->getEnableSelfAssessment());
613 //ilEditClipboard::setAction("");
614 $this->ctrl->returnToParent($this);
615 }
616
620 public function activate(): void
621 {
622 $ids = $this->request->getIds();
623 if (count($ids) > 0) {
624 $updated = $this->page->switchEnableMultiple(
625 $ids,
626 true,
627 $this->page_gui->getPageConfig()->getEnableSelfAssessment()
628 );
629 if ($updated !== true) {
630 $this->edit_repo->setPageError($updated);
631 } else {
632 $this->edit_repo->clearPageError();
633 }
634 }
635 $this->ctrl->returnToParent($this);
636 }
637
641 public function characteristic(): void
642 {
645
646 $ids = $this->request->getIds();
647 if (count($ids) > 0) {
648 $types = array();
649
650 // check what content element types have been selected
651 foreach ($ids as $t) {
652 $tarr = explode(":", $t);
653 $cont_obj = $this->page->getContentObject($tarr[0], $tarr[1]);
654 if (is_object($cont_obj) && $cont_obj->getType() == "par") {
655 $types["par"] = "par";
656 }
657 if (is_object($cont_obj) && $cont_obj->getType() == "sec") {
658 $types["sec"] = "sec";
659 }
660 }
661
662 if (count($types) == 0) {
663 $this->tpl->setOnScreenMessage('failure', $lng->txt("cont_select_par_or_section"), true);
664 $this->ctrl->returnToParent($this);
665 } else {
666 $this->initCharacteristicForm($ids, $types);
667 $tpl->setContent($this->form->getHTML());
668 }
669 } else {
670 $this->ctrl->returnToParent($this);
671 }
672 }
673
677 public function initCharacteristicForm(
678 array $a_target,
679 array $a_types
680 ): void {
681 $ilCtrl = $this->ctrl;
683
684
685 // edit form
686 $this->form = new ilPropertyFormGUI();
687 $this->form->setTitle($this->lng->txt("cont_choose_characteristic"));
688
689 if ($a_types["par"] == "par") {
690 $select_prop = new ilSelectInputGUI(
691 $this->lng->txt("cont_choose_characteristic_text"),
692 "char_par"
693 );
694 $options = ilPCParagraphGUI::_getCharacteristics($this->page_gui->getStyleId());
695 $select_prop->setOptions($options);
696 $this->form->addItem($select_prop);
697 }
698 if ($a_types["sec"] == "sec") {
699 $select_prop = new ilSelectInputGUI(
700 $this->lng->txt("cont_choose_characteristic_section"),
701 "char_sec"
702 );
703 $options = ilPCSectionGUI::_getCharacteristics($this->page_gui->getStyleId());
704 $select_prop->setOptions($options);
705 $this->form->addItem($select_prop);
706 }
707
708 foreach ($a_target as $t) {
709 $hidden = new ilHiddenInputGUI("target[]");
710 $hidden->setValue($t);
711 $this->form->addItem($hidden);
712 }
713
714 $this->form->setFormAction($ilCtrl->getFormAction($this));
715 $this->form->addCommandButton("assignCharacteristic", $lng->txt("save"));
716 $this->form->addCommandButton("showPage", $lng->txt("cancel"));
717 }
718
719 public function assignCharacteristic(): void
720 {
721 $char_par = $this->request->getString("char_par");
722 $char_sec = $this->request->getString("char_sec");
723
724 $updated = $this->page->assignCharacteristic(
725 $this->request->getStringArray("target"),
726 $char_par,
727 $char_sec,
728 ""
729 );
730 if ($updated !== true) {
731 $this->edit_repo->setPageError($updated);
732 } else {
733 $this->edit_repo->clearPageError();
734 }
735 $this->ctrl->returnToParent($this);
736 }
737
741 public function pasteFromClipboard(string $a_hier_id): void
742 {
743 $ilCtrl = $this->ctrl;
744 //var_dump($a_hier_id);
745 $ilCtrl->setParameter($this, "hier_id", $a_hier_id);
746 $ilCtrl->setParameterByClass(
747 "ilEditClipboardGUI",
748 "returnCommand",
749 rawurlencode($ilCtrl->getLinkTarget(
750 $this,
751 "insertFromClipboard",
752 "",
753 false,
754 false
755 ))
756 );
757 //echo ":".$ilCtrl->getLinkTarget($this, "insertFromClipboard").":";
758 $ilCtrl->redirectByClass("ilEditClipboardGUI", "getObject");
759 }
760
765 public function insertFromClipboard(): void
766 {
768
769 $hier_id = $this->page->getHierIdForPcId($this->requested_pc_id);
770 if ($hier_id == "") {
771 $hier_id = "pg";
772 }
773
774 if ($ids != "") {
775 foreach ($ids as $id2) {
776 $id = explode(":", $id2);
777 $type = $id[0];
778 $id = $id[1];
779 if ($type == "mob") {
780 $this->content_obj = new ilPCMediaObject($this->page);
781 $this->content_obj->readMediaObject($id);
782 $this->content_obj->createAlias($this->page, $hier_id);
783 $this->page->update();
784 }
785 if ($type == "incl") {
786 $this->content_obj = new ilPCContentInclude($this->page);
787 $this->content_obj->create($this->page, $hier_id);
788 $this->content_obj->setContentType("mep");
789 $this->content_obj->setContentId($id);
790 $this->page->update();
791 }
792 }
793 }
794 $this->ctrl->returnToParent($this);
795 }
796
800 public function displayPage(): void
801 {
802 $this->ctrl->returnToParent($this);
803 }
804
808 public function showSnippetInfo(): void
809 {
810 $tpl = $this->tpl;
812 $ilAccess = $this->access;
813 $ilCtrl = $this->ctrl;
814
815 $stpl = new ilTemplate("tpl.snippet_info.html", true, true, "components/ILIAS/COPage");
816
818 $this->request->getString("ci_id")
819 );
820 foreach ($mep_pools as $mep_id) {
821 $ref_ids = ilObject::_getAllReferences($mep_id);
822 $edit_link = false;
823 foreach ($ref_ids as $rid) {
824 if (!$edit_link && $ilAccess->checkAccess("write", "", $rid)) {
825 $stpl->setCurrentBlock("edit_link");
826 $stpl->setVariable("TXT_EDIT", $lng->txt("edit"));
827 $stpl->setVariable(
828 "HREF_EDIT",
829 "./goto.php?target=mep_" . $rid
830 );
831 $stpl->parseCurrentBlock();
832 }
833 }
834 $stpl->setCurrentBlock("pool");
835 $stpl->setVariable("TXT_MEDIA_POOL", $lng->txt("obj_mep"));
836 $stpl->setVariable("VAL_MEDIA_POOL", ilObject::_lookupTitle($mep_id));
837 $stpl->parseCurrentBlock();
838 }
839
840 $stpl->setVariable("TXT_TITLE", $lng->txt("title"));
841 $stpl->setVariable(
842 "VAL_TITLE",
843 ilMediaPoolPage::lookupTitle($this->request->getString("ci_id"))
844 );
845 $stpl->setVariable("TXT_BACK", $lng->txt("back"));
846 $stpl->setVariable(
847 "HREF_BACK",
848 $ilCtrl->getLinkTarget($this->page_gui, "edit")
849 );
850 $tpl->setContent($stpl->get());
851 }
852}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
Page component editing request.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilCtrl provides processing control methods.
Help GUI class.
This class represents a hidden form property in a property form.
Internal link selector.
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...
static getLogger(string $a_component_id)
Get component logger.
Component logger with individual log levels by component id.
static getPoolForItemId(int $a_id)
static lookupTitle(int $a_page_id)
Editing User Interface for MediaObjects within LMs (see ILIAS DTD)
User class.
writePref(string $keyword, string $value)
addObjectToClipboard(int $a_item_id, string $a_type, string $a_title, int $a_parent=0, string $a_time='', int $a_order_nr=0)
add an item to user's personal clipboard
parses the objects.xml it handles the xml-description of all ilias objects
static _getAllReferences(int $id)
get all reference ids for object ID
static _lookupTitle(int $obj_id)
Class ilPCContentInclude.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilPCMediaObject Media content object (see ILIAS DTD)
static _getCharacteristics(int $a_style_id)
Get characteristics.
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 _getCharacteristics(int $a_style_id)
Content object of ilPageObject (see ILIAS DTD).
Page Editor GUI class.
copyLinkedMediaToMediaPool()
copy linked media object to media pool
ilPropertyFormGUI $form
ilPageContent $content_obj
initCharacteristicForm(array $a_target, array $a_types)
Init map creation/update form.
ilGlobalTemplateInterface $tpl
paste(string $a_hier_id)
paste from clipboard (redirects to clipboard)
__construct(ilPageObject $a_page_object, ilPageObjectGUI $a_page_object_gui)
insertFromClipboard()
insert object from clipboard
copyLinkedMediaToClipboard()
copy linked media object to clipboard
ilAccessHandler $access
ILIAS DI UIServices $ui
copy()
Copy selected items.
ilPageObjectGUI $page_gui
displayPage()
Default for POST reloads and missing.
cut()
Cut selected items.
setMediaMode()
set media and editing mode
ILIAS GlobalScreen ScreenContext ContextServices $tool_context
setHeader(string $a_header)
set header title
characteristic()
Assign characeristic to text blocks/sections.
setIntLinkReturn(string $a_return)
ilObjectDefinition $objDefinition
activate()
(de-)activate selected items
EditGUIRequest $request
ServerRequestInterface $http_request
EditSessionRepository $edit_repo
showSnippetInfo()
Show snippet info.
pasteFromClipboard(string $a_hier_id)
paste from clipboard (redirects to clipboard)
setPageBackTitle(string $a_title)
executeCommand()
execute command
ILIAS COPage PC PCDefinition $pc_definition
Class ilPageObjectGUI.
Class ilPageObject Handles PageObjects of ILIAS Learning Modules (see ILIAS DTD)
This class represents a property form user interface.
This class represents a selection list property in a property form.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
special template class to simplify handling of ITX/PEAR
setContent(string $a_html)
Sets content for standard template.
Interface ilAccessHandler This interface combines all available interfaces which can be called via gl...
form( $class_path, string $cmd, string $submit_caption="")
global $lng
Definition: privfeed.php:31
global $DIC
Definition: shib_login.php:26