ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
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 include_once ("classes/class.ilTabsGUI.php");
6 
25 {
31  var $ilias;
32  var $tpl;
33  var $lng;
34  var $ctrl;
36  var $page;
39  var $header;
40  var $tabs;
41  var $cont_obj;
44 
51  function ilPageEditorGUI(&$a_page_object, &$a_page_object_gui)
52  {
53  global $ilias, $tpl, $lng, $objDefinition, $ilCtrl,$ilTabs;
54 
55  // initiate variables
56  $this->ilias =& $ilias;
57  $this->ctrl =& $ilCtrl;
58  $this->tpl =& $tpl;
59  $this->lng =& $lng;
60  $this->objDefinition = $objDefinition;
61  $this->tabs_gui =& $ilTabs;
62  $this->page =& $a_page_object;
63  $this->page_gui =& $a_page_object_gui;
64 
65  $this->ctrl->saveParameter($this, array("hier_id", "pc_id"));
66  }
67 
68 
74  function setHeader($a_header)
75  {
76  $this->header = $a_header;
77  }
78 
84  function getHeader()
85  {
86  return $this->header;
87  }
88 
94  function setLocator(&$a_locator)
95  {
96  $this->locator =& $a_locator;
97  }
98 
102  function returnToContext()
103  {
104  $this->ctrl->returnToParent($this);
105  }
106 
107  function setIntLinkHelpDefault($a_type, $a_id)
108  {
109  $this->int_link_def_type = $a_type;
110  $this->int_link_def_id = $a_id;
111  }
112 
113  function setIntLinkReturn($a_return)
114  {
115  $this->int_link_return = $a_return;
116  }
117 
118 
119  function setPageBackTitle($a_title)
120  {
121  $this->page_back_title = $a_title;
122  }
123 
129  function setEnableInternalLinks($a_val)
130  {
131  $this->enable_internal_links = $a_val;
132  }
133 
140  {
141  return $this->enable_internal_links;
142  }
143 
149  function setEnableKeywords($a_val)
150  {
151  $this->enable_keywords = $a_val;
152  }
153 
159  function getEnableKeywords()
160  {
161  return $this->enable_keywords;
162  }
163 
169  function setEnableAnchors($a_val)
170  {
171  $this->enable_anchors = $a_val;
172  }
173 
179  function getEnableAnchors()
180  {
181  return $this->enable_anchors;
182  }
183 
187  function &executeCommand()
188  {
189  global $ilCtrl;
190 
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  {
198  $hier_id = $_POST["new_hier_id"];
199  }
200 //echo "GEThier_id:".$_GET["hier_id"]."<br>";
201 //$this->ctrl->debug("hier_id:".$hier_id);
202 
203  $new_type = (isset($_GET["new_type"]))
204  ? $_GET["new_type"]
205  : $_POST["new_type"];
206 //echo "-$cmd-";
207 //var_dump($_POST);
208  if (substr($cmd, 0, 5) == "exec_")
209  {
210 //echo ":".key($_POST["cmd"]).":";
211  // check whether pc id is given
212  $pca = explode(":", key($_POST["cmd"]));
213  $pc_id = $pca[1];
214 //echo "<br />exec_pc_id:-$pc_id-";
215  $cmd = explode("_", $pca[0]);
216  unset($cmd[0]);
217  $hier_id = implode($cmd, "_");
218  $cmd = $_POST["command".$hier_id];
219  }
220 //echo "<br>cmd:$cmd:";
221  // strip "c" "r" of table ids from hierarchical id
222  $first_hier_character = substr($hier_id, 0, 1);
223  if ($first_hier_character == "c" ||
224  $first_hier_character == "r" ||
225  $first_hier_character == "i")
226  {
227  $hier_id = substr($hier_id, 1);
228  }
229 
230  $this->page->buildDom();
231  $this->page->addHierIDs();
232 
233  // determine command and content object
234  if ($cmdClass != "ilfilesystemgui")
235  {
236  $com = explode("_", $cmd);
237  $cmd = $com[0];
238  }
239 //echo ";$cmd;";
240 //$this->ctrl->debug("hier_id:$hier_id:cmd:$cmd:");
241  $next_class = $this->ctrl->getNextClass($this);
242 
243  // determine content type
244  if ($com[0] == "insert" || $com[0] == "create")
245  {
246  $cmd = $com[0];
247  $ctype = $com[1];
248  $add_type = $com[2];
249  if ($ctype == "mob") $ctype = "media";
250  }
251  else
252  {
253  // setting cmd and cmdclass for editing of linked media
254  if ($cmd == "editLinkedMedia")
255  {
256  $this->ctrl->setCmd("edit");
257  $cmd = "edit";
258  $_GET["pgEdMediaMode"] = "editLinkedMedia";
259  $_GET["mob_id"] = $_POST["mob_id"];
260  }
261  if ($_GET["pgEdMediaMode"] == "editLinkedMedia")
262  {
263  $this->ctrl->setParameter($this, "pgEdMediaMode", "editLinkedMedia");
264  $this->ctrl->setParameter($this, "mob_id", $_GET["mob_id"]);
265  if ($cmdClass != "ilinternallinkgui" && $cmdClass != "ilmdeditorgui"
266  && $cmdClass != "ilimagemapeditorgui" && $cmdClass != "ilfilesystemgui")
267  {
268  $this->ctrl->setCmdClass("ilobjmediaobjectgui");
269  $cmdClass = "ilobjmediaobjectgui";
270  }
271  }
272 //echo "-$pc_id-";
273 //echo "-$cmd-".$this->ctrl->getCmd()."-";
274 //var_dump($_POST);
275  // note: ilinternallinkgui for page: no cont_obj is received
276  // ilinternallinkgui for mob: cont_obj is received
277  if ($cmd != "insertFromClipboard" && $cmd != "pasteFromClipboard" &&
278  $cmd != "setMediaMode" && $cmd != "copyLinkedMediaToClipboard" &&
279  $cmd != "activatePage" && $cmd != "deactivatePage" &&
280  $cmd != "copyLinkedMediaToMediaPool" && $cmd != "showSnippetInfo" &&
281  $cmd != "deleteSelected" && $cmd != "paste" &&
282  $cmd != "copySelected" && $cmd != "cutSelected" &&
283  ($cmd != "displayPage" || $_POST["editImagemapForward_x"] != "" || $_POST["imagemap_x"] != "") &&
284  ($cmd != "displayPage" || $_POST["editImagemapForward_x"] != "") &&
285  $cmd != "activateSelected" && $cmd != "assignCharacteristicForm" &&
286  $cmd != "assignCharacteristic" &&
287  $cmd != "cancelCreate" && $cmd != "popup" &&
288  $cmdClass != "ileditclipboardgui" && $cmd != "addChangeComment" &&
289  ($cmdClass != "ilinternallinkgui" || ($next_class == "ilpcmediaobjectgui")))
290  {
291  if ($_GET["pgEdMediaMode"] != "editLinkedMedia")
292  {
293 //$this->ctrl->debug("gettingContentObject (no linked media)");
294 //echo $hier_id."-".$pc_id;
295  $cont_obj =& $this->page->getContentObject($hier_id, $pc_id);
296 //var_dump($cont_obj);
297  if (!is_object($cont_obj))
298  {
299  $ilCtrl->returnToParent($this);
300  }
301  $ctype = $cont_obj->getType();
302  }
303  }
304  }
305 //$this->ctrl->debug("+ctype:".$ctype."+");
306 // $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
307 // $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
308 
309  if ($ctype != "media" || !is_object ($cont_obj))
310  {
311  if ($this->getHeader() != "")
312  {
313  $this->tpl->setTitle($this->getHeader());
314  }
315  $this->displayLocator();
316  }
317 
318  $this->cont_obj =& $cont_obj;
319 
320  // special command / command class handling
321  $this->ctrl->setParameter($this, "hier_id", $hier_id);
322  $this->ctrl->setParameter($this, "pc_id", $pc_id);
323  $this->ctrl->setCmd($cmd);
324  //$next_class = $this->ctrl->getNextClass($this);
325 //$this->ctrl->debug("+next_class:".$next_class."+");
326 //echo("+next_class:".$next_class."+".$ctype."+");
327  if ($next_class == "")
328  {
329  switch($ctype)
330  {
331  case "src":
332  $this->ctrl->setCmdClass("ilPCSourcecodeGUI");
333  break;
334 
335  case "par":
336  $this->ctrl->setCmdClass("ilPCParagraphGUI");
337  break;
338 
339  // advanced table
340  case "tab":
341  $this->ctrl->setCmdClass("ilPCTableGUI");
342  break;
343 
344  // data table
345  case "dtab":
346  $this->ctrl->setCmdClass("ilPCDataTableGUI");
347  break;
348 
349  case "td":
350  $this->ctrl->setCmdClass("ilPCTableDataGUI");
351  break;
352 
353  case "media":
354  $this->ctrl->setCmdClass("ilPCMediaObjectGUI");
355  break;
356 
357  case "list":
358  $this->ctrl->setCmdClass("ilPCListGUI");
359  break;
360 
361  case "li":
362  $this->ctrl->setCmdClass("ilPCListItemGUI");
363  break;
364 
365  case "flst":
366  $this->ctrl->setCmdClass("ilPCFileListGUI");
367  break;
368 
369  case "flit":
370  $this->ctrl->setCmdClass("ilPCFileItemGUI");
371  break;
372 
373  case "pcqst":
374  $this->ctrl->setCmdClass("ilPCQuestionGUI");
375  break;
376 
377  case "sec":
378  $this->ctrl->setCmdClass("ilPCSectionGUI");
379  break;
380 
381  case "repobj":
382  $this->ctrl->setCmdClass("ilPCResourcesGUI");
383  break;
384 
385  case "map":
386  $this->ctrl->setCmdClass("ilPCMapGUI");
387  break;
388 
389  case "tabs":
390  $this->ctrl->setCmdClass("ilPCTabsGUI");
391  break;
392 
393  case "tabstab":
394  $this->ctrl->setCmdClass("ilPCTabGUI");
395  break;
396 
397  case "plug":
398  $this->ctrl->setCmdClass("ilPCPluggedGUI");
399  break;
400 
401  case "plach":
402  $this->ctrl->setCmdClass("ilPCPlaceHolderGUI");
403  break;
404 
405  case "incl":
406  $this->ctrl->setCmdClass("ilPCContentIncludeGUI");
407  break;
408 
409  }
410  $next_class = $this->ctrl->getNextClass($this);
411  }
412 
413  // do not do this while imagemap editing is ongoing
414  if ($cmd == "displayPage" && $_POST["editImagemapForward_x"] == "" && $_POST["imagemap_x"] == "")
415  {
416  $next_class = "";
417  }
418 
419 //echo "hier_id:$hier_id:type:$type:cmd:$cmd:ctype:$ctype:next_class:$next_class:<br>";
420  switch($next_class)
421  {
422  case "ilinternallinkgui":
423  $link_gui = new ilInternalLinkGUI(
424  $this->int_link_def_type, $this->int_link_def_id);
425  $link_gui->setMode("normal");
426  foreach ($this->page_gui->getPageConfig()->getIntLinkFilters() as $filter)
427  {
428  $link_gui->filterLinkType($filter);
429  }
430  $link_gui->setSetLinkTargetScript(
431  $this->ctrl->getLinkTarget($this, "setInternalLink"));
432  $link_gui->setReturn($this->int_link_return);
433  $ret =& $this->ctrl->forwardCommand($link_gui);
434  break;
435 
436  // Sourcecode
437  case "ilpcsourcecodegui":
438  $this->tabs_gui->clearTargets();
439  include_once ("./Services/COPage/classes/class.ilPCSourcecodeGUI.php");
440  $src_gui =& new ilPCSourcecodeGUI($this->page, $cont_obj, $hier_id, $pc_id);
441  $ret =& $this->ctrl->forwardCommand($src_gui);
442  break;
443 
444  // Paragraph
445  case "ilpcparagraphgui":
446  $this->tabs_gui->clearTargets();
447  include_once ("./Services/COPage/classes/class.ilPCParagraphGUI.php");
448  $par_gui =& new ilPCParagraphGUI($this->page, $cont_obj, $hier_id, $pc_id);
449  $par_gui->setEnableWikiLinks($this->page_gui->getEnabledWikiLinks());
450  $par_gui->setStyleId($this->page_gui->getStyleId());
451  $par_gui->setEnableInternalLinks($this->getEnableInternalLinks());
452  $par_gui->setEnableKeywords($this->getEnableKeywords());
453  $par_gui->setEnableAnchors($this->getEnableAnchors());
454  $ret =& $this->ctrl->forwardCommand($par_gui);
455  break;
456 
457  // Table
458  case "ilpctablegui":
459  $this->tabs_gui->clearTargets();
460  include_once ("./Services/COPage/classes/class.ilPCTableGUI.php");
461  $tab_gui =& new ilPCTableGUI($this->page, $cont_obj, $hier_id, $pc_id);
462  $tab_gui->setStyleId($this->page_gui->getStyleId());
463  $ret =& $this->ctrl->forwardCommand($tab_gui);
464  break;
465 
466  // Table Cell
467  case "ilpctabledatagui":
468  $this->tabs_gui->clearTargets();
469  include_once ("./Services/COPage/classes/class.ilPCTableDataGUI.php");
470  $td_gui =& new ilPCTableDataGUI($this->page, $cont_obj, $hier_id, $pc_id);
471  $ret =& $this->ctrl->forwardCommand($td_gui);
472  break;
473 
474  // Data Table
475  case "ilpcdatatablegui":
476  $this->tabs_gui->clearTargets();
477  include_once ("./Services/COPage/classes/class.ilPCDataTableGUI.php");
478  $tab_gui =& new ilPCDataTableGUI($this->page, $cont_obj, $hier_id, $pc_id);
479  // scorm2004-start
480  $tab_gui->setStyleId($this->page_gui->getStyleId());
481  // scorm2004-end
482  $ret =& $this->ctrl->forwardCommand($tab_gui);
483  break;
484 
485  // PC Media Object
486  case "ilpcmediaobjectgui":
487  include_once ("./Services/COPage/classes/class.ilPCMediaObjectGUI.php");
488 
489  $this->tabs_gui->clearTargets();
490  $this->tabs_gui->setBackTarget($this->page_gui->page_back_title,
491  $ilCtrl->getLinkTarget($this->page_gui, "edit"));
492  $pcmob_gui =& new ilPCMediaObjectGUI($this->page, $cont_obj, $hier_id, $pc_id);
493  $pcmob_gui->setStyleId($this->page_gui->getStyleId());
494  $pcmob_gui->setEnabledMapAreas($this->page_gui->getEnabledInternalLinks());
495  $ret =& $this->ctrl->forwardCommand($pcmob_gui);
496  break;
497 
498  // only for "linked" media
499  case "ilobjmediaobjectgui":
500  $this->tabs_gui->clearTargets();
501  $this->tabs_gui->setBackTarget($this->lng->txt("back"),
502  $ilCtrl->getParentReturn($this));
503  $mob_gui =& new ilObjMediaObjectGUI("", $_GET["mob_id"],false, false);
504  $mob_gui->getTabs($this->tabs_gui);
505  $mob_gui->setEnabledMapAreas($this->page_gui->getEnabledInternalLinks());
506  $this->tpl->setTitle($this->lng->txt("mob").": ".
507  ilObject::_lookupTitle($_GET["mob_id"]));
508  $ret =& $this->ctrl->forwardCommand($mob_gui);
509  break;
510 
511  // List
512  case "ilpclistgui":
513  $this->tabs_gui->clearTargets();
514  include_once ("./Services/COPage/classes/class.ilPCListGUI.php");
515  $list_gui =& new ilPCListGUI($this->page, $cont_obj, $hier_id, $pc_id);
516  $list_gui->setStyleId($this->page_gui->getStyleId());
517  $ret =& $this->ctrl->forwardCommand($list_gui);
518  break;
519 
520  // List Item
521  case "ilpclistitemgui":
522  $this->tabs_gui->clearTargets();
523  include_once ("./Services/COPage/classes/class.ilPCListItemGUI.php");
524  $list_item_gui =& new ilPCListItemGUI($this->page, $cont_obj, $hier_id, $pc_id);
525  //$ret =& $list_item_gui->executeCommand();
526  $ret =& $this->ctrl->forwardCommand($list_item_gui);
527  break;
528 
529  // File List
530  case "ilpcfilelistgui":
531  $this->tabs_gui->clearTargets();
532  include_once ("./Services/COPage/classes/class.ilPCFileListGUI.php");
533  $file_list_gui =& new ilPCFileListGUI($this->page, $cont_obj, $hier_id, $pc_id);
534  // scorm2004-start
535  $file_list_gui->setStyleId($this->page_gui->getStyleId());
536  // scorm2004-end
537  //$ret =& $file_list_gui->executeCommand();
538  $ret =& $this->ctrl->forwardCommand($file_list_gui);
539  break;
540 
541  // File List Item
542  case "ilpcfileitemgui":
543  $this->tabs_gui->clearTargets();
544  include_once ("./Services/COPage/classes/class.ilPCFileItemGUI.php");
545  $file_item_gui =& new ilPCFileItemGUI($this->page, $cont_obj, $hier_id, $pc_id);
546  //$ret =& $file_item_gui->executeCommand();
547  $ret =& $this->ctrl->forwardCommand($file_item_gui);
548  break;
549 
550  // Question
551  case "ilpcquestiongui":
552  include_once("./Services/COPage/classes/class.ilPCQuestionGUI.php");
553  $pc_question_gui =& new ilPCQuestionGUI($this->page, $cont_obj, $hier_id, $pc_id);
554  $pc_question_gui->setSelfAssessmentMode($this->page_gui->getEnabledSelfAssessment());
555  $pc_question_gui->setPageConfig($this->page_gui->getPageConfig());
556 
557  if ($this->page_gui->getEnabledSelfAssessment())
558  {
559  $this->tabs_gui->clearTargets();
560  $this->tabs_gui->setBackTarget($this->lng->txt("back"),
561  $ilCtrl->getParentReturn($this));
562  $ret = $this->ctrl->forwardCommand($pc_question_gui);
563  }
564  else
565  {
566  $cmd = $this->ctrl->getCmd();
567  $pc_question_gui->$cmd();
568  $this->ctrl->redirectByClass(array("ilobjquestionpoolgui", get_class($cont_obj)), "editQuestion");
569  }
570  break;
571 
572 
573  // PlaceHolder
574  case "ilpcplaceholdergui":
575  $this->tabs_gui->clearTargets();
576  include_once ("./Services/COPage/classes/class.ilPCPlaceHolderGUI.php");
577  $plch_gui =& new ilPCPlaceHolderGUI($this->page, $cont_obj, $hier_id, $pc_id);
578  $plch_gui->setEnableInternalLinks($this->getEnableInternalLinks());
579  $plch_gui->setEnableKeywords($this->getEnableKeywords());
580  $plch_gui->setEnableAnchors($this->getEnableAnchors());
581  // scorm2004-start
582  $plch_gui->setStyleId($this->page_gui->getStyleId());
583  // scorm2004-end
584  $ret =& $this->ctrl->forwardCommand($plch_gui);
585  break;
586 
587  // Section
588  case "ilpcsectiongui":
589  $this->tabs_gui->clearTargets();
590  include_once ("./Services/COPage/classes/class.ilPCSectionGUI.php");
591  $sec_gui =& new ilPCSectionGUI($this->page, $cont_obj, $hier_id, $pc_id);
592  // scorm2004-start
593  $sec_gui->setStyleId($this->page_gui->getStyleId());
594  // scorm2004-end
595  $ret =& $this->ctrl->forwardCommand($sec_gui);
596  break;
597 
598  // Resources
599  case "ilpcresourcesgui":
600  $this->tabs_gui->clearTargets();
601  include_once ("./Services/COPage/classes/class.ilPCResourcesGUI.php");
602  $res_gui =& new ilPCResourcesGUI($this->page, $cont_obj, $hier_id, $pc_id);
603  $ret =& $this->ctrl->forwardCommand($res_gui);
604  break;
605 
606  // Map
607  case "ilpcmapgui":
608  $this->tabs_gui->clearTargets();
609  include_once ("./Services/COPage/classes/class.ilPCMapGUI.php");
610  $map_gui =& new ilPCMapGUI($this->page, $cont_obj, $hier_id, $pc_id);
611  $ret =& $this->ctrl->forwardCommand($map_gui);
612  break;
613 
614  // Tabs
615  case "ilpctabsgui":
616  $this->tabs_gui->clearTargets();
617  include_once ("./Services/COPage/classes/class.ilPCTabsGUI.php");
618  $tabs_gui =& new ilPCTabsGUI($this->page, $cont_obj, $hier_id, $pc_id);
619  $tabs_gui->setStyleId($this->page_gui->getStyleId());
620  $ret =& $this->ctrl->forwardCommand($tabs_gui);
621  break;
622 
623  // Tab
624  case "ilpctabgui":
625  $this->tabs_gui->clearTargets();
626  include_once ("./Services/COPage/classes/class.ilPCTabGUI.php");
627  $tab_gui = new ilPCTabGUI($this->page, $cont_obj, $hier_id, $pc_id);
628  //$ret =& $list_item_gui->executeCommand();
629  $ret =& $this->ctrl->forwardCommand($tab_gui);
630  break;
631 
632  // Plugged Component
633  case "ilpcpluggedgui":
634  $this->tabs_gui->clearTargets();
635  include_once ("./Services/COPage/classes/class.ilPCPluggedGUI.php");
636  $plugged_gui =& new ilPCPluggedGUI($this->page, $cont_obj, $hier_id,
637  $add_type, $pc_id);
638  $ret =& $this->ctrl->forwardCommand($plugged_gui);
639  break;
640 
641  // Content Include
642  case "ilpccontentincludegui":
643  $this->tabs_gui->clearTargets();
644  include_once ("./Services/COPage/classes/class.ilPCContentIncludeGUI.php");
645  $incl_gui = new ilPCContentIncludeGUI($this->page, $cont_obj, $hier_id, $pc_id);
646  $ret =& $this->ctrl->forwardCommand($incl_gui);
647  break;
648 
649  default:
650  if ($cmd == "pasteFromClipboard")
651  {
652  $ret = $this->pasteFromClipboard($hier_id);
653  }
654  else if ($cmd == "paste")
655  {
656  $ret = $this->paste($hier_id);
657  }
658  else
659  {
660  $ret = $this->$cmd();
661  }
662  break;
663 
664  }
665 
666  return $ret;
667  }
668 
673  function _doJSEditing()
674  {
675  global $ilUser, $ilias, $ilSetting;
676 
677  if ($ilUser->getPref("ilPageEditor_JavaScript") != "disable"
678  && $ilSetting->get("enable_js_edit", 1)
680  {
681  return true;
682  }
683  return false;
684  }
685 
690  {
691  global $ilBrowser;
692 return true;
693  $version = $ilBrowser->getVersion();
694 
695  if ($ilBrowser->isFirefox() ||
696  ($ilBrowser->isIE() && !$ilBrowser->isMac()) ||
697  ($ilBrowser->isMozilla() && $version[0] >= 5))
698  {
699  return true;
700  }
701  return false;
702  }
703 
704  function activatePage()
705  {
706  $this->page_gui->activatePage();
707  }
708 
709  function deactivatePage()
710  {
711  $this->page_gui->deactivatePage();
712  }
713 
717  function setMediaMode()
718  {
719  global $ilUser, $ilias;
720 
721  $ilUser->writePref("ilPageEditor_MediaMode", $_POST["media_mode"]);
722  $ilUser->writePref("ilPageEditor_HTMLMode", $_POST["html_mode"]);
723  if ($ilias->getSetting("enable_js_edit"))
724  {
725  if ($ilUser->getPref("ilPageEditor_JavaScript") != $_POST["js_mode"])
726  {
727  // not nice, should be solved differently in the future
728  if ($this->page->getParentType() == "lm" ||
729  $this->page->getParentType() == "dbk")
730  {
731  $this->ctrl->setParameterByClass("illmpageobjectgui", "reloadTree", "y");
732  }
733  }
734  $ilUser->writePref("ilPageEditor_JavaScript", $_POST["js_mode"]);
735  }
736 
737  // again not so nice...
738  if ($this->page->getParentType() == "lm" ||
739  $this->page->getParentType() == "dbk")
740  {
741  $this->ctrl->redirectByClass("illmpageobjectgui", "edit");
742  }
743  else
744  {
745  $this->ctrl->returnToParent($this);
746  }
747  }
748 
753  {
754  global $ilUser;
755 
756  ilUtil::sendSuccess($this->lng->txt("copied_to_clipboard"), true);
757  $ilUser->addObjectToClipboard($_POST["mob_id"], "mob", ilObject::_lookupTitle($_POST["mob_id"]));
758  $this->ctrl->returnToParent($this);
759  }
760 
765  {
766  global $ilUser;
767 
768  $this->ctrl->setParameterByClass("ilmediapooltargetselector", "mob_id", $_POST["mob_id"]);
769  $this->ctrl->redirectByClass("ilmediapooltargetselector", "listPools");
770  }
771 
775  function addChangeComment()
776  {
777  include_once("classes/class.ilHistory.php");
778  ilHistory::_createEntry($this->page->getId(), "update",
779  "", $this->page->getParentType().":pg",
780  ilUtil::stripSlashes($_POST["change_comment"]), true);
781  ilUtil::sendSuccess($this->lng->txt("cont_added_comment"), true);
782  $this->ctrl->returnToParent($this);
783  }
784 
788  function deleteSelected()
789  {
790  if (is_int(strpos($_POST["target"][0], ";")))
791  {
792  $_POST["target"] = explode(";", $_POST["target"][0]);
793  }
794  if (is_array($_POST["target"]))
795  {
796  $updated = $this->page->deleteContents($_POST["target"]);
797  if($updated !== true)
798  {
799  $_SESSION["il_pg_error"] = $updated;
800  }
801  else
802  {
803  unset($_SESSION["il_pg_error"]);
804  }
805  }
806  $this->ctrl->returnToParent($this);
807  }
808 
812  function copySelected()
813  {
814  if (is_int(strpos($_POST["target"][0], ";")))
815  {
816  $_POST["target"] = explode(";", $_POST["target"][0]);
817  }
818  if (is_array($_POST["target"]))
819  {
820  $this->page->copyContents($_POST["target"]);
821  }
822  $this->ctrl->returnToParent($this);
823  }
824 
828  function cutSelected()
829  {
830  if (is_int(strpos($_POST["target"][0], ";")))
831  {
832  $_POST["target"] = explode(";", $_POST["target"][0]);
833  }
834  if (is_array($_POST["target"]))
835  {
836  $updated = $this->page->cutContents($_POST["target"]);
837  if($updated !== true)
838  {
839  $_SESSION["il_pg_error"] = $updated;
840  }
841  else
842  {
843  unset($_SESSION["il_pg_error"]);
844  }
845  }
846  $this->ctrl->returnToParent($this);
847  }
848 
852  function paste($a_hier_id)
853  {
854  global $ilCtrl;
855  $this->page->pasteContents($a_hier_id);
856  include_once("./Modules/LearningModule/classes/class.ilEditClipboard.php");
858  $this->ctrl->returnToParent($this);
859  }
860 
864  function activateSelected()
865  {
866  if (is_int(strpos($_POST["target"][0], ";")))
867  {
868  $_POST["target"] = explode(";", $_POST["target"][0]);
869  }
870  if (is_array($_POST["target"]))
871  {
872  $updated = $this->page->switchEnableMultiple($_POST["target"]);
873  if($updated !== true)
874  {
875  $_SESSION["il_pg_error"] = $updated;
876  }
877  else
878  {
879  unset($_SESSION["il_pg_error"]);
880  }
881  }
882  $this->ctrl->returnToParent($this);
883  }
884 
889  {
890  global $tpl, $lng;
891 
892  if (is_int(strpos($_POST["target"][0], ";")))
893  {
894  $_POST["target"] = explode(";", $_POST["target"][0]);
895  }
896  if (is_array($_POST["target"]))
897  {
898  $types = array();
899 
900  // check what content element types have been selected
901  foreach ($_POST["target"] as $t)
902  {
903  $tarr = explode(":", $t);
904  $cont_obj =& $this->page->getContentObject($tarr[0], $tarr[1]);
905  if (is_object($cont_obj) && $cont_obj->getType() == "par")
906  {
907  $types["par"] = "par";
908  }
909  if (is_object($cont_obj) && $cont_obj->getType() == "sec")
910  {
911  $types["sec"] = "sec";
912  }
913  }
914 
915  if (count($types) == 0)
916  {
917  ilUtil::sendFailure($lng->txt("cont_select_par_or_section"), true);
918  $this->ctrl->returnToParent($this);
919  }
920  else
921  {
922  $this->initCharacteristicForm($_POST["target"], $types);
923  $tpl->setContent($this->form->getHTML());
924  }
925  }
926  else
927  {
928  $this->ctrl->returnToParent($this);
929  }
930  }
931 
935  function initCharacteristicForm($a_target, $a_types)
936  {
937  global $ilCtrl, $lng;
938 
939 
940  // edit form
941  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
942  $this->form = new ilPropertyFormGUI();
943  $this->form->setTitle($this->lng->txt("cont_choose_characteristic"));
944 
945  if ($a_types["par"] == "par")
946  {
947  $select_prop = new ilSelectInputGUI($this->lng->txt("cont_choose_characteristic_text"),
948  "char_par");
949  include_once("./Services/COPage/classes/class.ilPCParagraphGUI.php");
950  $options = ilPCParagraphGUI::_getCharacteristics($this->page_gui->getStyleId());
951  $select_prop->setOptions($options);
952  $this->form->addItem($select_prop);
953  }
954  if ($a_types["sec"] == "sec")
955  {
956  $select_prop = new ilSelectInputGUI($this->lng->txt("cont_choose_characteristic_section"),
957  "char_sec");
958  include_once("./Services/COPage/classes/class.ilPCSectionGUI.php");
959  $options = ilPCSectionGUI::_getCharacteristics($this->page_gui->getStyleId());
960  $select_prop->setOptions($options);
961  $this->form->addItem($select_prop);
962  }
963 
964  foreach ($a_target as $t)
965  {
966  $hidden = new ilHiddenInputGUI("target[]");
967  $hidden->setValue($t);
968  $this->form->addItem($hidden);
969  }
970 
971  $this->form->setFormAction($ilCtrl->getFormAction($this));
972  $this->form->addCommandButton("assignCharacteristic", $lng->txt("save"));
973  $this->form->addCommandButton("showPage", $lng->txt("cancel"));
974 
975  }
976 
981  {
982  $char_par = ilUtil::stripSlashes($_POST["char_par"]);
983  $char_sec = ilUtil::stripSlashes($_POST["char_sec"]);
984  if (is_array($_POST["target"]))
985  {
986  foreach ($_POST["target"] as $t)
987  {
988  $tarr = explode(":", $t);
989  $cont_obj =& $this->page->getContentObject($tarr[0], $tarr[1]);
990  if (is_object($cont_obj) && $cont_obj->getType() == "par")
991  {
992  $cont_obj->setCharacteristic($char_par);
993  }
994  if (is_object($cont_obj) && $cont_obj->getType() == "sec")
995  {
996  $cont_obj->setCharacteristic($char_sec);
997  }
998  }
999  $updated = $this->page->update();
1000  if($updated !== true)
1001  {
1002  $_SESSION["il_pg_error"] = $updated;
1003  }
1004  else
1005  {
1006  unset($_SESSION["il_pg_error"]);
1007  }
1008  }
1009  $this->ctrl->returnToParent($this);
1010  }
1011 
1015  function pasteFromClipboard($a_hier_id)
1016  {
1017  global $ilCtrl;
1018 //var_dump($a_hier_id);
1019  $ilCtrl->setParameter($this, "hier_id", $a_hier_id);
1020  $ilCtrl->setParameterByClass("ilEditClipboardGUI", "returnCommand",
1021  rawurlencode($ilCtrl->getLinkTarget($this,
1022  "insertFromClipboard", "", false, false)));
1023 //echo ":".$ilCtrl->getLinkTarget($this, "insertFromClipboard").":";
1024  $ilCtrl->redirectByClass("ilEditClipboardGUI", "getObject");
1025  }
1026 
1031  {
1032  include_once("./Services/Clipboard/classes/class.ilEditClipboardGUI.php");
1034  include_once ("./Services/COPage/classes/class.ilPCMediaObject.php");
1035  if ($ids != "")
1036  {
1037  foreach ($ids as $id2)
1038  {
1039  $id = explode(":", $id2);
1040  $type = $id[0];
1041  $id = $id[1];
1042  if ($type == "mob")
1043  {
1044  $this->content_obj = new ilPCMediaObject($this->page->getDom());
1045  $this->content_obj->readMediaObject($id);
1046  $this->content_obj->createAlias($this->page, $_GET["hier_id"]);
1047  $this->updated = $this->page->update();
1048  }
1049  if ($type == "incl")
1050  {
1051  include_once("./Services/COPage/classes/class.ilPCContentInclude.php");
1052  $this->content_obj = new ilPCContentInclude($this->page->getDom());
1053  $this->content_obj->create($this->page, $_GET["hier_id"]);
1054  $this->content_obj->setContentType("mep");
1055  $this->content_obj->setContentId($id);
1056  $this->updated = $this->page->update();
1057  }
1058  }
1059  }
1060  $this->ctrl->returnToParent($this);
1061  }
1062 
1066  function displayPage()
1067  {
1068  $this->ctrl->returnToParent($this);
1069  }
1070 
1074  function displayLocator()
1075  {
1076  if(is_object($this->locator))
1077  {
1078  $this->locator->display();
1079  }
1080  }
1081 
1085  function showSnippetInfo()
1086  {
1087  global $tpl, $lng, $ilAccess, $ilCtrl;
1088 
1089  $stpl = new ilTemplate("tpl.snippet_info.html", true, true, "Services/COPage");
1090 
1091  include_once("./Modules/MediaPool/classes/class.ilMediaPoolItem.php");
1092  $mep_pools = ilMediaPoolItem::getPoolForItemId($_POST["ci_id"]);
1093  foreach ($mep_pools as $mep_id)
1094  {
1095  $ref_ids = ilObject::_getAllReferences($mep_id);
1096  $edit_link = false;
1097  foreach ($ref_ids as $rid)
1098  {
1099  if (!$edit_link && $ilAccess->checkAccess("write", "", $rid))
1100  {
1101  $stpl->setCurrentBlock("edit_link");
1102  $stpl->setVariable("TXT_EDIT", $lng->txt("edit"));
1103  $stpl->setVariable("HREF_EDIT",
1104  "./goto.php?target=mep_".$rid);
1105  $stpl->parseCurrentBlock();
1106  }
1107  }
1108  $stpl->setCurrentBlock("pool");
1109  $stpl->setVariable("TXT_MEDIA_POOL", $lng->txt("obj_mep"));
1110  $stpl->setVariable("VAL_MEDIA_POOL", ilObject::_lookupTitle($mep_id));
1111  $stpl->parseCurrentBlock();
1112  }
1113 
1114  include_once("./Modules/MediaPool/classes/class.ilMediaPoolPage.php");
1115  $stpl->setVariable("TXT_TITLE", $lng->txt("title"));
1116  $stpl->setVariable("VAL_TITLE", ilMediaPoolPage::lookupTitle($_POST["ci_id"]));
1117  $stpl->setVariable("TXT_BACK", $lng->txt("back"));
1118  $stpl->setVariable("HREF_BACK",
1119  $ilCtrl->getLinkTargetByClass("ilpageobjectgui", "edit"));
1120  $tpl->setContent($stpl->get());
1121  }
1122 
1123 }
1124 ?>