ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 
4 include_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;
53  public $page;
56  public $header;
57  public $tabs;
58  public $cont_obj;
61 
65  protected $log;
66 
73  public function __construct(&$a_page_object, &$a_page_object_gui)
74  {
75  global $DIC;
76 
77  $this->help = $DIC["ilHelp"];
78  $this->user = $DIC->user();
79  $this->access = $DIC->access();
80  $tpl = $DIC["tpl"];
81  $lng = $DIC->language();
82  $objDefinition = $DIC["objDefinition"];
83  $ilCtrl = $DIC->ctrl();
84  $ilTabs = $DIC->tabs();
85 
86  $this->log = ilLoggerFactory::getLogger('copg');
87 
88  // initiate variables
89  $this->ctrl = $ilCtrl;
90  $this->tpl = $tpl;
91  $this->lng = $lng;
92  $this->objDefinition = $objDefinition;
93  $this->tabs_gui = $ilTabs;
94  $this->page = $a_page_object;
95  $this->page_gui = $a_page_object_gui;
96 
97  $this->ctrl->saveParameter($this, array("hier_id", "pc_id"));
98  }
99 
100 
106  public function setHeader($a_header)
107  {
108  $this->header = $a_header;
109  }
110 
116  public function getHeader()
117  {
118  return $this->header;
119  }
120 
126  public function setLocator(&$a_locator)
127  {
128  $this->locator = $a_locator;
129  }
130 
134  public function returnToContext()
135  {
136  $this->ctrl->returnToParent($this);
137  }
138 
139  public function setIntLinkReturn($a_return)
140  {
141  $this->int_link_return = $a_return;
142  }
143 
144 
145  public function setPageBackTitle($a_title)
146  {
147  $this->page_back_title = $a_title;
148  }
149 
153  public function executeCommand()
154  {
156  $ilHelp = $this->help;
157 
158  $this->log->debug("begin ============");
159 
160  // Step BC (basic command determination)
161  // determine cmd, cmdClass, hier_id and pc_id
162  $cmd = $this->ctrl->getCmd("displayPage");
163  $cmdClass = strtolower($this->ctrl->getCmdClass());
164 
165  $hier_id = $_GET["hier_id"];
166  $pc_id = $_GET["pc_id"];
167  if (isset($_POST["new_hier_id"])) {
168  $hier_id = $_POST["new_hier_id"];
169  }
170 
171  $new_type = (isset($_GET["new_type"]))
172  ? $_GET["new_type"]
173  : $_POST["new_type"];
174 
175  $this->log->debug("step BC: cmd:$cmd, cmdClass:$cmdClass, hier_id: $hier_id, pc_id: $pc_id");
176 
177  // Step EC (exec_ command handling)
178  // handle special exec_ commands, modify pc, hier_id
179  if (substr($cmd, 0, 5) == "exec_") {
180  // check whether pc id is given
181  $pca = explode(":", key($_POST["cmd"]));
182  $pc_id = $pca[1];
183  $cmd = explode("_", $pca[0]);
184  unset($cmd[0]);
185  $hier_id = implode($cmd, "_");
186  $cmd = $_POST["command" . $hier_id];
187  }
188  $this->log->debug("step EC: cmd:$cmd, hier_id: $hier_id, pc_id: $pc_id");
189 
190  // Step CC (handle table container (and similar) commands
191  // ... strip "c" "r" of table ids from hierarchical id
192  $first_hier_character = substr($hier_id, 0, 1);
193  if ($first_hier_character == "c" ||
194  $first_hier_character == "r" ||
195  $first_hier_character == "g" ||
196  $first_hier_character == "i") {
197  $hier_id = substr($hier_id, 1);
198  }
199  $this->log->debug("step CC: cmd:$cmd, hier_id: $hier_id, pc_id: $pc_id");
200 
201  // Step B (build dom, and ids in XML)
202  $this->page->buildDom();
203  $this->page->addHierIDs();
204 
205 
206  // Step CS (strip base command)
207  if ($cmdClass != "ilfilesystemgui") {
208  $com = explode("_", $cmd);
209  $cmd = $com[0];
210  }
211  $this->log->debug("step CS: cmd:$cmd");
212 
213 
214  // Step NC (determine next class)
215  $next_class = $this->ctrl->getNextClass($this);
216  $this->log->debug("step NC: next class: " . $next_class);
217 
218 
219  // Step PH (placeholder handling, placeholders from preview mode come without hier_id)
220  if ($next_class == "ilpcplaceholdergui" && $hier_id == "" && $_GET["pl_pc_id"] != "") {
221  $hid = $this->page->getHierIdsForPCIds(array($_GET["pl_pc_id"]));
222  $hier_id = $hid[$_GET["pl_pc_id"]];
223  }
224  $this->log->debug("step PH: next class: " . $next_class);
225 
226  if ($com[0] == "insert" || $com[0] == "create") {
227  // Step CM (creation mode handling)
228  $cmd = $com[0];
229  $ctype = $com[1]; // note ctype holds type if cmdclass is empty, but also subcommands if not (e.g. applyFilter in ilpcmediaobjectgui)
230  $add_type = $com[2];
231  if ($ctype == "mob") {
232  $ctype = "media";
233  }
234 
235  $this->log->debug("step CM: cmd: " . $cmd . ", ctype: " . $ctype . ", add_type: " . $add_type);
236  } else {
237  // Step LM (setting cmd and cmdclass for editing of linked media)
238  if ($cmd == "editLinkedMedia") {
239  $this->ctrl->setCmd("edit");
240  $cmd = "edit";
241  $_GET["pgEdMediaMode"] = "editLinkedMedia";
242  $_GET["mob_id"] = $_POST["mob_id"];
243  }
244  if ($_GET["pgEdMediaMode"] == "editLinkedMedia") {
245  $this->ctrl->setParameter($this, "pgEdMediaMode", "editLinkedMedia");
246  $this->ctrl->setParameter($this, "mob_id", $_GET["mob_id"]);
247  if ($cmdClass != "ilinternallinkgui" && $cmdClass != "ilmdeditorgui"
248  && $cmdClass != "ilimagemapeditorgui" && $cmdClass != "ilfilesystemgui") {
249  $this->ctrl->setCmdClass("ilobjmediaobjectgui");
250  $cmdClass = "ilobjmediaobjectgui";
251  }
252  }
253  $this->log->debug("step LM: cmd: " . $cmd . ", cmdClass: " . $cmdClass);
254 
255 
256  // Step PR (get content object and return to parent)
257  $this->log->debug("before PR: cmdClass: $cmdClass, nextClass: $next_class" .
258  ", hier_id: " . $hier_id . ", pc_id: " . $pc_id . ")");
259  // note: ilinternallinkgui for page: no cont_obj is received
260  // ilinternallinkgui for mob: cont_obj is received
261  if ($cmd != "insertFromClipboard" && $cmd != "pasteFromClipboard" &&
262  $cmd != "setMediaMode" && $cmd != "copyLinkedMediaToClipboard" &&
263  $cmd != "activatePage" && $cmd != "deactivatePage" &&
264  $cmd != "copyLinkedMediaToMediaPool" && $cmd != "showSnippetInfo" &&
265  $cmd != "deleteSelected" && $cmd != "paste" &&
266  $cmd != "cancelDeleteSelected" && $cmd != "confirmedDeleteSelected" &&
267  $cmd != "copySelected" && $cmd != "cutSelected" &&
268  ($cmd != "displayPage" || $_POST["editImagemapForward_x"] != "" || $_POST["imagemap_x"] != "") &&
269  ($cmd != "displayPage" || $_POST["editImagemapForward_x"] != "") &&
270  $cmd != "activateSelected" && $cmd != "assignCharacteristicForm" &&
271  $cmd != "assignCharacteristic" &&
272  $cmdClass != "ilrepositoryselector2inputgui" &&
273  $cmd != "cancelCreate" && $cmd != "popup" &&
274  $cmdClass != "ileditclipboardgui" && $cmd != "addChangeComment" &&
275  ($cmdClass != "ilinternallinkgui" || ($next_class == "ilpcmediaobjectgui"))) {
276  if ($_GET["pgEdMediaMode"] != "editLinkedMedia") {
277  $cont_obj = $this->page->getContentObject($hier_id, $pc_id);
278  if (!is_object($cont_obj)) {
279  $this->log->debug("returnToParent");
280  $ilCtrl->returnToParent($this);
281  }
282  $ctype = $cont_obj->getType();
283  }
284  }
285  $this->log->debug("step PR: ctype: $ctype");
286  }
287 
288 
289  if ($ctype != "media" || !is_object($cont_obj)) {
290  if ($this->getHeader() != "") {
291  $this->tpl->setTitle($this->getHeader());
292  }
293  $this->displayLocator();
294  }
295 
296  $this->cont_obj = $cont_obj;
297 
298 
299  // Step NC (handle empty next class)
300  $this->ctrl->setParameter($this, "hier_id", $hier_id);
301  $this->ctrl->setParameter($this, "pc_id", $pc_id);
302  $this->ctrl->setCmd($cmd);
303  if ($next_class == "") {
304  include_once("./Services/COPage/classes/class.ilCOPagePCDef.php");
305  $pc_def = ilCOPagePCDef::getPCDefinitionByType($ctype);
306  if (is_array($pc_def)) {
307  $this->ctrl->setCmdClass($pc_def["pc_gui_class"]);
308  }
309  $next_class = $this->ctrl->getNextClass($this);
310  }
311  $this->log->debug("step NC: next_class: $next_class");
312 
313  // ... do not do this while imagemap editing is ongoing
314  // Step IM (handle image map editing)
315  if ($cmd == "displayPage" && $_POST["editImagemapForward_x"] == "" && $_POST["imagemap_x"] == "") {
316  $next_class = "";
317  }
318  $this->log->debug("step IM: next_class: $next_class");
319 
320 
321  // Step FC (forward command)
322  $this->log->debug("before FC: next_class:" . $next_class . ", pc_id:" . $pc_id .
323  ", hier_id:" . $hier_id . ", ctype:" . $ctype . ", cmd:" . $cmd . ", _GET[cmd]: " . $_GET["cmd"]);
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  include_once("./Services/COPage/classes/class.ilPCMediaObjectGUI.php");
345 
346  $this->tabs_gui->clearTargets();
347  $this->tabs_gui->setBackTarget(
348  $this->page_gui->page_back_title,
349  $ilCtrl->getLinkTarget($this->page_gui, "edit")
350  );
351  $pcmob_gui = new ilPCMediaObjectGUI($this->page, $cont_obj, $hier_id, $pc_id);
352  $pcmob_gui->setStyleId($this->page_gui->getStyleId());
353  $pcmob_gui->setSubCmd($ctype);
354  $pcmob_gui->setEnabledMapAreas($this->page_gui->getPageConfig()->getEnableInternalLinks());
355  $ret = $this->ctrl->forwardCommand($pcmob_gui);
356  $ilHelp->setScreenIdComponent("copg_media");
357  break;
358 
359  // only for "linked" media
360  case "ilobjmediaobjectgui":
361  $this->tabs_gui->clearTargets();
362  $this->tabs_gui->setBackTarget(
363  $this->lng->txt("back"),
364  $ilCtrl->getParentReturn($this)
365  );
366  $mob_gui = new ilObjMediaObjectGUI("", $_GET["mob_id"], false, false);
367  $mob_gui->getTabs();
368  $mob_gui->setEnabledMapAreas($this->page_gui->getPageConfig()->getEnableInternalLinks());
369  $this->tpl->setTitle($this->lng->txt("mob") . ": " .
370  ilObject::_lookupTitle($_GET["mob_id"]));
371  $ret = $this->ctrl->forwardCommand($mob_gui);
372  break;
373 
374  // Question
375  case "ilpcquestiongui":
376  include_once("./Services/COPage/classes/class.ilPCQuestionGUI.php");
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  $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  include_once("./Services/COPage/classes/class.ilPCPluggedGUI.php");
400  $plugged_gui = new ilPCPluggedGUI(
401  $this->page,
402  $cont_obj,
403  $hier_id,
404  $add_type,
405  $pc_id
406  );
407  $ret = $this->ctrl->forwardCommand($plugged_gui);
408  break;
409 
410  default:
411 
412  // generic calls to gui classes
413  include_once("./Services/COPage/classes/class.ilCOPagePCDef.php");
414  if (ilCOPagePCDef::isPCGUIClassName($next_class, true)) {
415  $this->log->debug("Generic Call");
416  $pc_def = ilCOPagePCDef::getPCDefinitionByGUIClassName($next_class);
417  $this->tabs_gui->clearTargets();
418  $this->tabs_gui->setBackTarget(
419  $this->page_gui->page_back_title,
420  $ilCtrl->getLinkTarget($this->page_gui, "edit")
421  );
422  $ilHelp->setScreenIdComponent("copg_" . $pc_def["pc_type"]);
424  $gui_class_name = $pc_def["pc_gui_class"];
425  $pc_gui = new $gui_class_name($this->page, $cont_obj, $hier_id, $pc_id);
426  if ($pc_def["style_classes"]) {
427  $pc_gui->setStyleId($this->page_gui->getStyleId());
428  }
429  $pc_gui->setPageConfig($this->page_gui->getPageConfig());
430  $ret = $this->ctrl->forwardCommand($pc_gui);
431  } else {
432  $this->log->debug("Call ilPageEditorGUI command.");
433  // cmd belongs to ilPageEditorGUI
434 
435  if ($cmd == "pasteFromClipboard") {
436  $ret = $this->pasteFromClipboard($hier_id);
437  } elseif ($cmd == "paste") {
438  $ret = $this->paste($hier_id);
439  } else {
440  $ret = $this->$cmd();
441  }
442  }
443  break;
444 
445  }
446 
447  $this->log->debug("end ---");
448 
449  return $ret;
450  }
451 
456  public static function _doJSEditing()
457  {
458  global $DIC;
459 
460  $ilUser = $DIC->user();
461 
462  if ($ilUser->getPref("ilPageEditor_JavaScript") != "disable"
464  return true;
465  }
466  return false;
467  }
468 
472  public static function _isBrowserJSEditCapable()
473  {
474  return true;
475  }
476 
477  public function activatePage()
478  {
479  $this->page_gui->activatePage();
480  }
481 
482  public function deactivatePage()
483  {
484  $this->page_gui->deactivatePage();
485  }
486 
490  public function setMediaMode()
491  {
493 
494  $ilUser->writePref("ilPageEditor_MediaMode", $_POST["media_mode"]);
495  $ilUser->writePref("ilPageEditor_HTMLMode", $_POST["html_mode"]);
496  if ($ilUser->getPref("ilPageEditor_JavaScript") != $_POST["js_mode"]) {
497  // not nice, should be solved differently in the future
498  if ($this->page->getParentType() == "lm") {
499  $this->ctrl->setParameterByClass("illmpageobjectgui", "reloadTree", "y");
500  }
501  }
502  $ilUser->writePref("ilPageEditor_JavaScript", $_POST["js_mode"]);
503 
504  // again not so nice...
505  if ($this->page->getParentType() == "lm") {
506  $this->ctrl->redirectByClass("illmpageobjectgui", "edit");
507  } else {
508  $this->ctrl->returnToParent($this);
509  }
510  }
511 
515  public function copyLinkedMediaToClipboard()
516  {
518 
519  ilUtil::sendSuccess($this->lng->txt("copied_to_clipboard"), true);
520  $ilUser->addObjectToClipboard($_POST["mob_id"], "mob", ilObject::_lookupTitle($_POST["mob_id"]));
521  $this->ctrl->returnToParent($this);
522  }
523 
527  public function copyLinkedMediaToMediaPool()
528  {
530 
531  $this->ctrl->setParameterByClass("ilmediapooltargetselector", "mob_id", $_POST["mob_id"]);
532  $this->ctrl->redirectByClass("ilmediapooltargetselector", "listPools");
533  }
534 
538  public function addChangeComment()
539  {
540  include_once("./Services/History/classes/class.ilHistory.php");
542  $this->page->getId(),
543  "update",
544  "",
545  $this->page->getParentType() . ":pg",
546  ilUtil::stripSlashes($_POST["change_comment"]),
547  true
548  );
549  ilUtil::sendSuccess($this->lng->txt("cont_added_comment"), true);
550  $this->ctrl->returnToParent($this);
551  }
552 
556  public function deleteSelected()
557  {
559  $tpl = $this->tpl;
560  $lng = $this->lng;
561 
562  $targets = explode(";", $_POST["target"][0]);
563 
564  if (count($targets) == 0) {
565  ilUtil::sendInfo($lng->txt("no_checkbox"), true);
566  $this->ctrl->returnToParent($this);
567  } else {
568  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
569  $cgui = new ilConfirmationGUI();
570  $cgui->setFormAction($ilCtrl->getFormAction($this));
571  $cgui->setHeaderText($lng->txt("copg_confirm_el_deletion"));
572  $cgui->setCancel($lng->txt("cancel"), "cancelDeleteSelected");
573  $cgui->setConfirm($lng->txt("confirm"), "confirmedDeleteSelected");
574  $cgui->addHiddenItem("target", $_POST["target"][0]);
575 
576  $tpl->setContent($cgui->getHTML());
577  }
578  }
579 
586  public function cancelDeleteSelected()
587  {
588  $this->ctrl->returnToParent($this);
589  }
590 
591 
595  public function confirmedDeleteSelected()
596  {
597  $targets = explode(";", $_POST["target"]);
598  if (count($targets) > 0) {
599  $updated = $this->page->deleteContents(
600  $targets,
601  true,
602  $this->page_gui->getPageConfig()->getEnableSelfAssessment()
603  );
604  if ($updated !== true) {
605  $_SESSION["il_pg_error"] = $updated;
606  } else {
607  unset($_SESSION["il_pg_error"]);
608  }
609  }
610  $this->ctrl->returnToParent($this);
611  }
612 
616  public function copySelected()
617  {
618  $lng = $this->lng;
619 
620  if (is_int(strpos($_POST["target"][0], ";"))) {
621  $_POST["target"] = explode(";", $_POST["target"][0]);
622  }
623  if (is_array($_POST["target"])) {
624  $this->page->copyContents($_POST["target"]);
625  ilUtil::sendSuccess($lng->txt("cont_sel_el_copied_use_paste"), true);
626  }
627  $this->ctrl->returnToParent($this);
628  }
629 
633  public function cutSelected()
634  {
635  $lng = $this->lng;
636 
637  if (is_int(strpos($_POST["target"][0], ";"))) {
638  $_POST["target"] = explode(";", $_POST["target"][0]);
639  }
640  if (is_array($_POST["target"])) {
641  $updated = $this->page->cutContents($_POST["target"]);
642  if ($updated !== true) {
643  $_SESSION["il_pg_error"] = $updated;
644  } else {
645  unset($_SESSION["il_pg_error"]);
646  }
647  ilUtil::sendSuccess($lng->txt("cont_sel_el_cut_use_paste"), true);
648  }
649  $this->ctrl->returnToParent($this);
650  }
651 
655  public function paste($a_hier_id)
656  {
658  $this->page->pasteContents($a_hier_id, $this->page_gui->getPageConfig()->getEnableSelfAssessment());
659  include_once("./Modules/LearningModule/classes/class.ilEditClipboard.php");
660  //ilEditClipboard::setAction("");
661  $this->ctrl->returnToParent($this);
662  }
663 
667  public function activateSelected()
668  {
669  if (is_int(strpos($_POST["target"][0], ";"))) {
670  $_POST["target"] = explode(";", $_POST["target"][0]);
671  }
672  if (is_array($_POST["target"])) {
673  $updated = $this->page->switchEnableMultiple(
674  $_POST["target"],
675  true,
676  $this->page_gui->getPageConfig()->getEnableSelfAssessment()
677  );
678  if ($updated !== true) {
679  $_SESSION["il_pg_error"] = $updated;
680  } else {
681  unset($_SESSION["il_pg_error"]);
682  }
683  }
684  $this->ctrl->returnToParent($this);
685  }
686 
690  public function assignCharacteristicForm()
691  {
692  $tpl = $this->tpl;
693  $lng = $this->lng;
694 
695  if (is_int(strpos($_POST["target"][0], ";"))) {
696  $_POST["target"] = explode(";", $_POST["target"][0]);
697  }
698  if (is_array($_POST["target"])) {
699  $types = array();
700 
701  // check what content element types have been selected
702  foreach ($_POST["target"] as $t) {
703  $tarr = explode(":", $t);
704  $cont_obj = $this->page->getContentObject($tarr[0], $tarr[1]);
705  if (is_object($cont_obj) && $cont_obj->getType() == "par") {
706  $types["par"] = "par";
707  }
708  if (is_object($cont_obj) && $cont_obj->getType() == "sec") {
709  $types["sec"] = "sec";
710  }
711  }
712 
713  if (count($types) == 0) {
714  ilUtil::sendFailure($lng->txt("cont_select_par_or_section"), true);
715  $this->ctrl->returnToParent($this);
716  } else {
717  $this->initCharacteristicForm($_POST["target"], $types);
718  $tpl->setContent($this->form->getHTML());
719  }
720  } else {
721  $this->ctrl->returnToParent($this);
722  }
723  }
724 
728  public function initCharacteristicForm($a_target, $a_types)
729  {
731  $lng = $this->lng;
732 
733 
734  // edit form
735  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
736  $this->form = new ilPropertyFormGUI();
737  $this->form->setTitle($this->lng->txt("cont_choose_characteristic"));
738 
739  if ($a_types["par"] == "par") {
740  $select_prop = new ilSelectInputGUI(
741  $this->lng->txt("cont_choose_characteristic_text"),
742  "char_par"
743  );
744  include_once("./Services/COPage/classes/class.ilPCParagraphGUI.php");
745  $options = ilPCParagraphGUI::_getCharacteristics($this->page_gui->getStyleId());
746  $select_prop->setOptions($options);
747  $this->form->addItem($select_prop);
748  }
749  if ($a_types["sec"] == "sec") {
750  $select_prop = new ilSelectInputGUI(
751  $this->lng->txt("cont_choose_characteristic_section"),
752  "char_sec"
753  );
754  include_once("./Services/COPage/classes/class.ilPCSectionGUI.php");
755  $options = ilPCSectionGUI::_getCharacteristics($this->page_gui->getStyleId());
756  $select_prop->setOptions($options);
757  $this->form->addItem($select_prop);
758  }
759 
760  foreach ($a_target as $t) {
761  $hidden = new ilHiddenInputGUI("target[]");
762  $hidden->setValue($t);
763  $this->form->addItem($hidden);
764  }
765 
766  $this->form->setFormAction($ilCtrl->getFormAction($this));
767  $this->form->addCommandButton("assignCharacteristic", $lng->txt("save"));
768  $this->form->addCommandButton("showPage", $lng->txt("cancel"));
769  }
770 
774  public function assignCharacteristic()
775  {
776  $char_par = ilUtil::stripSlashes($_POST["char_par"]);
777  $char_sec = ilUtil::stripSlashes($_POST["char_sec"]);
778  if (is_array($_POST["target"])) {
779  foreach ($_POST["target"] as $t) {
780  $tarr = explode(":", $t);
781  $cont_obj = $this->page->getContentObject($tarr[0], $tarr[1]);
782  if (is_object($cont_obj) && $cont_obj->getType() == "par") {
783  $cont_obj->setCharacteristic($char_par);
784  }
785  if (is_object($cont_obj) && $cont_obj->getType() == "sec") {
786  $cont_obj->setCharacteristic($char_sec);
787  }
788  }
789  $updated = $this->page->update();
790  if ($updated !== true) {
791  $_SESSION["il_pg_error"] = $updated;
792  } else {
793  unset($_SESSION["il_pg_error"]);
794  }
795  }
796  $this->ctrl->returnToParent($this);
797  }
798 
802  public function pasteFromClipboard($a_hier_id)
803  {
805  //var_dump($a_hier_id);
806  $ilCtrl->setParameter($this, "hier_id", $a_hier_id);
807  $ilCtrl->setParameterByClass(
808  "ilEditClipboardGUI",
809  "returnCommand",
810  rawurlencode($ilCtrl->getLinkTarget(
811  $this,
812  "insertFromClipboard",
813  "",
814  false,
815  false
816  ))
817  );
818  //echo ":".$ilCtrl->getLinkTarget($this, "insertFromClipboard").":";
819  $ilCtrl->redirectByClass("ilEditClipboardGUI", "getObject");
820  }
821 
825  public function insertFromClipboard()
826  {
827  include_once("./Services/Clipboard/classes/class.ilEditClipboardGUI.php");
829  include_once("./Services/COPage/classes/class.ilPCMediaObject.php");
830  if ($ids != "") {
831  foreach ($ids as $id2) {
832  $id = explode(":", $id2);
833  $type = $id[0];
834  $id = $id[1];
835  if ($type == "mob") {
836  $this->content_obj = new ilPCMediaObject($this->page);
837  $this->content_obj->readMediaObject($id);
838  $this->content_obj->createAlias($this->page, $_GET["hier_id"]);
839  $this->updated = $this->page->update();
840  }
841  if ($type == "incl") {
842  include_once("./Services/COPage/classes/class.ilPCContentInclude.php");
843  $this->content_obj = new ilPCContentInclude($this->page);
844  $this->content_obj->create($this->page, $_GET["hier_id"]);
845  $this->content_obj->setContentType("mep");
846  $this->content_obj->setContentId($id);
847  $this->updated = $this->page->update();
848  }
849  }
850  }
851  $this->ctrl->returnToParent($this);
852  }
853 
857  public function displayPage()
858  {
859  $this->ctrl->returnToParent($this);
860  }
861 
865  public function displayLocator()
866  {
867  /*if(is_object($this->locator))
868  {
869  $this->locator->display();
870  }*/
871  }
872 
876  public function showSnippetInfo()
877  {
878  $tpl = $this->tpl;
879  $lng = $this->lng;
880  $ilAccess = $this->access;
882 
883  $stpl = new ilTemplate("tpl.snippet_info.html", true, true, "Services/COPage");
884 
885  include_once("./Modules/MediaPool/classes/class.ilMediaPoolItem.php");
886  $mep_pools = ilMediaPoolItem::getPoolForItemId($_POST["ci_id"]);
887  foreach ($mep_pools as $mep_id) {
888  $ref_ids = ilObject::_getAllReferences($mep_id);
889  $edit_link = false;
890  foreach ($ref_ids as $rid) {
891  if (!$edit_link && $ilAccess->checkAccess("write", "", $rid)) {
892  $stpl->setCurrentBlock("edit_link");
893  $stpl->setVariable("TXT_EDIT", $lng->txt("edit"));
894  $stpl->setVariable(
895  "HREF_EDIT",
896  "./goto.php?target=mep_" . $rid
897  );
898  $stpl->parseCurrentBlock();
899  }
900  }
901  $stpl->setCurrentBlock("pool");
902  $stpl->setVariable("TXT_MEDIA_POOL", $lng->txt("obj_mep"));
903  $stpl->setVariable("VAL_MEDIA_POOL", ilObject::_lookupTitle($mep_id));
904  $stpl->parseCurrentBlock();
905  }
906 
907  include_once("./Modules/MediaPool/classes/class.ilMediaPoolPage.php");
908  $stpl->setVariable("TXT_TITLE", $lng->txt("title"));
909  $stpl->setVariable("VAL_TITLE", ilMediaPoolPage::lookupTitle($_POST["ci_id"]));
910  $stpl->setVariable("TXT_BACK", $lng->txt("back"));
911  $stpl->setVariable(
912  "HREF_BACK",
913  $ilCtrl->getLinkTarget($this->page_gui, "edit")
914  );
915  $tpl->setContent($stpl->get());
916  }
917 }
static _isBrowserJSEditCapable()
checks wether browser is javascript editing capable
static isPCGUIClassName($a_class_name, $a_lower_case=false)
Is given class name a pc gui class?
static getPoolForItemId($a_id)
Get media pools for item id.
returnToContext()
redirect to parent context
$_SESSION["AccountId"]
This class represents a selection list property in a property form.
displayLocator()
display locator
This class represents a property form user interface.
setMediaMode()
set media and editing mode
$type
cutSelected()
Cut selected items.
global $DIC
Definition: saml.php:7
$_GET["client_id"]
showSnippetInfo()
Show snippet info.
Class ilPCPluggedGUI.
static getPCDefinitionByGUIClassName($a_gui_class_name)
Get PC definition by name.
if(!array_key_exists('StateId', $_REQUEST)) $id
confirmedDeleteSelected()
Delete selected items.
assignCharacteristicForm()
Assign characeristic to text blocks/sections.
displayPage()
Default for POST reloads and missing.
static _getCharacteristics($a_style_id)
Get characteristics.
setFilterWhiteList($a_white_list)
Set filter list as white list (per detault it is a black list)
static _lookupTitle($a_id)
lookup object title
Class ilInternalLinkGUI.
paste($a_hier_id)
paste from clipboard (redirects to clipboard)
executeCommand()
execute command
setLocator(&$a_locator)
set locator object
static lookupTitle($a_page_id)
Lookup title.
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.
user()
Definition: user.php:4
static _getAllReferences($a_id)
get all reference ids of object
__construct(&$a_page_object, &$a_page_object_gui)
Constructor.
Class ilPCMediaObjectGUI.
Page Editor GUI class.
global $ilCtrl
Definition: ilias.php:18
copySelected()
Copy selected items.
static sendInfo($a_info="", $a_keep=false)
Send Info Message to Screen.
Class ilPCQuestionGUI.
initCharacteristicForm($a_target, $a_types)
Init map creation/update form.
copyLinkedMediaToClipboard()
copy linked media object to clipboard
This class represents a hidden form property in a property form.
Class ilPCContentInclude.
static _getCharacteristics($a_style_id)
Get characteristics.
assignCharacteristic()
Assign characteristic.
insertFromClipboard()
insert object from clipboard
copyLinkedMediaToMediaPool()
copy linked media object to media pool
activateSelected()
(de-)activate selected items
special template class to simplify handling of ITX/PEAR
static _doJSEditing()
checks if current user has activated js editing and if browser is js capable
$ilUser
Definition: imgupload.php:18
setHeader($a_header)
set header title
addChangeComment()
add change comment to history
cancelDeleteSelected()
Cancel deletion.
static stripSlashes($a_str, $a_strip_html=true, $a_allow="")
strip slashes if magic qoutes is enabled
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.
Class ilObjMediaObjectGUI.
static requirePCGUIClassByName($a_name)
Get instance.
$ret
Definition: parser.php:6
static getLogger($a_component_id)
Get component logger.
Class ilPCMediaObject.
static getPCDefinitionByType($a_pc_type)
Get PC definition by type.
$_POST["username"]
pasteFromClipboard($a_hier_id)
paste from clipboard (redirects to clipboard)
Confirmation screen class.
getHeader()
get header title