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