ILIAS  release_4-3 Revision
 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 
26 {
32  var $ilias;
33  var $tpl;
34  var $lng;
35  var $ctrl;
37  var $page;
40  var $header;
41  var $tabs;
42  var $cont_obj;
45 
52  function ilPageEditorGUI(&$a_page_object, &$a_page_object_gui)
53  {
54  global $ilias, $tpl, $lng, $objDefinition, $ilCtrl,$ilTabs;
55 
56  // initiate variables
57  $this->ilias =& $ilias;
58  $this->ctrl =& $ilCtrl;
59  $this->tpl =& $tpl;
60  $this->lng =& $lng;
61  $this->objDefinition = $objDefinition;
62  $this->tabs_gui =& $ilTabs;
63  $this->page =& $a_page_object;
64  $this->page_gui =& $a_page_object_gui;
65 
66  $this->ctrl->saveParameter($this, array("hier_id", "pc_id"));
67  }
68 
69 
75  function setHeader($a_header)
76  {
77  $this->header = $a_header;
78  }
79 
85  function getHeader()
86  {
87  return $this->header;
88  }
89 
95  function setLocator(&$a_locator)
96  {
97  $this->locator =& $a_locator;
98  }
99 
103  function returnToContext()
104  {
105  $this->ctrl->returnToParent($this);
106  }
107 
108  function setIntLinkHelpDefault($a_type, $a_id)
109  {
110  $this->int_link_def_type = $a_type;
111  $this->int_link_def_id = $a_id;
112  }
113 
114  function setIntLinkReturn($a_return)
115  {
116  $this->int_link_return = $a_return;
117  }
118 
119 
120  function setPageBackTitle($a_title)
121  {
122  $this->page_back_title = $a_title;
123  }
124 
130  function setEnableInternalLinks($a_val)
131  {
132  $this->enable_internal_links = $a_val;
133  }
134 
141  {
142  return $this->enable_internal_links;
143  }
144 
150  function setEnableKeywords($a_val)
151  {
152  $this->enable_keywords = $a_val;
153  }
154 
160  function getEnableKeywords()
161  {
162  return $this->enable_keywords;
163  }
164 
170  function setEnableAnchors($a_val)
171  {
172  $this->enable_anchors = $a_val;
173  }
174 
180  function getEnableAnchors()
181  {
182  return $this->enable_anchors;
183  }
184 
188  function &executeCommand()
189  {
190  global $ilCtrl, $ilHelp;;
191 
192  $cmd = $this->ctrl->getCmd("displayPage");
193  $cmdClass = strtolower($this->ctrl->getCmdClass());
194 
195  $hier_id = $_GET["hier_id"];
196  $pc_id = $_GET["pc_id"];
197  if(isset($_POST["new_hier_id"]))
198  {
199  $hier_id = $_POST["new_hier_id"];
200  }
201 //echo "GEThier_id:".$_GET["hier_id"]."<br>";
202 //$this->ctrl->debug("hier_id:".$hier_id);
203 
204  $new_type = (isset($_GET["new_type"]))
205  ? $_GET["new_type"]
206  : $_POST["new_type"];
207 //echo "-$cmd-";
208 //var_dump($_GET); var_dump($_POST); exit;
209 /*array
210  'target' =>
211  array
212  0 => string '' (length=0)
213  'commandpg' => string 'insertJS' (length=8)
214  'cmd' =>
215  array
216  'exec_pg:' => string 'Ok' (length=2)
217  'ajaxform_content' => string '<div class=\"ilc_text_block_Standard\">sdfsdfsd sd</div>' (length=56)
218  'ajaxform_char' => string '' (length=0)*/
219 /*array
220  'usedwsiwygeditor' => string '0' (length=1)
221  'par_characteristic' => string 'Standard' (length=8)
222  'par_content' => string 'adasdaasda a
223 
224 ' (length=14)
225  'par_language' => string 'en' (length=2)
226  'cmd' =>
227  array
228  'create_par' => string 'Save' (length=4)*/
229 
230  if (substr($cmd, 0, 5) == "exec_")
231  {
232 //echo ":".key($_POST["cmd"]).":";
233  // check whether pc id is given
234  $pca = explode(":", key($_POST["cmd"]));
235  $pc_id = $pca[1];
236 //echo "<br />exec_pc_id:-$pc_id-";
237  $cmd = explode("_", $pca[0]);
238  unset($cmd[0]);
239  $hier_id = implode($cmd, "_");
240  $cmd = $_POST["command".$hier_id];
241  }
242 //echo "<br>cmd:$cmd:";exit;
243  // strip "c" "r" of table ids from hierarchical id
244  $first_hier_character = substr($hier_id, 0, 1);
245  if ($first_hier_character == "c" ||
246  $first_hier_character == "r" ||
247  $first_hier_character == "i")
248  {
249  $hier_id = substr($hier_id, 1);
250  }
251  $this->page->buildDom();
252  $this->page->addHierIDs();
253 
254  // determine command and content object
255  if ($cmdClass != "ilfilesystemgui")
256  {
257  $com = explode("_", $cmd);
258  $cmd = $com[0];
259  }
260 
261 
262  $next_class = $this->ctrl->getNextClass($this);
263 
264 
265  // determine content type
266  if ($com[0] == "insert" || $com[0] == "create")
267  {
268  $cmd = $com[0];
269  $ctype = $com[1];
270  $add_type = $com[2];
271  if ($ctype == "mob") $ctype = "media";
272  }
273  else
274  {
275  // setting cmd and cmdclass for editing of linked media
276  if ($cmd == "editLinkedMedia")
277  {
278  $this->ctrl->setCmd("edit");
279  $cmd = "edit";
280  $_GET["pgEdMediaMode"] = "editLinkedMedia";
281  $_GET["mob_id"] = $_POST["mob_id"];
282  }
283  if ($_GET["pgEdMediaMode"] == "editLinkedMedia")
284  {
285  $this->ctrl->setParameter($this, "pgEdMediaMode", "editLinkedMedia");
286  $this->ctrl->setParameter($this, "mob_id", $_GET["mob_id"]);
287  if ($cmdClass != "ilinternallinkgui" && $cmdClass != "ilmdeditorgui"
288  && $cmdClass != "ilimagemapeditorgui" && $cmdClass != "ilfilesystemgui")
289  {
290  $this->ctrl->setCmdClass("ilobjmediaobjectgui");
291  $cmdClass = "ilobjmediaobjectgui";
292  }
293  }
294 if (false)
295 {
296 var_dump($_POST);
297 var_dump($_GET);
298 echo ";$cmd;".$next_class.";";
299 echo "-$pc_id-";
300 echo "-$cmd-".$this->ctrl->getCmd()."-";
301 }
302 
303 //var_dump($_POST);
304  // note: ilinternallinkgui for page: no cont_obj is received
305  // ilinternallinkgui for mob: cont_obj is received
306  if ($cmd != "insertFromClipboard" && $cmd != "pasteFromClipboard" &&
307  $cmd != "setMediaMode" && $cmd != "copyLinkedMediaToClipboard" &&
308  $cmd != "activatePage" && $cmd != "deactivatePage" &&
309  $cmd != "copyLinkedMediaToMediaPool" && $cmd != "showSnippetInfo" &&
310  $cmd != "deleteSelected" && $cmd != "paste" &&
311  $cmd != "copySelected" && $cmd != "cutSelected" &&
312  ($cmd != "displayPage" || $_POST["editImagemapForward_x"] != "" || $_POST["imagemap_x"] != "") &&
313  ($cmd != "displayPage" || $_POST["editImagemapForward_x"] != "") &&
314  $cmd != "activateSelected" && $cmd != "assignCharacteristicForm" &&
315  $cmd != "assignCharacteristic" &&
316  $cmd != "cancelCreate" && $cmd != "popup" &&
317  $cmdClass != "ileditclipboardgui" && $cmd != "addChangeComment" &&
318  ($cmdClass != "ilinternallinkgui" || ($next_class == "ilpcmediaobjectgui")))
319  {
320  if ($_GET["pgEdMediaMode"] != "editLinkedMedia")
321  {
322 //$this->ctrl->debug("gettingContentObject (no linked media)");
323 //echo $hier_id."-".$pc_id;
324  $cont_obj =& $this->page->getContentObject($hier_id, $pc_id);
325  if (!is_object($cont_obj))
326  {
327  $ilCtrl->returnToParent($this);
328  }
329  $ctype = $cont_obj->getType();
330  }
331  }
332  }
333 //$this->ctrl->debug("+ctype:".$ctype."+");
334 // $this->tpl->addBlockFile("CONTENT", "content", "tpl.adm_content.html");
335 // $this->tpl->addBlockFile("STATUSLINE", "statusline", "tpl.statusline.html");
336 
337  if ($ctype != "media" || !is_object ($cont_obj))
338  {
339  if ($this->getHeader() != "")
340  {
341  $this->tpl->setTitle($this->getHeader());
342  }
343  $this->displayLocator();
344  }
345 
346  $this->cont_obj =& $cont_obj;
347 
348 
349  // special command / command class handling
350  $this->ctrl->setParameter($this, "hier_id", $hier_id);
351  $this->ctrl->setParameter($this, "pc_id", $pc_id);
352  $this->ctrl->setCmd($cmd);
353  //$next_class = $this->ctrl->getNextClass($this);
354 //$this->ctrl->debug("+next_class:".$next_class."+");
355 //echo("+next_class:".$next_class."+".$ctype."+"); exit;
356 
357  if ($next_class == "")
358  {
359  switch($ctype)
360  {
361  case "src":
362  $this->ctrl->setCmdClass("ilPCSourcecodeGUI");
363  break;
364 
365  case "par":
366  $this->ctrl->setCmdClass("ilPCParagraphGUI");
367  break;
368 
369  // advanced table
370  case "tab":
371  $this->ctrl->setCmdClass("ilPCTableGUI");
372  break;
373 
374  // data table
375  case "dtab":
376  $this->ctrl->setCmdClass("ilPCDataTableGUI");
377  break;
378 
379  case "td":
380  $this->ctrl->setCmdClass("ilPCTableDataGUI");
381  break;
382 
383  case "media":
384  $this->ctrl->setCmdClass("ilPCMediaObjectGUI");
385  break;
386 
387  case "list":
388  $this->ctrl->setCmdClass("ilPCListGUI");
389  break;
390 
391  case "li":
392  $this->ctrl->setCmdClass("ilPCListItemGUI");
393  break;
394 
395  case "flst":
396  $this->ctrl->setCmdClass("ilPCFileListGUI");
397  break;
398 
399  case "flit":
400  $this->ctrl->setCmdClass("ilPCFileItemGUI");
401  break;
402 
403  case "pcqst":
404  $this->ctrl->setCmdClass("ilPCQuestionGUI");
405  break;
406 
407  case "sec":
408  $this->ctrl->setCmdClass("ilPCSectionGUI");
409  break;
410 
411  case "repobj":
412  $this->ctrl->setCmdClass("ilPCResourcesGUI");
413  break;
414 
415  case 'lpe':
416  $this->ctrl->setCmdClass('ilPCLoginPageElementGUI');
417  break;
418 
419  case "map":
420  $this->ctrl->setCmdClass("ilPCMapGUI");
421  break;
422 
423  case "tabs":
424  $this->ctrl->setCmdClass("ilPCTabsGUI");
425  break;
426 
427  case "plug":
428  $this->ctrl->setCmdClass("ilPCPluggedGUI");
429  break;
430 
431  case "plach":
432  $this->ctrl->setCmdClass("ilPCPlaceHolderGUI");
433  break;
434 
435  case "incl":
436  $this->ctrl->setCmdClass("ilPCContentIncludeGUI");
437  break;
438 
439  case "iim":
440  $this->ctrl->setCmdClass("ilPCInteractiveImageGUI");
441  break;
442 
443  case "prof":
444  $this->ctrl->setCmdClass("ilPCProfileGUI");
445  break;
446 
447  case "vrfc":
448  $this->ctrl->setCmdClass("ilPCVerificationGUI");
449  break;
450 
451  case "blog":
452  $this->ctrl->setCmdClass("ilPCBlogGUI");
453  break;
454 
455  case "qover":
456  $this->ctrl->setCmdClass("ilPCQuestionOverviewGUI");
457  break;
458 
459  case "skills":
460  $this->ctrl->setCmdClass("ilPCSkillsGUI");
461  break;
462 
463  }
464  $next_class = $this->ctrl->getNextClass($this);
465  }
466 
467  // do not do this while imagemap editing is ongoing
468  if ($cmd == "displayPage" && $_POST["editImagemapForward_x"] == "" && $_POST["imagemap_x"] == "")
469  {
470  $next_class = "";
471  }
472 
473 //echo "hier_id:$hier_id:type:$type:cmd:$cmd:ctype:$ctype:next_class:$next_class:<br>"; exit;
474  switch($next_class)
475  {
476  case "ilinternallinkgui":
477  $link_gui = new ilInternalLinkGUI(
478  $this->int_link_def_type, $this->int_link_def_id);
479  $link_gui->setMode("normal");
480  $link_gui->setFilterWhiteList(
481  $this->page_gui->getPageConfig()->getIntLinkFilterWhiteList());
482  foreach ($this->page_gui->getPageConfig()->getIntLinkFilters() as $filter)
483  {
484  $link_gui->filterLinkType($filter);
485  }
486 // $link_gui->setSetLinkTargetScript(
487 // $this->ctrl->getLinkTarget($this, "setInternalLink"));
488  $link_gui->setReturn($this->int_link_return);
489  if ($ilCtrl->isAsynch())
490  {
491  $link_gui->setMode("asynch");
492  }
493 
494  $ret =& $this->ctrl->forwardCommand($link_gui);
495  break;
496 
497  // Sourcecode
498  case "ilpcsourcecodegui":
499  $this->tabs_gui->clearTargets();
500  $ilHelp->setScreenIdComponent("copg_code");
501  include_once ("./Services/COPage/classes/class.ilPCSourcecodeGUI.php");
502  $src_gui =& new ilPCSourcecodeGUI($this->page, $cont_obj, $hier_id, $pc_id);
503  $ret =& $this->ctrl->forwardCommand($src_gui);
504  break;
505 
506  // Paragraph
507  case "ilpcparagraphgui":
508  $this->tabs_gui->clearTargets();
509  $ilHelp->setScreenIdComponent("copg_par");
510  include_once ("./Services/COPage/classes/class.ilPCParagraphGUI.php");
511  $par_gui =& new ilPCParagraphGUI($this->page, $cont_obj, $hier_id, $pc_id);
512  $par_gui->setEnableWikiLinks($this->page_gui->getEnabledWikiLinks());
513  $par_gui->setStyleId($this->page_gui->getStyleId());
514  $par_gui->setEnableInternalLinks($this->getEnableInternalLinks());
515  $par_gui->setEnableKeywords($this->getEnableKeywords());
516  $par_gui->setEnableAnchors($this->getEnableAnchors());
517  $ret =& $this->ctrl->forwardCommand($par_gui);
518  break;
519 
520  // Table
521  case "ilpctablegui":
522  $this->tabs_gui->clearTargets();
523  $ilHelp->setScreenIdComponent("copg_tab");
524  include_once ("./Services/COPage/classes/class.ilPCTableGUI.php");
525  $tab_gui =& new ilPCTableGUI($this->page, $cont_obj, $hier_id, $pc_id);
526  $tab_gui->setStyleId($this->page_gui->getStyleId());
527  $ret =& $this->ctrl->forwardCommand($tab_gui);
528  break;
529 
530  // Table Cell
531  case "ilpctabledatagui":
532  $this->tabs_gui->clearTargets();
533  $ilHelp->setScreenIdComponent("copg_td");
534  include_once ("./Services/COPage/classes/class.ilPCTableDataGUI.php");
535  $td_gui =& new ilPCTableDataGUI($this->page, $cont_obj, $hier_id, $pc_id);
536  $ret =& $this->ctrl->forwardCommand($td_gui);
537  break;
538 
539  // Data Table
540  case "ilpcdatatablegui":
541  $this->tabs_gui->clearTargets();
542  $ilHelp->setScreenIdComponent("copg_dtab");
543  include_once ("./Services/COPage/classes/class.ilPCDataTableGUI.php");
544  $tab_gui =& new ilPCDataTableGUI($this->page, $cont_obj, $hier_id, $pc_id);
545  $tab_gui->setStyleId($this->page_gui->getStyleId());
546  $tab_gui->setEnableInternalLinks($this->getEnableInternalLinks());
547  $tab_gui->setEnableKeywords($this->getEnableKeywords());
548  $tab_gui->setEnableAnchors($this->getEnableAnchors());
549  $ret =& $this->ctrl->forwardCommand($tab_gui);
550  break;
551 
552  // PC Media Object
553  case "ilpcmediaobjectgui":
554  include_once ("./Services/COPage/classes/class.ilPCMediaObjectGUI.php");
555 
556  $this->tabs_gui->clearTargets();
557  $this->tabs_gui->setBackTarget($this->page_gui->page_back_title,
558  $ilCtrl->getLinkTarget($this->page_gui, "edit"));
559  $pcmob_gui =& new ilPCMediaObjectGUI($this->page, $cont_obj, $hier_id, $pc_id);
560  $pcmob_gui->setStyleId($this->page_gui->getStyleId());
561  $pcmob_gui->setEnabledMapAreas($this->page_gui->getEnabledInternalLinks());
562  $ret =& $this->ctrl->forwardCommand($pcmob_gui);
563  $ilHelp->setScreenIdComponent("copg_media");
564  break;
565 
566  // only for "linked" media
567  case "ilobjmediaobjectgui":
568  $this->tabs_gui->clearTargets();
569  $this->tabs_gui->setBackTarget($this->lng->txt("back"),
570  $ilCtrl->getParentReturn($this));
571  $mob_gui =& new ilObjMediaObjectGUI("", $_GET["mob_id"],false, false);
572  $mob_gui->getTabs($this->tabs_gui);
573  $mob_gui->setEnabledMapAreas($this->page_gui->getEnabledInternalLinks());
574  $this->tpl->setTitle($this->lng->txt("mob").": ".
575  ilObject::_lookupTitle($_GET["mob_id"]));
576  $ret =& $this->ctrl->forwardCommand($mob_gui);
577  break;
578 
579  // List
580  case "ilpclistgui":
581  $this->tabs_gui->clearTargets();
582  $ilHelp->setScreenIdComponent("copg_list");
583  include_once ("./Services/COPage/classes/class.ilPCListGUI.php");
584  $list_gui =& new ilPCListGUI($this->page, $cont_obj, $hier_id, $pc_id);
585  $list_gui->setStyleId($this->page_gui->getStyleId());
586  $ret =& $this->ctrl->forwardCommand($list_gui);
587  break;
588 
589  // List Item
590  case "ilpclistitemgui":
591  $this->tabs_gui->clearTargets();
592  $ilHelp->setScreenIdComponent("copg_li");
593  include_once ("./Services/COPage/classes/class.ilPCListItemGUI.php");
594  $list_item_gui =& new ilPCListItemGUI($this->page, $cont_obj, $hier_id, $pc_id);
595  //$ret =& $list_item_gui->executeCommand();
596  $ret =& $this->ctrl->forwardCommand($list_item_gui);
597  break;
598 
599  // File List
600  case "ilpcfilelistgui":
601  $this->tabs_gui->clearTargets();
602  $ilHelp->setScreenIdComponent("copg_flst");
603  include_once ("./Services/COPage/classes/class.ilPCFileListGUI.php");
604  $file_list_gui =& new ilPCFileListGUI($this->page, $cont_obj, $hier_id, $pc_id);
605  // scorm2004-start
606  $file_list_gui->setStyleId($this->page_gui->getStyleId());
607  // scorm2004-end
608  //$ret =& $file_list_gui->executeCommand();
609  $ret =& $this->ctrl->forwardCommand($file_list_gui);
610  break;
611 
612  // File List Item
613  case "ilpcfileitemgui":
614  $this->tabs_gui->clearTargets();
615  $ilHelp->setScreenIdComponent("copg_flit");
616  include_once ("./Services/COPage/classes/class.ilPCFileItemGUI.php");
617  $file_item_gui =& new ilPCFileItemGUI($this->page, $cont_obj, $hier_id, $pc_id);
618  //$ret =& $file_item_gui->executeCommand();
619  $ret =& $this->ctrl->forwardCommand($file_item_gui);
620  break;
621 
622  // Question
623  case "ilpcquestiongui":
624  include_once("./Services/COPage/classes/class.ilPCQuestionGUI.php");
625  $pc_question_gui =& new ilPCQuestionGUI($this->page, $cont_obj, $hier_id, $pc_id);
626  $pc_question_gui->setSelfAssessmentMode($this->page_gui->getEnabledSelfAssessment());
627  $pc_question_gui->setPageConfig($this->page_gui->getPageConfig());
628 
629  if ($this->page_gui->getEnabledSelfAssessment())
630  {
631  $this->tabs_gui->clearTargets();
632  $ilHelp->setScreenIdComponent("copg_pcqst");
633  $this->tabs_gui->setBackTarget($this->lng->txt("back"),
634  $ilCtrl->getParentReturn($this));
635  $ret = $this->ctrl->forwardCommand($pc_question_gui);
636  }
637  else
638  {
639  $cmd = $this->ctrl->getCmd();
640  $pc_question_gui->$cmd();
641  $this->ctrl->redirectByClass(array("ilobjquestionpoolgui", get_class($cont_obj)), "editQuestion");
642  }
643  break;
644 
645 
646  // PlaceHolder
647  case "ilpcplaceholdergui":
648  $this->tabs_gui->clearTargets();
649  $this->tabs_gui->setBackTarget($this->page_gui->page_back_title,
650  $ilCtrl->getLinkTarget($this->page_gui, "edit"));
651  $ilHelp->setScreenIdComponent("copg_plach");
652  include_once ("./Services/COPage/classes/class.ilPCPlaceHolderGUI.php");
653  $plch_gui =& new ilPCPlaceHolderGUI($this->page, $cont_obj, $hier_id, $pc_id);
654  $plch_gui->setEnableInternalLinks($this->getEnableInternalLinks());
655  $plch_gui->setEnableKeywords($this->getEnableKeywords());
656  $plch_gui->setEnableAnchors($this->getEnableAnchors());
657  $plch_gui->setStyleId($this->page_gui->getStyleId());
658  $ret =& $this->ctrl->forwardCommand($plch_gui);
659  break;
660 
661  // Section
662  case "ilpcsectiongui":
663  $this->tabs_gui->clearTargets();
664  $ilHelp->setScreenIdComponent("copg_sec");
665  include_once ("./Services/COPage/classes/class.ilPCSectionGUI.php");
666  $sec_gui =& new ilPCSectionGUI($this->page, $cont_obj, $hier_id, $pc_id);
667  $sec_gui->setStyleId($this->page_gui->getStyleId());
668  $ret =& $this->ctrl->forwardCommand($sec_gui);
669  break;
670 
671  // Resources
672  case "ilpcresourcesgui":
673  $this->tabs_gui->clearTargets();
674  $ilHelp->setScreenIdComponent("copg_repobj");
675  include_once ("./Services/COPage/classes/class.ilPCResourcesGUI.php");
676  $res_gui =& new ilPCResourcesGUI($this->page, $cont_obj, $hier_id, $pc_id);
677  $ret =& $this->ctrl->forwardCommand($res_gui);
678  break;
679 
680  // Login Page elements
681  case 'ilpcloginpageelementgui':
682  $this->tabs_gui->clearTargets();
683  $ilHelp->setScreenIdComponent("copg_lpe");
684  include_once './Services/COPage/classes/class.ilPCLoginPageElementGUI.php';
685  $res_gui = new ilPCLoginPageElementGUI($this->page,$cont_obj,$hier_id,$pc_id);
686  $ret = $this->ctrl->forwardCommand($res_gui);
687  break;
688 
689  // Map
690  case "ilpcmapgui":
691  $this->tabs_gui->clearTargets();
692  $ilHelp->setScreenIdComponent("copg_map");
693  include_once ("./Services/COPage/classes/class.ilPCMapGUI.php");
694  $map_gui =& new ilPCMapGUI($this->page, $cont_obj, $hier_id, $pc_id);
695  $ret =& $this->ctrl->forwardCommand($map_gui);
696  break;
697 
698  // Tabs
699  case "ilpctabsgui":
700  $this->tabs_gui->clearTargets();
701  $ilHelp->setScreenIdComponent("copg_tabs");
702  include_once ("./Services/COPage/classes/class.ilPCTabsGUI.php");
703  $tabs_gui =& new ilPCTabsGUI($this->page, $cont_obj, $hier_id, $pc_id);
704  $tabs_gui->setStyleId($this->page_gui->getStyleId());
705  $ret =& $this->ctrl->forwardCommand($tabs_gui);
706  break;
707 
708  // Plugged Component
709  case "ilpcpluggedgui":
710  $this->tabs_gui->clearTargets();
711  include_once ("./Services/COPage/classes/class.ilPCPluggedGUI.php");
712  $plugged_gui =& new ilPCPluggedGUI($this->page, $cont_obj, $hier_id,
713  $add_type, $pc_id);
714  $ret =& $this->ctrl->forwardCommand($plugged_gui);
715  break;
716 
717  // Content Include
718  case "ilpccontentincludegui":
719  $this->tabs_gui->clearTargets();
720  $ilHelp->setScreenIdComponent("copg_incl");
721  include_once ("./Services/COPage/classes/class.ilPCContentIncludeGUI.php");
722  $incl_gui = new ilPCContentIncludeGUI($this->page, $cont_obj, $hier_id, $pc_id);
723  $ret =& $this->ctrl->forwardCommand($incl_gui);
724  break;
725 
726  // Interactive Image
727  case "ilpcinteractiveimagegui":
728  $this->tabs_gui->clearTargets();
729  $ilHelp->setScreenIdComponent("copg_iim");
730  include_once ("./Services/COPage/classes/class.ilPCInteractiveImageGUI.php");
731  $iim_gui = new ilPCInteractiveImageGUI($this->page, $cont_obj, $hier_id, $pc_id);
732  $ret = $this->ctrl->forwardCommand($iim_gui);
733  break;
734 
735  // Profile
736  case "ilpcprofilegui":
737  $this->tabs_gui->clearTargets();
738  $ilHelp->setScreenIdComponent("copg_prof");
739  include_once ("./Services/COPage/classes/class.ilPCProfileGUI.php");
740  $prof_gui = new ilPCProfileGUI($this->page, $cont_obj, $hier_id, $pc_id);
741  $ret = $this->ctrl->forwardCommand($prof_gui);
742  break;
743 
744  // Verification
745  case "ilpcverificationgui":
746  $this->tabs_gui->clearTargets();
747  $ilHelp->setScreenIdComponent("copg_vrfc");
748  include_once ("./Services/COPage/classes/class.ilPCVerificationGUI.php");
749  $vrfc_gui = new ilPCVerificationGUI($this->page, $cont_obj, $hier_id, $pc_id);
750  $ret = $this->ctrl->forwardCommand($vrfc_gui);
751  break;
752 
753  // Blog
754  case "ilpcbloggui":
755  $this->tabs_gui->clearTargets();
756  $ilHelp->setScreenIdComponent("copg_blog");
757  include_once ("./Services/COPage/classes/class.ilPCBlogGUI.php");
758  $blog_gui = new ilPCBlogGUI($this->page, $cont_obj, $hier_id, $pc_id);
759  $ret = $this->ctrl->forwardCommand($blog_gui);
760  break;
761 
762  // Question Overview
763  case "ilpcquestionoverviewgui":
764  $this->tabs_gui->clearTargets();
765  $ilHelp->setScreenIdComponent("copg_qover");
766  include_once ("./Services/COPage/classes/class.ilPCQuestionOverviewGUI.php");
767  $qover_gui =& new ilPCQuestionOverviewGUI($this->page, $cont_obj, $hier_id, $pc_id);
768  $ret = $this->ctrl->forwardCommand($qover_gui);
769  break;
770 
771  // Skills
772  case "ilpcskillsgui":
773  $this->tabs_gui->clearTargets();
774  $ilHelp->setScreenIdComponent("copg_skills");
775  include_once ("./Services/COPage/classes/class.ilPCSkillsGUI.php");
776  $skills_gui = new ilPCSkillsGUI($this->page, $cont_obj, $hier_id, $pc_id);
777  $ret = $this->ctrl->forwardCommand($skills_gui);
778  break;
779 
780  default:
781  if ($cmd == "pasteFromClipboard")
782  {
783  $ret = $this->pasteFromClipboard($hier_id);
784  }
785  else if ($cmd == "paste")
786  {
787  $ret = $this->paste($hier_id);
788  }
789  else
790  {
791  $ret = $this->$cmd();
792  }
793  break;
794 
795  }
796 
797  return $ret;
798  }
799 
804  function _doJSEditing()
805  {
806  global $ilUser, $ilias, $ilSetting;
807 
808  if ($ilUser->getPref("ilPageEditor_JavaScript") != "disable"
810  {
811  return true;
812  }
813  return false;
814  }
815 
820  {
821  global $ilBrowser;
822 return true;
823  $version = $ilBrowser->getVersion();
824 
825  if ($ilBrowser->isFirefox() ||
826  ($ilBrowser->isIE() && !$ilBrowser->isMac()) ||
827  ($ilBrowser->isMozilla() && $version[0] >= 5))
828  {
829  return true;
830  }
831  return false;
832  }
833 
834  function activatePage()
835  {
836  $this->page_gui->activatePage();
837  }
838 
839  function deactivatePage()
840  {
841  $this->page_gui->deactivatePage();
842  }
843 
847  function setMediaMode()
848  {
849  global $ilUser, $ilias;
850 
851  $ilUser->writePref("ilPageEditor_MediaMode", $_POST["media_mode"]);
852  $ilUser->writePref("ilPageEditor_HTMLMode", $_POST["html_mode"]);
853  if ($ilUser->getPref("ilPageEditor_JavaScript") != $_POST["js_mode"])
854  {
855  // not nice, should be solved differently in the future
856  if ($this->page->getParentType() == "lm" ||
857  $this->page->getParentType() == "dbk")
858  {
859  $this->ctrl->setParameterByClass("illmpageobjectgui", "reloadTree", "y");
860  }
861  }
862  $ilUser->writePref("ilPageEditor_JavaScript", $_POST["js_mode"]);
863 
864  // again not so nice...
865  if ($this->page->getParentType() == "lm" ||
866  $this->page->getParentType() == "dbk")
867  {
868  $this->ctrl->redirectByClass("illmpageobjectgui", "edit");
869  }
870  else
871  {
872  $this->ctrl->returnToParent($this);
873  }
874  }
875 
880  {
881  global $ilUser;
882 
883  ilUtil::sendSuccess($this->lng->txt("copied_to_clipboard"), true);
884  $ilUser->addObjectToClipboard($_POST["mob_id"], "mob", ilObject::_lookupTitle($_POST["mob_id"]));
885  $this->ctrl->returnToParent($this);
886  }
887 
892  {
893  global $ilUser;
894 
895  $this->ctrl->setParameterByClass("ilmediapooltargetselector", "mob_id", $_POST["mob_id"]);
896  $this->ctrl->redirectByClass("ilmediapooltargetselector", "listPools");
897  }
898 
902  function addChangeComment()
903  {
904  include_once("./Services/History/classes/class.ilHistory.php");
905  ilHistory::_createEntry($this->page->getId(), "update",
906  "", $this->page->getParentType().":pg",
907  ilUtil::stripSlashes($_POST["change_comment"]), true);
908  ilUtil::sendSuccess($this->lng->txt("cont_added_comment"), true);
909  $this->ctrl->returnToParent($this);
910  }
911 
915  function deleteSelected()
916  {
917  if (is_int(strpos($_POST["target"][0], ";")))
918  {
919  $_POST["target"] = explode(";", $_POST["target"][0]);
920  }
921  if (is_array($_POST["target"]))
922  {
923  $updated = $this->page->deleteContents($_POST["target"], true,
924  $this->page_gui->getEnabledSelfAssessment());
925  if($updated !== true)
926  {
927  $_SESSION["il_pg_error"] = $updated;
928  }
929  else
930  {
931  unset($_SESSION["il_pg_error"]);
932  }
933  }
934  $this->ctrl->returnToParent($this);
935  }
936 
940  function copySelected()
941  {
942  global $lng;
943 
944  if (is_int(strpos($_POST["target"][0], ";")))
945  {
946  $_POST["target"] = explode(";", $_POST["target"][0]);
947  }
948  if (is_array($_POST["target"]))
949  {
950  $this->page->copyContents($_POST["target"]);
951  ilUtil::sendSuccess($lng->txt("cont_sel_el_copied_use_paste"), true);
952  }
953  $this->ctrl->returnToParent($this);
954  }
955 
959  function cutSelected()
960  {
961  global $lng;
962 
963  if (is_int(strpos($_POST["target"][0], ";")))
964  {
965  $_POST["target"] = explode(";", $_POST["target"][0]);
966  }
967  if (is_array($_POST["target"]))
968  {
969  $updated = $this->page->cutContents($_POST["target"]);
970  if($updated !== true)
971  {
972  $_SESSION["il_pg_error"] = $updated;
973  }
974  else
975  {
976  unset($_SESSION["il_pg_error"]);
977  }
978  ilUtil::sendSuccess($lng->txt("cont_sel_el_cut_use_paste"), true);
979  }
980  $this->ctrl->returnToParent($this);
981  }
982 
986  function paste($a_hier_id)
987  {
988  global $ilCtrl;
989  $this->page->pasteContents($a_hier_id, $this->page_gui->getEnabledSelfAssessment());
990  include_once("./Modules/LearningModule/classes/class.ilEditClipboard.php");
992  $this->ctrl->returnToParent($this);
993  }
994 
998  function activateSelected()
999  {
1000  if (is_int(strpos($_POST["target"][0], ";")))
1001  {
1002  $_POST["target"] = explode(";", $_POST["target"][0]);
1003  }
1004  if (is_array($_POST["target"]))
1005  {
1006  $updated = $this->page->switchEnableMultiple($_POST["target"], true,
1007  $this->page_gui->getEnabledSelfAssessment());
1008  if($updated !== true)
1009  {
1010  $_SESSION["il_pg_error"] = $updated;
1011  }
1012  else
1013  {
1014  unset($_SESSION["il_pg_error"]);
1015  }
1016  }
1017  $this->ctrl->returnToParent($this);
1018  }
1019 
1024  {
1025  global $tpl, $lng;
1026 
1027  if (is_int(strpos($_POST["target"][0], ";")))
1028  {
1029  $_POST["target"] = explode(";", $_POST["target"][0]);
1030  }
1031  if (is_array($_POST["target"]))
1032  {
1033  $types = array();
1034 
1035  // check what content element types have been selected
1036  foreach ($_POST["target"] as $t)
1037  {
1038  $tarr = explode(":", $t);
1039  $cont_obj =& $this->page->getContentObject($tarr[0], $tarr[1]);
1040  if (is_object($cont_obj) && $cont_obj->getType() == "par")
1041  {
1042  $types["par"] = "par";
1043  }
1044  if (is_object($cont_obj) && $cont_obj->getType() == "sec")
1045  {
1046  $types["sec"] = "sec";
1047  }
1048  }
1049 
1050  if (count($types) == 0)
1051  {
1052  ilUtil::sendFailure($lng->txt("cont_select_par_or_section"), true);
1053  $this->ctrl->returnToParent($this);
1054  }
1055  else
1056  {
1057  $this->initCharacteristicForm($_POST["target"], $types);
1058  $tpl->setContent($this->form->getHTML());
1059  }
1060  }
1061  else
1062  {
1063  $this->ctrl->returnToParent($this);
1064  }
1065  }
1066 
1070  function initCharacteristicForm($a_target, $a_types)
1071  {
1072  global $ilCtrl, $lng;
1073 
1074 
1075  // edit form
1076  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
1077  $this->form = new ilPropertyFormGUI();
1078  $this->form->setTitle($this->lng->txt("cont_choose_characteristic"));
1079 
1080  if ($a_types["par"] == "par")
1081  {
1082  $select_prop = new ilSelectInputGUI($this->lng->txt("cont_choose_characteristic_text"),
1083  "char_par");
1084  include_once("./Services/COPage/classes/class.ilPCParagraphGUI.php");
1085  $options = ilPCParagraphGUI::_getCharacteristics($this->page_gui->getStyleId());
1086  $select_prop->setOptions($options);
1087  $this->form->addItem($select_prop);
1088  }
1089  if ($a_types["sec"] == "sec")
1090  {
1091  $select_prop = new ilSelectInputGUI($this->lng->txt("cont_choose_characteristic_section"),
1092  "char_sec");
1093  include_once("./Services/COPage/classes/class.ilPCSectionGUI.php");
1094  $options = ilPCSectionGUI::_getCharacteristics($this->page_gui->getStyleId());
1095  $select_prop->setOptions($options);
1096  $this->form->addItem($select_prop);
1097  }
1098 
1099  foreach ($a_target as $t)
1100  {
1101  $hidden = new ilHiddenInputGUI("target[]");
1102  $hidden->setValue($t);
1103  $this->form->addItem($hidden);
1104  }
1105 
1106  $this->form->setFormAction($ilCtrl->getFormAction($this));
1107  $this->form->addCommandButton("assignCharacteristic", $lng->txt("save"));
1108  $this->form->addCommandButton("showPage", $lng->txt("cancel"));
1109 
1110  }
1111 
1116  {
1117  $char_par = ilUtil::stripSlashes($_POST["char_par"]);
1118  $char_sec = ilUtil::stripSlashes($_POST["char_sec"]);
1119  if (is_array($_POST["target"]))
1120  {
1121  foreach ($_POST["target"] as $t)
1122  {
1123  $tarr = explode(":", $t);
1124  $cont_obj =& $this->page->getContentObject($tarr[0], $tarr[1]);
1125  if (is_object($cont_obj) && $cont_obj->getType() == "par")
1126  {
1127  $cont_obj->setCharacteristic($char_par);
1128  }
1129  if (is_object($cont_obj) && $cont_obj->getType() == "sec")
1130  {
1131  $cont_obj->setCharacteristic($char_sec);
1132  }
1133  }
1134  $updated = $this->page->update();
1135  if($updated !== true)
1136  {
1137  $_SESSION["il_pg_error"] = $updated;
1138  }
1139  else
1140  {
1141  unset($_SESSION["il_pg_error"]);
1142  }
1143  }
1144  $this->ctrl->returnToParent($this);
1145  }
1146 
1150  function pasteFromClipboard($a_hier_id)
1151  {
1152  global $ilCtrl;
1153 //var_dump($a_hier_id);
1154  $ilCtrl->setParameter($this, "hier_id", $a_hier_id);
1155  $ilCtrl->setParameterByClass("ilEditClipboardGUI", "returnCommand",
1156  rawurlencode($ilCtrl->getLinkTarget($this,
1157  "insertFromClipboard", "", false, false)));
1158 //echo ":".$ilCtrl->getLinkTarget($this, "insertFromClipboard").":";
1159  $ilCtrl->redirectByClass("ilEditClipboardGUI", "getObject");
1160  }
1161 
1166  {
1167  include_once("./Services/Clipboard/classes/class.ilEditClipboardGUI.php");
1169  include_once ("./Services/COPage/classes/class.ilPCMediaObject.php");
1170  if ($ids != "")
1171  {
1172  foreach ($ids as $id2)
1173  {
1174  $id = explode(":", $id2);
1175  $type = $id[0];
1176  $id = $id[1];
1177  if ($type == "mob")
1178  {
1179  $this->content_obj = new ilPCMediaObject($this->page->getDom());
1180  $this->content_obj->readMediaObject($id);
1181  $this->content_obj->createAlias($this->page, $_GET["hier_id"]);
1182  $this->updated = $this->page->update();
1183  }
1184  if ($type == "incl")
1185  {
1186  include_once("./Services/COPage/classes/class.ilPCContentInclude.php");
1187  $this->content_obj = new ilPCContentInclude($this->page->getDom());
1188  $this->content_obj->create($this->page, $_GET["hier_id"]);
1189  $this->content_obj->setContentType("mep");
1190  $this->content_obj->setContentId($id);
1191  $this->updated = $this->page->update();
1192  }
1193  }
1194  }
1195  $this->ctrl->returnToParent($this);
1196  }
1197 
1201  function displayPage()
1202  {
1203  $this->ctrl->returnToParent($this);
1204  }
1205 
1209  function displayLocator()
1210  {
1211  if(is_object($this->locator))
1212  {
1213  $this->locator->display();
1214  }
1215  }
1216 
1220  function showSnippetInfo()
1221  {
1222  global $tpl, $lng, $ilAccess, $ilCtrl;
1223 
1224  $stpl = new ilTemplate("tpl.snippet_info.html", true, true, "Services/COPage");
1225 
1226  include_once("./Modules/MediaPool/classes/class.ilMediaPoolItem.php");
1227  $mep_pools = ilMediaPoolItem::getPoolForItemId($_POST["ci_id"]);
1228  foreach ($mep_pools as $mep_id)
1229  {
1230  $ref_ids = ilObject::_getAllReferences($mep_id);
1231  $edit_link = false;
1232  foreach ($ref_ids as $rid)
1233  {
1234  if (!$edit_link && $ilAccess->checkAccess("write", "", $rid))
1235  {
1236  $stpl->setCurrentBlock("edit_link");
1237  $stpl->setVariable("TXT_EDIT", $lng->txt("edit"));
1238  $stpl->setVariable("HREF_EDIT",
1239  "./goto.php?target=mep_".$rid);
1240  $stpl->parseCurrentBlock();
1241  }
1242  }
1243  $stpl->setCurrentBlock("pool");
1244  $stpl->setVariable("TXT_MEDIA_POOL", $lng->txt("obj_mep"));
1245  $stpl->setVariable("VAL_MEDIA_POOL", ilObject::_lookupTitle($mep_id));
1246  $stpl->parseCurrentBlock();
1247  }
1248 
1249  include_once("./Modules/MediaPool/classes/class.ilMediaPoolPage.php");
1250  $stpl->setVariable("TXT_TITLE", $lng->txt("title"));
1251  $stpl->setVariable("VAL_TITLE", ilMediaPoolPage::lookupTitle($_POST["ci_id"]));
1252  $stpl->setVariable("TXT_BACK", $lng->txt("back"));
1253  $stpl->setVariable("HREF_BACK",
1254  $ilCtrl->getLinkTargetByClass("ilpageobjectgui", "edit"));
1255  $tpl->setContent($stpl->get());
1256  }
1257 
1258 }
1259 ?>