ILIAS  release_7 Revision v7.30-3-g800a261c036
class.ilPageEditorGUI.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
3
4include_once("./Services/COPage/classes/class.ilPageObjectGUI.php");
5
28{
32 protected $tabs_gui;
33
37 protected $help;
38
42 protected $user;
43
47 protected $access;
48
49 public $tpl;
50 public $lng;
51 public $ctrl;
56 public $page;
59 public $header;
60 public $tabs;
61 public $cont_obj;
64
68 protected $log;
69
73 protected $ui;
74
78 protected $request;
79
83 protected $tool_context;
84
91 public function __construct(&$a_page_object, &$a_page_object_gui)
92 {
93 global $DIC;
94
95 $this->help = $DIC["ilHelp"];
96 $this->user = $DIC->user();
97 $this->access = $DIC->access();
98 $tpl = $DIC["tpl"];
99 $lng = $DIC->language();
100 $objDefinition = $DIC["objDefinition"];
101 $ilCtrl = $DIC->ctrl();
102 $ilTabs = $DIC->tabs();
103
104 $this->ui = $DIC->ui();
105 $this->request = $DIC->http()->request();
106
107 $this->log = ilLoggerFactory::getLogger('copg');
108
109 $this->tool_context = $DIC->globalScreen()->tool()->context();
110
111 // initiate variables
112 $this->ctrl = $ilCtrl;
113 $this->tpl = $tpl;
114 $this->lng = $lng;
115 $this->objDefinition = $objDefinition;
116 $this->tabs_gui = $ilTabs;
117 $this->page = $a_page_object;
118 $this->page_gui = $a_page_object_gui;
119
120 $this->ctrl->saveParameter($this, array("hier_id", "pc_id"));
121 }
122
123
129 public function setHeader($a_header)
130 {
131 $this->header = $a_header;
132 }
133
139 public function getHeader()
140 {
141 return $this->header;
142 }
143
149 public function setLocator(&$a_locator)
150 {
151 $this->locator = $a_locator;
152 }
153
157 public function returnToContext()
158 {
159 $this->ctrl->returnToParent($this);
160 }
161
162 public function setIntLinkReturn($a_return)
163 {
164 $this->int_link_return = $a_return;
165 }
166
167
168 public function setPageBackTitle($a_title)
169 {
170 $this->page_back_title = $a_title;
171 }
172
176 public function executeCommand()
177 {
178 $ilCtrl = $this->ctrl;
179 $ilHelp = $this->help;
180 $this->log->debug("begin =========================");
181
182 if (!true) {
183 var_dump($_GET);
184 echo "<br><br>";
185 var_dump($_POST);
186 exit;
187 }
188
189 // Step BC (basic command determination)
190 // determine cmd, cmdClass, hier_id and pc_id
191 $cmd = $this->ctrl->getCmd("displayPage");
192 $cmdClass = strtolower($this->ctrl->getCmdClass());
193
194 $hier_id = $_GET["hier_id"];
195 $pc_id = $_GET["pc_id"];
196 if (isset($_POST["new_hier_id"])) {
197 $hier_id = $_POST["new_hier_id"];
198 }
199
200 $new_type = (isset($_GET["new_type"]))
201 ? $_GET["new_type"]
202 : $_POST["new_type"];
203
204 $this->log->debug("step BC: cmd:$cmd, cmdClass:$cmdClass, hier_id: $hier_id, pc_id: $pc_id");
205
206 // Step EC (exec_ command handling)
207 // handle special exec_ commands, modify pc, hier_id
208 if (substr($cmd, 0, 5) == "exec_") {
209 // check whether pc id is given
210 $pca = explode(":", key($_POST["cmd"]));
211 $pc_id = $pca[1];
212 $cmd = explode("_", $pca[0]);
213 unset($cmd[0]);
214 $hier_id = implode("_", $cmd);
215 $cmd = $_POST["command" . $hier_id];
216 }
217 $this->log->debug("step EC: cmd:$cmd, hier_id: $hier_id, pc_id: $pc_id");
218
219 // Step CC (handle table container (and similar) commands
220 // ... strip "c" "r" of table ids from hierarchical id
221 $first_hier_character = substr($hier_id, 0, 1);
222 if ($first_hier_character == "c" ||
223 $first_hier_character == "r" ||
224 $first_hier_character == "g" ||
225 $first_hier_character == "i") {
226 $hier_id = substr($hier_id, 1);
227 }
228 $this->log->debug("step CC: cmd:$cmd, hier_id: $hier_id, pc_id: $pc_id");
229
230 // Step B (build dom, and ids in XML)
231 $this->page->buildDom();
232 $this->page->addHierIDs();
233
234
235 // Step CS (strip base command)
236 if ($cmdClass != "ilfilesystemgui") {
237 $com = explode("_", $cmd);
238 $cmd = $com[0];
239 }
240 $this->log->debug("step CS: cmd:$cmd");
241
242
243 // Step NC (determine next class)
244 $next_class = $this->ctrl->getNextClass($this);
245 $this->log->debug("step NC: next class: " . $next_class);
246
247
248 // Step PH (placeholder handling, placeholders from preview mode come without hier_id)
249 if ($next_class == "ilpcplaceholdergui" && $hier_id == "" && $_GET["pl_pc_id"] != "") {
250 $hid = $this->page->getHierIdsForPCIds(array($_GET["pl_pc_id"]));
251 $hier_id = $hid[$_GET["pl_pc_id"]];
252 }
253 $this->log->debug("step PH: next class: " . $next_class);
254
255 if ($com[0] == "insert" || $com[0] == "create") {
256 // Step CM (creation mode handling)
257 $cmd = $com[0];
258 $ctype = $com[1]; // note ctype holds type if cmdclass is empty, but also subcommands if not (e.g. applyFilter in ilpcmediaobjectgui)
259 $add_type = $_POST["pluginName"];
260 if ($ctype == "mob") {
261 $ctype = "media";
262 }
263
264 $this->log->debug("step CM: cmd: " . $cmd . ", ctype: " . $ctype . ", add_type: " . $add_type);
265 } else {
266 // Step LM (setting cmd and cmdclass for editing of linked media)
267 if ($cmd == "editLinkedMedia") {
268 $this->ctrl->setCmd("edit");
269 $cmd = "edit";
270 $_GET["pgEdMediaMode"] = "editLinkedMedia";
271 $_GET["mob_id"] = $_POST["mob_id"];
272 }
273 if ($_GET["pgEdMediaMode"] == "editLinkedMedia") {
274 $this->ctrl->setParameter($this, "pgEdMediaMode", "editLinkedMedia");
275 $this->ctrl->setParameter($this, "mob_id", $_GET["mob_id"]);
276 if ($cmdClass != "ilinternallinkgui" && $cmdClass != "ilmdeditorgui"
277 && $cmdClass != "ilimagemapeditorgui" && $cmdClass != "ilfilesystemgui") {
278 $this->ctrl->setCmdClass("ilobjmediaobjectgui");
279 $cmdClass = "ilobjmediaobjectgui";
280 }
281 }
282 $this->log->debug("step LM: cmd: " . $cmd . ", cmdClass: " . $cmdClass);
283
284
285 // Step PR (get content object and return to parent)
286 $this->log->debug("before PR: cmdClass: $cmdClass, nextClass: $next_class" .
287 ", hier_id: " . $hier_id . ", pc_id: " . $pc_id . ")");
288 // note: ilinternallinkgui for page: no cont_obj is received
289 // ilinternallinkgui for mob: cont_obj is received
290 if ($_REQUEST["ctype"] == "" && $_REQUEST["cname"] == "" &&
291 $cmd != "insertFromClipboard" && $cmd != "pasteFromClipboard" &&
292 $cmd != "setMediaMode" && $cmd != "copyLinkedMediaToClipboard" &&
293 $cmd != "activatePage" && $cmd != "deactivatePage" &&
294 $cmd != "copyLinkedMediaToMediaPool" && $cmd != "showSnippetInfo" &&
295 $cmd != "delete" && $cmd != "paste" &&
296 $cmd != "cancelDeleteSelected" && $cmd != "confirmedDeleteSelected" &&
297 $cmd != "copy" && $cmd != "cut" &&
298 ($cmd != "displayPage" || $_POST["editImagemapForward_x"] != "" || $_POST["imagemap_x"] != "") &&
299 ($cmd != "displayPage" || $_POST["editImagemapForward_x"] != "") &&
300 $cmd != "activate" && $cmd != "characteristic" &&
301 $cmd != "assignCharacteristic" &&
302 $cmdClass != "ilrepositoryselector2inputgui" &&
303 $cmdClass != "ilpageeditorserveradaptergui" &&
304 $cmd != "cancelCreate" && $cmd != "popup" &&
305 $cmdClass != "ileditclipboardgui" && $cmd != "addChangeComment" &&
306 ($cmdClass != "ilinternallinkgui" || ($next_class == "ilpcmediaobjectgui"))) {
307 if ($_GET["pgEdMediaMode"] != "editLinkedMedia") {
308 $cont_obj = $this->page->getContentObject($hier_id, $pc_id);
309 if (!is_object($cont_obj)) {
310 $this->log->debug("returnToParent");
311 $ilCtrl->returnToParent($this);
312 }
313 $ctype = $cont_obj->getType();
314 }
315 }
316 $this->log->debug("step PR: ctype: $ctype");
317 }
318
319 // Step NC (handle empty next class)
320 if ($_REQUEST["ctype"] != "" || $_REQUEST["cname"] != "") {
321 $ctype = $_REQUEST["ctype"];
322 if ($_REQUEST["cname"] != "") {
323 $pc_def = ilCOPagePCDef::getPCDefinitionByName($_REQUEST["cname"]);
324 $ctype = $pc_def["pc_type"];
325 }
326 $pc_id = $_REQUEST["pcid"];
327 $hier_id = $_REQUEST["hier_id"];
328 if (!in_array($cmd, ["insert", "create"])) {
329 $cont_obj = $this->page->getContentObject($hier_id, $pc_id);
330 }
331 }
332 // this fixes e.g. #31214
333 if ($pc_id != "" && $hier_id == "") {
334 $hier_id = $this->page->getHierIdForPcId($pc_id);
335 }
336 if ($ctype != "media" || !is_object($cont_obj)) {
337 if ($this->getHeader() != "") {
338 $this->tpl->setTitle($this->getHeader());
339 }
340 $this->displayLocator();
341 }
342
343 $this->cont_obj = $cont_obj;
344
345
346 $this->ctrl->setParameter($this, "hier_id", $hier_id);
347 $this->ctrl->setParameter($this, "pc_id", $pc_id);
348 $this->ctrl->setCmd($cmd);
349 if ($next_class == "") {
350 include_once("./Services/COPage/classes/class.ilCOPagePCDef.php");
351 $pc_def = ilCOPagePCDef::getPCDefinitionByType($ctype);
352 if (is_array($pc_def)) {
353 $this->ctrl->setCmdClass($pc_def["pc_gui_class"]);
354 }
355 $next_class = $this->ctrl->getNextClass($this);
356 }
357 $this->log->debug("step NC2: next_class: $next_class");
358
359 // ... do not do this while imagemap editing is ongoing
360 // Step IM (handle image map editing)
361 if ($cmd == "displayPage" && $_POST["editImagemapForward_x"] == "" && $_POST["imagemap_x"] == "") {
362 $next_class = "";
363 }
364 $this->log->debug("step IM: next_class: $next_class");
365 // Step FC (forward command)
366 $this->log->debug("before FC: next_class:" . $next_class . ", pc_id:" . $pc_id .
367 ", hier_id:" . $hier_id . ", ctype:" . $ctype . ", cmd:" . $cmd . ", _GET[cmd]: " . $_GET["cmd"]);
368
369
370 switch ($next_class) {
371 case "ilinternallinkgui":
372 $link_gui = new ilInternalLinkGUI(
373 $this->page_gui->getPageConfig()->getIntLinkHelpDefaultType(),
374 $this->page_gui->getPageConfig()->getIntLinkHelpDefaultId(),
375 $this->page_gui->getPageConfig()->getIntLinkHelpDefaultIdIsRef()
376 );
377 $link_gui->setFilterWhiteList(
378 $this->page_gui->getPageConfig()->getIntLinkFilterWhiteList()
379 );
380 foreach ($this->page_gui->getPageConfig()->getIntLinkFilters() as $filter) {
381 $link_gui->filterLinkType($filter);
382 }
383 $link_gui->setReturn($this->int_link_return);
384
385 $ret = $this->ctrl->forwardCommand($link_gui);
386 break;
387
388 // PC Media Object
389 case "ilpcmediaobjectgui":
390 include_once("./Services/COPage/classes/class.ilPCMediaObjectGUI.php");
391
392 $this->tabs_gui->clearTargets();
393 $this->tabs_gui->setBackTarget(
394 $this->page_gui->page_back_title,
395 $ilCtrl->getLinkTarget($this->page_gui, "edit")
396 );
397 $pcmob_gui = new ilPCMediaObjectGUI($this->page, $cont_obj, $hier_id, $pc_id);
398 $pcmob_gui->setStyleId($this->page_gui->getStyleId());
399 $pcmob_gui->setSubCmd($ctype);
400 $pcmob_gui->setEnabledMapAreas($this->page_gui->getPageConfig()->getEnableInternalLinks());
401 $ret = $this->ctrl->forwardCommand($pcmob_gui);
402 $ilHelp->setScreenIdComponent("copg_media");
403 break;
404
405 // only for "linked" media
406 case "ilobjmediaobjectgui":
407 $this->tabs_gui->clearTargets();
408 $this->tabs_gui->setBackTarget(
409 $this->lng->txt("back"),
410 $ilCtrl->getParentReturn($this)
411 );
412 $mob_gui = new ilObjMediaObjectGUI("", $_GET["mob_id"], false, false);
413 $mob_gui->getTabs();
414 $mob_gui->setEnabledMapAreas($this->page_gui->getPageConfig()->getEnableInternalLinks());
415 $this->tpl->setTitle($this->lng->txt("mob") . ": " .
416 ilObject::_lookupTitle($_GET["mob_id"]));
417 $ret = $this->ctrl->forwardCommand($mob_gui);
418 break;
419
420 // Question
421 case "ilpcquestiongui":
422 include_once("./Services/COPage/classes/class.ilPCQuestionGUI.php");
423 $pc_question_gui = new ilPCQuestionGUI($this->page, $cont_obj, $hier_id, $pc_id);
424 $pc_question_gui->setSelfAssessmentMode($this->page_gui->getPageConfig()->getEnableSelfAssessment());
425 $pc_question_gui->setPageConfig($this->page_gui->getPageConfig());
426
427 if ($this->page_gui->getPageConfig()->getEnableSelfAssessment()) {
428 $this->tabs_gui->clearTargets();
429 $ilHelp->setScreenIdComponent("copg_pcqst");
430 $this->tabs_gui->setBackTarget(
431 $this->lng->txt("back"),
432 $ilCtrl->getParentReturn($this)
433 );
434 $ret = $this->ctrl->forwardCommand($pc_question_gui);
435 } else {
436 $cmd = $this->ctrl->getCmd();
437 $pc_question_gui->$cmd();
438 $this->ctrl->redirectByClass(array("ilobjquestionpoolgui", get_class($cont_obj)), "editQuestion");
439 }
440 break;
441
442 // Plugged Component
443 case "ilpcpluggedgui":
444 $this->tabs_gui->clearTargets();
445 include_once("./Services/COPage/classes/class.ilPCPluggedGUI.php");
446 $plugged_gui = new ilPCPluggedGUI(
447 $this->page,
448 $cont_obj,
449 $hier_id,
450 $add_type,
451 $pc_id
452 );
453 $ret = $this->ctrl->forwardCommand($plugged_gui);
454 break;
455
456 case "ilpageeditorserveradaptergui":
457 $adapter = new ilPageEditorServerAdapterGUI(
458 $this->page_gui,
459 $this->ctrl,
460 $this->ui,
461 $this->request
462 );
463 $this->ctrl->forwardCommand($adapter);
464 break;
465
466 default:
467
468 // generic calls to gui classes
469 include_once("./Services/COPage/classes/class.ilCOPagePCDef.php");
470 if (ilCOPagePCDef::isPCGUIClassName($next_class, true)) {
471 $this->log->debug("Generic Call");
473 $this->tabs_gui->clearTargets();
474 $this->tabs_gui->setBackTarget(
475 $this->page_gui->page_back_title,
476 $ilCtrl->getLinkTarget($this->page_gui, "edit")
477 );
478 $ilHelp->setScreenIdComponent("copg_" . $pc_def["pc_type"]);
480 $gui_class_name = $pc_def["pc_gui_class"];
481 $pc_gui = new $gui_class_name($this->page, $cont_obj, $hier_id, $pc_id);
482 if ($pc_def["style_classes"]) {
483 $pc_gui->setStyleId($this->page_gui->getStyleId());
484 }
485 $pc_gui->setPageConfig($this->page_gui->getPageConfig());
486 $ret = $this->ctrl->forwardCommand($pc_gui);
487 } else {
488 $this->log->debug("Call ilPageEditorGUI command.");
489 // cmd belongs to ilPageEditorGUI
490
491 if ($cmd == "pasteFromClipboard") {
492 $ret = $this->pasteFromClipboard($hier_id);
493 } elseif ($cmd == "paste") {
494 $ret = $this->paste($hier_id);
495 } else {
496 $ret = $this->$cmd();
497 }
498 }
499 break;
500
501 }
502
503 $this->log->debug("end --------------------");
504
505 return $ret;
506 }
507
512 public static function _doJSEditing()
513 {
514 global $DIC;
515
516 $ilUser = $DIC->user();
517
518 if ($ilUser->getPref("ilPageEditor_JavaScript") != "disable"
520 return true;
521 }
522 return false;
523 }
524
528 public static function _isBrowserJSEditCapable()
529 {
530 return true;
531 }
532
533 public function activatePage()
534 {
535 $this->page_gui->activatePage();
536 }
537
538 public function deactivatePage()
539 {
540 $this->page_gui->deactivatePage();
541 }
542
546 public function setMediaMode()
547 {
549
550 $ilUser->writePref("ilPageEditor_MediaMode", $_POST["media_mode"]);
551 $ilUser->writePref("ilPageEditor_HTMLMode", $_POST["html_mode"]);
552 if ($ilUser->getPref("ilPageEditor_JavaScript") != $_POST["js_mode"]) {
553 // not nice, should be solved differently in the future
554 if ($this->page->getParentType() == "lm") {
555 $this->ctrl->setParameterByClass("illmpageobjectgui", "reloadTree", "y");
556 }
557 }
558 $ilUser->writePref("ilPageEditor_JavaScript", $_POST["js_mode"]);
559
560 // again not so nice...
561 if ($this->page->getParentType() == "lm") {
562 $this->ctrl->redirectByClass("illmpageobjectgui", "edit");
563 } else {
564 $this->ctrl->returnToParent($this);
565 }
566 }
567
572 {
574
575 ilUtil::sendSuccess($this->lng->txt("copied_to_clipboard"), true);
576 $ilUser->addObjectToClipboard($_POST["mob_id"], "mob", ilObject::_lookupTitle($_POST["mob_id"]));
577 $this->ctrl->returnToParent($this);
578 }
579
584 {
586
587 $this->ctrl->setParameterByClass("ilmediapooltargetselector", "mob_id", $_POST["mob_id"]);
588 $this->ctrl->redirectByClass("ilmediapooltargetselector", "listPools");
589 }
590
594 public function addChangeComment()
595 {
596 include_once("./Services/History/classes/class.ilHistory.php");
598 $this->page->getId(),
599 "update",
600 "",
601 $this->page->getParentType() . ":pg",
602 ilUtil::stripSlashes($_POST["change_comment"]),
603 true
604 );
605 ilUtil::sendSuccess($this->lng->txt("cont_added_comment"), true);
606 $this->ctrl->returnToParent($this);
607 }
608
612 public function delete()
613 {
614 $ilCtrl = $this->ctrl;
617
618 $targets = $_POST["ids"];
619
620 if (count($targets) == 0) {
621 ilUtil::sendInfo($lng->txt("no_checkbox"), true);
622 $this->ctrl->returnToParent($this);
623 } else {
624 include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
625 $cgui = new ilConfirmationGUI();
626 $cgui->setFormAction($ilCtrl->getFormAction($this));
627 $cgui->setHeaderText($lng->txt("copg_confirm_el_deletion"));
628 $cgui->setCancel($lng->txt("cancel"), "cancelDeleteSelected");
629 $cgui->setConfirm($lng->txt("confirm"), "confirmedDeleteSelected");
630 foreach ($targets as $t) {
631 $cgui->addHiddenItem("ids[]", $t);
632 }
633
634 $tpl->setContent($cgui->getHTML());
635 }
636 }
637
644 public function cancelDeleteSelected()
645 {
646 $this->ctrl->returnToParent($this);
647 }
648
649
653 public function confirmedDeleteSelected()
654 {
655 $targets = $_POST["ids"];
656 if (count($targets) > 0) {
657 $updated = $this->page->deleteContents(
658 $targets,
659 true,
660 $this->page_gui->getPageConfig()->getEnableSelfAssessment()
661 );
662 if ($updated !== true) {
663 $_SESSION["il_pg_error"] = $updated;
664 } else {
665 unset($_SESSION["il_pg_error"]);
666 }
667 }
668 $this->ctrl->returnToParent($this);
669 }
670
674 public function copy()
675 {
677
678 if (is_array($_POST["ids"])) {
679 $this->page->copyContents($_POST["ids"]);
680 ilUtil::sendSuccess($lng->txt("cont_sel_el_copied_use_paste"), true);
681 }
682 $this->ctrl->returnToParent($this);
683 }
684
688 public function cut()
689 {
691
692 if (is_array($_POST["ids"])) {
693 $updated = $this->page->cutContents($_POST["ids"]);
694 if ($updated !== true) {
695 $_SESSION["il_pg_error"] = $updated;
696 } else {
697 unset($_SESSION["il_pg_error"]);
698 }
699 ilUtil::sendSuccess($lng->txt("cont_sel_el_cut_use_paste"), true);
700 }
701 $this->ctrl->returnToParent($this);
702 }
703
707 public function paste($a_hier_id)
708 {
709 $ilCtrl = $this->ctrl;
710 $this->page->pasteContents($a_hier_id, $this->page_gui->getPageConfig()->getEnableSelfAssessment());
711 include_once("./Modules/LearningModule/classes/class.ilEditClipboard.php");
712 //ilEditClipboard::setAction("");
713 $this->ctrl->returnToParent($this);
714 }
715
719 public function activate()
720 {
721 if (is_array($_POST["ids"])) {
722 $updated = $this->page->switchEnableMultiple(
723 $_POST["ids"],
724 true,
725 $this->page_gui->getPageConfig()->getEnableSelfAssessment()
726 );
727 if ($updated !== true) {
728 $_SESSION["il_pg_error"] = $updated;
729 } else {
730 unset($_SESSION["il_pg_error"]);
731 }
732 }
733 $this->ctrl->returnToParent($this);
734 }
735
739 public function characteristic()
740 {
743
744 if (is_array($_POST["ids"])) {
745 $types = array();
746
747 // check what content element types have been selected
748 foreach ($_POST["ids"] as $t) {
749 $tarr = explode(":", $t);
750 $cont_obj = $this->page->getContentObject($tarr[0], $tarr[1]);
751 if (is_object($cont_obj) && $cont_obj->getType() == "par") {
752 $types["par"] = "par";
753 }
754 if (is_object($cont_obj) && $cont_obj->getType() == "sec") {
755 $types["sec"] = "sec";
756 }
757 }
758
759 if (count($types) == 0) {
760 ilUtil::sendFailure($lng->txt("cont_select_par_or_section"), true);
761 $this->ctrl->returnToParent($this);
762 } else {
763 $this->initCharacteristicForm($_POST["ids"], $types);
764 $tpl->setContent($this->form->getHTML());
765 }
766 } else {
767 $this->ctrl->returnToParent($this);
768 }
769 }
770
774 public function initCharacteristicForm($a_target, $a_types)
775 {
776 $ilCtrl = $this->ctrl;
778
779
780 // edit form
781 include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
782 $this->form = new ilPropertyFormGUI();
783 $this->form->setTitle($this->lng->txt("cont_choose_characteristic"));
784
785 if ($a_types["par"] == "par") {
786 $select_prop = new ilSelectInputGUI(
787 $this->lng->txt("cont_choose_characteristic_text"),
788 "char_par"
789 );
790 include_once("./Services/COPage/classes/class.ilPCParagraphGUI.php");
791 $options = ilPCParagraphGUI::_getCharacteristics($this->page_gui->getStyleId());
792 $select_prop->setOptions($options);
793 $this->form->addItem($select_prop);
794 }
795 if ($a_types["sec"] == "sec") {
796 $select_prop = new ilSelectInputGUI(
797 $this->lng->txt("cont_choose_characteristic_section"),
798 "char_sec"
799 );
800 include_once("./Services/COPage/classes/class.ilPCSectionGUI.php");
801 $options = ilPCSectionGUI::_getCharacteristics($this->page_gui->getStyleId());
802 $select_prop->setOptions($options);
803 $this->form->addItem($select_prop);
804 }
805
806 foreach ($a_target as $t) {
807 $hidden = new ilHiddenInputGUI("target[]");
808 $hidden->setValue($t);
809 $this->form->addItem($hidden);
810 }
811
812 $this->form->setFormAction($ilCtrl->getFormAction($this));
813 $this->form->addCommandButton("assignCharacteristic", $lng->txt("save"));
814 $this->form->addCommandButton("showPage", $lng->txt("cancel"));
815 }
816
820 public function assignCharacteristic()
821 {
822 $char_par = ilUtil::stripSlashes($_POST["char_par"]);
823 $char_sec = ilUtil::stripSlashes($_POST["char_sec"]);
824
825 $updated = $this->page->assignCharacteristic($_POST["target"], $char_par, $char_sec);
826 if ($updated !== true) {
827 $_SESSION["il_pg_error"] = $updated;
828 } else {
829 unset($_SESSION["il_pg_error"]);
830 }
831 $this->ctrl->returnToParent($this);
832 }
833
837 public function pasteFromClipboard($a_hier_id)
838 {
839 $ilCtrl = $this->ctrl;
840 //var_dump($a_hier_id);
841 $ilCtrl->setParameter($this, "hier_id", $a_hier_id);
842 $ilCtrl->setParameterByClass(
843 "ilEditClipboardGUI",
844 "returnCommand",
845 rawurlencode($ilCtrl->getLinkTarget(
846 $this,
847 "insertFromClipboard",
848 "",
849 false,
850 false
851 ))
852 );
853 //echo ":".$ilCtrl->getLinkTarget($this, "insertFromClipboard").":";
854 $ilCtrl->redirectByClass("ilEditClipboardGUI", "getObject");
855 }
856
860 public function insertFromClipboard()
861 {
862 include_once("./Services/Clipboard/classes/class.ilEditClipboardGUI.php");
864 include_once("./Services/COPage/classes/class.ilPCMediaObject.php");
865
866 $hier_id = $this->page->getHierIDForPCId($_GET["pc_id"]);
867 if ($hier_id == "") {
868 $hier_id = "pg";
869 }
870
871 if ($ids != "") {
872 foreach ($ids as $id2) {
873 $id = explode(":", $id2);
874 $type = $id[0];
875 $id = $id[1];
876 if ($type == "mob") {
877 $this->content_obj = new ilPCMediaObject($this->page);
878 $this->content_obj->readMediaObject($id);
879 $this->content_obj->createAlias($this->page, $hier_id);
880 $this->updated = $this->page->update();
881 }
882 if ($type == "incl") {
883 include_once("./Services/COPage/classes/class.ilPCContentInclude.php");
884 $this->content_obj = new ilPCContentInclude($this->page);
885 $this->content_obj->create($this->page, $hier_id);
886 $this->content_obj->setContentType("mep");
887 $this->content_obj->setContentId($id);
888 $this->updated = $this->page->update();
889 }
890 }
891 }
892 $this->ctrl->returnToParent($this);
893 }
894
898 public function displayPage()
899 {
900 $this->ctrl->returnToParent($this);
901 }
902
906 public function displayLocator()
907 {
908 /*if(is_object($this->locator))
909 {
910 $this->locator->display();
911 }*/
912 }
913
917 public function showSnippetInfo()
918 {
921 $ilAccess = $this->access;
922 $ilCtrl = $this->ctrl;
923
924 $stpl = new ilTemplate("tpl.snippet_info.html", true, true, "Services/COPage");
925
926 include_once("./Modules/MediaPool/classes/class.ilMediaPoolItem.php");
927 $mep_pools = ilMediaPoolItem::getPoolForItemId($_POST["ci_id"]);
928 foreach ($mep_pools as $mep_id) {
929 $ref_ids = ilObject::_getAllReferences($mep_id);
930 $edit_link = false;
931 foreach ($ref_ids as $rid) {
932 if (!$edit_link && $ilAccess->checkAccess("write", "", $rid)) {
933 $stpl->setCurrentBlock("edit_link");
934 $stpl->setVariable("TXT_EDIT", $lng->txt("edit"));
935 $stpl->setVariable(
936 "HREF_EDIT",
937 "./goto.php?target=mep_" . $rid
938 );
939 $stpl->parseCurrentBlock();
940 }
941 }
942 $stpl->setCurrentBlock("pool");
943 $stpl->setVariable("TXT_MEDIA_POOL", $lng->txt("obj_mep"));
944 $stpl->setVariable("VAL_MEDIA_POOL", ilObject::_lookupTitle($mep_id));
945 $stpl->parseCurrentBlock();
946 }
947
948 include_once("./Modules/MediaPool/classes/class.ilMediaPoolPage.php");
949 $stpl->setVariable("TXT_TITLE", $lng->txt("title"));
950 $stpl->setVariable("VAL_TITLE", ilMediaPoolPage::lookupTitle($_POST["ci_id"]));
951 $stpl->setVariable("TXT_BACK", $lng->txt("back"));
952 $stpl->setVariable(
953 "HREF_BACK",
954 $ilCtrl->getLinkTarget($this->page_gui, "edit")
955 );
956 $tpl->setContent($stpl->get());
957 }
958}
user()
Definition: user.php:4
$_GET["client_id"]
$_POST["username"]
$_SESSION["AccountId"]
An exception for terminatinating execution or to throw for unit testing.
static getPCDefinitionByGUIClassName($a_gui_class_name)
Get PC definition by name.
static getPCDefinitionByType($a_pc_type)
Get PC definition by type.
static getPCDefinitionByName($a_pc_name)
Get PC definition by name.
static requirePCGUIClassByName($a_name)
Get instance.
static isPCGUIClassName($a_class_name, $a_lower_case=false)
Is given class name a pc gui class?
Confirmation screen class.
This class represents a hidden form property in a property form.
static _createEntry( $a_obj_id, $a_action, $a_info_params="", $a_obj_type="", $a_user_comment="", $a_update_last=false)
Creates a new history entry for an object.
Class ilInternalLinkGUI.
static getLogger($a_component_id)
Get component logger.
static getPoolForItemId($a_id)
Get media pools for item id.
static lookupTitle($a_page_id)
Lookup title.
Class ilObjMediaObjectGUI.
static _lookupTitle($a_id)
lookup object title
static _getAllReferences($a_id)
get all reference ids of object
Class ilPCContentInclude.
Class ilPCMediaObjectGUI.
Class ilPCMediaObject.
static _getCharacteristics($a_style_id)
Get characteristics.
Class ilPCPluggedGUI.
Class ilPCQuestionGUI.
static _getCharacteristics($a_style_id)
Get characteristics.
Page Editor GUI class.
copyLinkedMediaToMediaPool()
copy linked media object to media pool
__construct(&$a_page_object, &$a_page_object_gui)
Constructor.
addChangeComment()
add change comment to history
initCharacteristicForm($a_target, $a_types)
Init map creation/update form.
insertFromClipboard()
insert object from clipboard
copyLinkedMediaToClipboard()
copy linked media object to clipboard
setLocator(&$a_locator)
set locator object
copy()
Copy selected items.
cancelDeleteSelected()
Cancel deletion.
displayPage()
Default for POST reloads and missing.
pasteFromClipboard($a_hier_id)
paste from clipboard (redirects to clipboard)
cut()
Cut selected items.
setMediaMode()
set media and editing mode
paste($a_hier_id)
paste from clipboard (redirects to clipboard)
static _isBrowserJSEditCapable()
checks wether browser is javascript editing capable
static _doJSEditing()
checks if current user has activated js editing and if browser is js capable
characteristic()
Assign characeristic to text blocks/sections.
confirmedDeleteSelected()
Delete selected items.
activate()
(de-)activate selected items
displayLocator()
display locator
setHeader($a_header)
set header title
showSnippetInfo()
Show snippet info.
returnToContext()
redirect to parent context
getHeader()
get header title
executeCommand()
execute command
assignCharacteristic()
Assign characteristic.
This class represents a property form user interface.
This class represents a selection list property in a property form.
special template class to simplify handling of ITX/PEAR
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
global $DIC
Definition: goto.php:24
help()
Definition: help.php:2
$ilUser
Definition: imgupload.php:18
exit
Definition: login.php:29
$ret
Definition: parser.php:6
$type
ui()
Definition: ui.php:5