ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilPageObjectGUI.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 define ("IL_PAGE_PRESENTATION", "presentation");
5 define ("IL_PAGE_EDIT", "edit");
6 define ("IL_PAGE_PREVIEW", "preview");
7 define ("IL_PAGE_OFFLINE", "offline");
8 define ("IL_PAGE_PRINT", "print");
9 
10 include_once ("./Services/COPage/classes/class.ilPageEditorGUI.php");
11 include_once("./Services/COPage/classes/class.ilPageObject.php");
12 include_once("./Services/Clipboard/classes/class.ilEditClipboardGUI.php");
13 include_once("./Services/Utilities/classes/class.ilDOMUtil.php");
14 
31 {
32  var $tpl;
33  var $lng;
34  var $ctrl;
35  var $obj;
44  var $bib_id;
45  var $citation;
49  var $activation = false;
50  var $activated = true;
51  var $editpreview = false;
52  var $use_meta_data = false;
53  var $link_xml_set = false;
54  var $enableediting = true;
55  var $rawpagecontent = false;
57  var $compare_mode = false;
58  var $page_config = null;
59  var $tabs_enabled = true;
61  private $abstract_only = false;
62  protected $parent_type = "";
63 
64  //var $pl_start = "&#123;&#123;&#123;&#123;&#123;";
65  //var $pl_end = "&#125;&#125;&#125;&#125;&#125;";
66  var $pl_start = "{{{{{";
67  var $pl_end = "}}}}}";
68 
78  function ilPageObjectGUI($a_parent_type, $a_id, $a_old_nr = 0,
79  $a_prevent_get_id = false, $a_lang = "")
80  {
81  global $tpl, $lng, $ilCtrl,$ilTabs;
82 
83  $this->setParentType($a_parent_type);
84  $this->setId($a_id);
85  if ($a_old_nr == 0 && !$a_prevent_get_id && $_GET["old_nr"] > 0)
86  {
87  $a_old_nr = $_GET["old_nr"];
88  }
89  $this->setOldNr($a_old_nr);
90 
91  if ($a_lang == "" && $_GET["transl"] != "")
92  {
93  $this->setLanguage($_GET["transl"]);
94  }
95  else
96  {
97  if ($a_lang == "")
98  {
99  $a_lang = "-";
100  }
101  $this->setLanguage($a_lang);
102  }
103 
104  $this->tpl = $tpl;
105  $this->ctrl = $ilCtrl;
106  $this->lng = $lng;
107 
109  $this->setEnabledPageFocus(true);
110  $this->initPageObject();
111  $this->setPageConfig($this->getPageObject()->getPageConfig());
112 
113  $this->output2template = true;
114  $this->question_xml = "";
115  $this->question_html = "";
116  $this->tabs_gui =& $ilTabs;
117 
118  $this->template_output_var = "PAGE_CONTENT";
119  $this->citation = false;
120  $this->change_comments = false;
121  $this->page_back_title = $this->lng->txt("page");
122  $lng->loadLanguageModule("content");
123 
124  $this->setTemplateOutput(false);
125 
126  $ilCtrl->saveParameter($this, "transl");
127 
128  $this->afterConstructor();
129  }
130 
134  function afterConstructor()
135  {
136  }
137 
138 
142  protected final function initPageObject()
143  {
144  include_once("./Services/COPage/classes/class.ilPageObjectFactory.php");
145  $page = ilPageObjectFactory::getInstance($this->getParentType(), $this->getId(), $this->getOldNr(),
146  $this->getLanguage());
147  $this->setPageObject($page);
148  }
149 
155  function setParentType($a_val)
156  {
157  $this->parent_type = $a_val;
158  }
159 
165  function getParentType()
166  {
167  return $this->parent_type;
168  }
169 
175  function setId($a_val)
176  {
177  $this->id = $a_val;
178  }
179 
185  function getId()
186  {
187  return $this->id;
188  }
189 
195  function setOldNr($a_val)
196  {
197  $this->old_nr = $a_val;
198  }
199 
205  function getOldNr()
206  {
207  return $this->old_nr;
208  }
209 
215  function setLanguage($a_val)
216  {
217  $this->language = $a_val;
218  }
219 
225  function getLanguage()
226  {
227  if ($this->language == "")
228  {
229  return "-";
230  }
231 
232  return $this->language;
233  }
234 
240  function setEnablePCType($a_pc_type, $a_val)
241  {
242  $this->getPageConfig()->setEnablePCType($a_pc_type, $a_val);
243  }
244 
250  function getEnablePCType($a_pc_type)
251  {
252  return $this->getPageConfig()->getEnablePCType($a_pc_type);
253  }
254 
260  function setPageConfig($a_val)
261  {
262  $this->page_config = $a_val;
263  }
264 
270  function getPageConfig()
271  {
272  return $this->page_config;
273  }
274 
278  function setBibId($a_id)
279  {
280  // USED FOR SELECTION WHICH PAGE TURNS AND LATER PAGES SHOULD BE SHOWN
281  $this->bib_id = $a_id;
282  }
283 
287  function getBibId()
288  {
289  return $this->bib_id ? $this->bib_id : 0;
290  }
291 
297  function setPageObject($a_pg_obj)
298  {
299  $this->obj = $a_pg_obj;
300  }
301 
307  function getPageObject()
308  {
309  return $this->obj;
310  }
311 
318  {
319  $this->output_mode = $a_mode;
320  }
321 
322  function getOutputMode()
323  {
324  return $this->output_mode;
325  }
326 
327  function setTemplateOutput($a_output = true)
328  {
329  $this->output2template = $a_output;
330  }
331 
332  function outputToTemplate()
333  {
334  return $this->output2template;
335  }
336 
337  function setPresentationTitle($a_title = "")
338  {
339  $this->presentation_title = $a_title;
340  }
341 
343  {
345  }
346 
347  function setHeader($a_title = "")
348  {
349  $this->header = $a_title;
350  }
351 
352  function getHeader()
353  {
354  return $this->header;
355  }
356 
357  function setLinkParams($l_params = "")
358  {
359  $this->link_params = $l_params;
360  }
361 
362  function getLinkParams()
363  {
364  return $this->link_params;
365  }
366 
367  function setLinkFrame($l_frame = "")
368  {
369  $this->link_frame = $l_frame;
370  }
371 
372  function getLinkFrame()
373  {
374  return $this->link_frame;
375  }
376 
377  function setLinkXML($link_xml)
378  {
379  $this->link_xml = $link_xml;
380  $this->link_xml_set = true;
381  }
382 
383  function getLinkXML()
384  {
385  return $this->link_xml;
386  }
387 
388  function setQuestionXML($question_xml)
389  {
390  $this->question_xml = $question_xml;
391  }
392 
394  {
395  $this->getPageConfig()->setQuestionHTML($question_html);
396  }
397 
398  function getQuestionXML()
399  {
400  return $this->question_xml;
401  }
402 
403  function getQuestionHTML()
404  {
405  return $this->getPageConfig()->getQuestionHTML();
406  }
407 
408  function setTemplateTargetVar($a_variable)
409  {
410  $this->target_var = $a_variable;
411  }
412 
414  {
415  return $this->target_var;
416  }
417 
418  function setTemplateOutputVar($a_value)
419  {
420  $this->template_output_var = $a_value;
421  }
422 
424  {
426  }
427 
428  // @todo 1: can we get rid of this?
429  function setSourcecodeDownloadScript ($script_name) {
430  $this->sourcecode_download_script = $script_name;
431  }
432 
435  }
436 
437  function enableCitation($a_enabled)
438  {
439  $this->citation = $a_enabled;
440  }
441 
442  function isEnabledCitation()
443  {
444  return $this->citation;
445  }
446 
447  function setLocator(&$a_locator)
448  {
449  $this->locator =& $a_locator;
450  }
451 
452  function setTabs($a_tabs)
453  {
454  $this->tabs_gui = $a_tabs;
455  }
456 
457  function setPageBackTitle($a_title)
458  {
459  $this->page_back_title = $a_title;
460  }
461 
462  // @todo 1: can we get rid of this?
463  function setFileDownloadLink($a_download_link)
464  {
465  $this->file_download_link = $a_download_link;
466  }
467 
469  {
470  return $this->file_download_link;
471  }
472 
473  // @todo 1: can we get rid of this?
474  function setFullscreenLink($a_fullscreen_link)
475  {
476  $this->fullscreen_link = $a_fullscreen_link;
477  }
478 
479  function getFullscreenLink()
480  {
481  return $this->fullscreen_link;
482  }
483 
484  function setIntLinkReturn($a_return)
485  {
486  $this->int_link_return = $a_return;
487  }
488 
489  function enableChangeComments($a_enabled)
490  {
491  $this->change_comments = $a_enabled;
492  }
493 
495  {
496  return $this->change_comments;
497  }
498 
499  function enableNotes($a_enabled, $a_parent_id)
500  {
501  $this->notes_enabled = $a_enabled;
502  $this->notes_parent_id = $a_parent_id;
503  }
504 
505  function isEnabledNotes()
506  {
507  return $this->notes_enabled;
508  }
509 
515  function setOfflineDirectory ($offdir) {
516  $this->offline_directory = $offdir;
517  }
518 
519 
524  function getOfflineDirectory () {
525  return $this->offline_directory;
526  }
527 
528 
535  function setViewPageLink($a_link, $a_target = "")
536  {
537  $this->view_page_link = $a_link;
538  $this->view_page_target = $a_target;
539  }
540 
544  function getViewPageLink()
545  {
546  return $this->view_page_link;
547  }
548 
552  function getViewPageTarget()
553  {
554  return $this->view_page_target;
555  }
556 
557  function setActivationListener(&$a_obj, $a_meth)
558  {
559  $this->act_obj =& $a_obj;
560  $this->act_meth = $a_meth;
561  }
562 
568  function setEnabledNews($a_enabled, $a_news_obj_id = 0, $a_news_obj_type = 0)
569  {
570  $this->enabled_news = $a_enabled;
571  $this->news_obj_id = $a_news_obj_id;
572  $this->news_obj_type = $a_news_obj_type;
573  }
574 
580  function getEnabledNews()
581  {
582  return $this->enabled_news;
583  }
584 
588  function setTabHook($a_object, $a_function)
589  {
590  $this->tab_hook = array("obj" => $a_object, "func" => $a_function);
591  }
592 
598  function setEditPreview($a_editpreview)
599  {
600  $this->editpreview = $a_editpreview;
601  }
602 
608  function getEditPreview()
609  {
610  return $this->editpreview;
611  }
612 
618  function setEnabledTabs($a_enabledtabs)
619  {
620  $this->tabs_enabled = $a_enabledtabs;
621  }
622 
628  function getEnabledTabs()
629  {
630  return $this->tabs_enabled;
631  }
632 
638  function setEnabledPageFocus($a_enabledpagefocus)
639  {
640  $this->enabledpagefocus = $a_enabledpagefocus;
641  }
642 
649  {
650  return $this->enabledpagefocus;
651  }
652 
658  function setExplorerUpdater($a_exp_frame, $a_exp_id, $a_exp_target_script)
659  {
660 return;
661  $this->exp_frame = $a_exp_frame;
662  $this->exp_id = $a_exp_id;
663  $this->exp_target_script = $a_exp_target_script;
664  }
665 
671  function setPrependingHtml($a_prependinghtml)
672  {
673  $this->prependinghtml = $a_prependinghtml;
674  }
675 
681  function getPrependingHtml()
682  {
683  return $this->prependinghtml;
684  }
685 
691  function setEnableEditing($a_enableediting)
692  {
693  $this->enableediting = $a_enableediting;
694  }
695 
701  function getEnableEditing()
702  {
703  return $this->enableediting;
704  }
705 
711  function setRawPageContent($a_rawpagecontent)
712  {
713  $this->rawpagecontent = $a_rawpagecontent;
714  }
715 
721  function getRawPageContent()
722  {
723  return $this->rawpagecontent;
724  }
725 
731  function setStyleId($a_styleid)
732  {
733  $this->styleid = $a_styleid;
734  }
735 
741  function getStyleId()
742  {
743  return $this->styleid;
744  }
745 
751  function setCompareMode($a_val)
752  {
753  $this->compare_mode = $a_val;
754  }
755 
761  function getCompareMode()
762  {
763  return $this->compare_mode;
764  }
765 
771  function setAbstractOnly($a_val)
772  {
773  $this->abstract_only = $a_val;
774  }
775 
781  function getAbstractOnly()
782  {
783  return $this->abstract_only;
784  }
785 
791  function setRenderPageContainer($a_val)
792  {
793  $this->render_page_container = $a_val;
794  }
795 
802  {
804  }
805 
815  function activateMetaDataEditor($a_rep_obj_id, $a_sub_obj_id, $a_type,
816  $a_observer_obj = NULL, $a_observer_func = "")
817  {
818  $this->use_meta_data = true;
819  $this->meta_data_rep_obj_id = $a_rep_obj_id;
820  $this->meta_data_sub_obj_id = $a_sub_obj_id;
821  $this->meta_data_type = $a_type;
822  $this->meta_data_observer_obj = $a_observer_obj;
823  $this->meta_data_observer_func = $a_observer_func;
824  }
825 
832  {
833  global $ilCtrl;
834 
835  $file_download_link = $this->getFileDownloadLink();
836  if ($this->getFileDownloadLink() == "" && $this->getOutputMode() != "offline")
837  {
838  $file_download_link = $ilCtrl->getLinkTarget($this, "downloadFile");
839  }
840  return $file_download_link;
841  }
842 
849  {
850  global $ilCtrl;
851 
852  $fullscreen_link = $this->getFullscreenLink();
853  if ($this->getFullscreenLink() == "" && $this->getOutputMode() != "offline")
854  {
855  $fullscreen_link = $ilCtrl->getLinkTarget($this, "displayMediaFullscreen", "", false, false);
856  }
857  return $fullscreen_link;
858  }
859 
866  {
867  global $ilCtrl;
868 
870  if ($this->sourcecode_download_script == "" && $this->getOutputMode() != "offline")
871  {
872  $l = $ilCtrl->getLinkTarget($this, "");
873  }
874  return $l;
875  }
876 
881  {
882  $xml = "";
883  if($this->getOutputMode() == "edit")
884  {
885  global $ilPluginAdmin;
886 
887  $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_SERVICE,
888  "COPage", "pgcp");
889  foreach ($pl_names as $pl_name)
890  {
891  $plugin = $ilPluginAdmin->getPluginObject(IL_COMP_SERVICE,
892  "COPage", "pgcp", $pl_name);
893  if ($plugin->isValidParentType($this->getPageObject()->getParentType()))
894  {
895  $xml.= '<ComponentPlugin Name="'.$plugin->getPluginName().
896  '" InsertText="'.$plugin->txt(ilPageComponentPlugin::TXT_CMD_INSERT).'" />';
897  }
898  }
899  }
900  if ($xml != "")
901  {
902  $xml = "<ComponentPlugins>".$xml."</ComponentPlugins>";
903  }
904  return $xml;
905  }
906 
907 
911  function &executeCommand()
912  {
913  global $ilCtrl, $ilTabs, $lng, $ilAccess, $tpl;
914 
915  $next_class = $this->ctrl->getNextClass($this);
916 
917  $cmd = $this->ctrl->getCmd();
918  //$this->ctrl->addTab("clipboard", $this->ctrl->getLinkTargetByClass("ilEditClipboardGUI", "view")
919  // , "view", "ilEditClipboardGUI");
920  $this->getTabs();
921 
922  $ilCtrl->setReturn($this, "edit");
923 //echo "-".$next_class."-";
924  switch($next_class)
925  {
926  case 'ilmdeditorgui':
927  //$this->setTabs();
928  $ilTabs->setTabActive("meta_data");
929  include_once 'Services/MetaData/classes/class.ilMDEditorGUI.php';
930  $md_gui =& new ilMDEditorGUI($this->meta_data_rep_obj_id,
931  $this->meta_data_sub_obj_id, $this->meta_data_type);
932  if (is_object($this->meta_data_observer_obj))
933  {
934  $md_gui->addObserver($this->meta_data_observer_obj,
935  $this->meta_data_observer_func, "General");
936  }
937  $this->ctrl->forwardCommand($md_gui);
938  break;
939 
940  case "ileditclipboardgui":
941  //$this->tabs_gui->clearTargets();
942  //$this->ctrl->setReturn($this, "view");
943  $clip_gui = new ilEditClipboardGUI();
944  $clip_gui->setPageBackTitle($this->page_back_title);
945  //$ret =& $clip_gui->executeCommand();
946  $ret =& $this->ctrl->forwardCommand($clip_gui);
947  break;
948 
949  // notes
950  case "ilnotegui":
951  switch($_GET["notes_mode"])
952  {
953  default:
954  $html = $this->edit();
955  $ilTabs->setTabActive("edit");
956  return $html;
957  }
958  break;
959 
960  case 'ilpublicuserprofilegui':
961  require_once './Services/User/classes/class.ilPublicUserProfileGUI.php';
962  $profile_gui = new ilPublicUserProfileGUI($_GET["user"]);
963  $ret = $this->ctrl->forwardCommand($profile_gui);
964  break;
965 
966  case "ilpageeditorgui":
967  if (!$this->getEnableEditing())
968  {
969  ilUtil::sendFailure($lng->txt("permission_denied"), true);
970  $ilCtrl->redirect($this, "preview");
971  }
972  $page_editor = new ilPageEditorGUI($this->getPageObject(), $this);
973  $page_editor->setLocator($this->locator);
974  $page_editor->setHeader($this->getHeader());
975  $page_editor->setPageBackTitle($this->page_back_title);
976  $page_editor->setIntLinkReturn($this->int_link_return);
977  //$page_editor->executeCommand();
978  $ret =& $this->ctrl->forwardCommand($page_editor);
979  break;
980 
981  case 'ilnewsitemgui':
982  include_once("./Services/News/classes/class.ilNewsItemGUI.php");
983  $news_item_gui = new ilNewsItemGUI();
984  $news_item_gui->setEnableEdit(true);
985  $news_item_gui->setContextObjId($this->news_obj_id);
986  $news_item_gui->setContextObjType($this->news_obj_type);
987  $news_item_gui->setContextSubObjId($this->obj->getId());
988  $news_item_gui->setContextSubObjType("pg");
989 
990  $ret = $ilCtrl->forwardCommand($news_item_gui);
991  break;
992 
993  $profile_gui = new ilPublicUserProfileGUI($_GET["user"]);
994  $ret = $this->ctrl->forwardCommand($profile_gui);
995  break;
996 
997  case "ilpropertyformgui":
998  include_once './Services/Form/classes/class.ilPropertyFormGUI.php';
999  $form = $this->initOpenedContentForm();
1000  $this->ctrl->forwardCommand($form);
1001  break;
1002 
1003  case "ilinternallinkgui":
1004  $this->lng->loadLanguageModule("content");
1005  require_once("./Services/Link/classes/class.ilInternalLinkGUI.php");
1006  $link_gui = new ilInternalLinkGUI("Media_Media", 0);
1007  //$link_gui->filterLinkType("RepositoryItem");
1008 
1009  $link_gui->filterLinkType("PageObject_FAQ");
1010  $link_gui->filterLinkType("GlossaryItem");
1011  $link_gui->filterLinkType("Media_Media");
1012  $link_gui->filterLinkType("Media_FAQ");
1013 
1014  $link_gui->setFilterWhiteList(true);
1015  $link_gui->setMode("asynch");
1016  $ilCtrl->forwardCommand($link_gui);
1017  break;
1018 
1019  case "ilquestioneditgui":
1020  $this->setQEditTabs("question");
1021  include_once("./Modules/TestQuestionPool/classes/class.ilQuestionEditGUI.php");
1022  $edit_gui = new ilQuestionEditGUI();
1023  $edit_gui->setPageConfig($this->getPageConfig());
1024 // $edit_gui->addNewIdListener($this, "setNewQuestionId");
1025  $edit_gui->setSelfAssessmentEditingMode(true);
1026  $ret = $ilCtrl->forwardCommand($edit_gui);
1027  $this->tpl->setContent($ret);
1028  break;
1029 
1030  case 'ilassquestionfeedbackeditinggui':
1031 
1032  $this->onFeedbackEditingForwarding();
1033 
1034  // set tabs
1035  $this->setQEditTabs("feedback");
1036 
1037  // load required lang mods
1038  $lng->loadLanguageModule("assessment");
1039 
1040  // set context tabs
1041  require_once 'Modules/TestQuestionPool/classes/class.assQuestionGUI.php';
1042  require_once 'Modules/TestQuestionPool/classes/class.assQuestion.php';
1043  $questionGUI = assQuestionGUI::_getQuestionGUI(assQuestion::_getQuestionType((int) $_GET['q_id']), (int) $_GET['q_id']);
1044  $questionGUI->object->setObjId(0);
1045  $questionGUI->object->setSelfAssessmentEditingMode(true);
1046  $questionGUI->object->setPreventRteUsage($this->getPageConfig()->getPreventRteUsage());
1047 
1048  // forward to ilAssQuestionFeedbackGUI
1049  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionFeedbackEditingGUI.php';
1050  $gui = new ilAssQuestionFeedbackEditingGUI($questionGUI, $ilCtrl, $ilAccess, $tpl, $ilTabs, $lng);
1051  $ilCtrl->forwardCommand($gui);
1052  break;
1053 
1054 /* case "ilpagemultilanggui":
1055  $ilCtrl->setReturn($this, "edit");
1056  include_once("./Services/COPage/classes/class.ilPageMultiLangGUI.php");
1057  $ml_gui = new ilPageMultiLangGUI($this->getPageObject()->getParentType(), $this->getPageObject()->getParentId(),
1058  $this->getPageConfig()->getSinglePageMode());
1059  //$this->setTabs("settings");
1060  //$this->setSubTabs("cont_multilinguality");
1061  $ret = $this->ctrl->forwardCommand($ml_gui);
1062  break;*/
1063 
1064  default:
1065  $cmd = $this->ctrl->getCmd("preview");
1066  $ret = $this->$cmd();
1067  break;
1068  }
1069 //echo "+$ret+";
1070  return $ret;
1071  }
1072 
1079  function setQEditTabs($a_active)
1080  {
1081  global $ilTabs, $ilCtrl, $lng;
1082  include_once("./Modules/TestQuestionPool/classes/class.assQuestion.php");
1083 
1084  $ilTabs->clearTargets();
1085 
1086  $ilTabs->setBackTarget($lng->txt("back"),
1087  $ilCtrl->getLinkTarget($this, "edit"));
1088 
1089  $ilCtrl->setParameterByClass("ilquestioneditgui", "q_id", $_GET["q_id"]);
1090  $ilTabs->addTab("question", $lng->txt("question"),
1091  $ilCtrl->getLinkTargetByClass("ilquestioneditgui", "editQuestion"));
1092 
1093  require_once 'Modules/TestQuestionPool/classes/class.ilAssQuestionFeedbackEditingGUI.php';
1094  $ilCtrl->setParameterByClass("ilAssQuestionFeedbackEditingGUI", "q_id", $_GET["q_id"]);
1095  $ilTabs->addTab("feedback", $lng->txt("feedback"),
1096  $ilCtrl->getLinkTargetByClass("ilAssQuestionFeedbackEditingGUI", ilAssQuestionFeedbackEditingGUI::CMD_SHOW));
1097 
1098  $ilTabs->activateTab($a_active);
1099  }
1100 
1105  {
1106 
1107  }
1108 
1109 
1110  function deactivatePage()
1111  {
1112  $this->getPageObject()->setActivationStart(null);
1113  $this->getPageObject()->setActivationEnd(null);
1114  $this->getPageObject()->setActive(false);
1115  $this->getPageObject()->update();
1116  $this->ctrl->redirect($this, "edit");
1117  }
1118 
1119  function activatePage()
1120  {
1121  $this->getPageObject()->setActivationStart(null);
1122  $this->getPageObject()->setActivationEnd(null);
1123  $this->getPageObject()->setActive(true);
1124  $this->getPageObject()->update();
1125  $this->ctrl->redirect($this, "edit");
1126  }
1127 
1131  function showPage()
1132  {
1133  global $tree, $ilUser, $lng, $ilCtrl, $ilSetting, $ilTabs;
1134 
1135  // jquery and jquery ui are always provided for components
1136  include_once("./Services/jQuery/classes/class.iljQueryUtil.php");
1139 
1140 // $this->initSelfAssessmentRendering();
1141 
1142  include_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
1144 
1145  $GLOBALS["tpl"]->addJavaScript("./Services/COPage/js/ilCOPagePres.js");
1146 
1147  // needed for overlays in iim
1148  include_once("./Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php");
1150 
1151  include_once("./Services/MediaObjects/classes/class.ilPlayerUtil.php");
1153 
1154  // init template
1155  //if($this->outputToTemplate())
1156  //{
1157  if($this->getOutputMode() == "edit")
1158  {
1159 //echo ":".$this->getTemplateTargetVar().":";
1160  $tpl = new ilTemplate("tpl.page_edit_wysiwyg.html", true, true, "Services/COPage");
1161  //$this->tpl->addBlockFile($this->getTemplateTargetVar(), "adm_content", "tpl.page_edit_wysiwyg.html", "Services/COPage");
1162 
1163  // to do: status dependent class
1164  $tpl->setVariable("CLASS_PAGE_TD", "ilc_Page");
1165 
1166  // user comment
1167  if ($this->isEnabledChangeComments())
1168  {
1169  $tpl->setCurrentBlock("change_comment");
1170  $tpl->setVariable("TXT_ADD_COMMENT", $this->lng->txt("cont_add_change_comment"));
1171  $tpl->parseCurrentBlock();
1172  }
1173 
1174  $tpl->setVariable("WYSIWYG_ACTION",
1175  $ilCtrl->getFormActionByClass("ilpageeditorgui", "", "", true));
1176 
1177  // determine media, html and javascript mode
1178  $sel_media_mode = ($ilUser->getPref("ilPageEditor_MediaMode") == "disable")
1179  ? "disable"
1180  : "enable";
1181  $sel_html_mode = ($ilUser->getPref("ilPageEditor_HTMLMode") == "disable")
1182  ? "disable"
1183  : "enable";
1184  $sel_js_mode = "disable";
1185  //if($ilSetting->get("enable_js_edit", 1))
1186  //{
1187  $sel_js_mode = (ilPageEditorGUI::_doJSEditing())
1188  ? "enable"
1189  : "disable";
1190  //}
1191 
1192  // show prepending html
1193  $tpl->setVariable("PREPENDING_HTML", $this->getPrependingHtml());
1194  $tpl->setVariable("TXT_CONFIRM_DELETE", $lng->txt("cont_confirm_delete"));
1195 
1196  // presentation view
1197  if ($this->getViewPageLink() != "")
1198  {
1199  $ilTabs->addNonTabbedLink("pres_view", $this->lng->txt("cont_presentation_view"),
1200  $this->getViewPageLink(), $this->getViewPageTarget());
1201  }
1202 
1203  // show actions drop down
1204  $this->addActionsMenu($tpl, $sel_media_mode, $sel_html_mode, $sel_js_mode);
1205 
1206  // get js files for JS enabled editing
1207  if ($sel_js_mode == "enable")
1208  {
1209  $this->insertHelp($tpl);
1210  include_once("./Services/YUI/classes/class.ilYuiUtil.php");
1213  ilYuiUtil::initPanel(false);
1214  $GLOBALS["tpl"]->addJavaScript("./Services/COPage/js/ilcopagecallback.js");
1215  $GLOBALS["tpl"]->addJavascript("Services/COPage/js/page_editing.js");
1216 
1217  include_once './Services/Style/classes/class.ilObjStyleSheet.php';
1218  $GLOBALS["tpl"]->addOnloadCode("var preloader = new Image();
1219  preloader.src = './templates/default/images/loader.svg';
1220  ilCOPage.setContentCss('".
1223  ", ./Services/COPage/css/tiny_extra.css".
1224  "')");
1225 
1226  //$GLOBALS["tpl"]->addJavascript("Services/RTE/tiny_mce_3_3_9_2/il_tiny_mce_src.js");
1227  $GLOBALS["tpl"]->addJavascript("Services/COPage/tiny/4_1_5/tinymce.js");
1228  $tpl->touchBlock("init_dragging");
1229 
1230  $cfg = $this->getPageConfig();
1231  $tpl->setVariable("IL_TINY_MENU",
1232  self::getTinyMenu(
1233  $this->getPageObject()->getParentType(),
1234  $cfg->getEnableInternalLinks(),
1235  $cfg->getEnableWikiLinks(),
1236  $cfg->getEnableKeywords(),
1237  $this->getStyleId(), true, true,
1238  $cfg->getEnableAnchors()
1239  ));
1240 
1241  // add int link parts
1242  include_once("./Services/Link/classes/class.ilInternalLinkGUI.php");
1243  $tpl->setCurrentBlock("int_link_prep");
1244  $tpl->setVariable("INT_LINK_PREP", ilInternalLinkGUI::getInitHTML(
1245  $ilCtrl->getLinkTargetByClass(array("ilpageeditorgui", "ilinternallinkgui"),
1246  "", false, true, false)));
1247  $tpl->parseCurrentBlock();
1248 
1249  include_once("./Services/YUI/classes/class.ilYuiUtil.php");
1251  $GLOBALS["tpl"]->addJavaScript("./Services/UIComponent/Explorer/js/ilExplorer.js");
1252 
1253  }
1254 
1255  // multiple actions
1256  $cnt_pcs = $this->getPageObject()->countPageContents();
1257  if ($cnt_pcs > 1 ||
1258  ($this->getPageObject()->getParentType() != "qpl" && $cnt_pcs > 0))
1259  {
1260  $tpl->setCurrentBlock("multi_actions");
1261  if ($sel_js_mode == "enable")
1262  {
1263  $tpl->setVariable("ONCLICK_DE_ACTIVATE_SELECTED", 'onclick="return ilEditMultiAction(\'activateSelected\');"');
1264  $tpl->setVariable("ONCLICK_DELETE_SELECTED", 'onclick="return ilEditMultiAction(\'deleteSelected\');"');
1265  $tpl->setVariable("ONCLICK_ASSIGN_CHARACTERISTIC", 'onclick="return ilEditMultiAction(\'assignCharacteristicForm\');"');
1266  $tpl->setVariable("ONCLICK_COPY_SELECTED", 'onclick="return ilEditMultiAction(\'copySelected\');"');
1267  $tpl->setVariable("ONCLICK_CUT_SELECTED", 'onclick="return ilEditMultiAction(\'cutSelected\');"');
1268  $tpl->setVariable("TXT_SELECT_ALL", $this->lng->txt("select_all"));
1269  $tpl->setVariable("ONCLICK_SELECT_ALL", 'onclick="return ilEditMultiAction(\'selectAll\');"');
1270  }
1271  $tpl->setVariable("TXT_DE_ACTIVATE_SELECTED", $this->lng->txt("cont_ed_enable"));
1272  $tpl->setVariable("TXT_ASSIGN_CHARACTERISTIC", $this->lng->txt("cont_assign_characteristic"));
1273  $tpl->setVariable("TXT_DELETE_SELECTED", $this->lng->txt("cont_delete_selected"));
1274  $tpl->setVariable("TXT_COPY_SELECTED", $this->lng->txt("copy"));
1275  $tpl->setVariable("TXT_CUT_SELECTED", $this->lng->txt("cut"));
1276  $tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.svg"));
1277  $tpl->parseCurrentBlock();
1278  }
1279  }
1280  else
1281  {
1282  // presentation or preview here
1283 
1284  $tpl = new ilTemplate("tpl.page.html", true, true, "Services/COPage");
1285  if ($this->getEnabledPageFocus())
1286  {
1287  $tpl->touchBlock("page_focus");
1288  }
1289 
1290  include_once("./Services/User/classes/class.ilUserUtil.php");
1291 
1292  // presentation
1293  if( $this->isPageContainerToBeRendered() )
1294  {
1295  $tpl->touchBlock("page_container_1");
1296  $tpl->touchBlock("page_container_2");
1297  $tpl->touchBlock("page_container_3");
1298  }
1299 
1300  // history
1301  $c_old_nr = $this->getPageObject()->old_nr;
1302  if ($c_old_nr > 0 || $this->getCompareMode() || $_GET["history_mode"] == 1)
1303  {
1304  $hist_info =
1305  $this->getPageObject()->getHistoryInfo($c_old_nr);
1306 
1307  if (!$this->getCompareMode())
1308  {
1309  $ilCtrl->setParameter($this, "history_mode", "1");
1310 
1311  // previous revision
1312  if (is_array($hist_info["previous"]))
1313  {
1314  $tpl->setCurrentBlock("previous_rev");
1315  $tpl->setVariable("TXT_PREV_REV", $lng->txt("cont_previous_rev"));
1316  $ilCtrl->setParameter($this, "old_nr", $hist_info["previous"]["nr"]);
1317  $tpl->setVariable("HREF_PREV",
1318  $ilCtrl->getLinkTarget($this, "preview"));
1319  $tpl->parseCurrentBlock();
1320  }
1321  else
1322  {
1323  $tpl->setCurrentBlock("previous_rev_disabled");
1324  $tpl->setVariable("TXT_PREV_REV", $lng->txt("cont_previous_rev"));
1325  $tpl->parseCurrentBlock();
1326  }
1327 
1328  // next revision
1329  if ($c_old_nr > 0)
1330  {
1331  $tpl->setCurrentBlock("next_rev");
1332  $tpl->setVariable("TXT_NEXT_REV", $lng->txt("cont_next_rev"));
1333  $ilCtrl->setParameter($this, "old_nr", $hist_info["next"]["nr"]);
1334  $tpl->setVariable("HREF_NEXT",
1335  $ilCtrl->getLinkTarget($this, "preview"));
1336  $tpl->parseCurrentBlock();
1337 
1338  // latest revision
1339  $tpl->setCurrentBlock("latest_rev");
1340  $tpl->setVariable("TXT_LATEST_REV", $lng->txt("cont_latest_rev"));
1341  $ilCtrl->setParameter($this, "old_nr", "");
1342  $tpl->setVariable("HREF_LATEST",
1343  $ilCtrl->getLinkTarget($this, "preview"));
1344  $tpl->parseCurrentBlock();
1345  }
1346 
1347  $ilCtrl->setParameter($this, "history_mode", "");
1348 
1349  // rollback
1350  if ($c_old_nr > 0 && $ilUser->getId() != ANONYMOUS_USER_ID)
1351  {
1352  $tpl->setCurrentBlock("rollback");
1353  $ilCtrl->setParameter($this, "old_nr", $c_old_nr);
1354  $tpl->setVariable("HREF_ROLLBACK",
1355  $ilCtrl->getLinkTarget($this, "rollbackConfirmation"));
1356  $ilCtrl->setParameter($this, "old_nr", "");
1357  $tpl->setVariable("TXT_ROLLBACK",
1358  $lng->txt("cont_rollback"));
1359  $tpl->parseCurrentBlock();
1360  }
1361  }
1362 
1363  $tpl->setCurrentBlock("hist_nav");
1364  $tpl->setVariable("TXT_REVISION", $lng->txt("cont_revision"));
1365  $tpl->setVariable("VAL_REVISION_DATE",
1366  ilDatePresentation::formatDate(new ilDateTime($hist_info["current"]["hdate"], IL_CAL_DATETIME)));
1367  $tpl->setVariable("VAL_REV_USER",
1368  ilUserUtil::getNamePresentation($hist_info["current"]["user_id"]));
1369  $tpl->parseCurrentBlock();
1370  }
1371  }
1372  if ($this->getOutputMode() != IL_PAGE_PRESENTATION &&
1373  $this->getOutputMode() != IL_PAGE_OFFLINE &&
1374  $this->getOutputMode() != IL_PAGE_PREVIEW &&
1375  $this->getOutputMode() != IL_PAGE_PRINT)
1376  {
1377  $tpl->setVariable("FORMACTION", $this->ctrl->getFormActionByClass("ilpageeditorgui"));
1378  }
1379 
1380  // output media object edit list (of media links)
1381  if($this->getOutputMode() == "edit")
1382  {
1383  $links = ilInternalLink::_getTargetsOfSource($this->obj->getParentType().":pg",
1384  $this->obj->getId(), $this->obj->getLanguage());
1385  $mob_links = array();
1386  foreach($links as $link)
1387  {
1388  if ($link["type"] == "mob")
1389  {
1390  if (ilObject::_exists($link["id"]) && ilObject::_lookupType($link["id"]) == "mob")
1391  {
1392  $mob_links[$link["id"]] = ilObject::_lookupTitle($link["id"])." [".$link["id"]."]";
1393  }
1394  }
1395  }
1396 
1397  // linked media objects
1398  if (count($mob_links) > 0)
1399  {
1400  $tpl->setCurrentBlock("med_link");
1401  $tpl->setVariable("TXT_LINKED_MOBS", $this->lng->txt("cont_linked_mobs"));
1402  $tpl->setVariable("SEL_MED_LINKS",
1403  ilUtil::formSelect(0, "mob_id", $mob_links, false, true));
1404  $tpl->setVariable("TXT_EDIT_MEDIA", $this->lng->txt("cont_edit_mob"));
1405  $tpl->setVariable("TXT_COPY_TO_CLIPBOARD", $this->lng->txt("cont_copy_to_clipboard"));
1406  //$this->tpl->setVariable("TXT_COPY_TO_POOL", $this->lng->txt("cont_copy_to_mediapool"));
1407  $tpl->parseCurrentBlock();
1408  }
1409 
1410  // content snippets used
1411  include_once("./Services/COPage/classes/class.ilPCContentInclude.php");
1413  $this->getPageObject()->getDomDoc());
1414  if (count($snippets) > 0)
1415  {
1416  foreach ($snippets as $s)
1417  {
1418  include_once("./Modules/MediaPool/classes/class.ilMediaPoolPage.php");
1419  $sn_arr[$s["id"]] = ilMediaPoolPage::lookupTitle($s["id"]);
1420  }
1421  $tpl->setCurrentBlock("med_link");
1422  $tpl->setVariable("TXT_CONTENT_SNIPPETS_USED", $this->lng->txt("cont_snippets_used"));
1423  $tpl->setVariable("SEL_SNIPPETS",
1424  ilUtil::formSelect(0, "ci_id", $sn_arr, false, true));
1425  $tpl->setVariable("TXT_SHOW_INFO", $this->lng->txt("cont_show_info"));
1426  $tpl->parseCurrentBlock();
1427  }
1428 
1429  // scheduled activation?
1430  if (!$this->getPageObject()->getActive() &&
1431  $this->getPageObject()->getActivationStart() != "" &&
1432  $this->getPageConfig()->getEnableScheduledActivation())
1433  {
1434  $tpl->setCurrentBlock("activation_txt");
1435  $tpl->setVariable("TXT_SCHEDULED_ACTIVATION", $lng->txt("cont_scheduled_activation"));
1436  $tpl->setVariable("SA_FROM",
1438  new ilDateTime($this->getPageObject()->getActivationStart(),
1439  IL_CAL_DATETIME)));
1440  $tpl->setVariable("SA_TO",
1442  new ilDateTime($this->getPageObject()->getActivationEnd(),
1443  IL_CAL_DATETIME)));
1444  $tpl->parseCurrentBlock();
1445  }
1446  }
1447 
1448  if ($_GET["reloadTree"] == "y")
1449  {
1450  $tpl->setCurrentBlock("reload_tree");
1451  if ($this->obj->getParentType() == "dbk")
1452  {
1453  $tpl->setVariable("LINK_TREE",
1454  $this->ctrl->getLinkTargetByClass("ilobjdlbookgui", "explorer", "", false, false));
1455  }
1456  else
1457  {
1458  $tpl->setVariable("LINK_TREE",
1459  $this->ctrl->getLinkTargetByClass("ilobjlearningmodulegui", "explorer", "", false, false));
1460  }
1461  $tpl->parseCurrentBlock();
1462  }
1463 // }
1464  // get content
1465  $builded = $this->obj->buildDom();
1466 
1467  // manage hierarchical ids
1468  if($this->getOutputMode() == "edit")
1469  {
1470 
1471  // add pc ids, if necessary
1472  if (!$this->obj->checkPCIds())
1473  {
1474  $this->obj->insertPCIds();
1475  $this->obj->update(true, true);
1476  }
1477 
1478  $this->obj->addFileSizes();
1479  $this->obj->addHierIDs();
1480 
1481  $hids = $this->obj->getHierIds();
1482  $row1_ids = $this->obj->getFirstRowIds();
1483  $col1_ids = $this->obj->getFirstColumnIds();
1484  $litem_ids = $this->obj->getListItemIds();
1485  $fitem_ids = $this->obj->getFileItemIds();
1486 
1487  // standard menues
1488  $hids = $this->obj->getHierIds();
1489  foreach($hids as $hid)
1490  {
1491  $tpl->setCurrentBlock("add_dhtml");
1492  $tpl->setVariable("CONTEXTMENU", "contextmenu_".$hid);
1493  $tpl->parseCurrentBlock();
1494  }
1495 
1496  // column menues for tables
1497  foreach($col1_ids as $hid)
1498  {
1499  $tpl->setCurrentBlock("add_dhtml");
1500  $tpl->setVariable("CONTEXTMENU", "contextmenu_r".$hid);
1501  $tpl->parseCurrentBlock();
1502  }
1503 
1504  // row menues for tables
1505  foreach($row1_ids as $hid)
1506  {
1507  $tpl->setCurrentBlock("add_dhtml");
1508  $tpl->setVariable("CONTEXTMENU", "contextmenu_c".$hid);
1509  $tpl->parseCurrentBlock();
1510  }
1511 
1512  // list item menues
1513  foreach($litem_ids as $hid)
1514  {
1515  $tpl->setCurrentBlock("add_dhtml");
1516  $tpl->setVariable("CONTEXTMENU", "contextmenu_i".$hid);
1517  $tpl->parseCurrentBlock();
1518  }
1519 
1520  // file item menues
1521  foreach($fitem_ids as $hid)
1522  {
1523  $tpl->setCurrentBlock("add_dhtml");
1524  $tpl->setVariable("CONTEXTMENU", "contextmenu_i".$hid);
1525  $tpl->parseCurrentBlock();
1526  }
1527  }
1528  else
1529  {
1530  $this->obj->addFileSizes();
1531  }
1532 
1533 //echo "<br>-".htmlentities($this->obj->getXMLContent())."-<br><br>";
1534 //echo "<br>-".htmlentities($this->getLinkXML())."-";
1535 
1536  // set default link xml, if nothing was set yet
1537  if (!$this->link_xml_set)
1538  {
1539  $this->setDefaultLinkXml();
1540  }
1541 
1542  //$content = $this->obj->getXMLFromDom(false, true, true,
1543  // $this->getLinkXML().$this->getQuestionXML().$this->getComponentPluginsXML());
1544  $link_xml = $this->getLinkXML();
1545 
1546  // disable/enable auto margins
1547  if ($this->getStyleId() > 0)
1548  {
1549  if (ilObject::_lookupType($this->getStyleId()) == "sty")
1550  {
1551  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
1552  $style = new ilObjStyleSheet($this->getStyleId());
1553  $template_xml = $style->getTemplateXML();
1554  $disable_auto_margins = "n";
1555  if ($style->lookupStyleSetting("disable_auto_margins"))
1556  {
1557  $disable_auto_margins = "y";
1558  }
1559  }
1560  }
1561 
1562  if ($this->getAbstractOnly())
1563  {
1564  $content = "<dummy><PageObject><PageContent><Paragraph>".
1565  $this->obj->getFirstParagraphText().$link_xml.
1566  "</Paragraph></PageContent></PageObject></dummy>";
1567  }
1568  else
1569  {
1570  $content = $this->obj->getXMLFromDom(false, true, true,
1571  $link_xml.$this->getQuestionXML().$template_xml.$this->getComponentPluginsXML());
1572  }
1573 
1574  // check validation errors
1575  if($builded !== true)
1576  {
1577  $this->displayValidationError($builded);
1578  }
1579  else
1580  {
1581  $this->displayValidationError($_SESSION["il_pg_error"]);
1582  }
1583  unset($_SESSION["il_pg_error"]);
1584 
1585  if(isset($_SESSION["citation_error"]))
1586  {
1587  ilUtil::sendFailure($this->lng->txt("cont_citation_selection_not_valid"));
1588  ilSession::clear("citation_error");
1589  }
1590 
1591  // get title
1592  $pg_title = $this->getPresentationTitle();
1593 
1594  $col_path = ilUtil::getImagePath("col.svg");
1595  $row_path = ilUtil::getImagePath("row.svg");
1596  $item_path = ilUtil::getImagePath("item.svg");
1597 
1598  if ($this->getOutputMode() != "offline")
1599  {
1600  $enlarge_path = ilUtil::getImagePath("enlarge.svg");
1601  $wb_path = ilUtil::getWebspaceDir("output")."/";
1602  }
1603  else
1604  {
1605  $enlarge_path = "images/enlarge.svg";
1606  $wb_path = "";
1607  }
1608  $pg_title_class = ($this->getOutputMode() == "print")
1609  ? "ilc_PrintPageTitle"
1610  : "";
1611 
1612  // page splitting only for learning modules and
1613  // digital books
1614  $enable_split_new = ($this->obj->getParentType() == "lm" ||
1615  $this->obj->getParentType() == "dbk")
1616  ? "y"
1617  : "n";
1618 
1619  // page splitting to next page only for learning modules and
1620  // digital books if next page exists in tree
1621  if (($this->obj->getParentType() == "lm" ||
1622  $this->obj->getParentType() == "dbk") &&
1623  ilObjContentObject::hasSuccessorPage($this->obj->getParentId(),
1624  $this->obj->getId()))
1625  {
1626  $enable_split_next = "y";
1627  }
1628  else
1629  {
1630  $enable_split_next = "n";
1631  }
1632 
1633  $img_path = ilUtil::getImagePath("", false, $this->getOutputMode(), $this->getOutputMode() == "offline");
1634 
1635 
1636  if ($this->getPageConfig()->getEnablePCType("Tabs"))
1637  {
1638  //include_once("./Services/YUI/classes/class.ilYuiUtil.php");
1639  //ilYuiUtil::initTabView();
1640  include_once("./Services/Accordion/classes/class.ilAccordionGUI.php");
1643  }
1644 
1645  $file_download_link = $this->determineFileDownloadLink();
1646  $fullscreen_link = $this->determineFullscreenLink();
1647  $this->sourcecode_download_script = $this->determineSourcecodeDownloadScript();
1648 
1649  // default values for various parameters (should be used by
1650  // all instances in the future)
1651  $media_mode = ($this->getOutputMode() == "edit")
1652  ? $ilUser->getPref("ilPageEditor_MediaMode")
1653  : "enable";
1654 
1655  include_once("./Modules/LearningModule/classes/class.ilEditClipboard.php");
1656  $paste = (ilEditClipboard::getAction() == "copy" &&
1657  $this->getOutputMode() == "edit");
1658 
1659  include_once("./Services/MediaObjects/classes/class.ilPlayerUtil.php");
1660 
1661  $flv_video_player = ($this->getOutputMode() != "offline")
1664 
1665  $cfg = $this->getPageConfig();
1666 
1667  // added UTF-8 encoding otherwise umlaute are converted too
1668  include_once("./Services/Maps/classes/class.ilMapUtil.php");
1669  $params = array ('mode' => $this->getOutputMode(), 'pg_title' => htmlentities($pg_title,ENT_QUOTES,"UTF-8"),
1670  'enable_placeholder' => $cfg->getEnablePCType("PlaceHolder") ? "y" : "n",
1671  'pg_id' => $this->obj->getId(), 'pg_title_class' => $pg_title_class,
1672  'webspace_path' => $wb_path, 'enlarge_path' => $enlarge_path,
1673  'img_col' => $col_path,
1674  'img_row' => $row_path,
1675  'img_item' => $item_path,
1676  'enable_split_new' => $enable_split_new,
1677  'enable_split_next' => $enable_split_next,
1678  'link_params' => $this->link_params,
1679  'file_download_link' => $file_download_link,
1680  'fullscreen_link' => $fullscreen_link,
1681  'img_path' => $img_path,
1682  'parent_id' => $this->obj->getParentId(),
1683  'download_script' => $this->sourcecode_download_script,
1684  'encoded_download_script' => urlencode($this->sourcecode_download_script),
1685  // digilib
1686  'bib_id' => $this->getBibId(),'citation' => (int) $this->isEnabledCitation(),
1687  'pagebreak' => $this->lng->txt('dgl_pagebreak'),
1688  'page' => $this->lng->txt('page'),
1689  'citate_page' => $this->lng->txt('citate_page'),
1690  'citate_from' => $this->lng->txt('citate_from'),
1691  'citate_to' => $this->lng->txt('citate_to'),
1692  'citate' => $this->lng->txt('citate'),
1693  'enable_rep_objects' => $cfg->getEnablePCType("Resources") ? "y" : "n",
1694  'enable_login_page' => $cfg->getEnablePCType("LoginPageElement") ? "y" : "n",
1695  'enable_map' => ($cfg->getEnablePCType("Map") && ilMapUtil::isActivated()) ? "y" : "n",
1696  'enable_tabs' => $cfg->getEnablePCType("Tabs") ? "y" : "n",
1697  'enable_sa_qst' => $cfg->getEnableSelfAssessment() ? "y" : "n",
1698  'enable_file_list' => $cfg->getEnablePCType("FileList") ? "y" : "n",
1699  'enable_content_includes' => $cfg->getEnablePCType("ContentInclude") ? "y" : "n",
1700  'enable_content_templates' => (count($this->getPageObject()->getContentTemplates()) > 0) ? "y" : "n",
1701  'paste' => $paste ? "y" : "n",
1702  'media_mode' => $media_mode,
1703  'javascript' => $sel_js_mode,
1704  'paragraph_plugins' => $paragraph_plugin_string,
1705  'disable_auto_margins' => $disable_auto_margins,
1706  'page_toc' => $cfg->getEnablePageToc() ? "y" : "n",
1707  'enable_profile' => $cfg->getEnablePCType("Profile") ? "y" : "n",
1708  'enable_verification' => $cfg->getEnablePCType("Verification") ? "y" : "n",
1709  'enable_blog' => $cfg->getEnablePCType("Blog") ? "y" : "n",
1710  'enable_skills' => $cfg->getEnablePCType("Skills") ? "y" : "n",
1711  'enable_qover' => $cfg->getEnablePCType("QuestionOverview") ? "y" : "n",
1712  'enable_consultation_hours' => $cfg->getEnablePCType("ConsultationHours") ? "y" : "n",
1713  'enable_my_courses' => $cfg->getEnablePCType("MyCourses") ? "y" : "n",
1714  'enable_amd_page_list' => $cfg->getEnablePCType("AMDPageList") ? "y" : "n",
1715  'flv_video_player' => $flv_video_player
1716  );
1717  if($this->link_frame != "") // todo other link types
1718  $params["pg_frame"] = $this->link_frame;
1719 
1720  //$content = str_replace("&nbsp;", "", $content);
1721 
1722  // this ensures that cache is emptied with every update
1723  $params["version"] = ILIAS_VERSION;
1724  // ensure no cache hit, if included files/media objects have been changed
1725  $params["incl_elements_date"] = $this->obj->getLastUpdateOfIncludedElements();
1726 
1727  // run xslt
1728  $md5 = md5(serialize($params).$link_xml.$template_xml);
1729 
1730 //$a = microtime();
1731 
1732  // check cache (same parameters, non-edit mode and rendered time
1733  // > last change
1734  if (($this->getOutputMode() == "preview" || $this->getOutputMode() == "presentation") &&
1735  !$this->getCompareMode() &&
1736  !$this->getAbstractOnly() &&
1737  $md5 == $this->obj->getRenderMd5() &&
1738  ($this->obj->getLastChange() < $this->obj->getRenderedTime()) &&
1739  $this->obj->getRenderedTime() != "" &&
1740  $this->obj->old_nr == 0)
1741  {
1742  // cache hit
1743  $output = $this->obj->getRenderedContent();
1744  }
1745  else
1746  {
1747  $xsl = file_get_contents("./Services/COPage/xsl/page.xsl");
1748 
1749  $args = array( '/_xml' => $content, '/_xsl' => $xsl );
1750  $xh = xslt_create();
1751  // echo "<b>XSLT</b>:".htmlentities($xsl).":<br>";
1752  // echo "mode:".$this->getOutputMode().":<br>";
1753  $output = xslt_process($xh, "arg:/_xml","arg:/_xsl", NULL, $args, $params);
1754 
1755  if (($this->getOutputMode() == "presentation" || $this->getOutputMode() == "preview")
1756  && !$this->getAbstractOnly()
1757  && $this->obj->old_nr == 0)
1758  {
1759 //echo "writerenderedcontent";
1760  $this->obj->writeRenderedContent($output, $md5);
1761  }
1762  //echo xslt_error($xh);
1763  xslt_free($xh);
1764  }
1765 
1766 //$b = microtime();
1767 //echo "$a - $b";
1768 //echo "<pre>".htmlentities($output)."</pre>";
1769 
1770  // unmask user html
1771  if (($this->getOutputMode() != "edit" ||
1772  $ilUser->getPref("ilPageEditor_HTMLMode") != "disable")
1773  && !$this->getPageConfig()->getPreventHTMLUnmasking())
1774  {
1775  $output = str_replace("&lt;","<",$output);
1776  $output = str_replace("&gt;",">",$output);
1777  }
1778  $output = str_replace("&amp;", "&", $output);
1779 
1780  $output = ilUtil::insertLatexImages($output);
1781 
1782  // insert page snippets
1783  $output = $this->insertContentIncludes($output);
1784 
1785  // insert resource blocks
1786  $output = $this->insertResources($output);
1787 
1788  // insert page toc
1789  if ($this->getPageConfig()->getEnablePageToc())
1790  {
1791  $output = $this->insertPageToc($output);
1792  }
1793 
1794  // insert advanced output trigger
1795  $output = $this->insertAdvTrigger($output);
1796 
1797  // workaround for preventing template engine
1798  // from hiding paragraph text that is enclosed
1799  // in curly brackets (e.g. "{a}", see ilLMEditorGUI::executeCommand())
1800  $output = $this->replaceCurlyBrackets($output);
1801 
1802  // remove all newlines (important for code / pre output)
1803  $output = str_replace("\n", "", $output);
1804 
1805 //echo htmlentities($output);
1806  $output = $this->postOutputProcessing($output);
1807 //echo htmlentities($output);
1808  if($this->getOutputMode() == "edit" &&
1809  !$this->getPageObject()->getActive($this->getPageConfig()->getEnableScheduledActivation()))
1810  {
1811  $output = '<div class="il_editarea_disabled">'.$output.'</div>';
1812  }
1813 
1814  // for all page components...
1815  include_once("./Services/COPage/classes/class.ilCOPagePCDef.php");
1817  foreach ($defs as $def)
1818  {
1820  $pc_class = $def["pc_class"];
1821  $pc_obj = new $pc_class($this->getPageObject());
1822 
1823  // post xsl page content modification by pc elements
1824  $output = $pc_obj->modifyPageContentPostXsl($output, $this->getOutputMode());
1825 
1826  // javascript files
1827  $js_files = $pc_obj->getJavascriptFiles($this->getOutputMode());
1828  foreach ($js_files as $js)
1829  {
1830  $GLOBALS["tpl"]->addJavascript($js);
1831  }
1832 
1833  // css files
1834  $css_files = $pc_obj->getCssFiles($this->getOutputMode());
1835  foreach ($css_files as $css)
1836  {
1837  $GLOBALS["tpl"]->addCss($css);
1838  }
1839 
1840  // onload code
1841  $onload_code = $pc_obj->getOnloadCode($this->getOutputMode());
1842  foreach ($onload_code as $code)
1843  {
1844  $GLOBALS["tpl"]->addOnloadCode($code);
1845  }
1846  }
1847 
1848 // $output = $this->selfAssessmentRendering($output);
1849 
1850  // output
1851  if ($ilCtrl->isAsynch() && !$this->getRawPageContent() &&
1852  $this->getOutputMode() == "edit")
1853  {
1854  // e.g. ###3:110dad8bad6df8620071a0a693a2d328###
1855  if ($_GET["updated_pc_id_str"] != "")
1856  {
1857  echo $_GET["updated_pc_id_str"];
1858  }
1859  $tpl->setVariable($this->getTemplateOutputVar(), $output);
1860  $tpl->setCurrentBlock("edit_page");
1861  $tpl->parseCurrentBlock();
1862  echo $tpl->get("edit_page");
1863  exit;
1864  }
1865  if ($this->outputToTemplate())
1866  {
1867  $tpl->setVariable($this->getTemplateOutputVar(), $output);
1868  $this->tpl->setVariable($this->getTemplateTargetVar(), $tpl->get());
1869  return $output;
1870  }
1871  else
1872  {
1873  if ($this->getRawPageContent()) // e.g. needed in glossaries
1874  {
1875  return $output;
1876  }
1877  else
1878  {
1879  $tpl->setVariable($this->getTemplateOutputVar(), $output);
1880  return $tpl->get();
1881  }
1882  }
1883  }
1884 
1891  function replaceCurlyBrackets($output)
1892  {
1893 //echo "<br><br>".htmlentities($output);
1894 
1895  while (is_int($start = strpos($output, "<!--ParStart-->")) &&
1896  is_int($end = strpos($output, "<!--ParEnd-->", $start)))
1897  {
1898  $output = substr($output, 0, $start).
1899  str_replace(array("{","}"), array("&#123;","&#125;"),
1900  substr($output, $start + 15, $end - ($start + 15))).
1901  substr($output, $end + 13);
1902  }
1903 
1904 // $output = str_replace("{", "&#123;", $output);
1905 // $output = str_replace("}", "&#125;", $output);
1906 //echo "<br><br>".htmlentities($output);
1907  return $output;
1908  }
1909 
1913  protected function getActivationCaptions()
1914  {
1915  global $lng;
1916 
1917  return array("deactivatePage" => $lng->txt("cont_deactivate_page"),
1918  "activatePage" => $lng->txt("cont_activate_page"));
1919  }
1920 
1924  function addActionsMenu($a_tpl, $sel_media_mode, $sel_html_mode, $sel_js_mode)
1925  {
1926  global $lng, $ilCtrl;
1927 
1928  // actions
1929  include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
1930 
1931  // activate/deactivate
1932  $list = new ilAdvancedSelectionListGUI();
1933  $list->setListTitle($lng->txt("actions"));
1934  $list->setId("copage_act");
1935  $entries = false;
1936  if ($this->getPageConfig()->getEnableActivation())
1937  {
1938  $entries = true;
1939  $captions = $this->getActivationCaptions();
1940  if ($this->getPageObject()->getActive())
1941  {
1942  $list->addItem($captions["deactivatePage"], "",
1943  $ilCtrl->getLinkTarget($this, "deactivatePage"));
1944  }
1945  else
1946  {
1947  $list->addItem($captions["activatePage"], "",
1948  $ilCtrl->getLinkTarget($this, "activatePage"));
1949  }
1950 
1951  $a_tpl->setVariable("PAGE_ACTIONS", $list->getHTML());
1952  }
1953 
1954  // initially opened content
1955  if ($this->getPageConfig()->getUseAttachedContent())
1956  {
1957  $entries = true;
1958  $list->addItem($lng->txt("cont_initial_attached_content"), "",
1959  $ilCtrl->getLinkTarget($this, "initialOpenedContent"));
1960  }
1961 
1962  // multi-lang actions
1963  if ($this->addMultiLangActionsAndInfo($list, $a_tpl))
1964  {
1965  $entries = true;
1966  }
1967 
1968  if ($entries)
1969  {
1970  $a_tpl->setVariable("PAGE_ACTIONS", $list->getHTML());
1971  }
1972 
1973  $lng->loadLanguageModule("content");
1974  $list = new ilAdvancedSelectionListGUI();
1975  $list->setListTitle($lng->txt("cont_edit_mode"));
1976  $list->setId("copage_ed_mode");
1977 
1978  // media mode
1979  if ($sel_media_mode == "enable")
1980  {
1981  $ilCtrl->setParameter($this, "media_mode", "disable");
1982  $list->addItem($lng->txt("cont_deactivate_media"), "",
1983  $ilCtrl->getLinkTarget($this, "setEditMode"));
1984  }
1985  else
1986  {
1987  $ilCtrl->setParameter($this, "media_mode", "enable");
1988  $list->addItem($lng->txt("cont_activate_media"), "",
1989  $ilCtrl->getLinkTarget($this, "setEditMode"));
1990  }
1991  $ilCtrl->setParameter($this, "media_mode", "");
1992 
1993  // html mode
1994  if (!$this->getPageConfig()->getPreventHTMLUnmasking())
1995  {
1996  if ($sel_html_mode == "enable")
1997  {
1998  $ilCtrl->setParameter($this, "html_mode", "disable");
1999  $list->addItem($lng->txt("cont_deactivate_html"), "",
2000  $ilCtrl->getLinkTarget($this, "setEditMode"));
2001  }
2002  else
2003  {
2004  $ilCtrl->setParameter($this, "html_mode", "enable");
2005  $list->addItem($lng->txt("cont_activate_html"), "",
2006  $ilCtrl->getLinkTarget($this, "setEditMode"));
2007  }
2008  }
2009  $ilCtrl->setParameter($this, "html_mode", "");
2010 
2011  // js mode
2012  if ($sel_js_mode == "enable")
2013  {
2014  $ilCtrl->setParameter($this, "js_mode", "disable");
2015  $list->addItem($lng->txt("cont_deactivate_js"), "",
2016  $ilCtrl->getLinkTarget($this, "setEditMode"));
2017  }
2018  else
2019  {
2020  $ilCtrl->setParameter($this, "js_mode", "enable");
2021  $list->addItem($lng->txt("cont_activate_js"), "",
2022  $ilCtrl->getLinkTarget($this, "setEditMode"));
2023  }
2024  $ilCtrl->setParameter($this, "js_mode", "");
2025 
2026  $a_tpl->setVariable("EDIT_MODE", $list->getHTML());
2027  }
2028 
2035  function addMultiLangActionsAndInfo($a_list, $a_tpl)
2036  {
2037  global $lng, $ilCtrl;
2038 
2039  $any_items = false;
2040 
2041  $cfg = $this->getPageConfig();
2042 
2043  // general multi lang support and single page mode?
2044  if ($cfg->getMultiLangSupport())
2045  {
2046  //include_once("./Services/COPage/classes/class.ilPageMultiLang.php");
2047  //$ml = new ilPageMultiLang($this->getPageObject()->getParentType(),
2048  // $this->getPageObject()->getParentId());
2049 
2050  include_once("./Services/Object/classes/class.ilObjectTranslation.php");
2051  $ot = ilObjectTranslation::getInstance($this->getPageObject()->getParentId());
2052 
2053  if (!$ot->getContentActivated())
2054  {
2055 /* if ($cfg->getSinglePageMode())
2056  {
2057  $a_list->addItem($lng->txt("cont_activate_multi_lang"), "",
2058  $ilCtrl->getLinkTargetByClass("ilpagemultilanggui", "activateMultilinguality"));
2059 
2060  $any_items = true;
2061  }*/
2062  }
2063  else
2064  {
2065  $lng->loadLanguageModule("meta");
2066 //echo $this->getPageObject()->getLanguage();
2067  if ($this->getPageObject()->getLanguage() != "-")
2068  {
2069  $l = $ot->getMasterLanguage();
2070  $a_list->addItem($lng->txt("cont_edit_language_version").": ".
2071  $lng->txt("meta_l_".$l), "",
2072  $ilCtrl->getLinkTarget($this, "editMasterLanguage"));
2073  }
2074 
2075  foreach ($ot->getLanguages() as $al => $lang)
2076  {
2077  if ($this->getPageObject()->getLanguage() != $al &&
2078  $al != $ot->getMasterLanguage())
2079  {
2080  $ilCtrl->setParameter($this, "totransl", $al);
2081  $a_list->addItem($lng->txt("cont_edit_language_version").": ".
2082  $lng->txt("meta_l_".$al), "",
2083  $ilCtrl->getLinkTarget($this, "switchToLanguage"));
2084  $ilCtrl->setParameter($this, "totransl", $_GET["totransl"]);
2085  }
2086  }
2087 
2088 /* if ($cfg->getSinglePageMode())
2089  {
2090  $a_list->addItem($lng->txt("cont_manage_multilang"), "",
2091  $ilCtrl->getLinkTargetByClass("ilpagemultilanggui", "settings"));
2092  }*/
2093 
2094  include_once("./Services/COPage/classes/class.ilPageMultiLangGUI.php");
2095  $ml_gui = new ilPageMultiLangGUI($this->getPageObject()->getParentType(),
2096  $this->getPageObject()->getParentId());
2097  $a_tpl->setVariable("MULTI_LANG_INFO", $ml_gui->getMultiLangInfo($this->getPageObject()->getLanguage()));
2098 
2099  $any_items = true;
2100  }
2101  }
2102 
2103  return $any_items;
2104  }
2105 
2106 
2110  function setEditMode()
2111  {
2112  global $ilCtrl, $ilUser;
2113 
2114  if ($_GET["media_mode"] != "")
2115  {
2116  if ($_GET["media_mode"] == "disable")
2117  {
2118  $ilUser->writePref("ilPageEditor_MediaMode", "disable");
2119  }
2120  else
2121  {
2122  $ilUser->writePref("ilPageEditor_MediaMode", "");
2123  }
2124  }
2125  if ($_GET["html_mode"] != "")
2126  {
2127  if ($_GET["html_mode"] == "disable")
2128  {
2129  $ilUser->writePref("ilPageEditor_HTMLMode", "disable");
2130  }
2131  else
2132  {
2133  $ilUser->writePref("ilPageEditor_HTMLMode", "");
2134  }
2135  }
2136  if ($_GET["js_mode"] != "")
2137  {
2138  if ($_GET["js_mode"] == "disable")
2139  {
2140  $ilUser->writePref("ilPageEditor_JavaScript", "disable");
2141  }
2142  else
2143  {
2144  $ilUser->writePref("ilPageEditor_JavaScript", "");
2145  }
2146  }
2147 
2148  $ilCtrl->redirect($this, "edit");
2149  }
2150 
2151 
2155  static function getTinyMenu($a_par_type,
2156  $a_int_links = false, $a_wiki_links = false, $a_keywords = false,
2157  $a_style_id = 0, $a_paragraph_styles = true, $a_save_return = true,
2158  $a_anchors = false, $a_save_new = true)
2159  {
2160  global $lng, $ilCtrl;
2161 
2162  $mathJaxSetting = new ilSetting("MathJax");
2163 
2164  include_once("./Services/COPage/classes/class.ilPageEditorSettings.php");
2165 
2166  include_once("./Services/UIComponent/Tooltip/classes/class.ilTooltipGUI.php");
2167 
2168  $btpl = new ilTemplate("tpl.tiny_menu.html", true, true, "Services/COPage");
2169 
2170  // debug ghost element
2171  if (DEVMODE == 1)
2172  {
2173  $btpl->touchBlock("debug_ghost");
2174  }
2175 
2176  // bullet list
2177  $btpl->touchBlock("blist_button");
2178  ilTooltipGUI::addTooltip("il_edm_blist",
2179  $lng->txt("cont_blist"),
2180  "iltinymenu_bd");
2181 
2182  // numbered list
2183  $btpl->touchBlock("nlist_button");
2184  ilTooltipGUI::addTooltip("il_edm_nlist",
2185  $lng->txt("cont_nlist"),
2186  "iltinymenu_bd");
2187 
2188  // list indent
2189  $btpl->touchBlock("list_indent");
2190  ilTooltipGUI::addTooltip("ilIndentBut",
2191  $lng->txt("cont_list_indent"),
2192  "iltinymenu_bd");
2193 
2194  // list outdent
2195  $btpl->touchBlock("list_outdent");
2196  ilTooltipGUI::addTooltip("ilOutdentBut",
2197  $lng->txt("cont_list_outdent"),
2198  "iltinymenu_bd");
2199 
2200  if ($a_int_links)
2201  {
2202  $btpl->touchBlock("bb_ilink_button");
2203  ilTooltipGUI::addTooltip("iosEditInternalLinkTrigger", $lng->txt("cont_link_to_internal"),
2204  "iltinymenu_bd");
2205  }
2206  ilTooltipGUI::addTooltip("il_edm_xlink", $lng->txt("cont_link_to_external"),
2207  "iltinymenu_bd");
2208 
2209  // remove format
2210  $btpl->touchBlock("rformat_button");
2211  ilTooltipGUI::addTooltip("il_edm_rformat", $lng->txt("cont_remove_format"),
2212  "iltinymenu_bd");
2213 
2214  if ($a_paragraph_styles)
2215  {
2216  // new paragraph
2217  $btpl->setCurrentBlock("new_par");
2218  $btpl->setVariable("IMG_NEWPAR", "+");
2219  $btpl->parseCurrentBlock();
2220  ilTooltipGUI::addTooltip("il_edm_newpar", $lng->txt("cont_insert_new_paragraph"),
2221  "iltinymenu_bd");
2222 
2223  $btpl->setCurrentBlock("par_edit");
2224  $btpl->setVariable("TXT_PAR_FORMAT", $lng->txt("cont_par_format"));
2225  include_once("./Services/COPage/classes/class.ilPCParagraphGUI.php");
2226  $btpl->setVariable("STYLE_SELECTOR", ilPCParagraphGUI::getStyleSelector($a_selected,
2227  ilPCParagraphGUI::_getCharacteristics($a_style_id), true));
2228 
2229  ilTooltipGUI::addTooltip("ilAdvSelListAnchorText_style_selection",
2230  $lng->txt("cont_paragraph_styles"), "iltinymenu_bd");
2231 
2232  $btpl->parseCurrentBlock();
2233  }
2234 
2235  if ($a_keywords)
2236  {
2237  $btpl->setCurrentBlock("bb_kw_button");
2238  $btpl->setVariable("CC_KW", "kw");
2239  $btpl->parseCurrentBlock();
2240  ilTooltipGUI::addTooltip("il_edm_kw", $lng->txt("cont_text_keyword"),
2241  "iltinymenu_bd");
2242 
2243  }
2244 
2245  if ($a_wiki_links)
2246  {
2247  $btpl->setCurrentBlock("bb_wikilink_button2");
2248  $btpl->setVariable("TXT_WIKI_BUTTON2", $lng->txt("obj_wiki"));
2249  $btpl->setVariable("WIKI_BUTTON2_URL", $ilCtrl->getLinkTargetByClass("ilwikipagegui", ""));
2250  $btpl->parseCurrentBlock();
2251  ilTooltipGUI::addTooltip("il_edm_wlinkd", $lng->txt("cont_wiki_link_dialog"),
2252  "iltinymenu_bd");
2253 
2254  $btpl->setCurrentBlock("bb_wikilink_button");
2255  $btpl->setVariable("TXT_WLN2", $lng->txt("obj_wiki"));
2256  $btpl->parseCurrentBlock();
2257  ilTooltipGUI::addTooltip("il_edm_wlink", $lng->txt("cont_link_to_wiki"),
2258  "iltinymenu_bd");
2259  }
2260 
2261  $aset = new ilSetting("adve");
2262 
2263  include_once("./Services/COPage/classes/class.ilPageContentGUI.php");
2264  foreach (ilPageContentGUI::_getCommonBBButtons() as $c => $st)
2265  {
2266  // these are handled via drop down now...
2267  if (in_array($c, array("com", "quot", "acc", "code")))
2268  {
2269  continue;
2270  }
2272  $a_par_type, "active_".$c, true))
2273  {
2274  $cc_code = $c;
2275  if ($aset->get("use_physical"))
2276  {
2277  $cc_code = str_replace(array("str", "emp", "imp"), array("B", "I", "U"), $cc_code);
2278  }
2279 
2280  if ($c != "tex" || $mathJaxSetting->get("enable") || defined("URL_TO_LATEX"))
2281  {
2282  $btpl->setCurrentBlock("bb_".$c."_button");
2283  $btpl->setVariable("CC_".strtoupper($c), $cc_code);
2284  $btpl->parseCurrentBlock();
2285  ilTooltipGUI::addTooltip("il_edm_cc_".$c,
2286  $lng->txt("cont_cc_".$c),
2287  "iltinymenu_bd");
2288 
2289 // $btpl->setVariable("TXT_".strtoupper($c), $this->lng->txt("cont_text_".$c));
2290  }
2291  }
2292  }
2293 
2294  if ($mathJaxSetting->get("enable") || defined("URL_TO_LATEX"))
2295  {
2296  ilTooltipGUI::addTooltip("il_edm_tex", $lng->txt("cont_tex"),
2297  "iltinymenu_bd");
2298  }
2299  ilTooltipGUI::addTooltip("il_edm_fn", $lng->txt("cont_fn"),
2300  "iltinymenu_bd");
2301 
2302  include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
2303  $sdd = new ilAdvancedSelectionListGUI();
2304  $sdd->setPullRight(false);
2305  $sdd->setListTitle($lng->txt("save")."...");
2306 
2307  if ($a_save_return)
2308  {
2309  $btpl->setCurrentBlock("save_return");
2310  $btpl->setVariable("TXT_SAVE_RETURN", $lng->txt("save_return"));
2311  $btpl->parseCurrentBlock();
2312  $sdd->addItem($lng->txt("save_return"), "", "#", "", "", "", "", "", "ilCOPage.cmdSaveReturn(false); return false;");
2313  }
2314 
2315  if ($a_save_new)
2316  {
2317  $btpl->setCurrentBlock("save_new");
2318  $btpl->setVariable("TXT_SAVE_NEW", $lng->txt("save_new"));
2319  $btpl->parseCurrentBlock();
2320  $sdd->addItem($lng->txt("save_new"), "", "#", "", "", "", "", "", "ilCOPage.cmdSaveReturn(true); return false;");
2321  }
2322 
2323  $sdd->addItem($lng->txt("save"), "", "#", "", "", "", "", "", "ilCOPage.cmdSave(null); return false;");
2324  $sdd->addItem($lng->txt("cancel"), "", "#", "", "", "", "", "", "ilCOPage.cmdCancel(); return false;");
2325 
2326  if ($a_anchors)
2327  {
2328  $btpl->setCurrentBlock("bb_anc_button");
2329  $btpl->setVariable("CC_ANC", "anc");
2330  $btpl->parseCurrentBlock();
2331  ilTooltipGUI::addTooltip("il_edm_anc", $lng->txt("cont_anchor"),
2332  "iltinymenu_bd");
2333  }
2334 
2335  $btpl->setVariable("SAVE_DROPDOWN", $sdd->getHTML());
2336 
2337 /* // footnote
2338  $btpl->setVariable("TXT_ILN", $this->lng->txt("cont_text_iln"));
2339  $btpl->setVariable("TXT_BB_TIP", $this->lng->txt("cont_bb_tip"));
2340  $btpl->setVariable("TXT_WLN", $lng->txt("wiki_wiki_page"));
2341 */
2342 // $btpl->setVariable("PAR_TA_NAME", $a_ta_name);
2343 
2344  $btpl->setVariable("TXT_SAVE", $lng->txt("save"));
2345  $btpl->setVariable("TXT_CANCEL", $lng->txt("cancel"));
2346 
2347  $btpl->setVariable("TXT_CHAR_FORMAT", $lng->txt("cont_char_format"));
2348  $btpl->setVariable("TXT_LISTS", $lng->txt("cont_lists"));
2349  $btpl->setVariable("TXT_LINKS", $lng->txt("cont_links"));
2350  $btpl->setVariable("TXT_MORE_FUNCTIONS", $lng->txt("cont_more_functions"));
2351  $btpl->setVariable("TXT_SAVING", $lng->txt("cont_saving"));
2352 
2353  include_once("./Services/COPage/classes/class.ilPCParagraphGUI.php");
2354  $btpl->setVariable("CHAR_STYLE_SELECTOR", ilPCParagraphGUI::getCharStyleSelector($a_par_type));
2355  ilTooltipGUI::addTooltip("ilAdvSelListAnchorElement_char_style_selection",
2356  $lng->txt("cont_more_character_styles"), "iltinymenu_bd");
2357 
2358  return $btpl->get();
2359  }
2360 
2365  {
2366  global $ilCtrl;
2367 
2368  $int_links = $this->getPageObject()->getInternalLinks();
2369 //var_dump($int_links);
2370  $link_info = "<IntLinkInfos>";
2371  $targetframe = "None";
2372  foreach ($int_links as $int_link)
2373  {
2374  $target = $int_link["Target"];
2375  if (substr($target, 0, 4) == "il__")
2376  {
2377  $target_arr = explode("_", $target);
2378  $target_id = $target_arr[count($target_arr) - 1];
2379  $type = $int_link["Type"];
2380 
2381  $targetframe = ($int_link["TargetFrame"] != "")
2382  ? $int_link["TargetFrame"]
2383  : "None";
2384 
2385  $ltarget="_top";
2386  if ($targetframe != "None")
2387  {
2388  $ltarget="_blank";
2389  }
2390 
2391  // anchor
2392  $anc = $anc_add = "";
2393  if ($int_link["Anchor"] != "")
2394  {
2395  $anc = $int_link["Anchor"];
2396  $anc_add = "_".rawurlencode($int_link["Anchor"]);
2397  }
2398 
2399  $href = "";
2400  switch($type)
2401  {
2402  case "PageObject":
2403  case "StructureObject":
2405  if ($type == "PageObject")
2406  {
2407  $href = "./goto.php?target=pg_".$target_id.$anc_add;
2408  }
2409  else
2410  {
2411  $href = "./goto.php?target=st_".$target_id;
2412  }
2413  break;
2414 
2415  case "GlossaryItem":
2416  if ($targetframe == "None")
2417  {
2418  $targetframe = "Glossary";
2419  }
2420  $href = "./goto.php?target=git_".$target_id;
2421  break;
2422 
2423  case "MediaObject":
2424  $ilCtrl->setParameter($this, "mob_id", $target_id);
2425  //$ilCtrl->setParameter($this, "pg_id", $this->obj->getId());
2426  $href = $ilCtrl->getLinkTarget($this, "displayMedia");
2427  $ilCtrl->setParameter($this, "mob_id", "");
2428  break;
2429 
2430  case "WikiPage":
2431  include_once("./Modules/Wiki/classes/class.ilWikiPage.php");
2433  break;
2434 
2435  case "RepositoryItem":
2436  $obj_type = ilObject::_lookupType($target_id, true);
2438  $href = "./goto.php?target=".$obj_type."_".$target_id;
2439  break;
2440 
2441 
2442  }
2443  $anc_par = 'Anchor="'.$anc.'"';
2444  $link_info.="<IntLinkInfo Target=\"$target\" Type=\"$type\" ".$anc_par." ".
2445  "TargetFrame=\"$targetframe\" LinkHref=\"$href\" LinkTarget=\"$ltarget\" />";
2446  }
2447  }
2448  $link_info.= "</IntLinkInfos>";
2449  $this->setLinkXML($link_info);
2450  }
2451 
2455  function downloadFile()
2456  {
2457  $this->obj->buildDom();
2458 
2459  include_once("./Services/COPage/classes/class.ilPCFileList.php");
2460  $files = ilPCFileList::collectFileItems($this->obj, $this->obj->getDomDoc());
2461 
2462  $file = explode("_", $_GET["file_id"]);
2463  require_once("./Modules/File/classes/class.ilObjFile.php");
2464  $file_id = $file[count($file) - 1];
2465 
2466  // file must be in page
2467  if (!in_array($file_id, $files))
2468  {
2469  exit;
2470  }
2471  $fileObj =& new ilObjFile($file_id, false);
2472  $fileObj->sendFile();
2473  exit;
2474  }
2475 
2480  {
2481  $this->displayMedia(true);
2482  }
2483 
2487  function displayMedia($a_fullscreen = false)
2488  {
2489  global $tpl;
2490 
2491  $tpl = new ilTemplate("tpl.fullscreen.html", true, true, "Modules/LearningModule");
2492  $tpl->setCurrentBlock("ilMedia");
2493 
2494  //$int_links = $page_object->getInternalLinks();
2495  $med_links = ilMediaItem::_getMapAreasIntLinks($_GET["mob_id"]);
2496 
2497  // @todo
2498  //$link_xml = $this->getLinkXML($med_links, $this->getLayoutLinkTargets());
2499 
2500  require_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
2501  $media_obj = new ilObjMediaObject($_GET["mob_id"]);
2502  require_once("./Services/COPage/classes/class.ilPageObject.php");
2503  $pg_obj = $this->getPageObject();
2504  $pg_obj->buildDom();
2505 
2506  if (!empty ($_GET["pg_id"]))
2507  {
2508  $xml = "<dummy>";
2509  $xml.= $pg_obj->getMediaAliasElement($_GET["mob_id"]);
2510  $xml.= $media_obj->getXML(IL_MODE_OUTPUT);
2511  $xml.= $link_xml;
2512  $xml.="</dummy>";
2513  }
2514  else
2515  {
2516  $xml = "<dummy>";
2517  $xml.= $media_obj->getXML(IL_MODE_ALIAS);
2518  $xml.= $media_obj->getXML(IL_MODE_OUTPUT);
2519  $xml.= $link_xml;
2520  $xml.="</dummy>";
2521  }
2522 
2523  $xsl = file_get_contents("./Services/COPage/xsl/page.xsl");
2524  $args = array( '/_xml' => $xml, '/_xsl' => $xsl );
2525  $xh = xslt_create();
2526 
2527  $mode = "media";
2528  if ($a_fullscreen)
2529  {
2530  $mode = "fullscreen";
2531  }
2532 
2533 //echo "<b>XML:</b>".htmlentities($xml);
2534  // determine target frames for internal links
2535  $wb_path = ilUtil::getWebspaceDir("output")."/";
2536  $enlarge_path = ilUtil::getImagePath("enlarge.svg");
2537  $params = array ('mode' => $mode, 'enlarge_path' => $enlarge_path,
2538  'link_params' => "ref_id=".$_GET["ref_id"],'fullscreen_link' => "",
2539  'ref_id' => $_GET["ref_id"], 'webspace_path' => $wb_path);
2540  $output = xslt_process($xh,"arg:/_xml","arg:/_xsl",NULL,$args, $params);
2541 //echo "<br><br>".htmlentities($output);
2542  //echo xslt_error($xh);
2543  xslt_free($xh);
2544 
2545  // unmask user html
2546  $tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
2548  $tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
2549  $tpl->setVariable("MEDIA_CONTENT", $output);
2550 
2551  // add js
2552  include_once("./Services/MediaObjects/classes/class.ilObjMediaObjectGUI.php");
2554  $tpl->fillJavaScriptFiles();
2555  $tpl->fillCssFiles();
2556 
2557  echo $tpl->get();
2558  exit;
2559  }
2560 
2565  {
2566  $pg_obj = $this->getPageObject();
2567  $pg_obj->send_paragraph($_GET["par_id"], $_GET["downloadtitle"]);
2568  }
2569 
2573  function insertContentIncludes($a_html)
2574  {
2575  global $ilCtrl, $lng;
2576 
2577  $c_pos = 0;
2578  $start = strpos($a_html, "{{{{{ContentInclude;");
2579  if (is_int($start))
2580  {
2581  $end = strpos($a_html, "}}}}}", $start);
2582  }
2583  $i = 1;
2584  while ($end > 0)
2585  {
2586  $param = substr($a_html, $start + 20, $end - $start - 20);
2587  $param = explode(";", $param);
2588 
2589  if ($param[0] == "mep" && is_numeric($param[1]) && $param[2] <= 0)
2590  {
2591  include_once("./Modules/MediaPool/classes/class.ilMediaPoolPageGUI.php");
2592 
2593  if (ilMediaPoolPage::_exists($param[1]))
2594  {
2595  $page_gui = new ilMediaPoolPageGUI($param[1], 0, true, "-");
2596  if ($this->getOutputMode() != "offline")
2597  {
2598  $page_gui->setFileDownloadLink($this->determineFileDownloadLink());
2599  $page_gui->setFullscreenLink($this->determineFullscreenLink());
2600  $page_gui->setSourceCodeDownloadScript($this->determineSourcecodeDownloadScript());
2601  }
2602  else
2603  {
2604  $page_gui->setOutputMode(IL_PAGE_OFFLINE);
2605  }
2606 
2607  $html = $page_gui->getRawContent();
2608  }
2609  else
2610  {
2611  if ($this->getOutputMode() == "edit")
2612  {
2613  $html = "// ".$lng->txt("cont_missing_snippet")." //";
2614  }
2615  }
2616  $h2 = substr($a_html, 0, $start).
2617  $html.
2618  substr($a_html, $end + 5);
2619  $a_html = $h2;
2620  $i++;
2621  }
2622  $start = strpos($a_html, "{{{{{ContentInclude;", $start + 5);
2623  $end = 0;
2624  if (is_int($start))
2625  {
2626  $end = strpos($a_html, "}}}}}", $start);
2627  }
2628  }
2629  return $a_html;
2630  }
2631 
2638  function insertPageToc($a_output)
2639  {
2640  global $lng;
2641 
2642  include_once("./Services/Utilities/classes/class.ilStr.php");
2643 
2644  // extract all headings
2645  $offsets = ilStr::strPosAll($a_output, "ilPageTocH");
2646  $page_heads = array();
2647  foreach ($offsets as $os)
2648  {
2649  $level = (int) substr($a_output, $os + 10, 1);
2650  if (in_array($level, array(1,2,3)))
2651  {
2652  $anchor = str_replace("TocH", "TocA",
2653  substr($a_output, $os, strpos($a_output, "<", $os) - $os - 3)
2654  );
2655 
2656  // get heading
2657  $tag_start = stripos($a_output, "<h".$level." ", $os);
2658  $tag_end = stripos($a_output, "</h".$level.">", $tag_start);
2659  $head = substr($a_output, $tag_start, $tag_end - $tag_start);
2660 
2661  // get headings text
2662  $text_start = stripos($head, ">") + 1;
2663  $text_end = strripos($head, "<!--", $text_start);
2664  $text = substr($head, $text_start, $text_end - $text_start);
2665  $page_heads[] = array("level" => $level, "text" => $text,
2666  "anchor" => $anchor);
2667  }
2668  }
2669 
2670  if (count($page_heads) > 1)
2671  {
2672  include_once("./Services/UIComponent/NestedList/classes/class.ilNestedList.php");
2673  $list = new ilNestedList();
2674  $list->setAutoNumbering(true);
2675  $list->setListClass("ilc_page_toc_PageTOCList");
2676  $list->setItemClass("ilc_page_toc_PageTOCItem");
2677  $i = 0;
2678  $c_depth = 1;
2679  $c_par[1] = 0;
2680  $c_par[2] = 0;
2681  $nr[1] = 1;
2682  $nr[2] = 1;
2683  $nr[3] = 1;
2684  foreach ($page_heads as $ind => $h)
2685  {
2686  $i++;
2687  $par = 0;
2688 
2689  // check if we have a parent for one level up
2690  $par = 0;
2691  if ($h["level"] == 2 && $c_par[1] > 0)
2692  {
2693  $par = $c_par[1];
2694  }
2695  if ($h["level"] == 3 && $c_par[2] > 0)
2696  {
2697  $par = $c_par[2];
2698  }
2699 
2700  $h["text"] = str_replace("<!--PageTocPH-->", "", $h["text"]);
2701 
2702  // add the list node
2703  $list->addListNode(
2704  "<a href='#".$h["anchor"]."' class='ilc_page_toc_PageTOCLink'>".$h["text"]."</a>",
2705  $i, $par);
2706 
2707  // set the node as current parent of the level
2708  if ($h["level"] == 1)
2709  {
2710  $c_par[1] = $i;
2711  $c_par[2] = 0;
2712  }
2713  if ($h["level"] == 2)
2714  {
2715  $c_par[2] = $i;
2716  }
2717  }
2718 
2719  $tpl = new ilTemplate("tpl.page_toc.html", true, true,
2720  "Services/COPage");
2721  $tpl->setVariable("PAGE_TOC", $list->getHTML());
2722  $tpl->setVariable("TXT_PAGE_TOC", $lng->txt("cont_page_toc"));
2723  $tpl->setVariable("TXT_HIDE", $lng->txt("hide"));
2724  $tpl->setVariable("TXT_SHOW", $lng->txt("show"));
2725 
2726  $a_output = str_replace("{{{{{PageTOC}}}}}",
2727  $tpl->get(), $a_output);
2728  $numbers = $list->getNumbers();
2729 
2730  if (count($numbers) > 0)
2731  {
2732  include_once("./Services/Utilities/classes/class.ilStr.php");
2733  foreach ($numbers as $n)
2734  {
2735  $a_output =
2736  ilStr::replaceFirsOccurence("<!--PageTocPH-->", $n." ", $a_output);
2737  }
2738  }
2739  }
2740  else
2741  {
2742  $a_output = str_replace("{{{{{PageTOC}}}}}",
2743  "", $a_output);
2744  }
2745 
2746  return $a_output;
2747  }
2748 
2755  function insertResources($a_output)
2756  {
2757  // this is edit mode only
2758 
2759  if ($this->getEnablePCType("Resources") &&
2760  ($this->getOutputMode() == "edit" || $this->getOutputMode() == "preview"))
2761  {
2762  include_once("./Services/COPage/classes/class.ilPCResourcesGUI.php");
2763  $a_output = ilPCResourcesGUI::insertResourcesIntoPageContent($a_output, $this->getOutputMode());
2764  }
2765  return $a_output;
2766  }
2767 
2768 
2769 
2776  function insertAdvTrigger($a_output)
2777  {
2778  global $lng;
2779 
2780  if (!$this->getAbstractOnly())
2781  {
2782  $a_output = str_replace("{{{{{LV_show_adv}}}}}",
2783  $lng->txt("cont_show_adv"), $a_output);
2784  $a_output = str_replace("{{{{{LV_hide_adv}}}}}",
2785  $lng->txt("cont_hide_adv"), $a_output);
2786  }
2787  else
2788  {
2789  $a_output = str_replace("{{{{{LV_show_adv}}}}}",
2790  "", $a_output);
2791  $a_output = str_replace("{{{{{LV_hide_adv}}}}}",
2792  "", $a_output);
2793  }
2794 
2795  return $a_output;
2796  }
2797 
2798 
2803  function postOutputProcessing($a_output)
2804  {
2805  return $a_output;
2806  }
2807 
2811  function insertHelp($a_tpl)
2812  {
2813  global $lng;
2814 
2815  $a_tpl->setCurrentBlock("help");
2816  $a_tpl->setVariable("TXT_ADD_EL", $lng->txt("cont_add_elements"));
2817  include_once("./Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php");
2818  $a_tpl->setVariable("PLUS", ilGlyphGUI::get(ilGlyphGUI::ADD));
2819  $a_tpl->setVariable("DRAG_ARROW", ilGlyphGUI::get(ilGlyphGUI::DRAG));
2820  $a_tpl->setVariable("TXT_DRAG", $lng->txt("cont_drag_and_drop_elements"));
2821  $a_tpl->setVariable("TXT_SEL", $lng->txt("cont_double_click_to_delete"));
2822  $a_tpl->parseCurrentBlock();
2823  }
2824 
2828  function previewHistory()
2829  {
2830  $this->preview();
2831  }
2832 
2836  function preview()
2837  {
2838  global $tree;
2840  return $this->showPage();
2841  }
2842 
2846  function edit()
2847  {
2848  global $tree, $lng, $ilCtrl, $ilSetting, $ilUser, $ilHelp;
2849 
2850  // editing allowed?
2851  if (!$this->getEnableEditing())
2852  {
2853  ilUtil::sendFailure($lng->txt("permission_denied"), true);
2854  $ilCtrl->redirect($this, "preview");
2855  }
2856 
2857  // not so nive workaround for container pages, bug #0015831
2858  $ptype = $this->getParentType();
2859  if ($ptype == "cont" && $_GET["ref_id"] > 0)
2860  {
2861  $ptype = ilObject::_lookupType((int) $_GET["ref_id"], true);
2862  }
2863  $ilHelp->setScreenId("edit_".$ptype);
2864 
2865  require_once 'Services/Captcha/classes/class.ilCaptchaUtil.php';
2866  if(
2867  $ilUser->isAnonymous() &&
2868  !$ilUser->isCaptchaVerified() &&
2869  ilCaptchaUtil::isActiveForWiki()
2870  )
2871  {
2872  $form = $this->initCaptchaForm();
2873  if($_POST['captcha_code'] && $form->checkInput())
2874  {
2875  $ilUser->setCaptchaVerified(true);
2876  }
2877  else
2878  {
2879  return $form->getHTML();
2880  }
2881  }
2882 
2883  // edit lock
2884  if (!$this->getPageObject()->getEditLock())
2885  {
2886  include_once("./Services/User/classes/class.ilUserUtil.php");
2887  $info = $lng->txt("content_no_edit_lock");
2888  $lock = $this->getPageObject()->getEditLockInfo();
2889  $info .= "</br>" . $lng->txt("content_until") . ": " .
2890  ilDatePresentation::formatDate(new ilDateTime($lock["edit_lock_until"], IL_CAL_UNIX));
2891  $info .= "</br>" . $lng->txt("obj_usr") . ": " .
2892  ilUserUtil::getNamePresentation($lock["edit_lock_user"]);
2893  if (!$ilCtrl->isAsynch())
2894  {
2895  ilUtil::sendInfo($info);
2896  return "";
2897  }
2898  else
2899  {
2900  echo $this->tpl->getMessageHTML($info);
2901  exit;
2902  }
2903  }
2904  else
2905  {
2906  $aset = new ilSetting("adve");
2907 
2908  $min = (int) $aset->get("block_mode_minutes") ;
2909  if ($min > 0)
2910  {
2911  include_once("./Services/User/classes/class.ilUserUtil.php");
2912  $lock = $this->getPageObject()->getEditLockInfo();
2913  $info = $lng->txt("cont_got_lock_until");
2914  $info = str_replace("%1", ilDatePresentation::formatDate(new ilDateTime($lock["edit_lock_until"],IL_CAL_UNIX)), $info);
2915  //$info.= "</br>".$lng->txt("content_until").": ".
2916  // ilDatePresentation::formatDate(new ilDateTime($lock["edit_lock_until"],IL_CAL_UNIX));
2917  //$info.= "</br>".$lng->txt("obj_usr").": ".
2918  // ilUserUtil::getNamePresentation($lock["edit_lock_user"]);
2919  include_once("./Services/UIComponent/Button/classes/class.ilLinkButton.php");
2920  $but = ilLinkButton::getInstance();
2921  $but->setCaption("cont_finish_editing");
2922  $but->setUrl($ilCtrl->getLinkTarget($this, "releasePageLock"));
2923  $info = str_replace("%2", $but->render(), $info);
2924  ilUtil::sendInfo($info);
2925  }
2926  }
2927 
2928  $this->setOutputMode(IL_PAGE_EDIT);
2929 
2930  $html = $this->showPage();
2931 
2932  if ($this->isEnabledNotes())
2933  {
2934  $html.= "<br /><br />".$this->getNotesHTML();
2935  }
2936 
2937  return $html;
2938  }
2939 
2947  {
2948  global $tpl;
2949 
2950 // 'pl_hier_id' => string '2_1_1_1' (length=7)
2951 // 'pl_pc_id' => string '1f77eb1d8a478497d69b99d938fda8f' (length=31)
2952  $html = $this->edit();
2953 
2954  $tpl->addOnLoadCode("ilCOPage.insertJSAtPlaceholder('".
2955  $_GET["pl_hier_id"].":".$_GET["pl_pc_id"].
2956  "');", 3);
2957 
2958  return $html;
2959  }
2960 
2964  public function initCaptchaForm()
2965  {
2970  global $lng, $ilCtrl;
2971 
2972  require_once 'Services/Form/classes/class.ilPropertyFormGUI.php';
2973  $form = new ilPropertyFormGUI();
2974 
2975  require_once 'Services/Captcha/classes/class.ilCaptchaInputGUI.php';
2976  $ci = new ilCaptchaInputGUI($lng->txt('cont_captcha_code'), 'captcha_code');
2977  $ci->setRequired(true);
2978  $form->addItem($ci);
2979 
2980  $form->addCommandButton('edit', $lng->txt('ok'));
2981 
2982  $form->setTitle($lng->txt('cont_captcha_verification'));
2983  $form->setFormAction($ilCtrl->getFormAction($this));
2984 
2985  return $form;
2986  }
2987 
2988  /*
2989  * presentation
2990  */
2992  {
2993  global $tree;
2994  $this->setOutputMode($a_mode);
2995 
2996  return $this->showPage();
2997  }
2998 
2999  function getHTML()
3000  {
3001  $this->getTabs("preview");
3002  return $this->showPage();
3003  }
3004 
3008  function showMediaFullscreen($a_style_id = 0)
3009  {
3010  $this->tpl = new ilTemplate("tpl.fullscreen.html", true, true, "Services/COPage");
3011  $this->tpl->setCurrentBlock("ContentStyle");
3012  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", 0);
3013  $this->tpl->parseCurrentBlock();
3014 
3015  $this->tpl->setVariable("PAGETITLE", " - ".ilObject::_lookupTitle($_GET["mob_id"]));
3016  $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
3017  $this->tpl->setCurrentBlock("ilMedia");
3018 
3019  require_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
3020  $media_obj =& new ilObjMediaObject($_GET["mob_id"]);
3021  if (!empty ($_GET["pg_id"]))
3022  {
3023  include_once("./Services/COPage/classes/class.ilPageObjectFactory.php");
3024  $pg_obj = ilPageObjectFactory::getInstance($this->obj->getParentType(), $_GET["pg_id"]);
3025  $pg_obj->buildDom();
3026 
3027  $xml = "<dummy>";
3028  // todo: we get always the first alias now (problem if mob is used multiple
3029  // times in page)
3030  $xml.= $pg_obj->getMediaAliasElement($_GET["mob_id"]);
3031  $xml.= $media_obj->getXML(IL_MODE_OUTPUT);
3032  $xml.="</dummy>";
3033  }
3034  else
3035  {
3036  $xml = "<dummy>";
3037  $xml.= $media_obj->getXML(IL_MODE_ALIAS);
3038  $xml.= $media_obj->getXML(IL_MODE_OUTPUT);
3039  $xml.="</dummy>";
3040  }
3041 
3042 //echo htmlentities($xml); exit;
3043 
3044  $xsl = file_get_contents("./Services/COPage/xsl/page.xsl");
3045  $args = array( '/_xml' => $xml, '/_xsl' => $xsl );
3046  $xh = xslt_create();
3047 
3048 //echo "<b>XML:</b>".htmlentities($xml);
3049  // determine target frames for internal links
3050  //$pg_frame = $_GET["frame"];
3051  $wb_path = ilUtil::getWebspaceDir("output")."/";
3052  $mode = "fullscreen";
3053  $params = array ('mode' => $mode, 'webspace_path' => $wb_path);
3054  $output = xslt_process($xh,"arg:/_xml","arg:/_xsl",NULL,$args, $params);
3055  echo xslt_error($xh);
3056  xslt_free($xh);
3057 
3058  // unmask user html
3059  $this->tpl->setVariable("MEDIA_CONTENT", $output);
3060  }
3061 
3067  function displayValidationError($a_error)
3068  {
3069  if(is_array($a_error))
3070  {
3071  $error_str = "<b>Error(s):</b><br>";
3072  foreach ($a_error as $error)
3073  {
3074  $err_mess = implode($error, " - ");
3075  if (!is_int(strpos($err_mess, ":0:")))
3076  {
3077  $error_str .= htmlentities($err_mess)."<br />";
3078  }
3079  }
3080  $this->tpl->setVariable("MESSAGE", $error_str);
3081  }
3082  }
3083 
3087  function history()
3088  {
3089  global $tpl, $lng, $ilAccess;
3090 
3091  if (!$this->getEnableEditing())
3092  {
3093  return;
3094  }
3095 
3096  $tpl->addJavaScript("./Services/COPage/js/page_history.js");
3097 
3098  include_once("./Services/COPage/classes/class.ilPageHistoryTableGUI.php");
3099  $table_gui = new ilPageHistoryTableGUI($this, "history");
3100  $table_gui->setId("hist_table");
3101  $entries = $this->getPageObject()->getHistoryEntries();
3102  $entries[] = array('page_id' => $this->getPageObject()->getId(),
3103  'parent_type' => $this->getPageObject()->getParentType(),
3104  'hdate' => $this->getPageObject()->getLastChange(),
3105  'parent_id' => $this->getPageObject()->getParentId(),
3106  'nr' => 0,
3107  'sortkey' => 999999,
3108  'user' => $this->getPageObject()->last_change_user);
3109  $table_gui->setData($entries);
3110  return $table_gui->getHTML();
3111  }
3112 
3117  {
3118  global $tpl, $lng, $ilAccess, $ilCtrl;
3119 
3120  if (!$this->getEnableEditing())
3121  {
3122  return;
3123  }
3124 
3125  include_once("Services/Utilities/classes/class.ilConfirmationGUI.php");
3126  $c_gui = new ilConfirmationGUI();
3127 
3128  // set confirm/cancel commands
3129  $ilCtrl->setParameter($this, "rollback_nr", $_GET["old_nr"]);
3130  $c_gui->setFormAction($ilCtrl->getFormAction($this, "rollback"));
3131  $c_gui->setHeaderText($lng->txt("cont_rollback_confirmation"));
3132  $c_gui->setCancel($lng->txt("cancel"), "history");
3133  $c_gui->setConfirm($lng->txt("confirm"), "rollback");
3134 
3135  $hentry = $this->obj->getHistoryEntry($_GET["old_nr"]);
3136 
3137  $c_gui->addItem("id[]", $_GET["old_nr"],
3139 
3140  $tpl->setContent($c_gui->getHTML());
3141  }
3142 
3146  function rollback()
3147  {
3148  global $ilCtrl;
3149 
3150  if (!$this->getEnableEditing())
3151  {
3152  return;
3153  }
3154 
3155  $hentry = $this->obj->getHistoryEntry($_GET["rollback_nr"]);
3156 
3157  if ($hentry["content"] != "")
3158  {
3159  $this->obj->setXMLContent($hentry["content"]);
3160  $this->obj->buildDom(true);
3161  if ($this->obj->update())
3162  {
3163  $ilCtrl->redirect($this, "history");
3164  }
3165  }
3166  $ilCtrl->redirect($this, "history");
3167  }
3168 
3176  {
3177  global $ilHelp;
3178 
3179  $ilHelp->setScreenIdComponent("copg");
3180  }
3181 
3187  function getTabs($a_activate = "")
3188  {
3189  global $ilTabs, $ilCtrl, $ilUser;
3190 
3191  $this->setScreenIdComponent();
3192 
3193  if (!$this->getEnabledTabs())
3194  {
3195  return;
3196  }
3197 
3198 //echo "-".$ilCtrl->getNextClass()."-".$ilCtrl->getCmd()."-";
3199  // back to upper context
3200 
3201  if (!$this->getEditPreview())
3202  {
3203  $ilTabs->addTarget("pg", $ilCtrl->getLinkTarget($this, "preview")
3204  , array("", "preview"));
3205 
3206  if ($this->getEnableEditing())
3207  {
3208  $ilTabs->addTarget("edit", $ilCtrl->getLinkTarget($this, "edit")
3209  , array("", "edit"));
3210  }
3211  }
3212  else
3213  {
3214  if ($this->getEnableEditing())
3215  {
3216  $ilTabs->addTarget("edit", $ilCtrl->getLinkTarget($this, "edit")
3217  , array("", "edit"));
3218  }
3219 
3220  $ilTabs->addTarget("cont_preview", $ilCtrl->getLinkTarget($this, "preview")
3221  , array("", "preview"));
3222  }
3223 
3224  //$tabs_gui->addTarget("properties", $this->ctrl->getLinkTarget($this, "properties")
3225  // , "properties", get_class($this));
3226 
3227  if ($this->use_meta_data)
3228  {
3229  $ilTabs->addTarget("meta_data",
3230  $this->ctrl->getLinkTargetByClass('ilmdeditorgui',''),
3231  "", "ilmdeditorgui");
3232  }
3233 
3234  $lm_set = new ilSetting("lm");
3235 
3236  if ($this->getEnableEditing() && $lm_set->get("page_history", 1))
3237  {
3238  $ilTabs->addTarget("history", $this->ctrl->getLinkTarget($this, "history")
3239  , "history", get_class($this));
3240  if ($_GET["history_mode"] == "1" || $this->ctrl->getCmd() == "compareVersion")
3241  {
3242  $ilTabs->activateTab("history");
3243  }
3244  }
3245 
3246 /* $tabs = $this->ctrl->getTabs();
3247  foreach ($tabs as $tab)
3248  {
3249  $tabs_gui->addTarget($tab["lang_var"], $tab["link"]
3250  , $tab["cmd"], $tab["class"]);
3251  }
3252 */
3253  if ($this->getEnableEditing() && $ilUser->getId() != ANONYMOUS_USER_ID)
3254  {
3255  $ilTabs->addTarget("clipboard", $this->ctrl->getLinkTargetByClass("ilEditClipboardGUI", "view")
3256  , "view", "ilEditClipboardGUI");
3257  }
3258 
3259  if ($this->getPageConfig()->getEnableScheduledActivation())
3260  {
3261  $ilTabs->addTarget("cont_activation", $this->ctrl->getLinkTarget($this, "editActivation"),
3262  "editActivation", get_class($this));
3263  }
3264 
3265  if ($this->getEnabledNews())
3266  {
3267  $ilTabs->addTarget("news",
3268  $this->ctrl->getLinkTargetByClass("ilnewsitemgui", "editNews"),
3269  "", "ilnewsitemgui");
3270  }
3271 
3272  // external hook to add tabs
3273  if (is_array($this->tab_hook))
3274  {
3275  $func = $this->tab_hook["func"];
3276  $this->tab_hook["obj"]->$func();
3277  }
3278  //$ilTabs->setTabActive("pg");
3279  }
3280 
3284  function compareVersion()
3285  {
3286  global $lng;
3287 
3288  if (!$this->getEnableEditing())
3289  {
3290  return;
3291  }
3292 
3293  $tpl = new ilTemplate("tpl.page_compare.html", true, true, "Services/COPage");
3294  $compare = $this->obj->compareVersion((int) $_POST["left"], (int) $_POST["right"]);
3295 
3296  // left page
3297  $lpage = $compare["l_page"];
3298  $cfg = $this->getPageConfig();
3299  $cfg->setPreventHTMLUnmasking(true);
3300 
3302  $this->setPageObject($lpage);
3303  $this->setPresentationTitle($this->getPresentationTitle());
3304  $this->setCompareMode(true);
3305 
3306  $lhtml = $this->showPage();
3307  $lhtml = $this->replaceDiffTags($lhtml);
3308  $lhtml = str_replace("&lt;br /&gt;", "<br />", $lhtml);
3309  $tpl->setVariable("LEFT", $lhtml);
3310 
3311  // right page
3312  $rpage = $compare["r_page"];
3313  $this->setPageObject($rpage);
3314  $this->setPresentationTitle($this->getPresentationTitle());
3315  $this->setCompareMode(true);
3317 
3318  $rhtml = $this->showPage();
3319  $rhtml = $this->replaceDiffTags($rhtml);
3320  $rhtml = str_replace("&lt;br /&gt;", "<br />", $rhtml);
3321  $tpl->setVariable("RIGHT", $rhtml);
3322 
3323  $tpl->setVariable("TXT_NEW", $lng->txt("cont_pc_new"));
3324  $tpl->setVariable("TXT_MODIFIED", $lng->txt("cont_pc_modified"));
3325  $tpl->setVariable("TXT_DELETED", $lng->txt("cont_pc_deleted"));
3326 
3327 //var_dump($left);
3328 //var_dump($right);
3329 
3330  return $tpl->get();
3331  }
3332 
3333  function replaceDiffTags($a_html)
3334  {
3335  $a_html = str_replace("[ilDiffInsStart]", '<span class="ilDiffIns">', $a_html);
3336  $a_html = str_replace("[ilDiffDelStart]", '<span class="ilDiffDel">', $a_html);
3337  $a_html = str_replace("[ilDiffInsEnd]", '</span>', $a_html);
3338  $a_html = str_replace("[ilDiffDelEnd]", '</span>', $a_html);
3339 
3340  return $a_html;
3341  }
3342 
3346  function editActivation()
3347  {
3348  global $ilCtrl, $lng, $tpl;
3349 
3350  $atpl = new ilTemplate("tpl.page_activation.php", true, true, "Services/COPage");
3351  $this->initActivationForm();
3352  $this->getActivationFormValues();
3353  $atpl->setVariable("FORM", $this->form->getHTML());
3354  $atpl->setCurrentBlock("updater");
3355  $atpl->setVariable("UPDATER_FRAME", $this->exp_frame);
3356  $atpl->setVariable("EXP_ID_UPDATER", $this->exp_id);
3357  $atpl->setVariable("HREF_UPDATER", $this->exp_target_script);
3358  $atpl->parseCurrentBlock();
3359  $tpl->setContent($atpl->get());
3360  }
3361 
3366  {
3367  global $ilCtrl, $lng;
3368 
3369  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
3370  $this->form = new ilPropertyFormGUI();
3371  $this->form->setFormAction($ilCtrl->getFormAction($this));
3372  $this->form->setTitle($lng->txt("cont_page_activation"));
3373 
3374  // activation type radio
3375  $rad = new ilRadioGroupInputGUI($lng->txt("cont_activation"), "activation");
3376  $rad_op1 = new ilRadioOption($lng->txt("cont_activated"), "activated");
3377 
3378  $rad->addOption($rad_op1);
3379  $rad_op2 = new ilRadioOption($lng->txt("cont_deactivated"), "deactivated");
3380  $rad->addOption($rad_op2);
3381  $rad_op3 = new ilRadioOption($lng->txt("cont_scheduled_activation"), "scheduled");
3382 
3383  $dt_prop = new ilDateTimeInputGUI($lng->txt("cont_start"), "start");
3384  $dt_prop->setShowTime(true);
3385  $rad_op3->addSubItem($dt_prop);
3386  $dt_prop2 = new ilDateTimeInputGUI($lng->txt("cont_end"), "end");
3387  $dt_prop2->setShowTime(true);
3388  $rad_op3->addSubItem($dt_prop2);
3389 
3390  // show activation information
3391  $cb = new ilCheckboxInputGUI($this->lng->txt("cont_show_activation_info"), "show_activation_info");
3392  $cb->setInfo($this->lng->txt("cont_show_activation_info_info"));
3393  $rad_op3->addSubItem($cb);
3394 
3395 
3396  $rad->addOption($rad_op3);
3397 
3398  $this->form->addCommandButton("saveActivation", $lng->txt("save"));
3399 
3400  $this->form->addItem($rad);
3401  }
3402 
3407  {
3408  $values = array();
3409  $values["activation"] = "deactivated";
3410  if ($this->getPageObject()->getActive())
3411  {
3412  $values["activation"] = "activated";
3413  }
3414 
3415  $dt_prop = $this->form->getItemByPostVar("start");
3416  if ($this->getPageObject()->getActivationStart() != "")
3417  {
3418  $values["activation"] = "scheduled";
3419  $dt_prop->setDate(new ilDateTime($this->getPageObject()->getActivationStart(),
3420  IL_CAL_DATETIME));
3421  }
3422  $dt_prop = $this->form->getItemByPostVar("end");
3423  if ($this->getPageObject()->getActivationEnd() != "")
3424  {
3425  $values["activation"] = "scheduled";
3426  $dt_prop->setDate(new ilDateTime($this->getPageObject()->getActivationEnd(),
3427  IL_CAL_DATETIME));
3428  }
3429 
3430  $values["show_activation_info"] = $this->getPageObject()->getShowActivationInfo();
3431 
3432  $this->form->setValuesByArray($values);
3433  }
3434 
3438  function saveActivation()
3439  {
3440  global $tpl, $lng, $ilCtrl;
3441 
3442  $this->initActivationForm();
3443 
3444  if ($this->form->checkInput())
3445  {
3446  $this->getPageObject()->setActive(true);
3447  $this->getPageObject()->setActivationStart(null);
3448  $this->getPageObject()->setActivationEnd(null);
3449  $this->getPageObject()->setShowActivationInfo($_POST["show_activation_info"]);
3450  if ($_POST["activation"] == "deactivated")
3451  {
3452  $this->getPageObject()->setActive(false);
3453  }
3454  if ($_POST["activation"] == "scheduled")
3455  {
3456  $this->getPageObject()->setActive(false);
3457  $this->getPageObject()->setActivationStart(
3458  $this->form->getItemByPostVar("start")->getDate()->get(IL_CAL_DATETIME));
3459  $this->getPageObject()->setActivationEnd(
3460  $this->form->getItemByPostVar("end")->getDate()->get(IL_CAL_DATETIME));
3461  }
3462  $this->getPageObject()->update();
3463  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
3464  $ilCtrl->redirect($this, "editActivation");
3465  }
3466  $this->form->getValuesByPost();
3467  $tpl->setContent($this->form->getHTML());
3468  }
3469 
3479  function getNotesHTML($a_content_object = null, $a_enable_private_notes = true, $a_enable_public_notes = false, $a_enable_notes_deletion = false, $a_callback = null)
3480  {
3481  global $ilCtrl;
3482 
3483  include_once("Services/Notes/classes/class.ilNoteGUI.php");
3484 
3485  // scorm 2004 page gui
3486  if(!$a_content_object)
3487  {
3488  $notes_gui = new ilNoteGUI($this->notes_parent_id,
3489  (int)$this->obj->getId(), "pg");
3490 
3491  $a_enable_private_notes = true;
3492  $a_enable_public_notes = true;
3493  $a_enable_notes_deletion = false;
3494  }
3495  // wiki page gui, blog posting gui
3496  else
3497  {
3498  $notes_gui = new ilNoteGUI($a_content_object->getParentId(),
3499  $a_content_object->getId(), $a_content_object->getParentType());
3500  }
3501 
3502  if($a_enable_private_notes)
3503  {
3504  $notes_gui->enablePrivateNotes();
3505  }
3506  if ($a_enable_public_notes)
3507  {
3508  $notes_gui->enablePublicNotes();
3509  if ((bool)$a_enable_notes_deletion)
3510  {
3511  $notes_gui->enablePublicNotesDeletion(true);
3512  }
3513  }
3514 
3515  if($a_callback)
3516  {
3517  $notes_gui->addObserver($a_callback);
3518  }
3519 
3520  $next_class = $this->ctrl->getNextClass($this);
3521  if ($next_class == "ilnotegui")
3522  {
3523  $html = $this->ctrl->forwardCommand($notes_gui);
3524  }
3525  else
3526  {
3527  $html = $notes_gui->getNotesHTML();
3528  }
3529  return $html;
3530  }
3531 
3535  function processAnswer()
3536  {
3537  global $ilLog;
3538 
3539  /*$ilLog->write($_POST);
3540  $ilLog->write($_POST["id"]);
3541  $ilLog->write($_POST["type"]);
3542  $ilLog->write($_POST["answer"]);
3543  $ilLog->write($_GET);*/
3544 
3545  include_once("./Services/COPage/classes/class.ilPageQuestionProcessor.php");
3547  ilUtil::stripSlashes($_POST["type"]),
3549  ilUtil::stripSlashes($_POST["answer"]));
3550  }
3551 
3552 
3553  //
3554  // Initially opened content (e.g. used in learning modules), that
3555  // is presented in another than the main content area (e.g. a picture in
3556  // the bottom left area)
3557  //
3558 
3566  {
3567  global $ilTabs, $ilCtrl;
3568 
3569  $ilTabs->activateTab("edit");
3570  $form = $this->initOpenedContentForm();
3571 
3572  $this->tpl->setContent($form->getHTML());
3573  }
3574 
3582  {
3583  global $ilCtrl;
3584 
3585  include_once("Services/Form/classes/class.ilPropertyFormGUI.php");
3586  $form = new ilPropertyFormGUI();
3587 
3588  // link input
3589  include_once 'Services/Form/classes/class.ilLinkInputGUI.php';
3590  $ac = new ilLinkInputGUI($this->lng->txt('cont_resource'), 'opened_content');
3592  $ac->setInternalLinkDefault("Media_Media", 0);
3593  $ac->setInternalLinkFilterTypes(array("PageObject_FAQ", "GlossaryItem", "Media_Media", "Media_FAQ"));
3594  $val = $this->obj->getInitialOpenedContent();
3595  if ($val["id"] != "" && $val["type"] != "")
3596  {
3597  $ac->setValue($val["type"]."|".$val["id"]."|".$val["target"]);
3598  }
3599 
3600  $form->addItem($ac);
3601 
3602  $form->addCommandButton("saveInitialOpenedContent", $this->lng->txt("save"));
3603  $form->addCommandButton("edit", $this->lng->txt("cancel"));
3604  $form->setTitle($this->lng->txt("cont_initial_attached_content"));
3605  $form->setFormAction($ilCtrl->getFormAction($this));
3606 
3607  return $form;
3608  }
3609 
3617  {
3618  global $ilCtrl;
3619 
3620  $this->obj->saveInitialOpenedContent(
3621  ilUtil::stripSlashes($_POST["opened_content_ajax_type"]),
3622  ilUtil::stripSlashes($_POST["opened_content_ajax_id"]),
3623  ilUtil::stripSlashes($_POST["opened_content_ajax_target"])
3624  );
3625 
3626  ilUtil::sendSuccess($this->lng->txt("msg_obj_modified"));
3627  $ilCtrl->redirect($this, "edit");
3628  }
3629 
3633 
3634 
3638  function switchToLanguage()
3639  {
3640  global $ilCtrl;
3641 
3642  $l = ilUtil::stripSlashes($_GET["totransl"]);
3643  $p = $this->getPageObject();
3644  if (!ilPageObject::_exists($p->getParentType(), $p->getId(), $l))
3645  {
3647  return;
3648  }
3649  $ilCtrl->setParameter($this, "transl", $_GET["totransl"]);
3650  $ilCtrl->redirect($this, "edit");
3651  }
3652 
3657  {
3658  global $ilCtrl, $tpl, $lng;
3659 
3660  $l = ilUtil::stripSlashes($_GET["totransl"]);
3661  $ilCtrl->setParameter($this, "totransl", $l);
3662  $lng->loadLanguageModule("meta");
3663 
3664  include_once("./Services/Utilities/classes/class.ilConfirmationGUI.php");
3665  $cgui = new ilConfirmationGUI();
3666  $cgui->setFormAction($ilCtrl->getFormAction($this));
3667  $cgui->setHeaderText($lng->txt("cont_page_translation_does_not_exist").": ".
3668  $lng->txt("meta_l_".$l));
3669  $cgui->setCancel($lng->txt("cancel"), "editMasterLanguage");
3670  $cgui->setConfirm($lng->txt("confirm"), "createPageTranslation");
3671  $tpl->setContent($cgui->getHTML());
3672  }
3673 
3678  {
3679  global $ilCtrl;
3680 
3681  $ilCtrl->setParameter($this, "transl", "");
3682  $ilCtrl->redirect($this, "edit");
3683  }
3684 
3689  {
3690  global $ilCtrl;
3691 
3692  $l = ilUtil::stripSlashes($_GET["totransl"]);
3693  $this->getPageObject()->copyPageToTranslation($l);
3694  $ilCtrl->setParameter($this, "transl", $l);
3695  $ilCtrl->redirect($this, "edit");
3696  }
3697 
3701  function releasePageLock()
3702  {
3703  global $ilCtrl, $lng;
3704 
3705  $this->getPageObject()->releasePageLock();
3706  ilUtil::sendSuccess($lng->txt("cont_page_lock_released"), true);
3707  $ilCtrl->redirect($this, "preview");
3708  }
3709 
3710  protected function isPageContainerToBeRendered()
3711  {
3712  return (
3713  $this->getRenderPageContainer() || $this->getOutputMode() == IL_PAGE_PREVIEW
3714  );
3715  }
3716 }
3717 ?>