ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
class.ilPageEditorGUI.php
Go to the documentation of this file.
1 <?php
2 
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 = "";
49  protected ilTabsGUI $tabs_gui;
50  protected ilHelpGUI $help;
51  protected ilObjUser $user;
54  public ilLanguage $lng;
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 != "ilfilesystemgui") {
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 
228  // Step PH (placeholder handling, placeholders from preview mode come without hier_id)
229  if ($next_class == "ilpcplaceholdergui" && $hier_id == "" && $this->requested_pl_pc_id != "") {
230  $hid = $this->page->getHierIdsForPCIds(array($this->requested_pl_pc_id));
231  $hier_id = $hid[$this->requested_pl_pc_id];
232  }
233  $this->log->debug("step PH: next class: " . $next_class);
234 
235  if (!is_null($com) && ($com[0] == "insert" || $com[0] == "create")) {
236  // Step CM (creation mode handling)
237  $cmd = $com[0];
238  $ctype = $com[1] ?? ""; // note ctype holds type if cmdclass is empty, but also subcommands if not (e.g. applyFilter in ilpcmediaobjectgui)
239  $add_type = $this->request->getString("pluginName");
240  if ($ctype == "mob") {
241  $ctype = "media";
242  }
243 
244  $this->log->debug("step CM: cmd: " . $cmd . ", ctype: " . $ctype . ", add_type: " . $add_type);
245  } else {
246  $this->log->debug("step LM: cmd: " . $cmd . ", cmdClass: " . $cmdClass);
247 
248  // Step PR (get content object and return to parent)
249  $this->log->debug("before PR: cmdClass: $cmdClass, nextClass: $next_class" .
250  ", hier_id: " . $hier_id . ", pc_id: " . $pc_id . ")");
251  // note: ilinternallinkgui for page: no cont_obj is received
252  // ilinternallinkgui for mob: cont_obj is received
253  if ($this->requested_ctype == "" && $this->requested_cname == "" &&
254  $cmd != "insertFromClipboard" && $cmd != "pasteFromClipboard" &&
255  $cmd != "setMediaMode" && $cmd != "copyLinkedMediaToClipboard" &&
256  $cmd != "activatePage" && $cmd != "deactivatePage" &&
257  $cmd != "copyLinkedMediaToMediaPool" && $cmd != "showSnippetInfo" &&
258  $cmd != "delete" && $cmd != "paste" &&
259  $cmd != "cancelDeleteSelected" && $cmd != "confirmedDeleteSelected" &&
260  $cmd != "copy" && $cmd != "cut" &&
261  ($cmd != "displayPage" || $this->request->getString("editImagemapForward_x") != "") &&
262  $cmd != "activate" && $cmd != "characteristic" &&
263  $cmd != "assignCharacteristic" &&
264  $cmdClass != "ilrepositoryselector2inputgui" &&
265  $cmdClass != "ilpageeditorserveradaptergui" &&
266  $cmd != "cancelCreate" && $cmd != "popup" &&
267  $cmdClass != "ileditclipboardgui" && $cmd != "addChangeComment" &&
268  ($cmdClass != "ilinternallinkgui" || ($next_class == "ilpcmediaobjectgui"))) {
269  $cont_obj = $this->page->getContentObject($hier_id, $pc_id);
270  if (!is_object($cont_obj)) {
271  $this->log->debug("returnToParent");
272  $ilCtrl->returnToParent($this);
273  }
274  $ctype = $cont_obj->getType();
275  }
276  }
277  // Step NC (handle empty next class)
278  if ($this->requested_ctype != "" || $this->requested_cname != "") {
279  $ctype = $this->requested_ctype;
280  if ($this->requested_cname != "") {
281  $pc_def = $this->pc_definition->getPCDefinitionByName($this->requested_cname);
282  $ctype = $pc_def["pc_type"];
283  }
284  $pc_id = $this->requested_pc_id;
285  $hier_id = $this->requested_hier_id;
286  if (!in_array($cmd, ["insert", "create"])) {
287  $cont_obj = $this->page->getContentObject($hier_id, $pc_id);
288  }
289  }
290  // this fixes e.g. #31214
291  if ($pc_id != "" && $hier_id == "") {
292  $hier_id = $this->page->getHierIdForPcId($pc_id);
293  }
294  if ($ctype != "media" || !is_object($cont_obj)) {
295  if ($this->getHeader() != "") {
296  $this->tpl->setTitle($this->getHeader());
297  }
298  }
299 
300  $this->cont_obj = $cont_obj;
301 
302 
303  $this->ctrl->setParameter($this, "hier_id", $hier_id);
304  $this->ctrl->setParameter($this, "pc_id", $pc_id);
305  $this->ctrl->setCmd($cmd);
306  if ($next_class == "") {
307  $pc_def = $this->pc_definition->getPCDefinitionByType($ctype);
308  if (is_array($pc_def)) {
309  $this->ctrl->setCmdClass($pc_def["pc_gui_class"]);
310  }
311  $next_class = $this->ctrl->getNextClass($this);
312  }
313  $this->log->debug("step NC2: next_class: $next_class");
314 
315  // ... do not do this while imagemap editing is ongoing
316  // Step IM (handle image map editing)
317  if ($cmd == "displayPage" &&
318  $this->request->getString("editImagemapForward_x") == ""
319  && $this->request->getString("imagemap_x") == "") {
320  $next_class = "";
321  }
322 
323 
324  switch ($next_class) {
325  case "ilinternallinkgui":
326  $link_gui = new ilInternalLinkGUI(
327  $this->page_gui->getPageConfig()->getIntLinkHelpDefaultType(),
328  $this->page_gui->getPageConfig()->getIntLinkHelpDefaultId(),
329  $this->page_gui->getPageConfig()->getIntLinkHelpDefaultIdIsRef()
330  );
331  $link_gui->setFilterWhiteList(
332  $this->page_gui->getPageConfig()->getIntLinkFilterWhiteList()
333  );
334  foreach ($this->page_gui->getPageConfig()->getIntLinkFilters() as $filter) {
335  $link_gui->filterLinkType($filter);
336  }
337  $link_gui->setReturn($this->int_link_return);
338 
339  $ret = $this->ctrl->forwardCommand($link_gui);
340  break;
341 
342  // PC Media Object
343  case "ilpcmediaobjectgui":
344  $this->tabs_gui->clearTargets();
345  $this->tabs_gui->setBackTarget(
346  $this->page_gui->page_back_title,
347  $ilCtrl->getLinkTarget($this->page_gui, "edit")
348  );
349  $pcmob_gui = new ilPCMediaObjectGUI($this->page, $cont_obj, $hier_id, $pc_id);
350  $pcmob_gui->setStyleId($this->page_gui->getStyleId());
351  $pcmob_gui->setSubCmd($ctype);
352  $pcmob_gui->setEnabledMapAreas($this->page_gui->getPageConfig()->getEnableInternalLinks());
353  $ret = $this->ctrl->forwardCommand($pcmob_gui);
354  $ilHelp->setScreenIdComponent("copg_media");
355  break;
356 
357  // only for "linked" media
358  case "ilobjmediaobjectgui":
359  $this->tabs_gui->clearTargets();
360  $this->tabs_gui->setBackTarget(
361  $this->lng->txt("back"),
362  (string) $ilCtrl->getParentReturn($this)
363  );
364  $mob_gui = new ilObjMediaObjectGUI("", $this->requested_mob_id, false, false);
365  $mob_gui->getTabs();
366  $mob_gui->setEnabledMapAreas($this->page_gui->getPageConfig()->getEnableInternalLinks());
367  $this->tpl->setTitle($this->lng->txt("mob") . ": " .
368  ilObject::_lookupTitle($this->requested_mob_id));
369  $ret = $this->ctrl->forwardCommand($mob_gui);
370  break;
371 
372  // Question
373  case "ilpcquestiongui":
374  $pc_question_gui = new ilPCQuestionGUI($this->page, $cont_obj, $hier_id, $pc_id);
375  $pc_question_gui->setSelfAssessmentMode($this->page_gui->getPageConfig()->getEnableSelfAssessment());
376  $pc_question_gui->setPageConfig($this->page_gui->getPageConfig());
377 
378  if ($this->page_gui->getPageConfig()->getEnableSelfAssessment()) {
379  $this->tabs_gui->clearTargets();
380  $ilHelp->setScreenIdComponent("copg_pcqst");
381  $this->tabs_gui->setBackTarget(
382  $this->lng->txt("back"),
383  (string) $ilCtrl->getParentReturn($this)
384  );
385  $ret = $this->ctrl->forwardCommand($pc_question_gui);
386  } else {
387  $cmd = $this->ctrl->getCmd();
388  $pc_question_gui->$cmd();
389  $this->ctrl->redirectByClass(array("ilobjquestionpoolgui", get_class($cont_obj)), "editQuestion");
390  }
391  break;
392 
393  // Plugged Component
394  case "ilpcpluggedgui":
395  $this->tabs_gui->clearTargets();
396  $plugged_gui = new ilPCPluggedGUI(
397  $this->page,
398  $cont_obj,
399  $hier_id,
400  $add_type,
401  $pc_id
402  );
403  $ret = $this->ctrl->forwardCommand($plugged_gui);
404  break;
405 
406  case "ilpageeditorserveradaptergui":
407  $adapter = new ilPageEditorServerAdapterGUI(
408  $this->page_gui,
409  $this->ctrl,
410  $this->ui,
411  $this->http_request
412  );
413  $this->ctrl->forwardCommand($adapter);
414  break;
415 
416  default:
417 
418  // generic calls to gui classes
419  if ($this->pc_definition->isPCGUIClassName($next_class, true)) {
420  $this->log->debug("Generic Call");
421  $pc_def = $this->pc_definition->getPCDefinitionByGUIClassName($next_class);
422  $this->tabs_gui->clearTargets();
423  $this->tabs_gui->setBackTarget(
424  $this->page_gui->page_back_title,
425  $ilCtrl->getLinkTarget($this->page_gui, "edit")
426  );
427  $ilHelp->setScreenIdComponent("copg_" . $pc_def["pc_type"]);
428  $gui_class_name = $pc_def["pc_gui_class"];
429  $pc_gui = new $gui_class_name($this->page, $cont_obj, $hier_id, $pc_id);
430  if ($pc_def["style_classes"]) {
431  $pc_gui->setStyleId($this->page_gui->getStyleId());
432  }
433  $pc_gui->setPageConfig($this->page_gui->getPageConfig());
434  $ret = $this->ctrl->forwardCommand($pc_gui);
435  } else {
436  $this->log->debug("Call ilPageEditorGUI command.");
437  // cmd belongs to ilPageEditorGUI
438 
439  if ($cmd == "pasteFromClipboard") {
440  //$ret = $this->pasteFromClipboard($hier_id);
441  $this->pasteFromClipboard($hier_id);
442  } elseif ($cmd == "paste") {
443  //$ret = $this->paste($hier_id);
444  $this->paste($hier_id);
445  } else {
446  $ret = $this->$cmd();
447  }
448  }
449  break;
450  }
451 
452  $this->log->debug("end --------------------");
453 
454  return (string) $ret;
455  }
456 
457  public function activatePage(): void
458  {
459  $this->page_gui->activatePage();
460  }
461 
462  public function deactivatePage(): void
463  {
464  $this->page_gui->deactivatePage();
465  }
466 
470  public function setMediaMode(): void
471  {
472  $ilUser = $this->user;
473 
474  $ilUser->writePref(
475  "ilPageEditor_MediaMode",
476  $this->request->getString("media_mode")
477  );
478  $ilUser->writePref(
479  "ilPageEditor_HTMLMode",
480  $this->request->getString("html_mode")
481  );
482  $js_mode = $this->request->getString("js_mode");
483  $ilUser->writePref("ilPageEditor_JavaScript", $js_mode);
484 
485  // again not so nice...
486  if ($this->page->getParentType() == "lm") {
487  $this->ctrl->redirectByClass("illmpageobjectgui", "edit");
488  } else {
489  $this->ctrl->returnToParent($this);
490  }
491  }
492 
496  public function copyLinkedMediaToClipboard(): void
497  {
498  $ilUser = $this->user;
499 
500  $this->tpl->setOnScreenMessage('success', $this->lng->txt("copied_to_clipboard"), true);
501  $ilUser->addObjectToClipboard(
502  $this->requested_mob_id,
503  "mob",
504  ilObject::_lookupTitle($this->requested_mob_id)
505  );
506  $this->ctrl->returnToParent($this);
507  }
508 
512  public function copyLinkedMediaToMediaPool(): void
513  {
514  $this->ctrl->setParameterByClass("ilmediapooltargetselector", "mob_id", $this->requested_mob_id);
515  $this->ctrl->redirectByClass("ilmediapooltargetselector", "listPools");
516  }
517 
521  public function addChangeComment(): void
522  {
524  $this->page->getId(),
525  "update",
526  [],
527  $this->page->getParentType() . ":pg",
528  $this->request->getString("change_comment"),
529  true
530  );
531  $this->tpl->setOnScreenMessage('success', $this->lng->txt("cont_added_comment"), true);
532  $this->ctrl->returnToParent($this);
533  }
534 
538  public function delete(): void
539  {
540  $ilCtrl = $this->ctrl;
541  $tpl = $this->tpl;
542  $lng = $this->lng;
543 
544  $targets = $this->request->getIds();
545 
546  if (count($targets) == 0) {
547  $this->tpl->setOnScreenMessage('info', $lng->txt("no_checkbox"), true);
548  $this->ctrl->returnToParent($this);
549  } else {
550  $cgui = new ilConfirmationGUI();
551  $cgui->setFormAction($ilCtrl->getFormAction($this));
552  $cgui->setHeaderText($lng->txt("copg_confirm_el_deletion"));
553  $cgui->setCancel($lng->txt("cancel"), "cancelDeleteSelected");
554  $cgui->setConfirm($lng->txt("confirm"), "confirmedDeleteSelected");
555  foreach ($targets as $t) {
556  $cgui->addHiddenItem("ids[]", $t);
557  }
558 
559  $tpl->setContent($cgui->getHTML());
560  }
561  }
562 
563  public function cancelDeleteSelected(): void
564  {
565  $this->ctrl->returnToParent($this);
566  }
567 
568  public function confirmedDeleteSelected(): void
569  {
570  $targets = $this->request->getIds();
571  if (count($targets) > 0) {
572  $updated = $this->page->deleteContents(
573  $targets,
574  true,
575  $this->page_gui->getPageConfig()->getEnableSelfAssessment()
576  );
577  if ($updated !== true) {
578  $this->edit_repo->setPageError($updated);
579  } else {
580  $this->edit_repo->clearPageError();
581  }
582  }
583  $this->ctrl->returnToParent($this);
584  }
585 
589  public function copy(): void
590  {
591  $lng = $this->lng;
592 
593  $ids = $this->request->getIds();
594  if (count($ids) > 0) {
595  $this->page->copyContents($ids);
596  $this->tpl->setOnScreenMessage('success', $lng->txt("cont_sel_el_copied_use_paste"), true);
597  }
598  $this->ctrl->returnToParent($this);
599  }
600 
604  public function cut(): void
605  {
606  $lng = $this->lng;
607 
608  $ids = $this->request->getIds();
609  if (count($ids)) {
610  $updated = $this->page->cutContents($ids);
611  if ($updated !== true) {
612  $this->edit_repo->setPageError($updated);
613  } else {
614  $this->edit_repo->clearPageError();
615  }
616  $this->tpl->setOnScreenMessage('success', $lng->txt("cont_sel_el_cut_use_paste"), true);
617  }
618  $this->ctrl->returnToParent($this);
619  }
620 
624  public function paste(string $a_hier_id): void
625  {
626  $this->page->pasteContents($a_hier_id, $this->page_gui->getPageConfig()->getEnableSelfAssessment());
627  //ilEditClipboard::setAction("");
628  $this->ctrl->returnToParent($this);
629  }
630 
634  public function activate(): void
635  {
636  $ids = $this->request->getIds();
637  if (count($ids) > 0) {
638  $updated = $this->page->switchEnableMultiple(
639  $ids,
640  true,
641  $this->page_gui->getPageConfig()->getEnableSelfAssessment()
642  );
643  if ($updated !== true) {
644  $this->edit_repo->setPageError($updated);
645  } else {
646  $this->edit_repo->clearPageError();
647  }
648  }
649  $this->ctrl->returnToParent($this);
650  }
651 
655  public function characteristic(): void
656  {
657  $tpl = $this->tpl;
658  $lng = $this->lng;
659 
660  $ids = $this->request->getIds();
661  if (count($ids) > 0) {
662  $types = array();
663 
664  // check what content element types have been selected
665  foreach ($ids as $t) {
666  $tarr = explode(":", $t);
667  $cont_obj = $this->page->getContentObject($tarr[0], $tarr[1]);
668  if (is_object($cont_obj) && $cont_obj->getType() == "par") {
669  $types["par"] = "par";
670  }
671  if (is_object($cont_obj) && $cont_obj->getType() == "sec") {
672  $types["sec"] = "sec";
673  }
674  }
675 
676  if (count($types) == 0) {
677  $this->tpl->setOnScreenMessage('failure', $lng->txt("cont_select_par_or_section"), true);
678  $this->ctrl->returnToParent($this);
679  } else {
680  $this->initCharacteristicForm($ids, $types);
681  $tpl->setContent($this->form->getHTML());
682  }
683  } else {
684  $this->ctrl->returnToParent($this);
685  }
686  }
687 
691  public function initCharacteristicForm(
692  array $a_target,
693  array $a_types
694  ): void {
695  $ilCtrl = $this->ctrl;
696  $lng = $this->lng;
697 
698 
699  // edit form
700  $this->form = new ilPropertyFormGUI();
701  $this->form->setTitle($this->lng->txt("cont_choose_characteristic"));
702 
703  if ($a_types["par"] == "par") {
704  $select_prop = new ilSelectInputGUI(
705  $this->lng->txt("cont_choose_characteristic_text"),
706  "char_par"
707  );
708  $options = ilPCParagraphGUI::_getCharacteristics($this->page_gui->getStyleId());
709  $select_prop->setOptions($options);
710  $this->form->addItem($select_prop);
711  }
712  if ($a_types["sec"] == "sec") {
713  $select_prop = new ilSelectInputGUI(
714  $this->lng->txt("cont_choose_characteristic_section"),
715  "char_sec"
716  );
717  $options = ilPCSectionGUI::_getCharacteristics($this->page_gui->getStyleId());
718  $select_prop->setOptions($options);
719  $this->form->addItem($select_prop);
720  }
721 
722  foreach ($a_target as $t) {
723  $hidden = new ilHiddenInputGUI("target[]");
724  $hidden->setValue($t);
725  $this->form->addItem($hidden);
726  }
727 
728  $this->form->setFormAction($ilCtrl->getFormAction($this));
729  $this->form->addCommandButton("assignCharacteristic", $lng->txt("save"));
730  $this->form->addCommandButton("showPage", $lng->txt("cancel"));
731  }
732 
733  public function assignCharacteristic(): void
734  {
735  $char_par = $this->request->getString("char_par");
736  $char_sec = $this->request->getString("char_sec");
737 
738  $updated = $this->page->assignCharacteristic(
739  $this->request->getStringArray("target"),
740  $char_par,
741  $char_sec,
742  ""
743  );
744  if ($updated !== true) {
745  $this->edit_repo->setPageError($updated);
746  } else {
747  $this->edit_repo->clearPageError();
748  }
749  $this->ctrl->returnToParent($this);
750  }
751 
755  public function pasteFromClipboard(string $a_hier_id): void
756  {
757  $ilCtrl = $this->ctrl;
758  //var_dump($a_hier_id);
759  $ilCtrl->setParameter($this, "hier_id", $a_hier_id);
760  $ilCtrl->setParameterByClass(
761  "ilEditClipboardGUI",
762  "returnCommand",
763  rawurlencode($ilCtrl->getLinkTarget(
764  $this,
765  "insertFromClipboard",
766  "",
767  false,
768  false
769  ))
770  );
771  //echo ":".$ilCtrl->getLinkTarget($this, "insertFromClipboard").":";
772  $ilCtrl->redirectByClass("ilEditClipboardGUI", "getObject");
773  }
774 
779  public function insertFromClipboard(): void
780  {
782 
783  $hier_id = $this->page->getHierIdForPcId($this->requested_pc_id);
784  if ($hier_id == "") {
785  $hier_id = "pg";
786  }
787 
788  if ($ids != "") {
789  foreach ($ids as $id2) {
790  $id = explode(":", $id2);
791  $type = $id[0];
792  $id = $id[1];
793  if ($type == "mob") {
794  $this->content_obj = new ilPCMediaObject($this->page);
795  $this->content_obj->readMediaObject($id);
796  $this->content_obj->createAlias($this->page, $hier_id);
797  $this->page->update();
798  }
799  if ($type == "incl") {
800  $this->content_obj = new ilPCContentInclude($this->page);
801  $this->content_obj->create($this->page, $hier_id);
802  $this->content_obj->setContentType("mep");
803  $this->content_obj->setContentId($id);
804  $this->page->update();
805  }
806  }
807  }
808  $this->ctrl->returnToParent($this);
809  }
810 
814  public function displayPage(): void
815  {
816  $this->ctrl->returnToParent($this);
817  }
818 
822  public function showSnippetInfo(): void
823  {
824  $tpl = $this->tpl;
825  $lng = $this->lng;
826  $ilAccess = $this->access;
827  $ilCtrl = $this->ctrl;
828 
829  $stpl = new ilTemplate("tpl.snippet_info.html", true, true, "Services/COPage");
830 
832  $this->request->getString("ci_id")
833  );
834  foreach ($mep_pools as $mep_id) {
835  $ref_ids = ilObject::_getAllReferences($mep_id);
836  $edit_link = false;
837  foreach ($ref_ids as $rid) {
838  if (!$edit_link && $ilAccess->checkAccess("write", "", $rid)) {
839  $stpl->setCurrentBlock("edit_link");
840  $stpl->setVariable("TXT_EDIT", $lng->txt("edit"));
841  $stpl->setVariable(
842  "HREF_EDIT",
843  "./goto.php?target=mep_" . $rid
844  );
845  $stpl->parseCurrentBlock();
846  }
847  }
848  $stpl->setCurrentBlock("pool");
849  $stpl->setVariable("TXT_MEDIA_POOL", $lng->txt("obj_mep"));
850  $stpl->setVariable("VAL_MEDIA_POOL", ilObject::_lookupTitle($mep_id));
851  $stpl->parseCurrentBlock();
852  }
853 
854  $stpl->setVariable("TXT_TITLE", $lng->txt("title"));
855  $stpl->setVariable(
856  "VAL_TITLE",
857  ilMediaPoolPage::lookupTitle($this->request->getString("ci_id"))
858  );
859  $stpl->setVariable("TXT_BACK", $lng->txt("back"));
860  $stpl->setVariable(
861  "HREF_BACK",
862  $ilCtrl->getLinkTarget($this->page_gui, "edit")
863  );
864  $tpl->setContent($stpl->get());
865  }
866 }
ILIAS COPage PC PCDefinition $pc_definition
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.
writePref(string $a_keyword, string $a_value)
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...
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.
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 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
static _getCharacteristics(int $a_style_id)
Content object of ilPageObject (see ILIAS DTD).
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Page Editor GUI class.
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&#39;s personal clipboard
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
Class ilPCContentInclude.
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
cut()
Cut selected items.
Editing User Interface for MediaObjects within LMs (see ILIAS DTD)
form( $class_path, string $cmd, string $submit_caption="")
setFilterWhiteList(bool $a_white_list)
Set filter list as white list (per detault it is a black list)
ilObjectDefinition $objDefinition
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)
setIntLinkReturn(string $a_return)