ILIAS  eassessment Revision 61809
 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-2009 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/COPage/classes/class.ilParagraphPlugins.php");
14 include_once("./Services/COPage/classes/class.ilParagraphPlugin.php");
15 include_once("./Services/Utilities/classes/class.ilDOMUtil.php");
16 
17 
33 {
34  var $ilias;
35  var $tpl;
36  var $lng;
37  var $ctrl;
38  var $obj;
48  var $bib_id;
49  var $citation;
53  var $activation = false;
54  var $activated = true;
55  var $enabledinternallinks = false;
56  var $editpreview = false;
57  var $use_meta_data = false;
58  var $enabledtabs = true;
59  var $enabledpctabs = false;
60  var $link_xml_set = false;
61  var $enableediting = true;
62  var $rawpagecontent = false;
63  var $layoutmode = false;
65  var $compare_mode = false;
66  var $page_config = null;
67  var $enable_keywords = false;
68  var $enable_anchors = false;
69 
74  function ilPageObjectGUI($a_parent_type, $a_id = 0, $a_old_nr = 0)
75  {
76  global $ilias, $tpl, $lng, $ilCtrl,$ilTabs;
77 
78  $this->ctrl =& $ilCtrl;
79 
80  if ($a_old_nr == 0 && $_GET["old_nr"] > 0)
81  {
82  $a_old_nr = $_GET["old_nr"];
83  }
84 
85  $this->ilias =& $ilias;
86  $this->tpl =& $tpl;
87  $this->ctrl =& $ilCtrl;
88  $this->lng =& $lng;
90 
91  // defaults (as in learning modules)
92  $this->setEnabledMaps(false);
93  $this->setEnabledPCTabs(false);
94  $this->setEnabledFileLists(true);
95  $this->setEnabledRepositoryObjects(false);
96  $this->setEnabledSelfAssessment(false);
97  $this->setEnabledPageFocus(true);
98  $this->setLayoutMode(false);
99 
100  include_once("./Services/COPage/classes/class.ilPageConfig.php");
101  $this->setPageConfig(new ilPageConfig());
102 
103  if ($a_id > 0)
104  {
105  $this->initPageObject($a_parent_type, $a_id, $a_old_nr);
106  }
107 
108  $this->output2template = true;
109  $this->question_xml = "";
110  $this->question_html = "";
111  $this->tabs_gui =& $ilTabs;
112 
113  // USED FOR TRANSLATIONS
114  $this->template_output_var = "PAGE_CONTENT";
115  $this->citation = false;
116  $this->change_comments = false;
117  $this->page_back_title = $this->lng->txt("page");
118  $lng->loadLanguageModule("content");
119  $this->setPreventHTMLUnmasking(false);
120  $this->setEnabledWikiLinks(false);
121 
122  $this->setTemplateOutput(false);
123  }
124 
130  function setPageConfig($a_val)
131  {
132  $this->page_config = $a_val;
133  }
134 
140  function getPageConfig()
141  {
142  return $this->page_config;
143  }
144 
145  function initPageObject($a_parent_type, $a_id, $a_old_nr)
146  {
147  $page = new ilPageObject($a_parent_type, $a_id, $a_old_nr);
148  $this->setPageObject($page);
149  }
150 
154  function setBibId($a_id)
155  {
156  // USED FOR SELECTION WHICH PAGE TURNS AND LATER PAGES SHOULD BE SHOWN
157  $this->bib_id = $a_id;
158  }
159 
163  function getBibId()
164  {
165  return $this->bib_id ? $this->bib_id : 0;
166  }
167 
173  function setPageObject($a_pg_obj)
174  {
175  $this->obj = $a_pg_obj;
176  }
177 
183  function getPageObject()
184  {
185  return $this->obj;
186  }
187 
194  {
195  $this->output_mode = $a_mode;
196  }
197 
198  function getOutputMode()
199  {
200  return $this->output_mode;
201  }
202 
203  function setTemplateOutput($a_output = true)
204  {
205  $this->output2template = $a_output;
206  }
207 
208  function outputToTemplate()
209  {
210  return $this->output2template;
211  }
212 
213  function setPresentationTitle($a_title = "")
214  {
215  $this->presentation_title = $a_title;
216  }
217 
219  {
221  }
222 
223  function setHeader($a_title = "")
224  {
225  $this->header = $a_title;
226  }
227 
228  function getHeader()
229  {
230  return $this->header;
231  }
232 
233  function setLinkParams($l_params = "")
234  {
235  $this->link_params = $l_params;
236  }
237 
238  function getLinkParams()
239  {
240  return $this->link_params;
241  }
242 
243  function setLinkFrame($l_frame = "")
244  {
245  $this->link_frame = $l_frame;
246  }
247 
248  function getLinkFrame()
249  {
250  return $this->link_frame;
251  }
252 
253  function setLinkXML($link_xml)
254  {
255  $this->link_xml = $link_xml;
256  $this->link_xml_set = true;
257  }
258 
259  function getLinkXML()
260  {
261  return $this->link_xml;
262  }
263 
264  function setQuestionXML($question_xml)
265  {
266  $this->question_xml = $question_xml;
267  }
268 
270  {
271  $this->question_html = $question_html;
272  }
273 
274  function getQuestionXML()
275  {
276  return $this->question_xml;
277  }
278 
279  function getQuestionHTML()
280  {
281  return $this->question_html;
282  }
283 
284  function setTemplateTargetVar($a_variable)
285  {
286  $this->target_var = $a_variable;
287  }
288 
290  {
291  return $this->target_var;
292  }
293 
294  function setTemplateOutputVar($a_value)
295  {
296  // USED FOR TRANSLATION PRESENTATION OF dbk OBJECTS
297  $this->template_output_var = $a_value;
298  }
299 
301  {
303  }
304 
305  function setOutputSubmode($a_mode)
306  {
307  // USED FOR TRANSLATION PRESENTATION OF dbk OBJECTS
308  $this->output_submode = $a_mode;
309  }
310 
311  function getOutputSubmode()
312  {
313  return $this->output_submode;
314  }
315 
316 
318  $this->sourcecode_download_script = $script_name;
319  }
320 
323  }
324 
325  function enableCitation($a_enabled)
326  {
327  $this->citation = $a_enabled;
328  }
329 
330  function isEnabledCitation()
331  {
332  return $this->citation;
333  }
334 
335  function setLocator(&$a_locator)
336  {
337  $this->locator =& $a_locator;
338  }
339 
340  function setTabs($a_tabs)
341  {
342  $this->tabs_gui = $a_tabs;
343  }
344 
345  function setPageBackTitle($a_title)
346  {
347  $this->page_back_title = $a_title;
348  }
349 
350  function setFileDownloadLink($a_download_link)
351  {
352  $this->file_download_link = $a_download_link;
353  }
354 
356  {
357  return $this->file_download_link;
358  }
359 
360  function setFullscreenLink($a_fullscreen_link)
361  {
362  $this->fullscreen_link = $a_fullscreen_link;
363  }
364 
365  function getFullscreenLink()
366  {
367  return $this->fullscreen_link;
368  }
369 
375  function setEnableKeywords($a_val)
376  {
377  $this->enable_keywords = $a_val;
378  }
379 
385  function getEnableKeywords()
386  {
387  return $this->enable_keywords;
388  }
389 
395  function setEnableAnchors($a_val)
396  {
397  $this->enable_anchors = $a_val;
398  }
399 
405  function getEnableAnchors()
406  {
407  return $this->enable_anchors;
408  }
409 
410  function setIntLinkHelpDefault($a_type, $a_id)
411  {
412  $this->int_link_def_type = $a_type;
413  $this->int_link_def_id = $a_id;
414  }
415 
416  function setIntLinkReturn($a_return)
417  {
418  $this->int_link_return = $a_return;
419  }
420 
421  function enableChangeComments($a_enabled)
422  {
423  $this->change_comments = $a_enabled;
424  }
425 
427  {
428  return $this->change_comments;
429  }
430 
431  function enableNotes($a_enabled, $a_parent_id)
432  {
433  $this->notes_enabled = $a_enabled;
434  $this->notes_parent_id = $a_parent_id;
435  }
436 
437  function isEnabledNotes()
438  {
439  return $this->notes_enabled;
440  }
441 
445  function enableContentIncludes($a_enable)
446  {
447  $this->enablecontentincludes = $a_enable;
448  }
449 
454  {
455  return $this->enablecontentincludes;
456  }
457 
463  function setOfflineDirectory ($offdir) {
464  $this->offline_directory = $offdir;
465  }
466 
467 
472  function getOfflineDirectory () {
473  return $this->offline_directory;
474  }
475 
476 
483  function setViewPageLink($a_link, $a_target = "")
484  {
485  $this->view_page_link = $a_link;
486  $this->view_page_target = $a_target;
487  }
488 
492  function getViewPageLink()
493  {
494  return $this->view_page_link;
495  }
496 
500  function getViewPageTarget()
501  {
502  return $this->view_page_target;
503  }
504 
505  function setActivationListener(&$a_obj, $a_meth)
506  {
507  $this->act_obj =& $a_obj;
508  $this->act_meth = $a_meth;
509  }
510 
511  function setEnabledActivation($a_act)
512  {
513  $this->activation = $a_act;
514  }
515 
517  {
518  return $this->activation;
519  }
520 
522  {
523  $this->scheduled_activation = $a_act;
524  }
525 
527  {
528  return $this->scheduled_activation;
529  }
530 
536  function setEnabledNews($a_enabled, $a_news_obj_id = 0, $a_news_obj_type = 0)
537  {
538  $this->enabled_news = $a_enabled;
539  $this->news_obj_id = $a_news_obj_id;
540  $this->news_obj_type = $a_news_obj_type;
541  }
542 
548  function getEnabledNews()
549  {
550  return $this->enabled_news;
551  }
552 
556  function setTabHook($a_object, $a_function)
557  {
558  $this->tab_hook = array("obj" => $a_object, "func" => $a_function);
559  }
560 
561 
567  function setEnabledInternalLinks($a_enabledinternallinks)
568  {
569  $this->enabledinternallinks = $a_enabledinternallinks;
570  }
571 
578  {
580  }
581 
587  function setEditPreview($a_editpreview)
588  {
589  $this->editpreview = $a_editpreview;
590  }
591 
597  function getEditPreview()
598  {
599  return $this->editpreview;
600  }
601 
607  function setPreventHTMLUnmasking($a_preventhtmlunmasking)
608  {
609  $this->preventhtmlunmasking = $a_preventhtmlunmasking;
610  }
611 
618  {
619  return $this->preventhtmlunmasking;
620  }
621 
627  function setEnabledTabs($a_enabledtabs)
628  {
629  $this->enabledtabs = $a_enabledtabs;
630  }
631 
637  function getEnabledTabs()
638  {
639  return $this->enabledtabs;
640  }
641 
647  function setEnabledRepositoryObjects($a_enabledrepositoryobjects)
648  {
649  $this->enabledrepositoryobjects = $a_enabledrepositoryobjects;
650  }
651 
658  {
659  return $this->enabledrepositoryobjects;
660  }
661 
667  function setEnabledMaps($a_enabledmaps)
668  {
669  $this->enabledmaps = $a_enabledmaps;
670  }
671 
677  function getEnabledMaps()
678  {
679  return $this->enabledmaps;
680  }
681 
687  function setEnabledPCTabs($a_enabledpctabs)
688  {
689  $this->enabledpctabs = $a_enabledpctabs;
690  }
691 
697  function getEnabledPCTabs()
698  {
699  return $this->enabledpctabs;
700  }
701 
707  function setEnabledFileLists($a_enabledfilelists)
708  {
709  $this->enabledfilelists = $a_enabledfilelists;
710  }
711 
718  {
719  return $this->enabledfilelists;
720  }
721 
727  function setEnabledPageFocus($a_enabledpagefocus)
728  {
729  $this->enabledpagefocus = $a_enabledpagefocus;
730  }
731 
738  {
739  return $this->enabledpagefocus;
740  }
741 
747  function setExplorerUpdater($a_exp_frame, $a_exp_id, $a_exp_target_script)
748  {
749  $this->exp_frame = $a_exp_frame;
750  $this->exp_id = $a_exp_id;
751  $this->exp_target_script = $a_exp_target_script;
752  }
753 
759  function setPrependingHtml($a_prependinghtml)
760  {
761  $this->prependinghtml = $a_prependinghtml;
762  }
763 
769  function getPrependingHtml()
770  {
771  return $this->prependinghtml;
772  }
773 
779  function setEnabledWikiLinks($a_enablewikilinks)
780  {
781  $this->enablewikilinks = $a_enablewikilinks;
782  }
783 
790  {
791  return $this->enablewikilinks;
792  }
793 
799  function setEnableEditing($a_enableediting)
800  {
801  $this->enableediting = $a_enableediting;
802  }
803 
809  function getEnableEditing()
810  {
811  return $this->enableediting;
812  }
813 
819  function setRawPageContent($a_rawpagecontent)
820  {
821  $this->rawpagecontent = $a_rawpagecontent;
822  }
823 
829  function getRawPageContent()
830  {
831  return $this->rawpagecontent;
832  }
833 
839  function setLayoutMode($a_layout_mode)
840  {
841  $this->layout_mode = $a_layout_mode;
842  }
843 
849  function getLayoutMode()
850  {
851  return $this->layout_mode;
852  }
853 
859  function setStyleId($a_styleid)
860  {
861  $this->styleid = $a_styleid;
862  }
863 
869  function getStyleId()
870  {
871  return $this->styleid;
872  }
873 
879  function setEnabledSelfAssessment($a_enabledselfassessment, $a_scorm = true)
880  {
881  $this->enabledselfassessment = $a_enabledselfassessment;
882  $this->enabledselfassessment_scorm = $a_scorm;
883  }
884 
885 
892  {
893  return $this->enabledselfassessment;
894  }
895 
902  {
903  return $this->enabledselfassessment_scorm;
904  }
905 
911  function setCompareMode($a_val)
912  {
913  $this->compare_mode = $a_val;
914  }
915 
921  function getCompareMode()
922  {
923  return $this->compare_mode;
924  }
925 
935  function activateMetaDataEditor($a_rep_obj_id, $a_sub_obj_id, $a_type,
936  $a_observer_obj = NULL, $a_observer_func = "")
937  {
938  $this->use_meta_data = true;
939  $this->meta_data_rep_obj_id = $a_rep_obj_id;
940  $this->meta_data_sub_obj_id = $a_sub_obj_id;
941  $this->meta_data_type = $a_type;
942  $this->meta_data_observer_obj = $a_observer_obj;
943  $this->meta_data_observer_func = $a_observer_func;
944  }
945 
952  {
953  global $ilCtrl;
954 
955  $file_download_link = $this->getFileDownloadLink();
956  if ($this->getFileDownloadLink() == "" && $this->getOutputMode() != "offline")
957  {
958  $file_download_link = $ilCtrl->getLinkTarget($this, "downloadFile");
959  }
960  return $file_download_link;
961  }
962 
969  {
970  global $ilCtrl;
971 
972  $fullscreen_link = $this->getFullscreenLink();
973  if ($this->getFullscreenLink() == "" && $this->getOutputMode() != "offline")
974  {
975  $fullscreen_link = $ilCtrl->getLinkTarget($this, "displayMediaFullscreen", "", false, false);
976  }
977  return $fullscreen_link;
978  }
979 
986  {
987  global $ilCtrl;
988 
990  if ($this->sourcecode_download_script == "" && $this->getOutputMode() != "offline")
991  {
992  $l = $ilCtrl->getLinkTarget($this, "");
993  }
994  return $l;
995  }
996 
1001  {
1002  $xml = "";
1003  if($this->getOutputMode() == "edit")
1004  {
1005  global $ilPluginAdmin;
1006 
1007  $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_SERVICE,
1008  "COPage", "pgcp");
1009  foreach ($pl_names as $pl_name)
1010  {
1011  $plugin = $ilPluginAdmin->getPluginObject(IL_COMP_SERVICE,
1012  "COPage", "pgcp", $pl_name);
1013  if ($plugin->isValidParentType($this->getPageObject()->getParentType()))
1014  {
1015  $xml = '<ComponentPlugin Name="'.$plugin->getPluginName().
1016  '" InsertText="'.$plugin->getUIText(ilPageComponentPlugin::TXT_CMD_INSERT).'" />';
1017  }
1018  }
1019  }
1020  if ($xml != "")
1021  {
1022  $xml = "<ComponentPlugins>".$xml."</ComponentPlugins>";
1023  }
1024 
1025  return $xml;
1026  }
1027 
1028 
1032  function &executeCommand()
1033  {
1034  global $ilCtrl, $ilTabs, $lng;
1035 
1036  $next_class = $this->ctrl->getNextClass($this);
1037 
1038  $cmd = $this->ctrl->getCmd();
1039  //$this->ctrl->addTab("clipboard", $this->ctrl->getLinkTargetByClass("ilEditClipboardGUI", "view")
1040  // , "view", "ilEditClipboardGUI");
1041  $this->getTabs();
1042 
1043  $ilCtrl->setReturn($this, "edit");
1044 //echo "-".$next_class."-";
1045  switch($next_class)
1046  {
1047  case 'ilmdeditorgui':
1048  //$this->setTabs();
1049  $ilTabs->setTabActive("meta_data");
1050  include_once 'Services/MetaData/classes/class.ilMDEditorGUI.php';
1051  $md_gui =& new ilMDEditorGUI($this->meta_data_rep_obj_id,
1052  $this->meta_data_sub_obj_id, $this->meta_data_type);
1053  if (is_object($this->meta_data_observer_obj))
1054  {
1055  $md_gui->addObserver($this->meta_data_observer_obj,
1056  $this->meta_data_observer_func, "General");
1057  }
1058  $this->ctrl->forwardCommand($md_gui);
1059  break;
1060 
1061  case "ileditclipboardgui":
1062  //$this->tabs_gui->clearTargets();
1063  //$this->ctrl->setReturn($this, "view");
1064  $clip_gui = new ilEditClipboardGUI();
1065  $clip_gui->setPageBackTitle($this->page_back_title);
1066  //$ret =& $clip_gui->executeCommand();
1067  $ret =& $this->ctrl->forwardCommand($clip_gui);
1068  break;
1069 
1070  // notes
1071  case "ilnotegui":
1072  switch($_GET["notes_mode"])
1073  {
1074  default:
1075  $html = $this->edit();
1076  $ilTabs->setTabActive("edit");
1077  return $html;
1078  }
1079  break;
1080 
1081  case 'ilpublicuserprofilegui':
1082  require_once './Services/User/classes/class.ilPublicUserProfileGUI.php';
1083  $profile_gui = new ilPublicUserProfileGUI($_GET["user"]);
1084  $ret = $this->ctrl->forwardCommand($profile_gui);
1085  break;
1086 
1087  case "ilpageeditorgui":
1088  if (!$this->getEnableEditing())
1089  {
1090  ilUtil::sendFailure($lng->txt("permission_denied"), true);
1091  $ilCtrl->redirect($this, "preview");
1092  }
1093  $page_editor =& new ilPageEditorGUI($this->getPageObject(), $this);
1094  $page_editor->setLocator($this->locator);
1095  $page_editor->setHeader($this->getHeader());
1096  $page_editor->setPageBackTitle($this->page_back_title);
1097  $page_editor->setEnableInternalLinks($this->getEnabledInternalLinks());
1098  $page_editor->setEnableKeywords($this->getEnableKeywords());
1099  $page_editor->setEnableAnchors($this->getEnableAnchors());
1100  $page_editor->setIntLinkHelpDefault($this->int_link_def_type,
1101  $this->int_link_def_id);
1102  $page_editor->setIntLinkReturn($this->int_link_return);
1103  //$page_editor->executeCommand();
1104  $ret =& $this->ctrl->forwardCommand($page_editor);
1105  break;
1106 
1107  case 'ilnewsitemgui':
1108  include_once("./Services/News/classes/class.ilNewsItemGUI.php");
1109  $news_item_gui = new ilNewsItemGUI();
1110  $news_item_gui->setEnableEdit(true);
1111  $news_item_gui->setContextObjId($this->news_obj_id);
1112  $news_item_gui->setContextObjType($this->news_obj_type);
1113  $news_item_gui->setContextSubObjId($this->obj->getId());
1114  $news_item_gui->setContextSubObjType("pg");
1115 
1116  $ret = $ilCtrl->forwardCommand($news_item_gui);
1117  break;
1118 
1119  $profile_gui = new ilPublicUserProfileGUI($_GET["user"]);
1120  $ret = $this->ctrl->forwardCommand($profile_gui);
1121  break;
1122 
1123  default:
1124  $cmd = $this->ctrl->getCmd("preview");
1125  $ret = $this->$cmd();
1126  break;
1127  }
1128 //echo "+$ret+";
1129  return $ret;
1130  }
1131 
1132  function deactivatePage()
1133  {
1134  $this->getPageObject()->setActivationStart(null);
1135  $this->getPageObject()->setActivationEnd(null);
1136  $this->getPageObject()->setActive(false);
1137  $this->getPageObject()->update();
1138  $this->ctrl->redirectByClass("ilpageobjectgui", "edit");
1139  }
1140 
1141  function activatePage()
1142  {
1143  $this->getPageObject()->setActivationStart(null);
1144  $this->getPageObject()->setActivationEnd(null);
1145  $this->getPageObject()->setActive(true);
1146  $this->getPageObject()->update();
1147  $this->ctrl->redirectByClass("ilpageobjectgui", "edit");
1148  }
1149 
1150  /*
1151  * display content of page
1152  */
1153  function showPage()
1154  {
1155  global $tree, $ilUser, $ilias, $lng, $ilCtrl, $ilBench, $ilSetting;
1156 
1157  $ilBench->start("ContentPresentation", "ilPageObjectGUI_showPage");
1158 
1159  $this->initSelfAssessmentRendering();
1160 
1161  // init template
1162  //if($this->outputToTemplate())
1163  //{
1164  if($this->getOutputMode() == "edit")
1165  {
1166 //echo ":".$this->getTemplateTargetVar().":";
1167  $tpl = new ilTemplate("tpl.page_edit_wysiwyg.html", true, true, "Services/COPage");
1168  //$this->tpl->addBlockFile($this->getTemplateTargetVar(), "adm_content", "tpl.page_edit_wysiwyg.html", "Services/COPage");
1169 
1170  // to do: status dependent class
1171  $tpl->setVariable("CLASS_PAGE_TD", "ilc_Page");
1172 
1173  // user comment
1174  if ($this->isEnabledChangeComments())
1175  {
1176  $tpl->setCurrentBlock("change_comment");
1177  $tpl->setVariable("TXT_ADD_COMMENT", $this->lng->txt("cont_add_change_comment"));
1178  $tpl->parseCurrentBlock();
1179  $tpl->setCurrentBlock("adm_content");
1180  }
1181 
1182  // explorer updater
1183  if ($this->exp_frame != "")
1184  {
1185  $tpl->setCurrentBlock("updater");
1186  $tpl->setVariable("UPDATER_FRAME", $this->exp_frame);
1187  $tpl->setVariable("EXP_ID_UPDATER", $this->exp_id);
1188  $tpl->setVariable("HREF_UPDATER", $this->exp_target_script);
1189  $tpl->parseCurrentBlock();
1190  }
1191 
1192 /* $tpl->setVariable("TXT_INSERT_BEFORE", $this->lng->txt("cont_set_before"));
1193  $tpl->setVariable("TXT_INSERT_AFTER", $this->lng->txt("cont_set_after"));
1194  $tpl->setVariable("TXT_INSERT_CANCEL", $this->lng->txt("cont_set_cancel"));
1195  $tpl->setVariable("TXT_CONFIRM_DELETE", $this->lng->txt("cont_confirm_delete"));
1196 */
1197  $tpl->setVariable("WYSIWYG_ACTION",
1198  $ilCtrl->getFormActionByClass("ilpageeditorgui", "", "", true));
1199 
1201  {
1202  $tpl->setVariable("TXT_JAVA_SCRIPT_CAPABLE", "<br />".$this->lng->txt("cont_browser_not_js_capable"));
1203  }
1204  $tpl->setVariable("TXT_CHANGE_EDIT_MODE", $this->lng->txt("cont_set_edit_mode"));
1205 
1206  if ($this->getEnabledActivation())
1207  {
1208  $tpl->setCurrentBlock("de_activate_page");
1209  if ($this->getPageObject()->getActive())
1210  {
1211  $tpl->setVariable("TXT_DE_ACTIVATE_PAGE", $this->lng->txt("cont_deactivate_page"));
1212  $tpl->setVariable("CMD_DE_ACTIVATE_PAGE", "deactivatePage");
1213  }
1214  else
1215  {
1216  $tpl->setVariable("TXT_DE_ACTIVATE_PAGE", $this->lng->txt("cont_activate_page"));
1217  $tpl->setVariable("CMD_DE_ACTIVATE_PAGE", "activatePage");
1218  }
1219  $tpl->parseCurrentBlock();
1220  }
1221 
1222  $med_mode = array("enable" => $this->lng->txt("cont_enable_media"),
1223  "disable" => $this->lng->txt("cont_disable_media"));
1224  $sel_media_mode = ($ilUser->getPref("ilPageEditor_MediaMode") == "disable")
1225  ? "disable"
1226  : "enable";
1227 
1228  $js_mode = array("enable" => $this->lng->txt("cont_enable_js"),
1229  "disable" => $this->lng->txt("cont_disable_js"));
1230 
1231  $tpl->setVariable("SEL_MEDIA_MODE",
1232  ilUtil::formSelect($sel_media_mode, "media_mode", $med_mode, false, true,
1233  0, "ilEditSelect"));
1234 
1235  // HTML active/inactive
1236  $html_mode = array("enable" => $this->lng->txt("cont_enable_html"),
1237  "disable" => $this->lng->txt("cont_disable_html"));
1238  $sel_html_mode = ($ilUser->getPref("ilPageEditor_HTMLMode") == "disable")
1239  ? "disable"
1240  : "enable";
1241  if (!$this->getPreventHTMLUnmasking())
1242  {
1243  $tpl->setVariable("SEL_HTML_MODE",
1244  ilUtil::formSelect($sel_html_mode, "html_mode", $html_mode, false, true,
1245  0, "ilEditSelect"));
1246  }
1247 
1248  $tpl->setVariable("PREPENDING_HTML", $this->getPrependingHtml());
1249  $tpl->setVariable("TXT_CONFIRM_DELETE", $lng->txt("cont_confirm_delete"));
1250 
1251  if ($this->getViewPageLink() != "")
1252  {
1253  $tpl->setCurrentBlock("view_link");
1254  $tpl->setVariable("LINK_VIEW_PAGE",
1255  $this->getViewPageLink());
1256  $tpl->setVariable("TARGET_VIEW_PAGE",
1257  $this->getViewPageTarget());
1258  $tpl->setVariable("TXT_VIEW_PAGE", $this->lng->txt("view"));
1259  $tpl->parseCurrentBlock();
1260  }
1261 
1262  // javascript activation
1263  $sel_js_mode = "disable";
1264  if($ilSetting->get("enable_js_edit", 1))
1265  {
1266  $sel_js_mode = (ilPageEditorGUI::_doJSEditing())
1267  ? "enable"
1268  : "disable";
1269  }
1270 
1271  // get js files for JS enabled editing
1272  if ($sel_js_mode == "enable")
1273  {
1274  $this->insertHelp($tpl);
1275  include_once("./Services/YUI/classes/class.ilYuiUtil.php");
1278  $GLOBALS["tpl"]->addJavaScript("./Services/COPage/js/ilcopagecallback.js");
1279  //$GLOBALS["tpl"]->addJavaScript("./Services/RTE/tiny_mce/tiny_mce.js");
1280  $GLOBALS["tpl"]->addJavaScript("./Services/COPage/js/ilpageedit.js");
1281  //$GLOBALS["tpl"]->addJavascript("Services/COPage/js/wz_dragdrop.js");
1282  $GLOBALS["tpl"]->addJavascript("Services/COPage/js/page_editing.js");
1283  $tpl->touchBlock("init_dragging");
1284  }
1285 
1286  if($ilias->getSetting("enable_js_edit"))
1287  {
1288  $tpl->setVariable("SEL_JAVA_SCRIPT",
1289  ilUtil::formSelect($sel_js_mode, "js_mode", $js_mode, false, true,
1290  0, "ilEditSelect"));
1291  }
1292 
1293  // multiple actions
1294  $tpl->setCurrentBlock("multi_actions");
1295  if ($sel_js_mode == "enable")
1296  {
1297  $tpl->setVariable("ONCLICK_DE_ACTIVATE_SELECTED", 'onclick="return ilEditMultiAction(\'activateSelected\');"');
1298  $tpl->setVariable("ONCLICK_DELETE_SELECTED", 'onclick="return ilEditMultiAction(\'deleteSelected\');"');
1299  $tpl->setVariable("ONCLICK_ASSIGN_CHARACTERISTIC", 'onclick="return ilEditMultiAction(\'assignCharacteristicForm\');"');
1300  $tpl->setVariable("ONCLICK_COPY_SELECTED", 'onclick="return ilEditMultiAction(\'copySelected\');"');
1301  $tpl->setVariable("ONCLICK_CUT_SELECTED", 'onclick="return ilEditMultiAction(\'cutSelected\');"');
1302  }
1303  $tpl->setVariable("TXT_DE_ACTIVATE_SELECTED", $this->lng->txt("cont_ed_enable"));
1304  $tpl->setVariable("TXT_ASSIGN_CHARACTERISTIC", $this->lng->txt("cont_assign_characteristic"));
1305  $tpl->setVariable("TXT_DELETE_SELECTED", $this->lng->txt("cont_delete_selected"));
1306  $tpl->setVariable("TXT_COPY_SELECTED", $this->lng->txt("copy"));
1307  $tpl->setVariable("TXT_CUT_SELECTED", $this->lng->txt("cut"));
1308  $tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
1309  $tpl->parseCurrentBlock();
1310  }
1311  else
1312  {
1313  if($this->getOutputSubmode() == 'translation')
1314  {
1315  $tpl = new ilTemplate("tpl.page_translation_content.html", true, true, "Services/COPage");
1316  }
1317  else
1318  {
1319  // presentation
1320  if ($this->getOutputMode() != IL_PAGE_PREVIEW)
1321  {
1322  $tpl = new ilTemplate("tpl.page_content.html", true, true, "Services/COPage");
1323  if ($this->getEnabledPageFocus())
1324  {
1325  $tpl->touchBlock("page_focus");
1326  }
1327  }
1328  else // preview
1329  {
1330  $tpl = new ilTemplate("tpl.page_preview.html", true, true, "Services/COPage");
1331  include_once("./Services/User/classes/class.ilUserUtil.php");
1332 
1333  $c_old_nr = $this->getPageObject()->old_nr;
1334  if ($c_old_nr > 0)
1335  {
1336  $hist_info =
1337  $this->getPageObject()->getHistoryInfo($c_old_nr);
1338 
1339  if (!$this->getCompareMode())
1340  {
1341  // previous revision
1342  if (is_array($hist_info["previous"]))
1343  {
1344  $tpl->setCurrentBlock("previous_rev");
1345  $tpl->setVariable("TXT_PREV_REV", $lng->txt("cont_previous_rev"));
1346  $ilCtrl->setParameter($this, "old_nr", $hist_info["previous"]["nr"]);
1347  $tpl->setVariable("HREF_PREV",
1348  $ilCtrl->getLinkTarget($this, "preview"));
1349  $tpl->parseCurrentBlock();
1350  }
1351  else
1352  {
1353  $tpl->setCurrentBlock("previous_rev_disabled");
1354  $tpl->setVariable("TXT_PREV_REV", $lng->txt("cont_previous_rev"));
1355  $tpl->parseCurrentBlock();
1356  }
1357 
1358  // next revision
1359  $tpl->setCurrentBlock("next_rev");
1360  $tpl->setVariable("TXT_NEXT_REV", $lng->txt("cont_next_rev"));
1361  $ilCtrl->setParameter($this, "old_nr", $hist_info["next"]["nr"]);
1362  $tpl->setVariable("HREF_NEXT",
1363  $ilCtrl->getLinkTarget($this, "preview"));
1364  $tpl->parseCurrentBlock();
1365 
1366  // latest revision
1367  $tpl->setCurrentBlock("latest_rev");
1368  $tpl->setVariable("TXT_LATEST_REV", $lng->txt("cont_latest_rev"));
1369  $ilCtrl->setParameter($this, "old_nr", "");
1370  $tpl->setVariable("HREF_LATEST",
1371  $ilCtrl->getLinkTarget($this, "preview"));
1372  $tpl->parseCurrentBlock();
1373 
1374  // rollback
1375  if ($c_old_nr > 0 && $ilUser->getId() != ANONYMOUS_USER_ID)
1376  {
1377  $tpl->setCurrentBlock("rollback");
1378  $ilCtrl->setParameter($this, "old_nr", $c_old_nr);
1379  $tpl->setVariable("HREF_ROLLBACK",
1380  $ilCtrl->getLinkTarget($this, "rollbackConfirmation"));
1381  $ilCtrl->setParameter($this, "old_nr", "");
1382  $tpl->setVariable("TXT_ROLLBACK",
1383  $lng->txt("cont_rollback"));
1384  $tpl->parseCurrentBlock();
1385  }
1386  }
1387 
1388  $tpl->setCurrentBlock("hist_nav");
1389  $tpl->setVariable("TXT_REVISION", $lng->txt("cont_revision"));
1390  $tpl->setVariable("VAL_REVISION_DATE",
1391  ilDatePresentation::formatDate(new ilDateTime($hist_info["current"]["hdate"], IL_CAL_DATETIME)));
1392  $tpl->setVariable("VAL_REV_USER",
1393  ilUserUtil::getNamePresentation($hist_info["current"]["user_id"]));
1394  $tpl->parseCurrentBlock();
1395  }
1396  }
1397  }
1398  }
1399  if ($this->getOutputMode() != IL_PAGE_PRESENTATION &&
1400  $this->getOutputMode() != IL_PAGE_OFFLINE &&
1401  $this->getOutputMode() != IL_PAGE_PREVIEW &&
1402  $this->getOutputMode() != IL_PAGE_PRINT)
1403  {
1404  $tpl->setVariable("FORMACTION", $this->ctrl->getFormActionByClass("ilpageeditorgui"));
1405  }
1406 
1407  // output media object edit list (of media links)
1408  if($this->getOutputMode() == "edit")
1409  {
1410  $links = ilInternalLink::_getTargetsOfSource($this->obj->getParentType().":pg",
1411  $this->obj->getId());
1412  $mob_links = array();
1413  foreach($links as $link)
1414  {
1415  if ($link["type"] == "mob")
1416  {
1417  if (ilObject::_exists($link["id"]) && ilObject::_lookupType($link["id"]) == "mob")
1418  {
1419  $mob_links[$link["id"]] = ilObject::_lookupTitle($link["id"])." [".$link["id"]."]";
1420  }
1421  }
1422  }
1423 
1424  // linked media objects
1425  if (count($mob_links) > 0)
1426  {
1427  $tpl->setCurrentBlock("med_link");
1428  $tpl->setVariable("TXT_LINKED_MOBS", $this->lng->txt("cont_linked_mobs"));
1429  $tpl->setVariable("SEL_MED_LINKS",
1430  ilUtil::formSelect(0, "mob_id", $mob_links, false, true));
1431  $tpl->setVariable("TXT_EDIT_MEDIA", $this->lng->txt("cont_edit_mob"));
1432  $tpl->setVariable("TXT_COPY_TO_CLIPBOARD", $this->lng->txt("cont_copy_to_clipboard"));
1433  //$this->tpl->setVariable("TXT_COPY_TO_POOL", $this->lng->txt("cont_copy_to_mediapool"));
1434  $tpl->parseCurrentBlock();
1435  }
1436 
1437  // content snippets used
1438  $snippets = $this->getPageObject()->collectContentIncludes();
1439  if (count($snippets) > 0)
1440  {
1441  foreach ($snippets as $s)
1442  {
1443  include_once("./Modules/MediaPool/classes/class.ilMediaPoolPage.php");
1444  $sn_arr[$s["id"]] = ilMediaPoolPage::lookupTitle($s["id"]);
1445  }
1446  $tpl->setCurrentBlock("med_link");
1447  $tpl->setVariable("TXT_CONTENT_SNIPPETS_USED", $this->lng->txt("cont_snippets_used"));
1448  $tpl->setVariable("SEL_SNIPPETS",
1449  ilUtil::formSelect(0, "ci_id", $sn_arr, false, true));
1450  $tpl->setVariable("TXT_SHOW_INFO", $this->lng->txt("cont_show_info"));
1451  $tpl->parseCurrentBlock();
1452  }
1453 
1454  // scheduled activation?
1455  if (!$this->getPageObject()->getActive() &&
1456  $this->getPageObject()->getActivationStart() != "" &&
1458  {
1459  $tpl->setCurrentBlock("activation_txt");
1460  $tpl->setVariable("TXT_SCHEDULED_ACTIVATION", $lng->txt("cont_scheduled_activation"));
1461  $tpl->setVariable("SA_FROM",
1463  new ilDateTime($this->getPageObject()->getActivationStart(),
1464  IL_CAL_DATETIME)));
1465  $tpl->setVariable("SA_TO",
1467  new ilDateTime($this->getPageObject()->getActivationEnd(),
1468  IL_CAL_DATETIME)));
1469  $tpl->parseCurrentBlock();
1470  }
1471  }
1472 
1473  if ($_GET["reloadTree"] == "y")
1474  {
1475  $tpl->setCurrentBlock("reload_tree");
1476  if ($this->obj->getParentType() == "dbk")
1477  {
1478  $tpl->setVariable("LINK_TREE",
1479  $this->ctrl->getLinkTargetByClass("ilobjdlbookgui", "explorer", "", false, false));
1480  }
1481  else
1482  {
1483  $tpl->setVariable("LINK_TREE",
1484  $this->ctrl->getLinkTargetByClass("ilobjlearningmodulegui", "explorer", "", false, false));
1485  }
1486  $tpl->parseCurrentBlock();
1487  }
1488 // }
1489 
1490  // get content
1491  $builded = $this->obj->buildDom();
1492 
1493  // manage hierarchical ids
1494  if($this->getOutputMode() == "edit")
1495  {
1496 
1497  // add pc ids, if necessary
1498  if (!$this->obj->checkPCIds())
1499  {
1500  $this->obj->insertPCIds();
1501  $this->obj->update(true, true);
1502  }
1503 
1504  $this->obj->addFileSizes();
1505  $this->obj->addHierIDs();
1506 
1507  $hids = $this->obj->getHierIds();
1508  $row1_ids = $this->obj->getFirstRowIds();
1509  $col1_ids = $this->obj->getFirstColumnIds();
1510  $litem_ids = $this->obj->getListItemIds();
1511  $fitem_ids = $this->obj->getFileItemIds();
1512 
1513  // standard menues
1514  $hids = $this->obj->getHierIds();
1515  foreach($hids as $hid)
1516  {
1517  $tpl->setCurrentBlock("add_dhtml");
1518  $tpl->setVariable("CONTEXTMENU", "contextmenu_".$hid);
1519  $tpl->parseCurrentBlock();
1520  }
1521 
1522  // column menues for tables
1523  foreach($col1_ids as $hid)
1524  {
1525  $tpl->setCurrentBlock("add_dhtml");
1526  $tpl->setVariable("CONTEXTMENU", "contextmenu_r".$hid);
1527  $tpl->parseCurrentBlock();
1528  }
1529 
1530  // row menues for tables
1531  foreach($row1_ids as $hid)
1532  {
1533  $tpl->setCurrentBlock("add_dhtml");
1534  $tpl->setVariable("CONTEXTMENU", "contextmenu_c".$hid);
1535  $tpl->parseCurrentBlock();
1536  }
1537 
1538  // list item menues
1539  foreach($litem_ids as $hid)
1540  {
1541  $tpl->setCurrentBlock("add_dhtml");
1542  $tpl->setVariable("CONTEXTMENU", "contextmenu_i".$hid);
1543  $tpl->parseCurrentBlock();
1544  }
1545 
1546  // file item menues
1547  foreach($fitem_ids as $hid)
1548  {
1549  $tpl->setCurrentBlock("add_dhtml");
1550  $tpl->setVariable("CONTEXTMENU", "contextmenu_i".$hid);
1551  $tpl->parseCurrentBlock();
1552  }
1553  }
1554  else
1555  {
1556  $this->obj->addFileSizes();
1557  }
1558 
1559 //echo "<br>-".htmlentities($this->obj->getXMLContent())."-<br><br>";
1560 //echo "<br>-".htmlentities($this->getLinkXML())."-";
1561 
1562  // set default link xml, if nothing was set yet
1563  if (!$this->link_xml_set)
1564  {
1565  $this->setDefaultLinkXml();
1566  }
1567 
1568  //$content = $this->obj->getXMLFromDom(false, true, true,
1569  // $this->getLinkXML().$this->getQuestionXML().$this->getComponentPluginsXML());
1570  $link_xml = $this->getLinkXML();
1571 
1572  if ($this->getStyleId() > 0)
1573  {
1574  if (ilObject::_lookupType($this->getStyleId()) == "sty")
1575  {
1576  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
1577  $style = new ilObjStyleSheet($this->getStyleId());
1578  $template_xml = $style->getTemplateXML();
1579  $disable_auto_margins = "n";
1580  if ($style->lookupStyleSetting("disable_auto_margins"))
1581  {
1582  $disable_auto_margins = "y";
1583  }
1584  }
1585  }
1586  $content = $this->obj->getXMLFromDom(false, true, true,
1587  $link_xml.$this->getQuestionXML().$template_xml);
1588 
1589  // get page component plugins
1590 
1591  // check validation errors
1592  if($builded !== true)
1593  {
1594  $this->displayValidationError($builded);
1595  }
1596  else
1597  {
1598  $this->displayValidationError($_SESSION["il_pg_error"]);
1599  }
1600  unset($_SESSION["il_pg_error"]);
1601 
1602  if(isset($_SESSION["citation_error"]))
1603  {
1604  ilUtil::sendFailure($this->lng->txt("cont_citation_selection_not_valid"));
1605  session_unregister("citation_error");
1606  unset($_SESSION["citation_error"]);
1607  }
1608 
1609  // get title
1610  $pg_title = $this->getPresentationTitle();
1611 
1612  $add_path = ilUtil::getImagePath("add.gif");
1613  $col_path = ilUtil::getImagePath("col.gif");
1614  $row_path = ilUtil::getImagePath("row.gif");
1615  $item_path = ilUtil::getImagePath("item.gif");
1616  $med_disabled_path = ilUtil::getImagePath("media_disabled.gif");
1617 
1618  if ($this->getOutputMode() != "offline")
1619  {
1620  $enlarge_path = ilUtil::getImagePath("enlarge.gif");
1621  $wb_path = ilUtil::getWebspaceDir("output")."/";
1622  }
1623  else
1624  {
1625  $enlarge_path = "images/enlarge.gif";
1626  $wb_path = "";
1627  }
1628  $pg_title_class = ($this->getOutputMode() == "print")
1629  ? "ilc_PrintPageTitle"
1630  : "";
1631 
1632  // page splitting only for learning modules and
1633  // digital books
1634  $enable_split_new = ($this->obj->getParentType() == "lm" ||
1635  $this->obj->getParentType() == "dbk")
1636  ? "y"
1637  : "n";
1638 
1639  // page splitting to next page only for learning modules and
1640  // digital books if next page exists in tree
1641  if (($this->obj->getParentType() == "lm" ||
1642  $this->obj->getParentType() == "dbk") &&
1643  ilObjContentObject::hasSuccessorPage($this->obj->getParentId(),
1644  $this->obj->getId()))
1645  {
1646  $enable_split_next = "y";
1647  }
1648  else
1649  {
1650  $enable_split_next = "n";
1651  }
1652 
1653 
1654  $paragraph_plugins = new ilParagraphPlugins();
1655  $paragraph_plugins->initialize ();
1656 
1657  if ($this->getOutputMode() == IL_PAGE_PRESENTATION)
1658  {
1659  $paragraph_plugin_string = $paragraph_plugins->serializeToString();
1660  $_SESSION ["paragraph_plugins"] = $paragraph_plugins;
1661  }
1662 
1663  $img_path = ilUtil::getImagePath("", false, $this->getOutputMode(), $this->getOutputMode() == "offline");
1664 
1665  //$wb_path = "../".$this->ilias->ini->readVariable("server","webspace_dir");
1666  //echo "-".$this->sourcecode_download_script.":";
1667 
1668  if ($this->getEnabledPCTabs())
1669  {
1670  //include_once("./Services/YUI/classes/class.ilYuiUtil.php");
1671  //ilYuiUtil::initTabView();
1672  include_once("./Services/Accordion/classes/class.ilAccordionGUI.php");
1675  }
1676 
1677  $file_download_link = $this->determineFileDownloadLink();
1678  $fullscreen_link = $this->determineFullscreenLink();
1679  $this->sourcecode_download_script = $this->determineSourcecodeDownloadScript();
1680 
1681  // default values for various parameters (should be used by
1682  // all instances in the future)
1683  $media_mode = ($this->getOutputMode() == "edit")
1684  ? $ilUser->getPref("ilPageEditor_MediaMode")
1685  : "enable";
1686 
1687  include_once("./Modules/LearningModule/classes/class.ilEditClipboard.php");
1688  $paste = (ilEditClipboard::getAction() == "copy" &&
1689  $this->getOutputMode() == "edit");
1690 
1691  // added UTF-8 encoding otherwise umlaute are converted too
1692  $params = array ('mode' => $this->getOutputMode(), 'pg_title' => htmlentities($pg_title,ENT_QUOTES,"UTF-8"),
1693  'pg_id' => $this->obj->getId(), 'pg_title_class' => $pg_title_class,
1694  'webspace_path' => $wb_path, 'enlarge_path' => $enlarge_path,
1695  'img_add' => $add_path,
1696  'img_col' => $col_path,
1697  'img_row' => $row_path,
1698  'img_item' => $item_path,
1699  'enable_split_new' => $enable_split_new,
1700  'enable_split_next' => $enable_split_next,
1701  'link_params' => $this->link_params,
1702  'file_download_link' => $file_download_link,
1703  'fullscreen_link' => $fullscreen_link,
1704  'med_disabled_path' => $med_disabled_path,
1705  'img_path' => $img_path,
1706  'parent_id' => $this->obj->getParentId(),
1707  'download_script' => $this->sourcecode_download_script,
1708  'encoded_download_script' => urlencode($this->sourcecode_download_script),
1709  // digilib
1710  'bib_id' => $this->getBibId(),'citation' => (int) $this->isEnabledCitation(),
1711  'pagebreak' => $this->lng->txt('dgl_pagebreak'),
1712  'page' => $this->lng->txt('page'),
1713  'citate_page' => $this->lng->txt('citate_page'),
1714  'citate_from' => $this->lng->txt('citate_from'),
1715  'citate_to' => $this->lng->txt('citate_to'),
1716  'citate' => $this->lng->txt('citate'),
1717  'enable_rep_objects' => $this->getEnabledRepositoryObjects() ? "y" : "n",
1718  'enable_map' => $this->getEnabledMaps() ? "y" : "n",
1719  'enable_tabs' => $this->getEnabledPCTabs() ? "y" : "n",
1720  'enable_sa_qst' => $this->getEnabledSelfAssessment() ? "y" : "n",
1721  'enable_file_list' => $this->getEnabledFileLists() ? "y" : "n",
1722  'enable_content_includes' => $this->isEnabledContentIncludes() ? "y" : "n",
1723  'paste' => $paste ? "y" : "n",
1724  'media_mode' => $media_mode,
1725  'javascript' => $sel_js_mode,
1726  'paragraph_plugins' => $paragraph_plugin_string,
1727  'disable_auto_margins' => $disable_auto_margins
1728  );
1729  if($this->link_frame != "") // todo other link types
1730  $params["pg_frame"] = $this->link_frame;
1731 
1732  //$content = str_replace("&nbsp;", "", $content);
1733 
1734  // this ensures that cache is emptied with every update
1735  $params["version"] = ILIAS_VERSION;
1736 
1737  // ensure no cache hit, if included files/media objects have been changed
1738  $params["incl_elements_date"] = $this->obj->getLastUpdateOfIncludedElements();
1739 
1740  // run xslt
1741 
1742  $md5 = md5(serialize($params).$link_xml.$template_xml);
1743 
1744 //$a = microtime();
1745 
1746  // check cache (same parameters, non-edit mode and rendered time
1747  // > last change
1748  if (($this->getOutputMode() == "preview" || $this->getOutputMode() == "presentation") &&
1749  $md5 == $this->obj->getRenderMd5() &&
1750  ($this->obj->getLastChange() < $this->obj->getRenderedTime()) &&
1751  $this->obj->getRenderedTime() != "" &&
1752  $this->obj->old_nr == 0)
1753  {
1754  // cache hit
1755  $output = $this->obj->getRenderedContent();
1756  }
1757  else
1758  {
1759  if ($this->getLayoutMode() == true) {
1760  $xsl = file_get_contents("./Services/COPage/xsl/page_layout.xsl");
1761  } else {
1762  $xsl = file_get_contents("./Services/COPage/xsl/page.xsl");
1763  }
1764 //echo htmlentities($content); exit;
1765  $args = array( '/_xml' => $content, '/_xsl' => $xsl );
1766  $xh = xslt_create();
1767  // echo "<b>XSLT</b>:".htmlentities($xsl).":<br>";
1768  // echo "mode:".$this->getOutputMode().":<br>";
1769  $output = xslt_process($xh, "arg:/_xml","arg:/_xsl", NULL, $args, $params);
1770 
1771  if (($this->getOutputMode() == "presentation" || $this->getOutputMode() == "preview")
1772  && $this->obj->old_nr == 0)
1773  {
1774 //echo "writerenderedcontent";
1775  $this->obj->writeRenderedContent($output, $md5);
1776  }
1777  //echo xslt_error($xh);
1778  xslt_free($xh);
1779  }
1780 
1781 //$b = microtime();
1782 //echo "$a - $b";
1783 //echo "<pre>".htmlentities($output)."</pre>";
1784 
1785  // unmask user html
1786  if (($this->getOutputMode() != "edit" ||
1787  $ilUser->getPref("ilPageEditor_HTMLMode") != "disable")
1788  && !$this->getPreventHTMLUnmasking())
1789  {
1790  $output = str_replace("&lt;","<",$output);
1791  $output = str_replace("&gt;",">",$output);
1792  }
1793  $output = str_replace("&amp;", "&", $output);
1794 
1795  // replace latex code: todo: finish
1796  if ($this->getOutputMode() != "offline")
1797  {
1798  $output = ilUtil::insertLatexImages($output);
1799  }
1800  else
1801  {
1802  $output = ilUtil::buildLatexImages($output,
1803  $this->getOfflineDirectory());
1804  }
1805 
1806  $output = $this->insertContentIncludes($output);
1807 
1808  // workaround for preventing template engine
1809  // from hiding paragraph text that is enclosed
1810  // in curly brackets (e.g. "{a}", see ilLMEditorGUI::executeCommand())
1811  $output = str_replace("{", "&#123;", $output);
1812  $output = str_replace("}", "&#125;", $output);
1813 
1814  // remove all newlines (important for code / pre output)
1815  $output = str_replace("\n", "", $output);
1816 
1817  // add question HTML
1818  $qhtml = $this->getQuestionHTML();
1819  if (is_array($qhtml))
1820  {
1821  foreach ($qhtml as $k => $h)
1822  {
1823  $output = str_replace("&#123;&#123;&#123;&#123;&#123;Question;il__qst_$k&#125;&#125;&#125;&#125;&#125;", " ".$h, $output);
1824  }
1825  }
1826 
1827 //echo htmlentities($output);
1828  $output = $this->postOutputProcessing($output);
1829 //echo htmlentities($output);
1830  if($this->getOutputMode() == "edit" && !$this->getPageObject()->getActive($this->getEnabledScheduledActivation()))
1831  {
1832  $output = '<div class="il_editarea_disabled">'.$output.'</div>';
1833  }
1834 
1835  $output = $this->insertMaps($output);
1836  $output = $this->obj->insertSourceCodeParagraphs($output, $this->getOutputMode());
1837 
1838  $ilBench->stop("ContentPresentation", "ilPageObjectGUI_showPage");
1839 
1840  $output = $this->selfAssessmentRendering($output);
1841 
1842  // output
1843  if ($ilCtrl->isAsynch())
1844  {
1845  $tpl->setVariable($this->getTemplateOutputVar(), $output);
1846  echo $tpl->get();
1847  exit;
1848 
1849  $tpl->setVariable($this->getTemplateOutputVar(), $output);
1850  $tpl->setCurrentBlock("adm_content");
1851  $tpl->parseCurrentBlock();
1852  echo $tpl->get("adm_content");
1853  exit;
1854  }
1855  if ($this->outputToTemplate())
1856  {
1857  $tpl->setVariable($this->getTemplateOutputVar(), $output);
1858  $this->tpl->setVariable($this->getTemplateTargetVar(), $tpl->get());
1859  return $output;
1860  }
1861  else
1862  {
1863  if ($this->getRawPageContent()) // e.g. needed in glossaries
1864  {
1865  return $output;
1866  }
1867  else
1868  {
1869  $tpl->setVariable($this->getTemplateOutputVar(), $output);
1870  return $tpl->get();
1871  }
1872  }
1873  }
1874 
1879  {
1880  global $ilCtrl;
1881 
1882  $int_links = $this->getPageObject()->getInternalLinks();
1883 //var_dump($int_links);
1884  $link_info = "<IntLinkInfos>";
1885  $targetframe = "None";
1886  foreach ($int_links as $int_link)
1887  {
1888  $target = $int_link["Target"];
1889  if (substr($target, 0, 4) == "il__")
1890  {
1891  $target_arr = explode("_", $target);
1892  $target_id = $target_arr[count($target_arr) - 1];
1893  $type = $int_link["Type"];
1894 
1895  $targetframe = ($int_link["TargetFrame"] != "")
1896  ? $int_link["TargetFrame"]
1897  : "None";
1898 
1899  $ltarget="_top";
1900  if ($targetframe != "None")
1901  {
1902  $ltarget="_blank";
1903  }
1904 
1905  // anchor
1906  $anc = $anc_add = "";
1907  if ($int_link["Anchor"] != "")
1908  {
1909  $anc = $int_link["Anchor"];
1910  $anc_add = "_".rawurlencode($int_link["Anchor"]);
1911  }
1912 
1913  $href = "";
1914  switch($type)
1915  {
1916  case "PageObject":
1917  case "StructureObject":
1919  if ($type == "PageObject")
1920  {
1921  $href = "./goto.php?target=pg_".$target_id.$anc_add;
1922  }
1923  else
1924  {
1925  $href = "./goto.php?target=st_".$target_id;
1926  }
1927  break;
1928 
1929  case "GlossaryItem":
1930  if ($targetframe == "None")
1931  {
1932  $targetframe = "Glossary";
1933  }
1934  $href = "./goto.php?target=git_".$target_id;
1935  break;
1936 
1937  case "MediaObject":
1938  $ilCtrl->setParameter($this, "mob_id", $target_id);
1939  //$ilCtrl->setParameter($this, "pg_id", $this->obj->getId());
1940  $href = $ilCtrl->getLinkTarget($this, "displayMedia");
1941  $ilCtrl->setParameter($this, "mob_id", "");
1942  break;
1943 
1944  case "RepositoryItem":
1945  $obj_type = ilObject::_lookupType($target_id, true);
1947  $href = "./goto.php?target=".$obj_type."_".$target_id;
1948  break;
1949 
1950 
1951  }
1952  $anc_par = 'Anchor="'.$anc.'"';
1953  $link_info.="<IntLinkInfo Target=\"$target\" Type=\"$type\" ".$anc_par." ".
1954  "TargetFrame=\"$targetframe\" LinkHref=\"$href\" LinkTarget=\"$ltarget\" />";
1955  }
1956  }
1957  $link_info.= "</IntLinkInfos>";
1958 //echo htmlentities($link_info);
1959  $this->setLinkXML($link_info);
1960  }
1961 
1965  function downloadFile()
1966  {
1967  $file = explode("_", $_GET["file_id"]);
1968  require_once("./Modules/File/classes/class.ilObjFile.php");
1969  $fileObj =& new ilObjFile($file[count($file) - 1], false);
1970  $fileObj->sendFile();
1971  exit;
1972  }
1973 
1978  {
1979  $this->displayMedia(true);
1980  }
1981 
1985  function displayMedia($a_fullscreen = false)
1986  {
1987  $tpl = new ilTemplate("tpl.fullscreen.html", true, true, "Modules/LearningModule");
1988  $tpl->setCurrentBlock("ilMedia");
1989 
1990  //$int_links = $page_object->getInternalLinks();
1991  $med_links = ilMediaItem::_getMapAreasIntLinks($_GET["mob_id"]);
1992 
1993  // @todo
1994  //$link_xml = $this->getLinkXML($med_links, $this->getLayoutLinkTargets());
1995 
1996  require_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1997  $media_obj = new ilObjMediaObject($_GET["mob_id"]);
1998  require_once("./Services/COPage/classes/class.ilPageObject.php");
1999  $pg_obj = $this->getPageObject();
2000  $pg_obj->buildDom();
2001 
2002  if (!empty ($_GET["pg_id"]))
2003  {
2004  $xml = "<dummy>";
2005  $xml.= $pg_obj->getMediaAliasElement($_GET["mob_id"]);
2006  $xml.= $media_obj->getXML(IL_MODE_OUTPUT);
2007  $xml.= $link_xml;
2008  $xml.="</dummy>";
2009  }
2010  else
2011  {
2012  $xml = "<dummy>";
2013  $xml.= $media_obj->getXML(IL_MODE_ALIAS);
2014  $xml.= $media_obj->getXML(IL_MODE_OUTPUT);
2015  $xml.= $link_xml;
2016  $xml.="</dummy>";
2017  }
2018 
2019  $xsl = file_get_contents("./Services/COPage/xsl/page.xsl");
2020  $args = array( '/_xml' => $xml, '/_xsl' => $xsl );
2021  $xh = xslt_create();
2022 
2023  $mode = "media";
2024  if ($a_fullscreen)
2025  {
2026  $mode = "fullscreen";
2027  }
2028 
2029 //echo "<b>XML:</b>".htmlentities($xml);
2030  // determine target frames for internal links
2031  $wb_path = ilUtil::getWebspaceDir("output")."/";
2032  $enlarge_path = ilUtil::getImagePath("enlarge.gif");
2033  $params = array ('mode' => $mode, 'enlarge_path' => $enlarge_path,
2034  'link_params' => "ref_id=".$_GET["ref_id"],'fullscreen_link' => "",
2035  'ref_id' => $_GET["ref_id"], 'webspace_path' => $wb_path);
2036  $output = xslt_process($xh,"arg:/_xml","arg:/_xsl",NULL,$args, $params);
2037 //echo "<br><br>".htmlentities($output);
2038  //echo xslt_error($xh);
2039  xslt_free($xh);
2040 
2041  // unmask user html
2042  $tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
2044  $tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
2045  $tpl->setVariable("MEDIA_CONTENT", $output);
2046  echo $tpl->get();
2047  exit;
2048  }
2049 
2054  {
2055  $pg_obj = $this->getPageObject();
2056  $pg_obj->send_paragraph($_GET["par_id"], $_GET["downloadtitle"]);
2057  }
2058 
2062  function insertMaps($a_html)
2063  {
2064  $c_pos = 0;
2065  $start = strpos($a_html, "[[[[[Map;");
2066  if (is_int($start))
2067  {
2068  $end = strpos($a_html, "]]]]]", $start);
2069  }
2070  $i = 1;
2071  while ($end > 0)
2072  {
2073  $param = substr($a_html, $start + 9, $end - $start - 9);
2074 
2075  $param = explode(";", $param);
2076  if (is_numeric($param[0]) && is_numeric($param[1]) && is_numeric($param[2]))
2077  {
2078  include_once("./Services/GoogleMaps/classes/class.ilGoogleMapGUI.php");
2079  $map_gui = new ilGoogleMapGUI();
2080  $map_gui->setMapId("map_".$i);
2081  $map_gui->setLatitude($param[0]);
2082  $map_gui->setLongitude($param[1]);
2083  $map_gui->setZoom($param[2]);
2084  $map_gui->setWidth($param[3]."px");
2085  $map_gui->setHeight($param[4]."px");
2086  $map_gui->setEnableTypeControl(true);
2087  $map_gui->setEnableNavigationControl(true);
2088  $map_gui->setEnableCentralMarker(true);
2089  $h2 = substr($a_html, 0, $start).
2090  $map_gui->getHtml().
2091  substr($a_html, $end + 5);
2092  $a_html = $h2;
2093  $i++;
2094  }
2095  $start = strpos($a_html, "[[[[[Map;", $start + 5);
2096  $end = 0;
2097  if (is_int($start))
2098  {
2099  $end = strpos($a_html, "]]]]]", $start);
2100  }
2101  }
2102 
2103  return $a_html;
2104  }
2105 
2109  function insertContentIncludes($a_html)
2110  {
2111  global $ilCtrl;
2112 
2113  $c_pos = 0;
2114  $start = strpos($a_html, "{{{{{ContentInclude;");
2115  if (is_int($start))
2116  {
2117  $end = strpos($a_html, "}}}}}", $start);
2118  }
2119  $i = 1;
2120  while ($end > 0)
2121  {
2122  $param = substr($a_html, $start + 20, $end - $start - 20);
2123  $param = explode(";", $param);
2124 
2125  if ($param[0] == "mep" && is_numeric($param[1]) && $param[2] <= 0)
2126  {
2127  include_once("./Modules/MediaPool/classes/class.ilMediaPoolPageGUI.php");
2128  if (ilMediaPoolPage::_exists($param[1]))
2129  {
2130  $page_gui = new ilMediaPoolPageGUI($param[1]);
2131 
2132  if ($this->getOutputMode() != "offline")
2133  {
2134  $page_gui->setFileDownloadLink($this->determineFileDownloadLink());
2135  $page_gui->setFullscreenLink($this->determineFullscreenLink());
2136  $page_gui->setSourceCodeDownloadScript($this->determineSourcecodeDownloadScript());
2137  }
2138  else
2139  {
2140  $page_gui->setOutputMode(IL_PAGE_OFFLINE);
2141  }
2142 
2143  $html = $page_gui->getRawContent();
2144  }
2145  else
2146  {
2147  $html = "";
2148  }
2149  $h2 = substr($a_html, 0, $start).
2150  $html.
2151  substr($a_html, $end + 5);
2152  $a_html = $h2;
2153  $i++;
2154  }
2155  $start = strpos($a_html, "{{{{{ContentInclude;", $start + 5);
2156  $end = 0;
2157  if (is_int($start))
2158  {
2159  $end = strpos($a_html, "}}}}}", $start);
2160  }
2161  }
2162  return $a_html;
2163  }
2164 
2169  function postOutputProcessing($a_output)
2170  {
2171  return $a_output;
2172  }
2173 
2177  function insertHelp($a_tpl)
2178  {
2179  global $lng;
2180 
2181  $a_tpl->setCurrentBlock("help_img");
2182  $a_tpl->setVariable("IMG_HELP", ilUtil::getImagePath("streaked_area.gif"));
2183  $a_tpl->parseCurrentBlock();
2184  $a_tpl->setCurrentBlock("help_item");
2185  $a_tpl->setVariable("TXT_HELP", $lng->txt("cont_add_elements"));
2186  $a_tpl->parseCurrentBlock();
2187 
2188  $a_tpl->setCurrentBlock("help_img");
2189  $a_tpl->setVariable("IMG_HELP", ilUtil::getImagePath("icon_cont_el_s.gif"));
2190  $a_tpl->parseCurrentBlock();
2191  $a_tpl->setCurrentBlock("help_img");
2192  $a_tpl->setVariable("IMG_HELP", ilUtil::getImagePath("drop_streaked_area.gif"));
2193  $a_tpl->parseCurrentBlock();
2194  $a_tpl->setCurrentBlock("help_item");
2195  $a_tpl->setVariable("TXT_HELP", $lng->txt("cont_drag_and_drop_elements"));
2196  $a_tpl->parseCurrentBlock();
2197 
2198  $a_tpl->setCurrentBlock("help_img");
2199  $a_tpl->setVariable("IMG_HELP", ilUtil::getImagePath("icon_cont_el_s.gif"));
2200  $a_tpl->parseCurrentBlock();
2201  $a_tpl->setCurrentBlock("help_item");
2202  $a_tpl->setVariable("TXT_HELP", $lng->txt("cont_double_click_to_delete"));
2203  $a_tpl->parseCurrentBlock();
2204 
2205  $a_tpl->setCurrentBlock("help");
2206  $a_tpl->parseCurrentBlock();
2207  }
2208 
2209  /*
2210  * preview
2211  */
2212  function preview()
2213  {
2214  global $tree;
2216  return $this->showPage();
2217  }
2218 
2219  /*
2220  * edit ("view" before)
2221  */
2222  function edit()
2223  {
2224  global $tree, $lng, $ilCtrl;
2225 
2226  if (!$this->getEnableEditing())
2227  {
2228  ilUtil::sendFailure($lng->txt("permission_denied"), true);
2229  $ilCtrl->redirect($this, "preview");
2230  }
2231 
2232  $this->setOutputMode(IL_PAGE_EDIT);
2233 
2234  // scorm2004-start
2235  $html = $this->showPage();
2236  if ($this->isEnabledNotes())
2237  {
2238  $html.= "<br /><br />".$this->getNotesHTML($a_mode = "");
2239  }
2240  // scorm2004-end
2241  return $html;
2242  }
2243 
2244  /*
2245  * presentation
2246  */
2248  {
2249  global $tree;
2250  $this->setOutputMode($a_mode);
2251 
2252  return $this->showPage();
2253  }
2254 
2255  function getHTML()
2256  {
2257  $this->getTabs("preview");
2258  return $this->showPage();
2259  }
2260 
2264  function showMediaFullscreen($a_style_id = 0)
2265  {
2266  $this->tpl = new ilTemplate("tpl.fullscreen.html", true, true, "Services/COPage");
2267  $this->tpl->setCurrentBlock("ContentStyle");
2268  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", 0);
2269  $this->tpl->parseCurrentBlock();
2270 
2271  $this->tpl->setVariable("PAGETITLE", " - ".ilObject::_lookupTitle($_GET["mob_id"]));
2272  $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
2273  $this->tpl->setCurrentBlock("ilMedia");
2274 
2275  require_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
2276  $media_obj =& new ilObjMediaObject($_GET["mob_id"]);
2277  if (!empty ($_GET["pg_id"]))
2278  {
2279  require_once("./Services/COPage/classes/class.ilPageObject.php");
2280  $pg_obj =& new ilPageObject($this->obj->getParentType(), $_GET["pg_id"]);
2281  $pg_obj->buildDom();
2282 
2283  $xml = "<dummy>";
2284  // todo: we get always the first alias now (problem if mob is used multiple
2285  // times in page)
2286  $xml.= $pg_obj->getMediaAliasElement($_GET["mob_id"]);
2287  $xml.= $media_obj->getXML(IL_MODE_OUTPUT);
2288  $xml.="</dummy>";
2289  }
2290  else
2291  {
2292  $xml = "<dummy>";
2293  $xml.= $media_obj->getXML(IL_MODE_ALIAS);
2294  $xml.= $media_obj->getXML(IL_MODE_OUTPUT);
2295  $xml.="</dummy>";
2296  }
2297 
2298 //echo htmlentities($xml); exit;
2299 
2300  $xsl = file_get_contents("./Services/COPage/xsl/page.xsl");
2301  $args = array( '/_xml' => $xml, '/_xsl' => $xsl );
2302  $xh = xslt_create();
2303 
2304 //echo "<b>XML:</b>".htmlentities($xml);
2305  // determine target frames for internal links
2306  //$pg_frame = $_GET["frame"];
2307  $wb_path = ilUtil::getWebspaceDir("output")."/";
2308 // $wb_path = "../".$this->ilias->ini->readVariable("server","webspace_dir");
2309  $mode = "fullscreen";
2310  $params = array ('mode' => $mode, 'webspace_path' => $wb_path);
2311  $output = xslt_process($xh,"arg:/_xml","arg:/_xsl",NULL,$args, $params);
2312  echo xslt_error($xh);
2313  xslt_free($xh);
2314 
2315  // unmask user html
2316  $this->tpl->setVariable("MEDIA_CONTENT", $output);
2317  }
2318 
2324  function displayValidationError($a_error)
2325  {
2326  if(is_array($a_error))
2327  {
2328  $error_str = "<b>Validation Error(s):</b><br>";
2329  foreach ($a_error as $error)
2330  {
2331  $err_mess = implode($error, " - ");
2332  if (!is_int(strpos($err_mess, ":0:")))
2333  {
2334  $error_str .= htmlentities($err_mess)."<br />";
2335  }
2336  }
2337  $this->tpl->setVariable("MESSAGE", $error_str);
2338  }
2339  }
2340 
2344  function history()
2345  {
2346  global $tpl, $lng, $ilAccess;
2347 
2348  $tpl->addJavaScript("./Services/COPage/js/page_history.js");
2349 
2350  include_once("./Services/COPage/classes/class.ilPageHistoryTableGUI.php");
2351  $table_gui = new ilPageHistoryTableGUI($this, "history");
2352  $table_gui->setId("hist_table");
2353  $entries = $this->getPageObject()->getHistoryEntries();
2354  $entries[] = array('page_id' => $this->getPageObject()->getId(),
2355  'parent_type' => $this->getPageObject()->getParentType(),
2356  'hdate' => $this->getPageObject()->getLastChange(),
2357  'parent_id' => $this->getPageObject()->getParentId(),
2358  'nr' => 0,
2359  'sortkey' => 999999,
2360  'user' => $this->getPageObject()->last_change_user);
2361  $table_gui->setData($entries);
2362  return $table_gui->getHTML();
2363  }
2364 
2369  {
2370  global $tpl, $lng, $ilAccess, $ilCtrl;
2371 
2372  include_once("Services/Utilities/classes/class.ilConfirmationGUI.php");
2373  $c_gui = new ilConfirmationGUI();
2374 
2375  // set confirm/cancel commands
2376  $ilCtrl->setParameter($this, "rollback_nr", $_GET["old_nr"]);
2377  $c_gui->setFormAction($ilCtrl->getFormAction($this, "rollback"));
2378  $c_gui->setHeaderText($lng->txt("cont_rollback_confirmation"));
2379  $c_gui->setCancel($lng->txt("cancel"), "history");
2380  $c_gui->setConfirm($lng->txt("confirm"), "rollback");
2381 
2382  $hentry = $this->obj->getHistoryEntry($_GET["old_nr"]);
2383 
2384  $c_gui->addItem("id[]", $_GET["old_nr"],
2386 
2387  $tpl->setContent($c_gui->getHTML());
2388  }
2389 
2393  function rollback()
2394  {
2395  global $ilCtrl;
2396 
2397  $hentry = $this->obj->getHistoryEntry($_GET["rollback_nr"]);
2398 
2399  if ($hentry["content"] != "")
2400  {
2401  $this->obj->setXMLContent($hentry["content"]);
2402  $this->obj->buildDom(true);
2403  if ($this->obj->update())
2404  {
2405  $ilCtrl->redirect($this, "history");
2406  }
2407  }
2408  $ilCtrl->redirect($this, "history");
2409  }
2410 
2416  function getTabs($a_activate = "")
2417  {
2418  global $ilTabs, $ilCtrl;
2419 
2420  if (!$this->getEnabledTabs())
2421  {
2422  return;
2423  }
2424 
2425 //echo "-".$ilCtrl->getNextClass()."-".$ilCtrl->getCmd()."-";
2426  // back to upper context
2427 
2428  if (!$this->getEditPreview())
2429  {
2430  $ilTabs->addTarget("pg", $ilCtrl->getLinkTarget($this, "preview")
2431  , array("", "preview"));
2432 
2433  if ($this->getEnableEditing())
2434  {
2435  $ilTabs->addTarget("edit", $ilCtrl->getLinkTarget($this, "edit")
2436  , array("", "edit"));
2437  }
2438  }
2439  else
2440  {
2441  if ($this->getEnableEditing())
2442  {
2443  $ilTabs->addTarget("edit", $ilCtrl->getLinkTarget($this, "edit")
2444  , array("", "edit"));
2445  }
2446 
2447  $ilTabs->addTarget("cont_preview", $ilCtrl->getLinkTarget($this, "preview")
2448  , array("", "preview"));
2449  }
2450 
2451  //$tabs_gui->addTarget("properties", $this->ctrl->getLinkTarget($this, "properties")
2452  // , "properties", get_class($this));
2453 
2454  if ($this->use_meta_data && !$this->layout_mode)
2455  {
2456  $ilTabs->addTarget("meta_data",
2457  $this->ctrl->getLinkTargetByClass('ilmdeditorgui',''),
2458  "", "ilmdeditorgui");
2459  }
2460 
2461  if ($this->getEnableEditing() && !$this->layout_mode)
2462  {
2463  $ilTabs->addTarget("history", $this->ctrl->getLinkTarget($this, "history")
2464  , "history", get_class($this));
2465  }
2466 
2467 /* $tabs = $this->ctrl->getTabs();
2468  foreach ($tabs as $tab)
2469  {
2470  $tabs_gui->addTarget($tab["lang_var"], $tab["link"]
2471  , $tab["cmd"], $tab["class"]);
2472  }
2473 */
2474  if ($this->getEnableEditing())
2475  {
2476  $ilTabs->addTarget("clipboard", $this->ctrl->getLinkTargetByClass("ilEditClipboardGUI", "view")
2477  , "view", "ilEditClipboardGUI");
2478  }
2479 
2480  if ($this->getEnabledScheduledActivation())
2481  {
2482  $ilTabs->addTarget("cont_activation", $this->ctrl->getLinkTarget($this, "editActivation"),
2483  "editActivation", get_class($this));
2484  }
2485 
2486  if ($this->getEnabledNews())
2487  {
2488  $ilTabs->addTarget("news",
2489  $this->ctrl->getLinkTargetByClass("ilnewsitemgui", "editNews"),
2490  "", "ilnewsitemgui");
2491  }
2492 
2493  // external hook to add tabs
2494  if (is_array($this->tab_hook))
2495  {
2496  $func = $this->tab_hook["func"];
2497  $this->tab_hook["obj"]->$func();
2498  }
2499  //$ilTabs->setTabActive("pg");
2500  }
2501 
2505  function compareVersion()
2506  {
2507  global $lng;
2508 
2509  $tpl = new ilTemplate("tpl.page_compare.html", true, true, "Services/COPage");
2510  $compare = $this->obj->compareVersion($_POST["left"], $_POST["right"]);
2511 
2512  // left page
2513  $lpage = $compare["l_page"];
2514  $lpage_gui->setOutputMode(IL_PAGE_PREVIEW);
2515  $lpage_gui->setPageObject($lpage);
2516  $lpage_gui->setPreventHTMLUnmasking(true);
2517  $lpage_gui->setPresentationTitle($this->getPresentationTitle());
2518  $lpage_gui->setCompareMode(true);
2519  $lhtml = $lpage_gui->showPage();
2520  $lhtml = $this->replaceDiffTags($lhtml);
2521  $lhtml = str_replace("&lt;br /&gt;", "<br />", $lhtml);
2522  $tpl->setVariable("LEFT", $lhtml);
2523 
2524  // right page
2525  $rpage = $compare["r_page"];
2526  $rpage_gui->setOutputMode(IL_PAGE_PREVIEW);
2527  $rpage_gui->setPageObject($rpage);
2528  $rpage_gui->setPreventHTMLUnmasking(true);
2529  $rpage_gui->setPresentationTitle($this->getPresentationTitle());
2530  $rpage_gui->setCompareMode(true);
2531  $rhtml = $rpage_gui->showPage();
2532  $rhtml = $this->replaceDiffTags($rhtml);
2533  $rhtml = str_replace("&lt;br /&gt;", "<br />", $rhtml);
2534  $tpl->setVariable("RIGHT", $rhtml);
2535 
2536  $tpl->setVariable("TXT_NEW", $lng->txt("cont_pc_new"));
2537  $tpl->setVariable("TXT_MODIFIED", $lng->txt("cont_pc_modified"));
2538  $tpl->setVariable("TXT_DELETED", $lng->txt("cont_pc_deleted"));
2539 
2540 //var_dump($left);
2541 //var_dump($right);
2542 
2543  return $tpl->get();
2544  }
2545 
2546  function replaceDiffTags($a_html)
2547  {
2548  $a_html = str_replace("[ilDiffInsStart]", '<span class="ilDiffIns">', $a_html);
2549  $a_html = str_replace("[ilDiffDelStart]", '<span class="ilDiffDel">', $a_html);
2550  $a_html = str_replace("[ilDiffInsEnd]", '</span>', $a_html);
2551  $a_html = str_replace("[ilDiffDelEnd]", '</span>', $a_html);
2552 
2553  return $a_html;
2554  }
2555 
2559  function editActivation()
2560  {
2561  global $ilCtrl, $lng, $tpl;
2562 
2563  $atpl = new ilTemplate("tpl.page_activation.php", true, true, "Services/COPage");
2564  $this->initActivationForm();
2565  $this->getActivationFormValues();
2566  $atpl->setVariable("FORM", $this->form->getHTML());
2567  $atpl->setCurrentBlock("updater");
2568  $atpl->setVariable("UPDATER_FRAME", $this->exp_frame);
2569  $atpl->setVariable("EXP_ID_UPDATER", $this->exp_id);
2570  $atpl->setVariable("HREF_UPDATER", $this->exp_target_script);
2571  $atpl->parseCurrentBlock();
2572  $tpl->setContent($atpl->get());
2573  }
2574 
2579  {
2580  global $ilCtrl, $lng;
2581 
2582  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
2583  $this->form = new ilPropertyFormGUI();
2584  $this->form->setFormAction($ilCtrl->getFormAction($this));
2585  $this->form->setTitle($lng->txt("cont_page_activation"));
2586 
2587  // activation type radio
2588  $rad = new ilRadioGroupInputGUI($lng->txt("cont_activation"), "activation");
2589  $rad_op1 = new ilRadioOption($lng->txt("cont_activated"), "activated");
2590 
2591  $rad->addOption($rad_op1);
2592  $rad_op2 = new ilRadioOption($lng->txt("cont_deactivated"), "deactivated");
2593  $rad->addOption($rad_op2);
2594  $rad_op3 = new ilRadioOption($lng->txt("cont_scheduled_activation"), "scheduled");
2595 
2596  $dt_prop = new ilDateTimeInputGUI($lng->txt("cont_start"), "start");
2597  $dt_prop->setShowTime(true);
2598  $rad_op3->addSubItem($dt_prop);
2599  $dt_prop2 = new ilDateTimeInputGUI($lng->txt("cont_end"), "end");
2600  $dt_prop2->setShowTime(true);
2601  $rad_op3->addSubItem($dt_prop2);
2602 
2603  $rad->addOption($rad_op3);
2604 
2605  $this->form->addCommandButton("saveActivation", $lng->txt("save"));
2606 
2607  $this->form->addItem($rad);
2608  }
2609 
2614  {
2615  $values = array();
2616  $values["activation"] = "deactivated";
2617  if ($this->getPageObject()->getActive())
2618  {
2619  $values["activation"] = "activated";
2620  }
2621 
2622  $dt_prop = $this->form->getItemByPostVar("start");
2623  if ($this->getPageObject()->getActivationStart() != "")
2624  {
2625  $values["activation"] = "scheduled";
2626  $dt_prop->setDate(new ilDateTime($this->getPageObject()->getActivationStart(),
2627  IL_CAL_DATETIME));
2628  }
2629  $dt_prop = $this->form->getItemByPostVar("end");
2630  if ($this->getPageObject()->getActivationEnd() != "")
2631  {
2632  $values["activation"] = "scheduled";
2633  $dt_prop->setDate(new ilDateTime($this->getPageObject()->getActivationEnd(),
2634  IL_CAL_DATETIME));
2635  }
2636 
2637  $this->form->setValuesByArray($values);
2638  }
2639 
2643  function saveActivation()
2644  {
2645  global $tpl, $lng, $ilCtrl;
2646 
2647  $this->initActivationForm();
2648 
2649  if ($this->form->checkInput())
2650  {
2651  $this->getPageObject()->setActive(true);
2652  $this->getPageObject()->setActivationStart(null);
2653  $this->getPageObject()->setActivationEnd(null);
2654  if ($_POST["activation"] == "deactivated")
2655  {
2656  $this->getPageObject()->setActive(false);
2657  }
2658  if ($_POST["activation"] == "scheduled")
2659  {
2660  $this->getPageObject()->setActive(false);
2661  $this->getPageObject()->setActivationStart(
2662  $this->form->getItemByPostVar("start")->getDate()->get(IL_CAL_DATETIME));
2663  $this->getPageObject()->setActivationEnd(
2664  $this->form->getItemByPostVar("end")->getDate()->get(IL_CAL_DATETIME));
2665  }
2666  $this->getPageObject()->update();
2667  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
2668  $ilCtrl->redirect($this, "editActivation");
2669  }
2670  $this->form->getValuesByPost();
2671  $tpl->setContent($this->form->getHTML());
2672  }
2673 
2677  function getNotesHTML($a_mode = "")
2678  {
2679  global $ilCtrl;
2680 
2681  // notes
2682  $ilCtrl->setParameter($this, "nodes_mode", $a_mode);
2683  include_once("Services/Notes/classes/class.ilNoteGUI.php");
2684  $notes_gui = new ilNoteGUI($this->notes_parent_id,
2685  (int) $this->obj->getId(), "pg");
2686 // if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
2687 // {
2688 // $notes_gui->enablePublicNotesDeletion(true);
2689 // }
2690  $notes_gui->enablePrivateNotes();
2691  $notes_gui->enablePublicNotes();
2692 
2693  $next_class = $ilCtrl->getNextClass($this);
2694  if ($next_class == "ilnotegui")
2695  {
2696  $html = $this->ctrl->forwardCommand($notes_gui);
2697  }
2698  else
2699  {
2700  $html = $notes_gui->getNotesHTML();
2701  }
2702  return $html;
2703  }
2704 
2708  function getQuestionJsOfPage($a_no_interaction = false)
2709  {
2710  require_once './Modules/Scorm2004/classes/class.ilQuestionExporter.php';
2711  $q_ids = $this->getPageObject()->getQuestionIds();
2712  $js = array();
2713  if (count($q_ids) > 0)
2714  {
2715  foreach ($q_ids as $q_id)
2716  {
2717  $q_exporter = new ilQuestionExporter($a_no_interaction);
2718  $js[$q_id] = $q_exporter->exportQuestion($q_id);
2719  }
2720  }
2721  return $js;
2722  }
2723 
2728  {
2729  global $tpl, $ilCtrl, $lng;
2730 
2731  if ($this->getEnabledSelfAssessment())
2732  {
2733  $qhtml = $this->getQuestionJsOfPage(($this->getOutputMode()=="edit") ? true : false);
2734  $this->setQuestionHTML($qhtml);
2735  //include JQuery Libraries before Prototpye
2736  $tpl->addJavaScript("./Modules/Scorm2004/scripts/questions/jquery.js");
2737  $tpl->addJavaScript("./Modules/Scorm2004/scripts/questions/jquery-ui-min.js");
2738  $tpl->addJavaScript("./Modules/Scorm2004/scripts/questions/pure.js");
2739  $tpl->addJavaScript("./Modules/Scorm2004/scripts/questions/question_handling.js");
2740 
2741  if (!$this->getEnabledSelfAssessmentScorm() && $this->getOutputMode() != IL_PAGE_PREVIEW
2742  && $this->getOutputMode() != "offline")
2743  {
2744  $tpl->addJavaScript("./Services/COPage/js/ilCOPageQuestionHandler.js");
2745  $url = $ilCtrl->getLinkTarget($this, "processAnswer", "", true, false);
2746  $tpl->addOnloadCode("ilCOPageQuestionHandler.initCallback('".$url."');");
2747  }
2748 
2749  $tpl->addOnloadCode('
2750  ilias.questions.txt.wrong_answers = "'.$lng->txt("cont_wrong_answers").'";
2751  ilias.questions.txt.tries_remaining = "'.$lng->txt("cont_tries_remaining").'";
2752  ilias.questions.txt.please_try_again = "'.$lng->txt("cont_please_try_again").'";
2753  ilias.questions.txt.all_answers_correct = "'.$lng->txt("cont_all_answers_correct").'";
2754  ilias.questions.txt.nr_of_tries_exceeded = "'.$lng->txt("cont_nr_of_tries_exceeded").'";
2755  ilias.questions.txt.correct_answers_shown = "'.$lng->txt("cont_correct_answers_shown").'";
2756  ');
2757  }
2758  }
2759 
2763  function processAnswer()
2764  {
2765  global $ilLog;
2766 
2767  /*$ilLog->write($_POST);
2768  $ilLog->write($_POST["id"]);
2769  $ilLog->write($_POST["type"]);
2770  $ilLog->write($_POST["answer"]);
2771  $ilLog->write($_GET);*/
2772 
2773  include_once("./Services/COPage/classes/class.ilPageQuestionProcessor.php");
2775  ilUtil::stripSlashes($_POST["type"]),
2777  ilUtil::stripSlashes($_POST["answer"]));
2778  }
2779 
2786  function selfAssessmentRendering($a_output)
2787  {
2788  if ($this->getEnabledSelfAssessment())
2789  {
2790  require_once './Modules/Scorm2004/classes/class.ilQuestionExporter.php';
2791  $a_output = "<script>var ScormApi=null;".ilQuestionExporter::questionsJS()."</script>".$a_output;
2792  }
2793 
2794  return $a_output;
2795  }
2796 
2797 
2798 }
2799 ?>