ILIAS  Release_4_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-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;
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 
71  function ilPageObjectGUI($a_parent_type, $a_id = 0, $a_old_nr = 0)
72  {
73  global $ilias, $tpl, $lng, $ilCtrl,$ilTabs;
74 
75  $this->ctrl =& $ilCtrl;
76 
77  if ($a_old_nr == 0 && $_GET["old_nr"] > 0)
78  {
79  $a_old_nr = $_GET["old_nr"];
80  }
81 
82  $this->ilias =& $ilias;
83  $this->tpl =& $tpl;
84  $this->ctrl =& $ilCtrl;
85  $this->lng =& $lng;
87 
88  // defaults (as in learning modules)
89  $this->setEnabledMaps(false);
90  $this->setEnabledPCTabs(false);
91  $this->setEnabledFileLists(true);
92  $this->setEnabledRepositoryObjects(false);
93  $this->setEnabledSelfAssessment(false);
94  $this->setEnabledPageFocus(true);
95  $this->setLayoutMode(false);
96 
97  if ($a_id > 0)
98  {
99  $this->initPageObject($a_parent_type, $a_id, $a_old_nr);
100  }
101 
102  $this->output2template = true;
103  $this->question_xml = "";
104  $this->question_html = "";
105  $this->tabs_gui =& $ilTabs;
106 
107  // USED FOR TRANSLATIONS
108  $this->template_output_var = "PAGE_CONTENT";
109  $this->citation = false;
110  $this->change_comments = false;
111  $this->page_back_title = $this->lng->txt("page");
112  $lng->loadLanguageModule("content");
113  $this->setPreventHTMLUnmasking(false);
114  $this->setEnabledWikiLinks(false);
115 
116  $this->setTemplateOutput(false);
117  }
118 
119  function initPageObject($a_parent_type, $a_id, $a_old_nr)
120  {
121  $page = new ilPageObject($a_parent_type, $a_id, $a_old_nr);
122  $this->setPageObject($page);
123  }
124 
128  function setBibId($a_id)
129  {
130  // USED FOR SELECTION WHICH PAGE TURNS AND LATER PAGES SHOULD BE SHOWN
131  $this->bib_id = $a_id;
132  }
133 
137  function getBibId()
138  {
139  return $this->bib_id ? $this->bib_id : 0;
140  }
141 
147  function setPageObject($a_pg_obj)
148  {
149  $this->obj = $a_pg_obj;
150  }
151 
157  function getPageObject()
158  {
159  return $this->obj;
160  }
161 
168  {
169  $this->output_mode = $a_mode;
170  }
171 
172  function getOutputMode()
173  {
174  return $this->output_mode;
175  }
176 
177  function setTemplateOutput($a_output = true)
178  {
179  $this->output2template = $a_output;
180  }
181 
182  function outputToTemplate()
183  {
184  return $this->output2template;
185  }
186 
187  function setPresentationTitle($a_title = "")
188  {
189  $this->presentation_title = $a_title;
190  }
191 
193  {
195  }
196 
197  function setHeader($a_title = "")
198  {
199  $this->header = $a_title;
200  }
201 
202  function getHeader()
203  {
204  return $this->header;
205  }
206 
207  function setLinkParams($l_params = "")
208  {
209  $this->link_params = $l_params;
210  }
211 
212  function getLinkParams()
213  {
214  return $this->link_params;
215  }
216 
217  function setLinkFrame($l_frame = "")
218  {
219  $this->link_frame = $l_frame;
220  }
221 
222  function getLinkFrame()
223  {
224  return $this->link_frame;
225  }
226 
227  function setLinkXML($link_xml)
228  {
229  $this->link_xml = $link_xml;
230  $this->link_xml_set = true;
231  }
232 
233  function getLinkXML()
234  {
235  return $this->link_xml;
236  }
237 
238  function setQuestionXML($question_xml)
239  {
240  $this->question_xml = $question_xml;
241  }
242 
244  {
245  $this->question_html = $question_html;
246  }
247 
248  function getQuestionXML()
249  {
250  return $this->question_xml;
251  }
252 
253  function getQuestionHTML()
254  {
255  return $this->question_html;
256  }
257 
258  function setTemplateTargetVar($a_variable)
259  {
260  $this->target_var = $a_variable;
261  }
262 
264  {
265  return $this->target_var;
266  }
267 
268  function setTemplateOutputVar($a_value)
269  {
270  // USED FOR TRANSLATION PRESENTATION OF dbk OBJECTS
271  $this->template_output_var = $a_value;
272  }
273 
275  {
277  }
278 
279  function setOutputSubmode($a_mode)
280  {
281  // USED FOR TRANSLATION PRESENTATION OF dbk OBJECTS
282  $this->output_submode = $a_mode;
283  }
284 
285  function getOutputSubmode()
286  {
287  return $this->output_submode;
288  }
289 
290 
292  $this->sourcecode_download_script = $script_name;
293  }
294 
297  }
298 
299  function enableCitation($a_enabled)
300  {
301  $this->citation = $a_enabled;
302  }
303 
304  function isEnabledCitation()
305  {
306  return $this->citation;
307  }
308 
309  function setLocator(&$a_locator)
310  {
311  $this->locator =& $a_locator;
312  }
313 
314  function setTabs($a_tabs)
315  {
316  $this->tabs_gui = $a_tabs;
317  }
318 
319  function setPageBackTitle($a_title)
320  {
321  $this->page_back_title = $a_title;
322  }
323 
324  function setFileDownloadLink($a_download_link)
325  {
326  $this->file_download_link = $a_download_link;
327  }
328 
330  {
331  return $this->file_download_link;
332  }
333 
334  function setFullscreenLink($a_fullscreen_link)
335  {
336  $this->fullscreen_link = $a_fullscreen_link;
337  }
338 
339  function getFullscreenLink()
340  {
341  return $this->fullscreen_link;
342  }
343 
344  function setIntLinkHelpDefault($a_type, $a_id)
345  {
346  $this->int_link_def_type = $a_type;
347  $this->int_link_def_id = $a_id;
348  }
349 
350  function setIntLinkReturn($a_return)
351  {
352  $this->int_link_return = $a_return;
353  }
354 
355  function enableChangeComments($a_enabled)
356  {
357  $this->change_comments = $a_enabled;
358  }
359 
361  {
362  return $this->change_comments;
363  }
364 
365  function enableNotes($a_enabled, $a_parent_id)
366  {
367  $this->notes_enabled = $a_enabled;
368  $this->notes_parent_id = $a_parent_id;
369  }
370 
371  function isEnabledNotes()
372  {
373  return $this->notes_enabled;
374  }
375 
379  function enableContentIncludes($a_enable)
380  {
381  $this->enablecontentincludes = $a_enable;
382  }
383 
388  {
389  return $this->enablecontentincludes;
390  }
391 
397  function setOfflineDirectory ($offdir) {
398  $this->offline_directory = $offdir;
399  }
400 
401 
406  function getOfflineDirectory () {
407  return $this->offline_directory;
408  }
409 
410 
417  function setViewPageLink($a_link, $a_target = "")
418  {
419  $this->view_page_link = $a_link;
420  $this->view_page_target = $a_target;
421  }
422 
426  function getViewPageLink()
427  {
428  return $this->view_page_link;
429  }
430 
434  function getViewPageTarget()
435  {
436  return $this->view_page_target;
437  }
438 
439  function setActivationListener(&$a_obj, $a_meth)
440  {
441  $this->act_obj =& $a_obj;
442  $this->act_meth = $a_meth;
443  }
444 
445  function setEnabledActivation($a_act)
446  {
447  $this->activation = $a_act;
448  }
449 
451  {
452  return $this->activation;
453  }
454 
456  {
457  $this->scheduled_activation = $a_act;
458  }
459 
461  {
462  return $this->scheduled_activation;
463  }
464 
468  function setTabHook($a_object, $a_function)
469  {
470  $this->tab_hook = array("obj" => $a_object, "func" => $a_function);
471  }
472 
473 
479  function setEnabledInternalLinks($a_enabledinternallinks)
480  {
481  $this->enabledinternallinks = $a_enabledinternallinks;
482  }
483 
490  {
492  }
493 
499  function setEditPreview($a_editpreview)
500  {
501  $this->editpreview = $a_editpreview;
502  }
503 
509  function getEditPreview()
510  {
511  return $this->editpreview;
512  }
513 
519  function setPreventHTMLUnmasking($a_preventhtmlunmasking)
520  {
521  $this->preventhtmlunmasking = $a_preventhtmlunmasking;
522  }
523 
530  {
531  return $this->preventhtmlunmasking;
532  }
533 
539  function setEnabledTabs($a_enabledtabs)
540  {
541  $this->enabledtabs = $a_enabledtabs;
542  }
543 
549  function getEnabledTabs()
550  {
551  return $this->enabledtabs;
552  }
553 
559  function setEnabledRepositoryObjects($a_enabledrepositoryobjects)
560  {
561  $this->enabledrepositoryobjects = $a_enabledrepositoryobjects;
562  }
563 
570  {
571  return $this->enabledrepositoryobjects;
572  }
573 
579  function setEnabledMaps($a_enabledmaps)
580  {
581  $this->enabledmaps = $a_enabledmaps;
582  }
583 
589  function getEnabledMaps()
590  {
591  return $this->enabledmaps;
592  }
593 
599  function setEnabledPCTabs($a_enabledpctabs)
600  {
601  $this->enabledpctabs = $a_enabledpctabs;
602  }
603 
609  function getEnabledPCTabs()
610  {
611  return $this->enabledpctabs;
612  }
613 
619  function setEnabledFileLists($a_enabledfilelists)
620  {
621  $this->enabledfilelists = $a_enabledfilelists;
622  }
623 
630  {
631  return $this->enabledfilelists;
632  }
633 
639  function setEnabledPageFocus($a_enabledpagefocus)
640  {
641  $this->enabledpagefocus = $a_enabledpagefocus;
642  }
643 
650  {
651  return $this->enabledpagefocus;
652  }
653 
659  function setExplorerUpdater($a_exp_frame, $a_exp_id, $a_exp_target_script)
660  {
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 setEnabledWikiLinks($a_enablewikilinks)
692  {
693  $this->enablewikilinks = $a_enablewikilinks;
694  }
695 
702  {
703  return $this->enablewikilinks;
704  }
705 
711  function setEnableEditing($a_enableediting)
712  {
713  $this->enableediting = $a_enableediting;
714  }
715 
721  function getEnableEditing()
722  {
723  return $this->enableediting;
724  }
725 
731  function setRawPageContent($a_rawpagecontent)
732  {
733  $this->rawpagecontent = $a_rawpagecontent;
734  }
735 
741  function getRawPageContent()
742  {
743  return $this->rawpagecontent;
744  }
745 
751  function setLayoutMode($a_layout_mode)
752  {
753  $this->layout_mode = $a_layout_mode;
754  }
755 
761  function getLayoutMode()
762  {
763  return $this->layout_mode;
764  }
765 
771  function setStyleId($a_styleid)
772  {
773  $this->styleid = $a_styleid;
774  }
775 
781  function getStyleId()
782  {
783  return $this->styleid;
784  }
785 
791  function setEnabledSelfAssessment($a_enabledselfassessment)
792  {
793  $this->enabledselfassessment = $a_enabledselfassessment;
794  }
795 
802  {
803  return $this->enabledselfassessment;
804  }
805 
811  function setCompareMode($a_val)
812  {
813  $this->compare_mode = $a_val;
814  }
815 
821  function getCompareMode()
822  {
823  return $this->compare_mode;
824  }
825 
835  function activateMetaDataEditor($a_rep_obj_id, $a_sub_obj_id, $a_type,
836  $a_observer_obj = NULL, $a_observer_func = "")
837  {
838  $this->use_meta_data = true;
839  $this->meta_data_rep_obj_id = $a_rep_obj_id;
840  $this->meta_data_sub_obj_id = $a_sub_obj_id;
841  $this->meta_data_type = $a_type;
842  $this->meta_data_observer_obj = $a_observer_obj;
843  $this->meta_data_observer_func = $a_observer_func;
844  }
845 
852  {
853  global $ilCtrl;
854 
855  $file_download_link = $this->getFileDownloadLink();
856  if ($this->getFileDownloadLink() == "" && $this->getOutputMode() != "offline")
857  {
858  $file_download_link = $ilCtrl->getLinkTarget($this, "downloadFile");
859  }
860  return $file_download_link;
861  }
862 
869  {
870  global $ilCtrl;
871 
872  $fullscreen_link = $this->getFullscreenLink();
873  if ($this->getFullscreenLink() == "" && $this->getOutputMode() != "offline")
874  {
875  $fullscreen_link = $ilCtrl->getLinkTarget($this, "displayMediaFullscreen");
876  }
877  return $fullscreen_link;
878  }
879 
886  {
887  global $ilCtrl;
888 
890  if ($this->sourcecode_download_script == "" && $this->getOutputMode() != "offline")
891  {
892  $l = $ilCtrl->getLinkTarget($this, "");
893  }
894  return $l;
895  }
896 
901  {
902  $xml = "";
903  if($this->getOutputMode() == "edit")
904  {
905  global $ilPluginAdmin;
906 
907  $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_SERVICE,
908  "COPage", "pgcp");
909  foreach ($pl_names as $pl_name)
910  {
911  $plugin = $ilPluginAdmin->getPluginObject(IL_COMP_SERVICE,
912  "COPage", "pgcp", $pl_name);
913  if ($plugin->isValidParentType($this->getPageObject()->getParentType()))
914  {
915  $xml = '<ComponentPlugin Name="'.$plugin->getPluginName().
916  '" InsertText="'.$plugin->getUIText(ilPageComponentPlugin::TXT_CMD_INSERT).'" />';
917  }
918  }
919  }
920  if ($xml != "")
921  {
922  $xml = "<ComponentPlugins>".$xml."</ComponentPlugins>";
923  }
924 
925  return $xml;
926  }
927 
928 
932  function &executeCommand()
933  {
934  global $ilCtrl, $ilTabs, $lng;
935 
936  $next_class = $this->ctrl->getNextClass($this);
937 
938  $cmd = $this->ctrl->getCmd();
939  //$this->ctrl->addTab("clipboard", $this->ctrl->getLinkTargetByClass("ilEditClipboardGUI", "view")
940  // , "view", "ilEditClipboardGUI");
941  $this->getTabs();
942 
943  $ilCtrl->setReturn($this, "edit");
944 //echo "-".$next_class."-";
945  switch($next_class)
946  {
947  case 'ilmdeditorgui':
948  //$this->setTabs();
949  $ilTabs->setTabActive("meta_data");
950  include_once 'Services/MetaData/classes/class.ilMDEditorGUI.php';
951  $md_gui =& new ilMDEditorGUI($this->meta_data_rep_obj_id,
952  $this->meta_data_sub_obj_id, $this->meta_data_type);
953  if (is_object($this->meta_data_observer_obj))
954  {
955  $md_gui->addObserver($this->meta_data_observer_obj,
956  $this->meta_data_observer_func, "General");
957  }
958  $this->ctrl->forwardCommand($md_gui);
959  break;
960 
961  case "ileditclipboardgui":
962  //$this->tabs_gui->clearTargets();
963  //$this->ctrl->setReturn($this, "view");
964  $clip_gui = new ilEditClipboardGUI();
965  $clip_gui->setPageBackTitle($this->page_back_title);
966  //$ret =& $clip_gui->executeCommand();
967  $ret =& $this->ctrl->forwardCommand($clip_gui);
968  break;
969 
970  // notes
971  case "ilnotegui":
972  switch($_GET["notes_mode"])
973  {
974  default:
975  $html = $this->edit();
976  $ilTabs->setTabActive("edit");
977  return $html;
978  }
979  break;
980 
981  case 'ilpublicuserprofilegui':
982  require_once './Services/User/classes/class.ilPublicUserProfileGUI.php';
983  $profile_gui = new ilPublicUserProfileGUI($_GET["user"]);
984  $ret = $this->ctrl->forwardCommand($profile_gui);
985  break;
986 
987  case "ilpageeditorgui":
988  if (!$this->getEnableEditing())
989  {
990  ilUtil::sendFailure($lng->txt("permission_denied"), true);
991  $ilCtrl->redirect($this, "preview");
992  }
993  $page_editor =& new ilPageEditorGUI($this->getPageObject(), $this);
994  $page_editor->setLocator($this->locator);
995  $page_editor->setHeader($this->getHeader());
996  $page_editor->setPageBackTitle($this->page_back_title);
997  $page_editor->setIntLinkHelpDefault($this->int_link_def_type,
998  $this->int_link_def_id);
999  $page_editor->setIntLinkReturn($this->int_link_return);
1000  //$page_editor->executeCommand();
1001  $ret =& $this->ctrl->forwardCommand($page_editor);
1002  break;
1003 
1004  default:
1005  $cmd = $this->ctrl->getCmd("preview");
1006  $ret = $this->$cmd();
1007  break;
1008  }
1009 //echo "+$ret+";
1010  return $ret;
1011  }
1012 
1013  function deactivatePage()
1014  {
1015  $this->getPageObject()->setActivationStart(null);
1016  $this->getPageObject()->setActivationEnd(null);
1017  $this->getPageObject()->setActive(false);
1018  $this->getPageObject()->update();
1019  $this->ctrl->redirectByClass("ilpageobjectgui", "edit");
1020  }
1021 
1022  function activatePage()
1023  {
1024  $this->getPageObject()->setActivationStart(null);
1025  $this->getPageObject()->setActivationEnd(null);
1026  $this->getPageObject()->setActive(true);
1027  $this->getPageObject()->update();
1028  $this->ctrl->redirectByClass("ilpageobjectgui", "edit");
1029  }
1030 
1031  /*
1032  * display content of page
1033  */
1034  function showPage()
1035  {
1036  global $tree, $ilUser, $ilias, $lng, $ilCtrl, $ilBench, $ilSetting;
1037 
1038  $ilBench->start("ContentPresentation", "ilPageObjectGUI_showPage");
1039 
1040  // init template
1041  //if($this->outputToTemplate())
1042  //{
1043  if($this->getOutputMode() == "edit")
1044  {
1045 //echo ":".$this->getTemplateTargetVar().":";
1046  $tpl = new ilTemplate("tpl.page_edit_wysiwyg.html", true, true, "Services/COPage");
1047  //$this->tpl->addBlockFile($this->getTemplateTargetVar(), "adm_content", "tpl.page_edit_wysiwyg.html", "Services/COPage");
1048 
1049  // to do: status dependent class
1050  $tpl->setVariable("CLASS_PAGE_TD", "ilc_Page");
1051 
1052  // user comment
1053  if ($this->isEnabledChangeComments())
1054  {
1055  $tpl->setCurrentBlock("change_comment");
1056  $tpl->setVariable("TXT_ADD_COMMENT", $this->lng->txt("cont_add_change_comment"));
1057  $tpl->parseCurrentBlock();
1058  $tpl->setCurrentBlock("adm_content");
1059  }
1060 
1061  // explorer updater
1062  if ($this->exp_frame != "")
1063  {
1064  $tpl->setCurrentBlock("updater");
1065  $tpl->setVariable("UPDATER_FRAME", $this->exp_frame);
1066  $tpl->setVariable("EXP_ID_UPDATER", $this->exp_id);
1067  $tpl->setVariable("HREF_UPDATER", $this->exp_target_script);
1068  $tpl->parseCurrentBlock();
1069  }
1070 
1071 /* $tpl->setVariable("TXT_INSERT_BEFORE", $this->lng->txt("cont_set_before"));
1072  $tpl->setVariable("TXT_INSERT_AFTER", $this->lng->txt("cont_set_after"));
1073  $tpl->setVariable("TXT_INSERT_CANCEL", $this->lng->txt("cont_set_cancel"));
1074  $tpl->setVariable("TXT_CONFIRM_DELETE", $this->lng->txt("cont_confirm_delete"));
1075 */
1076  $tpl->setVariable("WYSIWYG_ACTION",
1077  $ilCtrl->getFormActionByClass("ilpageeditorgui", "", "", true));
1078 
1080  {
1081  $tpl->setVariable("TXT_JAVA_SCRIPT_CAPABLE", "<br />".$this->lng->txt("cont_browser_not_js_capable"));
1082  }
1083  $tpl->setVariable("TXT_CHANGE_EDIT_MODE", $this->lng->txt("cont_set_edit_mode"));
1084 
1085  if ($this->getEnabledActivation())
1086  {
1087  $tpl->setCurrentBlock("de_activate_page");
1088  if ($this->getPageObject()->getActive())
1089  {
1090  $tpl->setVariable("TXT_DE_ACTIVATE_PAGE", $this->lng->txt("cont_deactivate_page"));
1091  $tpl->setVariable("CMD_DE_ACTIVATE_PAGE", "deactivatePage");
1092  }
1093  else
1094  {
1095  $tpl->setVariable("TXT_DE_ACTIVATE_PAGE", $this->lng->txt("cont_activate_page"));
1096  $tpl->setVariable("CMD_DE_ACTIVATE_PAGE", "activatePage");
1097  }
1098  $tpl->parseCurrentBlock();
1099  }
1100 
1101  $med_mode = array("enable" => $this->lng->txt("cont_enable_media"),
1102  "disable" => $this->lng->txt("cont_disable_media"));
1103  $sel_media_mode = ($ilUser->getPref("ilPageEditor_MediaMode") == "disable")
1104  ? "disable"
1105  : "enable";
1106 
1107  $js_mode = array("enable" => $this->lng->txt("cont_enable_js"),
1108  "disable" => $this->lng->txt("cont_disable_js"));
1109 
1110  $tpl->setVariable("SEL_MEDIA_MODE",
1111  ilUtil::formSelect($sel_media_mode, "media_mode", $med_mode, false, true,
1112  0, "ilEditSelect"));
1113 
1114  // HTML active/inactive
1115  $html_mode = array("enable" => $this->lng->txt("cont_enable_html"),
1116  "disable" => $this->lng->txt("cont_disable_html"));
1117  $sel_html_mode = ($ilUser->getPref("ilPageEditor_HTMLMode") == "disable")
1118  ? "disable"
1119  : "enable";
1120  if (!$this->getPreventHTMLUnmasking())
1121  {
1122  $tpl->setVariable("SEL_HTML_MODE",
1123  ilUtil::formSelect($sel_html_mode, "html_mode", $html_mode, false, true,
1124  0, "ilEditSelect"));
1125  }
1126 
1127  $tpl->setVariable("PREPENDING_HTML", $this->getPrependingHtml());
1128  $tpl->setVariable("TXT_CONFIRM_DELETE", $lng->txt("cont_confirm_delete"));
1129 
1130  if ($this->getViewPageLink() != "")
1131  {
1132  $tpl->setCurrentBlock("view_link");
1133  $tpl->setVariable("LINK_VIEW_PAGE",
1134  $this->getViewPageLink());
1135  $tpl->setVariable("TARGET_VIEW_PAGE",
1136  $this->getViewPageTarget());
1137  $tpl->setVariable("TXT_VIEW_PAGE", $this->lng->txt("view"));
1138  $tpl->parseCurrentBlock();
1139  }
1140 
1141  // javascript activation
1142  $sel_js_mode = "disable";
1143  if($ilSetting->get("enable_js_edit", 1))
1144  {
1145  $sel_js_mode = (ilPageEditorGUI::_doJSEditing())
1146  ? "enable"
1147  : "disable";
1148  }
1149 
1150  // get js files for JS enabled editing
1151  if ($sel_js_mode == "enable")
1152  {
1153  $this->insertHelp($tpl);
1154  include_once("./Services/YUI/classes/class.ilYuiUtil.php");
1157  $GLOBALS["tpl"]->addJavaScript("./Services/COPage/js/ilcopagecallback.js");
1158  //$GLOBALS["tpl"]->addJavaScript("./Services/RTE/tiny_mce/tiny_mce.js");
1159  $GLOBALS["tpl"]->addJavaScript("./Services/COPage/js/ilpageedit.js");
1160  //$GLOBALS["tpl"]->addJavascript("Services/COPage/js/wz_dragdrop.js");
1161  $GLOBALS["tpl"]->addJavascript("Services/COPage/js/page_editing.js");
1162  $tpl->touchBlock("init_dragging");
1163  }
1164 
1165  if($ilias->getSetting("enable_js_edit"))
1166  {
1167  $tpl->setVariable("SEL_JAVA_SCRIPT",
1168  ilUtil::formSelect($sel_js_mode, "js_mode", $js_mode, false, true,
1169  0, "ilEditSelect"));
1170  }
1171 
1172  // multiple actions
1173  $tpl->setCurrentBlock("multi_actions");
1174  if ($sel_js_mode == "enable")
1175  {
1176  $tpl->setVariable("ONCLICK_DE_ACTIVATE_SELECTED", 'onclick="return ilEditMultiAction(\'activateSelected\');"');
1177  $tpl->setVariable("ONCLICK_DELETE_SELECTED", 'onclick="return ilEditMultiAction(\'deleteSelected\');"');
1178  $tpl->setVariable("ONCLICK_ASSIGN_CHARACTERISTIC", 'onclick="return ilEditMultiAction(\'assignCharacteristicForm\');"');
1179  $tpl->setVariable("ONCLICK_COPY_SELECTED", 'onclick="return ilEditMultiAction(\'copySelected\');"');
1180  $tpl->setVariable("ONCLICK_CUT_SELECTED", 'onclick="return ilEditMultiAction(\'cutSelected\');"');
1181  }
1182  $tpl->setVariable("TXT_DE_ACTIVATE_SELECTED", $this->lng->txt("cont_ed_enable"));
1183  $tpl->setVariable("TXT_ASSIGN_CHARACTERISTIC", $this->lng->txt("cont_assign_characteristic"));
1184  $tpl->setVariable("TXT_DELETE_SELECTED", $this->lng->txt("cont_delete_selected"));
1185  $tpl->setVariable("TXT_COPY_SELECTED", $this->lng->txt("copy"));
1186  $tpl->setVariable("TXT_CUT_SELECTED", $this->lng->txt("cut"));
1187  $tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
1188  $tpl->parseCurrentBlock();
1189  }
1190  else
1191  {
1192  if($this->getOutputSubmode() == 'translation')
1193  {
1194  $tpl = new ilTemplate("tpl.page_translation_content.html", true, true, "Services/COPage");
1195  }
1196  else
1197  {
1198  // presentation
1199  if ($this->getOutputMode() != IL_PAGE_PREVIEW)
1200  {
1201  $tpl = new ilTemplate("tpl.page_content.html", true, true, "Services/COPage");
1202  if ($this->getEnabledPageFocus())
1203  {
1204  $tpl->touchBlock("page_focus");
1205  }
1206  }
1207  else // preview
1208  {
1209  $tpl = new ilTemplate("tpl.page_preview.html", true, true, "Services/COPage");
1210  include_once("./Services/User/classes/class.ilUserUtil.php");
1211 
1212  $c_old_nr = $this->getPageObject()->old_nr;
1213  if ($c_old_nr > 0)
1214  {
1215  $hist_info =
1216  $this->getPageObject()->getHistoryInfo($c_old_nr);
1217 
1218  if (!$this->getCompareMode())
1219  {
1220  // previous revision
1221  if (is_array($hist_info["previous"]))
1222  {
1223  $tpl->setCurrentBlock("previous_rev");
1224  $tpl->setVariable("TXT_PREV_REV", $lng->txt("cont_previous_rev"));
1225  $ilCtrl->setParameter($this, "old_nr", $hist_info["previous"]["nr"]);
1226  $tpl->setVariable("HREF_PREV",
1227  $ilCtrl->getLinkTarget($this, "preview"));
1228  $tpl->parseCurrentBlock();
1229  }
1230  else
1231  {
1232  $tpl->setCurrentBlock("previous_rev_disabled");
1233  $tpl->setVariable("TXT_PREV_REV", $lng->txt("cont_previous_rev"));
1234  $tpl->parseCurrentBlock();
1235  }
1236 
1237  // next revision
1238  $tpl->setCurrentBlock("next_rev");
1239  $tpl->setVariable("TXT_NEXT_REV", $lng->txt("cont_next_rev"));
1240  $ilCtrl->setParameter($this, "old_nr", $hist_info["next"]["nr"]);
1241  $tpl->setVariable("HREF_NEXT",
1242  $ilCtrl->getLinkTarget($this, "preview"));
1243  $tpl->parseCurrentBlock();
1244 
1245  // latest revision
1246  $tpl->setCurrentBlock("latest_rev");
1247  $tpl->setVariable("TXT_LATEST_REV", $lng->txt("cont_latest_rev"));
1248  $ilCtrl->setParameter($this, "old_nr", "");
1249  $tpl->setVariable("HREF_LATEST",
1250  $ilCtrl->getLinkTarget($this, "preview"));
1251  $tpl->parseCurrentBlock();
1252 
1253  // rollback
1254  if ($c_old_nr > 0 && $ilUser->getId() != ANONYMOUS_USER_ID)
1255  {
1256  $tpl->setCurrentBlock("rollback");
1257  $ilCtrl->setParameter($this, "old_nr", $c_old_nr);
1258  $tpl->setVariable("HREF_ROLLBACK",
1259  $ilCtrl->getLinkTarget($this, "rollbackConfirmation"));
1260  $ilCtrl->setParameter($this, "old_nr", "");
1261  $tpl->setVariable("TXT_ROLLBACK",
1262  $lng->txt("cont_rollback"));
1263  $tpl->parseCurrentBlock();
1264  }
1265  }
1266 
1267  $tpl->setCurrentBlock("hist_nav");
1268  $tpl->setVariable("TXT_REVISION", $lng->txt("cont_revision"));
1269  $tpl->setVariable("VAL_REVISION_DATE",
1270  ilDatePresentation::formatDate(new ilDateTime($hist_info["current"]["hdate"], IL_CAL_DATETIME)));
1271  $tpl->setVariable("VAL_REV_USER",
1272  ilUserUtil::getNamePresentation($hist_info["current"]["user_id"]));
1273  $tpl->parseCurrentBlock();
1274  }
1275  }
1276  }
1277  }
1278  if ($this->getOutputMode() != IL_PAGE_PRESENTATION &&
1279  $this->getOutputMode() != IL_PAGE_OFFLINE &&
1280  $this->getOutputMode() != IL_PAGE_PREVIEW &&
1281  $this->getOutputMode() != IL_PAGE_PRINT)
1282  {
1283  $tpl->setVariable("FORMACTION", $this->ctrl->getFormActionByClass("ilpageeditorgui"));
1284  }
1285 
1286  // output media object edit list (of media links)
1287  if($this->getOutputMode() == "edit")
1288  {
1289  $links = ilInternalLink::_getTargetsOfSource($this->obj->getParentType().":pg",
1290  $this->obj->getId());
1291  $mob_links = array();
1292  foreach($links as $link)
1293  {
1294  if ($link["type"] == "mob")
1295  {
1296  if (ilObject::_exists($link["id"]) && ilObject::_lookupType($link["id"]) == "mob")
1297  {
1298  $mob_links[$link["id"]] = ilObject::_lookupTitle($link["id"])." [".$link["id"]."]";
1299  }
1300  }
1301  }
1302 
1303  // linked media objects
1304  if (count($mob_links) > 0)
1305  {
1306  $tpl->setCurrentBlock("med_link");
1307  $tpl->setVariable("TXT_LINKED_MOBS", $this->lng->txt("cont_linked_mobs"));
1308  $tpl->setVariable("SEL_MED_LINKS",
1309  ilUtil::formSelect(0, "mob_id", $mob_links, false, true));
1310  $tpl->setVariable("TXT_EDIT_MEDIA", $this->lng->txt("cont_edit_mob"));
1311  $tpl->setVariable("TXT_COPY_TO_CLIPBOARD", $this->lng->txt("cont_copy_to_clipboard"));
1312  //$this->tpl->setVariable("TXT_COPY_TO_POOL", $this->lng->txt("cont_copy_to_mediapool"));
1313  $tpl->parseCurrentBlock();
1314  }
1315 
1316  // content snippets used
1317  $snippets = $this->getPageObject()->collectContentIncludes();
1318  if (count($snippets) > 0)
1319  {
1320  foreach ($snippets as $s)
1321  {
1322  include_once("./Modules/MediaPool/classes/class.ilMediaPoolPage.php");
1323  $sn_arr[$s["id"]] = ilMediaPoolPage::lookupTitle($s["id"]);
1324  }
1325  $tpl->setCurrentBlock("med_link");
1326  $tpl->setVariable("TXT_CONTENT_SNIPPETS_USED", $this->lng->txt("cont_snippets_used"));
1327  $tpl->setVariable("SEL_SNIPPETS",
1328  ilUtil::formSelect(0, "ci_id", $sn_arr, false, true));
1329  $tpl->setVariable("TXT_SHOW_INFO", $this->lng->txt("cont_show_info"));
1330  $tpl->parseCurrentBlock();
1331  }
1332 
1333  // scheduled activation?
1334  if (!$this->getPageObject()->getActive() &&
1335  $this->getPageObject()->getActivationStart() != "" &&
1337  {
1338  $tpl->setCurrentBlock("activation_txt");
1339  $tpl->setVariable("TXT_SCHEDULED_ACTIVATION", $lng->txt("cont_scheduled_activation"));
1340  $tpl->setVariable("SA_FROM",
1342  new ilDateTime($this->getPageObject()->getActivationStart(),
1343  IL_CAL_DATETIME)));
1344  $tpl->setVariable("SA_TO",
1346  new ilDateTime($this->getPageObject()->getActivationEnd(),
1347  IL_CAL_DATETIME)));
1348  $tpl->parseCurrentBlock();
1349  }
1350  }
1351 
1352  if ($_GET["reloadTree"] == "y")
1353  {
1354  $tpl->setCurrentBlock("reload_tree");
1355  if ($this->obj->getParentType() == "dbk")
1356  {
1357  $tpl->setVariable("LINK_TREE",
1358  $this->ctrl->getLinkTargetByClass("ilobjdlbookgui", "explorer"));
1359  }
1360  else
1361  {
1362  $tpl->setVariable("LINK_TREE",
1363  $this->ctrl->getLinkTargetByClass("ilobjlearningmodulegui", "explorer"));
1364  }
1365  $tpl->parseCurrentBlock();
1366  }
1367 // }
1368 
1369  // get content
1370  $builded = $this->obj->buildDom();
1371 
1372  // manage hierarchical ids
1373  if($this->getOutputMode() == "edit")
1374  {
1375 
1376  // add pc ids, if necessary
1377  if (!$this->obj->checkPCIds())
1378  {
1379  $this->obj->insertPCIds();
1380  $this->obj->update(true, true);
1381  }
1382 
1383  $this->obj->addFileSizes();
1384  $this->obj->addHierIDs();
1385 
1386  $hids = $this->obj->getHierIds();
1387  $row1_ids = $this->obj->getFirstRowIds();
1388  $col1_ids = $this->obj->getFirstColumnIds();
1389  $litem_ids = $this->obj->getListItemIds();
1390  $fitem_ids = $this->obj->getFileItemIds();
1391 
1392  // standard menues
1393  $hids = $this->obj->getHierIds();
1394  foreach($hids as $hid)
1395  {
1396  $tpl->setCurrentBlock("add_dhtml");
1397  $tpl->setVariable("CONTEXTMENU", "contextmenu_".$hid);
1398  $tpl->parseCurrentBlock();
1399  }
1400 
1401  // column menues for tables
1402  foreach($col1_ids as $hid)
1403  {
1404  $tpl->setCurrentBlock("add_dhtml");
1405  $tpl->setVariable("CONTEXTMENU", "contextmenu_r".$hid);
1406  $tpl->parseCurrentBlock();
1407  }
1408 
1409  // row menues for tables
1410  foreach($row1_ids as $hid)
1411  {
1412  $tpl->setCurrentBlock("add_dhtml");
1413  $tpl->setVariable("CONTEXTMENU", "contextmenu_c".$hid);
1414  $tpl->parseCurrentBlock();
1415  }
1416 
1417  // list item menues
1418  foreach($litem_ids as $hid)
1419  {
1420  $tpl->setCurrentBlock("add_dhtml");
1421  $tpl->setVariable("CONTEXTMENU", "contextmenu_i".$hid);
1422  $tpl->parseCurrentBlock();
1423  }
1424 
1425  // file item menues
1426  foreach($fitem_ids as $hid)
1427  {
1428  $tpl->setCurrentBlock("add_dhtml");
1429  $tpl->setVariable("CONTEXTMENU", "contextmenu_i".$hid);
1430  $tpl->parseCurrentBlock();
1431  }
1432  }
1433  else
1434  {
1435  $this->obj->addFileSizes();
1436  }
1437 
1438 //echo "<br>-".htmlentities($this->obj->getXMLContent())."-<br><br>";
1439 //echo "<br>-".htmlentities($this->getLinkXML())."-";
1440 
1441  // set default link xml, if nothing was set yet
1442  if (!$this->link_xml_set)
1443  {
1444  $this->setDefaultLinkXml();
1445  }
1446 
1447  //$content = $this->obj->getXMLFromDom(false, true, true,
1448  // $this->getLinkXML().$this->getQuestionXML().$this->getComponentPluginsXML());
1449  $link_xml = $this->getLinkXML();
1450 
1451  if ($this->getStyleId() > 0)
1452  {
1453  if (ilObject::_lookupType($this->getStyleId()) == "sty")
1454  {
1455  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
1456  $style = new ilObjStyleSheet($this->getStyleId());
1457  $template_xml = $style->getTemplateXML();
1458  $disable_auto_margins = "n";
1459  if ($style->lookupStyleSetting("disable_auto_margins"))
1460  {
1461  $disable_auto_margins = "y";
1462  }
1463  }
1464  }
1465  $content = $this->obj->getXMLFromDom(false, true, true,
1466  $link_xml.$this->getQuestionXML().$template_xml);
1467 
1468  // get page component plugins
1469 
1470  // check validation errors
1471  if($builded !== true)
1472  {
1473  $this->displayValidationError($builded);
1474  }
1475  else
1476  {
1477  $this->displayValidationError($_SESSION["il_pg_error"]);
1478  }
1479  unset($_SESSION["il_pg_error"]);
1480 
1481  if(isset($_SESSION["citation_error"]))
1482  {
1483  ilUtil::sendFailure($this->lng->txt("cont_citation_selection_not_valid"));
1484  session_unregister("citation_error");
1485  unset($_SESSION["citation_error"]);
1486  }
1487 
1488  // get title
1489  $pg_title = $this->getPresentationTitle();
1490 
1491  $add_path = ilUtil::getImagePath("add.gif");
1492  $col_path = ilUtil::getImagePath("col.gif");
1493  $row_path = ilUtil::getImagePath("row.gif");
1494  $item_path = ilUtil::getImagePath("item.gif");
1495  $med_disabled_path = ilUtil::getImagePath("media_disabled.gif");
1496 
1497  if ($this->getOutputMode() != "offline")
1498  {
1499  $enlarge_path = ilUtil::getImagePath("enlarge.gif");
1500  $wb_path = ilUtil::getWebspaceDir("output");
1501  }
1502  else
1503  {
1504  $enlarge_path = "images/enlarge.gif";
1505  $wb_path = ".";
1506  }
1507  $pg_title_class = ($this->getOutputMode() == "print")
1508  ? "ilc_PrintPageTitle"
1509  : "";
1510 
1511  // page splitting only for learning modules and
1512  // digital books
1513  $enable_split_new = ($this->obj->getParentType() == "lm" ||
1514  $this->obj->getParentType() == "dbk")
1515  ? "y"
1516  : "n";
1517 
1518  // page splitting to next page only for learning modules and
1519  // digital books if next page exists in tree
1520  if (($this->obj->getParentType() == "lm" ||
1521  $this->obj->getParentType() == "dbk") &&
1522  ilObjContentObject::hasSuccessorPage($this->obj->getParentId(),
1523  $this->obj->getId()))
1524  {
1525  $enable_split_next = "y";
1526  }
1527  else
1528  {
1529  $enable_split_next = "n";
1530  }
1531 
1532 
1533  $paragraph_plugins = new ilParagraphPlugins();
1534  $paragraph_plugins->initialize ();
1535 
1536  if ($this->getOutputMode() == IL_PAGE_PRESENTATION)
1537  {
1538  $paragraph_plugin_string = $paragraph_plugins->serializeToString();
1539  $_SESSION ["paragraph_plugins"] = $paragraph_plugins;
1540  }
1541 
1542  $img_path = ilUtil::getImagePath("", false, $this->getOutputMode(), $this->getOutputMode() == "offline");
1543 
1544  //$wb_path = "../".$this->ilias->ini->readVariable("server","webspace_dir");
1545  //echo "-".$this->sourcecode_download_script.":";
1546 
1547  if ($this->getEnabledPCTabs())
1548  {
1549  //include_once("./Services/YUI/classes/class.ilYuiUtil.php");
1550  //ilYuiUtil::initTabView();
1551  include_once("./Services/Accordion/classes/class.ilAccordionGUI.php");
1554  }
1555 
1556  $file_download_link = $this->determineFileDownloadLink();
1557  $fullscreen_link = $this->determineFullscreenLink();
1558  $this->sourcecode_download_script = $this->determineSourcecodeDownloadScript();
1559 
1560  // default values for various parameters (should be used by
1561  // all instances in the future)
1562  $media_mode = ($this->getOutputMode() == "edit")
1563  ? $ilUser->getPref("ilPageEditor_MediaMode")
1564  : "enable";
1565 
1566  include_once("./Modules/LearningModule/classes/class.ilEditClipboard.php");
1567  $paste = (ilEditClipboard::getAction() == "copy" &&
1568  $this->getOutputMode() == "edit");
1569 
1570  // added UTF-8 encoding otherwise umlaute are converted too
1571  $params = array ('mode' => $this->getOutputMode(), 'pg_title' => htmlentities($pg_title,ENT_QUOTES,"UTF-8"),
1572  'pg_id' => $this->obj->getId(), 'pg_title_class' => $pg_title_class,
1573  'webspace_path' => $wb_path, 'enlarge_path' => $enlarge_path,
1574  'img_add' => $add_path,
1575  'img_col' => $col_path,
1576  'img_row' => $row_path,
1577  'img_item' => $item_path,
1578  'enable_split_new' => $enable_split_new,
1579  'enable_split_next' => $enable_split_next,
1580  'link_params' => $this->link_params,
1581  'file_download_link' => $file_download_link,
1582  'fullscreen_link' => $fullscreen_link,
1583  'med_disabled_path' => $med_disabled_path,
1584  'img_path' => $img_path,
1585  'parent_id' => $this->obj->getParentId(),
1586  'download_script' => $this->sourcecode_download_script,
1587  'encoded_download_script' => urlencode($this->sourcecode_download_script),
1588  // digilib
1589  'bib_id' => $this->getBibId(),'citation' => (int) $this->isEnabledCitation(),
1590  'pagebreak' => $this->lng->txt('dgl_pagebreak'),
1591  'page' => $this->lng->txt('page'),
1592  'citate_page' => $this->lng->txt('citate_page'),
1593  'citate_from' => $this->lng->txt('citate_from'),
1594  'citate_to' => $this->lng->txt('citate_to'),
1595  'citate' => $this->lng->txt('citate'),
1596  'enable_rep_objects' => $this->getEnabledRepositoryObjects() ? "y" : "n",
1597  'enable_map' => $this->getEnabledMaps() ? "y" : "n",
1598  'enable_tabs' => $this->getEnabledPCTabs() ? "y" : "n",
1599  'enable_sa_qst' => $this->getEnabledSelfAssessment() ? "y" : "n",
1600  'enable_file_list' => $this->getEnabledFileLists() ? "y" : "n",
1601  'enable_content_includes' => $this->isEnabledContentIncludes() ? "y" : "n",
1602  'paste' => $paste ? "y" : "n",
1603  'media_mode' => $media_mode,
1604  'javascript' => $sel_js_mode,
1605  'paragraph_plugins' => $paragraph_plugin_string,
1606  'disable_auto_margins' => $disable_auto_margins
1607  );
1608  if($this->link_frame != "") // todo other link types
1609  $params["pg_frame"] = $this->link_frame;
1610 
1611  //$content = str_replace("&nbsp;", "", $content);
1612 
1613  // this ensures that cache is emptied with every update
1614  $params["version"] = ILIAS_VERSION;
1615 
1616  // ensure no cache hit, if included files/media objects have been changed
1617  $params["incl_elements_date"] = $this->obj->getLastUpdateOfIncludedElements();
1618 
1619  // run xslt
1620 
1621  $md5 = md5(serialize($params).$link_xml.$template_xml);
1622 
1623 //$a = microtime();
1624 
1625  // check cache (same parameters, non-edit mode and rendered time
1626  // > last change
1627  if (($this->getOutputMode() == "preview" || $this->getOutputMode() == "presentation") &&
1628  $md5 == $this->obj->getRenderMd5() &&
1629  ($this->obj->getLastChange() < $this->obj->getRenderedTime()) &&
1630  $this->obj->getRenderedTime() != "" &&
1631  $this->obj->old_nr == 0)
1632  {
1633  // cache hit
1634  $output = $this->obj->getRenderedContent();
1635  }
1636  else
1637  {
1638  if ($this->getLayoutMode() == true) {
1639  $xsl = file_get_contents("./Services/COPage/xsl/page_layout.xsl");
1640  } else {
1641  $xsl = file_get_contents("./Services/COPage/xsl/page.xsl");
1642  }
1643 //echo htmlentities($content);
1644  $args = array( '/_xml' => $content, '/_xsl' => $xsl );
1645  $xh = xslt_create();
1646  // echo "<b>XSLT</b>:".htmlentities($xsl).":<br>";
1647  // echo "mode:".$this->getOutputMode().":<br>";
1648  $output = xslt_process($xh, "arg:/_xml","arg:/_xsl", NULL, $args, $params);
1649 
1650  if (($this->getOutputMode() == "presentation" || $this->getOutputMode() == "preview")
1651  && $this->obj->old_nr == 0)
1652  {
1653 //echo "writerenderedcontent";
1654  $this->obj->writeRenderedContent($output, $md5);
1655  }
1656  //echo xslt_error($xh);
1657  xslt_free($xh);
1658  }
1659 
1660 //$b = microtime();
1661 //echo "$a - $b";
1662 //echo "<pre>".htmlentities($output)."</pre>";
1663 
1664  // unmask user html
1665  if (($this->getOutputMode() != "edit" ||
1666  $ilUser->getPref("ilPageEditor_HTMLMode") != "disable")
1667  && !$this->getPreventHTMLUnmasking())
1668  {
1669  $output = str_replace("&lt;","<",$output);
1670  $output = str_replace("&gt;",">",$output);
1671  }
1672  $output = str_replace("&amp;", "&", $output);
1673 
1674  // replace latex code: todo: finish
1675  if ($this->getOutputMode() != "offline")
1676  {
1677  $output = ilUtil::insertLatexImages($output);
1678  }
1679  else
1680  {
1681  $output = ilUtil::buildLatexImages($output,
1682  $this->getOfflineDirectory());
1683  }
1684 
1685  $output = $this->insertContentIncludes($output);
1686 
1687  // workaround for preventing template engine
1688  // from hiding paragraph text that is enclosed
1689  // in curly brackets (e.g. "{a}", see ilLMEditorGUI::executeCommand())
1690  $output = str_replace("{", "&#123;", $output);
1691  $output = str_replace("}", "&#125;", $output);
1692 
1693  // remove all newlines (important for code / pre output)
1694  $output = str_replace("\n", "", $output);
1695 
1696  // add question HTML
1697  $qhtml = $this->getQuestionHTML();
1698  if (is_array($qhtml))
1699  {
1700  foreach ($qhtml as $k => $h)
1701  {
1702  $output = str_replace("&#123;&#123;&#123;&#123;&#123;Question;il__qst_$k&#125;&#125;&#125;&#125;&#125;", " ".$h, $output);
1703  }
1704  }
1705 
1706 //echo htmlentities($output);
1707  $output = $this->postOutputProcessing($output);
1708 //echo htmlentities($output);
1709  if($this->getOutputMode() == "edit" && !$this->getPageObject()->getActive($this->getEnabledScheduledActivation()))
1710  {
1711  $output = '<div class="il_editarea_disabled">'.$output.'</div>';
1712  }
1713 
1714  $output = $this->insertMaps($output);
1715  $output = $this->obj->insertSourceCodeParagraphs($output, $this->getOutputMode());
1716 
1717  $ilBench->stop("ContentPresentation", "ilPageObjectGUI_showPage");
1718 
1719  // output
1720  if ($ilCtrl->isAsynch())
1721  {
1722  $tpl->setVariable($this->getTemplateOutputVar(), $output);
1723  echo $tpl->get();
1724  exit;
1725 
1726  $tpl->setVariable($this->getTemplateOutputVar(), $output);
1727  $tpl->setCurrentBlock("adm_content");
1728  $tpl->parseCurrentBlock();
1729  echo $tpl->get("adm_content");
1730  exit;
1731  }
1732  if ($this->outputToTemplate())
1733  {
1734  $tpl->setVariable($this->getTemplateOutputVar(), $output);
1735  $this->tpl->setVariable($this->getTemplateTargetVar(), $tpl->get());
1736  return $output;
1737  }
1738  else
1739  {
1740  if ($this->getRawPageContent()) // e.g. needed in glossaries
1741  {
1742  return $output;
1743  }
1744  else
1745  {
1746  $tpl->setVariable($this->getTemplateOutputVar(), $output);
1747  return $tpl->get();
1748  }
1749  }
1750  }
1751 
1756  {
1757  $int_links = $this->getPageObject()->getInternalLinks();
1758 
1759  $link_info = "<IntLinkInfos>";
1760  $targetframe = "None";
1761  foreach ($int_links as $int_link)
1762  {
1763  $target = $int_link["Target"];
1764  if (substr($target, 0, 4) == "il__")
1765  {
1766  $target_arr = explode("_", $target);
1767  $target_id = $target_arr[count($target_arr) - 1];
1768  $type = $int_link["Type"];
1769 
1770  // anchor
1771  $anc = $anc_add = "";
1772  if ($int_link["Anchor"] != "")
1773  {
1774  $anc = $int_link["Anchor"];
1775  $anc_add = "_".rawurlencode($int_link["Anchor"]);
1776  }
1777 
1778  switch($type)
1779  {
1780  case "PageObject":
1781  case "StructureObject":
1783  $ltarget="_top";
1784  if ($type == "PageObject")
1785  {
1786  $href = "./goto.php?target=pg_".$target_id.$anc_add;
1787  }
1788  else
1789  {
1790  $href = "./goto.php?target=st_".$target_id;
1791  }
1792  break;
1793 
1794  case "GlossaryItem":
1795  $ltarget="_blank";
1796  $href = "./goto.php?target=git_".$target_id;
1797  break;
1798 
1799  case "MediaObject":
1800  $ltarget="_blank";
1801  $href = "";
1802  break;
1803 
1804  case "RepositoryItem":
1805  $ltarget="_top";
1806  $obj_type = ilObject::_lookupType($target_id, true);
1808  $href = "./goto.php?target=".$obj_type."_".$target_id;
1809  break;
1810 
1811  }
1812  $anc_par = 'Anchor="'.$anc.'"';
1813  $link_info.="<IntLinkInfo Target=\"$target\" Type=\"$type\" ".$anc_par." ".
1814  "TargetFrame=\"$targetframe\" LinkHref=\"$href\" LinkTarget=\"$ltarget\" />";
1815  }
1816  }
1817  $link_info.= "</IntLinkInfos>";
1818  $this->setLinkXML($link_info);
1819  }
1820 
1824  function downloadFile()
1825  {
1826  $file = explode("_", $_GET["file_id"]);
1827  require_once("./Modules/File/classes/class.ilObjFile.php");
1828  $fileObj =& new ilObjFile($file[count($file) - 1], false);
1829  $fileObj->sendFile();
1830  exit;
1831  }
1832 
1837  {
1838  $tpl = new ilTemplate("tpl.fullscreen.html", true, true, "Modules/LearningModule");
1839  $tpl->setCurrentBlock("ilMedia");
1840 
1841  //$int_links = $page_object->getInternalLinks();
1842  $med_links = ilMediaItem::_getMapAreasIntLinks($_GET["mob_id"]);
1843 
1844  // @todo
1845  //$link_xml = $this->getLinkXML($med_links, $this->getLayoutLinkTargets());
1846 
1847  require_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1848  $media_obj = new ilObjMediaObject($_GET["mob_id"]);
1849  require_once("./Services/COPage/classes/class.ilPageObject.php");
1850  $pg_obj = $this->getPageObject();
1851  $pg_obj->buildDom();
1852 
1853  $xml = "<dummy>";
1854  // todo: we get always the first alias now (problem if mob is used multiple
1855  // times in page)
1856  $xml.= $pg_obj->getMediaAliasElement($_GET["mob_id"]);
1857  $xml.= $media_obj->getXML(IL_MODE_OUTPUT);
1858  $xml.= $link_xml;
1859  $xml.="</dummy>";
1860 
1861  $xsl = file_get_contents("./Services/COPage/xsl/page.xsl");
1862  $args = array( '/_xml' => $xml, '/_xsl' => $xsl );
1863  $xh = xslt_create();
1864 
1865 //echo "<b>XML:</b>".htmlentities($xml);
1866  // determine target frames for internal links
1867  $wb_path = ilUtil::getWebspaceDir("output");
1868  $enlarge_path = ilUtil::getImagePath("enlarge.gif");
1869  $params = array ('mode' => "fullscreen", 'enlarge_path' => $enlarge_path,
1870  'link_params' => "ref_id=".$_GET["ref_id"],'fullscreen_link' => "",
1871  'ref_id' => $_GET["ref_id"], 'webspace_path' => $wb_path);
1872  $output = xslt_process($xh,"arg:/_xml","arg:/_xsl",NULL,$args, $params);
1873  //echo xslt_error($xh);
1874  xslt_free($xh);
1875 
1876  // unmask user html
1877  $tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
1879  $tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
1880  $tpl->setVariable("MEDIA_CONTENT", $output);
1881  echo $tpl->get();
1882  exit;
1883  }
1884 
1889  {
1890  $pg_obj = $this->getPageObject();
1891  $pg_obj->send_paragraph($_GET["par_id"], $_GET["downloadtitle"]);
1892  }
1893 
1897  function insertMaps($a_html)
1898  {
1899  $c_pos = 0;
1900  $start = strpos($a_html, "[[[[[Map;");
1901  if (is_int($start))
1902  {
1903  $end = strpos($a_html, "]]]]]", $start);
1904  }
1905  $i = 1;
1906  while ($end > 0)
1907  {
1908  $param = substr($a_html, $start + 9, $end - $start - 9);
1909 
1910  $param = explode(";", $param);
1911  if (is_numeric($param[0]) && is_numeric($param[1]) && is_numeric($param[2]))
1912  {
1913  include_once("./Services/GoogleMaps/classes/class.ilGoogleMapGUI.php");
1914  $map_gui = new ilGoogleMapGUI();
1915  $map_gui->setMapId("map_".$i);
1916  $map_gui->setLatitude($param[0]);
1917  $map_gui->setLongitude($param[1]);
1918  $map_gui->setZoom($param[2]);
1919  $map_gui->setWidth($param[3]."px");
1920  $map_gui->setHeight($param[4]."px");
1921  $map_gui->setEnableTypeControl(true);
1922  $map_gui->setEnableNavigationControl(true);
1923  $map_gui->setEnableCentralMarker(true);
1924  $h2 = substr($a_html, 0, $start).
1925  $map_gui->getHtml().
1926  substr($a_html, $end + 5);
1927  $a_html = $h2;
1928  $i++;
1929  }
1930  $start = strpos($a_html, "[[[[[Map;", $start + 5);
1931  $end = 0;
1932  if (is_int($start))
1933  {
1934  $end = strpos($a_html, "]]]]]", $start);
1935  }
1936  }
1937 
1938  return $a_html;
1939  }
1940 
1944  function insertContentIncludes($a_html)
1945  {
1946  global $ilCtrl;
1947 
1948  $c_pos = 0;
1949  $start = strpos($a_html, "{{{{{ContentInclude;");
1950  if (is_int($start))
1951  {
1952  $end = strpos($a_html, "}}}}}", $start);
1953  }
1954  $i = 1;
1955  while ($end > 0)
1956  {
1957  $param = substr($a_html, $start + 20, $end - $start - 20);
1958  $param = explode(";", $param);
1959 
1960  if ($param[0] == "mep" && is_numeric($param[1]) && $param[2] <= 0)
1961  {
1962  include_once("./Modules/MediaPool/classes/class.ilMediaPoolPageGUI.php");
1964  {
1965  $page_gui = new ilMediaPoolPageGUI($param[1]);
1966 
1967  if ($this->getOutputMode() != "offline")
1968  {
1969  $page_gui->setFileDownloadLink($this->determineFileDownloadLink());
1970  $page_gui->setFullscreenLink($this->determineFullscreenLink());
1971  $page_gui->setSourceCodeDownloadScript($this->determineSourcecodeDownloadScript());
1972  }
1973  else
1974  {
1975  $page_gui->setOutputMode(IL_PAGE_OFFLINE);
1976  }
1977 
1978  $html = $page_gui->getRawContent();
1979  }
1980  else
1981  {
1982  $html = "";
1983  }
1984  $h2 = substr($a_html, 0, $start).
1985  $html.
1986  substr($a_html, $end + 5);
1987  $a_html = $h2;
1988  $i++;
1989  }
1990  $start = strpos($a_html, "{{{{{ContentInclude;", $start + 5);
1991  $end = 0;
1992  if (is_int($start))
1993  {
1994  $end = strpos($a_html, "}}}}}", $start);
1995  }
1996  }
1997  return $a_html;
1998  }
1999 
2004  function postOutputProcessing($a_output)
2005  {
2006  return $a_output;
2007  }
2008 
2012  function insertHelp($a_tpl)
2013  {
2014  global $lng;
2015 
2016  $a_tpl->setCurrentBlock("help_img");
2017  $a_tpl->setVariable("IMG_HELP", ilUtil::getImagePath("streaked_area.gif"));
2018  $a_tpl->parseCurrentBlock();
2019  $a_tpl->setCurrentBlock("help_item");
2020  $a_tpl->setVariable("TXT_HELP", $lng->txt("cont_add_elements"));
2021  $a_tpl->parseCurrentBlock();
2022 
2023  $a_tpl->setCurrentBlock("help_img");
2024  $a_tpl->setVariable("IMG_HELP", ilUtil::getImagePath("icon_cont_el_s.gif"));
2025  $a_tpl->parseCurrentBlock();
2026  $a_tpl->setCurrentBlock("help_img");
2027  $a_tpl->setVariable("IMG_HELP", ilUtil::getImagePath("drop_streaked_area.gif"));
2028  $a_tpl->parseCurrentBlock();
2029  $a_tpl->setCurrentBlock("help_item");
2030  $a_tpl->setVariable("TXT_HELP", $lng->txt("cont_drag_and_drop_elements"));
2031  $a_tpl->parseCurrentBlock();
2032 
2033  $a_tpl->setCurrentBlock("help_img");
2034  $a_tpl->setVariable("IMG_HELP", ilUtil::getImagePath("icon_cont_el_s.gif"));
2035  $a_tpl->parseCurrentBlock();
2036  $a_tpl->setCurrentBlock("help_item");
2037  $a_tpl->setVariable("TXT_HELP", $lng->txt("cont_double_click_to_delete"));
2038  $a_tpl->parseCurrentBlock();
2039 
2040  $a_tpl->setCurrentBlock("help");
2041  $a_tpl->parseCurrentBlock();
2042  }
2043 
2044  /*
2045  * preview
2046  */
2047  function preview()
2048  {
2049  global $tree;
2051  return $this->showPage();
2052  }
2053 
2054  /*
2055  * edit ("view" before)
2056  */
2057  function edit()
2058  {
2059  global $tree, $lng, $ilCtrl;
2060 
2061  if (!$this->getEnableEditing())
2062  {
2063  ilUtil::sendFailure($lng->txt("permission_denied"), true);
2064  $ilCtrl->redirect($this, "preview");
2065  }
2066 
2067  $this->setOutputMode(IL_PAGE_EDIT);
2068 
2069  // scorm2004-start
2070  $html = $this->showPage();
2071  if ($this->isEnabledNotes())
2072  {
2073  $html.= "<br /><br />".$this->getNotesHTML($a_mode = "");
2074  }
2075  // scorm2004-end
2076  return $html;
2077  }
2078 
2079  /*
2080  * presentation
2081  */
2083  {
2084  global $tree;
2085  $this->setOutputMode($a_mode);
2086 
2087  return $this->showPage();
2088  }
2089 
2090  function getHTML()
2091  {
2092  $this->getTabs("preview");
2093  return $this->showPage();
2094  }
2095 
2099  function showMediaFullscreen($a_style_id = 0)
2100  {
2101  $this->tpl = new ilTemplate("tpl.fullscreen.html", true, true, "Services/COPage");
2102  $this->tpl->setCurrentBlock("ContentStyle");
2103  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", 0);
2104  $this->tpl->parseCurrentBlock();
2105 
2106  $this->tpl->setVariable("PAGETITLE", " - ".ilObject::_lookupTitle($_GET["mob_id"]));
2107  $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
2108  $this->tpl->setCurrentBlock("ilMedia");
2109 
2110  require_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
2111  $media_obj =& new ilObjMediaObject($_GET["mob_id"]);
2112  if (!empty ($_GET["pg_id"]))
2113  {
2114  require_once("./Services/COPage/classes/class.ilPageObject.php");
2115  $pg_obj =& new ilPageObject($this->obj->getParentType(), $_GET["pg_id"]);
2116  $pg_obj->buildDom();
2117 
2118  $xml = "<dummy>";
2119  // todo: we get always the first alias now (problem if mob is used multiple
2120  // times in page)
2121  $xml.= $pg_obj->getMediaAliasElement($_GET["mob_id"]);
2122  $xml.= $media_obj->getXML(IL_MODE_OUTPUT);
2123  $xml.="</dummy>";
2124  }
2125  else
2126  {
2127  $xml = "<dummy>";
2128  $xml.= $media_obj->getXML(IL_MODE_ALIAS);
2129  $xml.= $media_obj->getXML(IL_MODE_OUTPUT);
2130  $xml.="</dummy>";
2131  }
2132 
2133 //echo htmlentities($xml); exit;
2134 
2135  $xsl = file_get_contents("./Services/COPage/xsl/page.xsl");
2136  $args = array( '/_xml' => $xml, '/_xsl' => $xsl );
2137  $xh = xslt_create();
2138 
2139 //echo "<b>XML:</b>".htmlentities($xml);
2140  // determine target frames for internal links
2141  //$pg_frame = $_GET["frame"];
2142  $wb_path = ilUtil::getWebspaceDir("output");
2143 // $wb_path = "../".$this->ilias->ini->readVariable("server","webspace_dir");
2144  $mode = "fullscreen";
2145  $params = array ('mode' => $mode, 'webspace_path' => $wb_path);
2146  $output = xslt_process($xh,"arg:/_xml","arg:/_xsl",NULL,$args, $params);
2147  echo xslt_error($xh);
2148  xslt_free($xh);
2149 
2150  // unmask user html
2151  $this->tpl->setVariable("MEDIA_CONTENT", $output);
2152  }
2153 
2159  function displayValidationError($a_error)
2160  {
2161  if(is_array($a_error))
2162  {
2163  $error_str = "<b>Validation Error(s):</b><br>";
2164  foreach ($a_error as $error)
2165  {
2166  $err_mess = implode($error, " - ");
2167  if (!is_int(strpos($err_mess, ":0:")))
2168  {
2169  $error_str .= htmlentities($err_mess)."<br />";
2170  }
2171  }
2172  $this->tpl->setVariable("MESSAGE", $error_str);
2173  }
2174  }
2175 
2179  function history()
2180  {
2181  global $tpl, $lng, $ilAccess;
2182 
2183  if (!$this->getEnableEditing())
2184  {
2185  return;
2186  }
2187 
2188  $tpl->addJavaScript("./Services/COPage/js/page_history.js");
2189 
2190  include_once("./Services/COPage/classes/class.ilPageHistoryTableGUI.php");
2191  $table_gui = new ilPageHistoryTableGUI($this, "history");
2192  $table_gui->setId("hist_table");
2193  $entries = $this->getPageObject()->getHistoryEntries();
2194  $entries[] = array('page_id' => $this->getPageObject()->getId(),
2195  'parent_type' => $this->getPageObject()->getParentType(),
2196  'hdate' => $this->getPageObject()->getLastChange(),
2197  'parent_id' => $this->getPageObject()->getParentId(),
2198  'nr' => 0,
2199  'sortkey' => 999999,
2200  'user' => $this->getPageObject()->last_change_user);
2201  $table_gui->setData($entries);
2202  return $table_gui->getHTML();
2203  }
2204 
2209  {
2210  global $tpl, $lng, $ilAccess, $ilCtrl;
2211 
2212  if (!$this->getEnableEditing())
2213  {
2214  return;
2215  }
2216 
2217  include_once("Services/Utilities/classes/class.ilConfirmationGUI.php");
2218  $c_gui = new ilConfirmationGUI();
2219 
2220  // set confirm/cancel commands
2221  $ilCtrl->setParameter($this, "rollback_nr", $_GET["old_nr"]);
2222  $c_gui->setFormAction($ilCtrl->getFormAction($this, "rollback"));
2223  $c_gui->setHeaderText($lng->txt("cont_rollback_confirmation"));
2224  $c_gui->setCancel($lng->txt("cancel"), "history");
2225  $c_gui->setConfirm($lng->txt("confirm"), "rollback");
2226 
2227  $hentry = $this->obj->getHistoryEntry($_GET["old_nr"]);
2228 
2229  $c_gui->addItem("id[]", $_GET["old_nr"],
2231 
2232  $tpl->setContent($c_gui->getHTML());
2233  }
2234 
2238  function rollback()
2239  {
2240  global $ilCtrl;
2241 
2242  if (!$this->getEnableEditing())
2243  {
2244  return;
2245  }
2246 
2247  $hentry = $this->obj->getHistoryEntry($_GET["rollback_nr"]);
2248 
2249  if ($hentry["content"] != "")
2250  {
2251  $this->obj->setXMLContent($hentry["content"]);
2252  $this->obj->buildDom(true);
2253  if ($this->obj->update())
2254  {
2255  $ilCtrl->redirect($this, "history");
2256  }
2257  }
2258  $ilCtrl->redirect($this, "history");
2259  }
2260 
2266  function getTabs($a_activate = "")
2267  {
2268  global $ilTabs, $ilCtrl;
2269 
2270  if (!$this->getEnabledTabs())
2271  {
2272  return;
2273  }
2274 
2275 //echo "-".$ilCtrl->getNextClass()."-".$ilCtrl->getCmd()."-";
2276  // back to upper context
2277 
2278  if (!$this->getEditPreview())
2279  {
2280  $ilTabs->addTarget("pg", $ilCtrl->getLinkTarget($this, "preview")
2281  , array("", "preview"));
2282 
2283  if ($this->getEnableEditing())
2284  {
2285  $ilTabs->addTarget("edit", $ilCtrl->getLinkTarget($this, "edit")
2286  , array("", "edit"));
2287  }
2288  }
2289  else
2290  {
2291  if ($this->getEnableEditing())
2292  {
2293  $ilTabs->addTarget("edit", $ilCtrl->getLinkTarget($this, "edit")
2294  , array("", "edit"));
2295  }
2296 
2297  $ilTabs->addTarget("cont_preview", $ilCtrl->getLinkTarget($this, "preview")
2298  , array("", "preview"));
2299  }
2300 
2301  //$tabs_gui->addTarget("properties", $this->ctrl->getLinkTarget($this, "properties")
2302  // , "properties", get_class($this));
2303 
2304  if ($this->use_meta_data && !$this->layout_mode)
2305  {
2306  $ilTabs->addTarget("meta_data",
2307  $this->ctrl->getLinkTargetByClass('ilmdeditorgui',''),
2308  "", "ilmdeditorgui");
2309  }
2310 
2311  if ($this->getEnableEditing() && !$this->layout_mode)
2312  {
2313  $ilTabs->addTarget("history", $this->ctrl->getLinkTarget($this, "history")
2314  , "history", get_class($this));
2315  }
2316 
2317 /* $tabs = $this->ctrl->getTabs();
2318  foreach ($tabs as $tab)
2319  {
2320  $tabs_gui->addTarget($tab["lang_var"], $tab["link"]
2321  , $tab["cmd"], $tab["class"]);
2322  }
2323 */
2324  if ($this->getEnableEditing())
2325  {
2326  $ilTabs->addTarget("clipboard", $this->ctrl->getLinkTargetByClass("ilEditClipboardGUI", "view")
2327  , "view", "ilEditClipboardGUI");
2328  }
2329 
2330  if ($this->getEnabledScheduledActivation())
2331  {
2332  $ilTabs->addTarget("cont_activation", $this->ctrl->getLinkTarget($this, "editActivation"),
2333  "editActivation", get_class($this));
2334  }
2335 
2336  // external hook to add tabs
2337  if (is_array($this->tab_hook))
2338  {
2339  $func = $this->tab_hook["func"];
2340  $this->tab_hook["obj"]->$func();
2341  }
2342  //$ilTabs->setTabActive("pg");
2343  }
2344 
2348  function compareVersion()
2349  {
2350  global $lng;
2351 
2352  if (!$this->getEnableEditing())
2353  {
2354  return;
2355  }
2356 
2357  $tpl = new ilTemplate("tpl.page_compare.html", true, true, "Services/COPage");
2358  $compare = $this->obj->compareVersion($_POST["left"], $_POST["right"]);
2359 
2360  // left page
2361  $lpage = $compare["l_page"];
2362  $lpage_gui = new ilPageObjectGUI("wpg");
2363  $lpage_gui->setOutputMode(IL_PAGE_PREVIEW);
2364  $lpage_gui->setPageObject($lpage);
2365  $lpage_gui->setPreventHTMLUnmasking(true);
2366  $lpage_gui->setPresentationTitle($this->getPresentationTitle());
2367  $lpage_gui->setCompareMode(true);
2368  $lhtml = $lpage_gui->showPage();
2369  $lhtml = $this->replaceDiffTags($lhtml);
2370  $lhtml = str_replace("&lt;br /&gt;", "<br />", $lhtml);
2371  $tpl->setVariable("LEFT", $lhtml);
2372 
2373  // right page
2374  $rpage = $compare["r_page"];
2375  $rpage_gui = new ilPageObjectGUI("wpg");
2376  $rpage_gui->setOutputMode(IL_PAGE_PREVIEW);
2377  $rpage_gui->setPageObject($rpage);
2378  $rpage_gui->setPreventHTMLUnmasking(true);
2379  $rpage_gui->setPresentationTitle($this->getPresentationTitle());
2380  $rpage_gui->setCompareMode(true);
2381  $rhtml = $rpage_gui->showPage();
2382  $rhtml = $this->replaceDiffTags($rhtml);
2383  $rhtml = str_replace("&lt;br /&gt;", "<br />", $rhtml);
2384  $tpl->setVariable("RIGHT", $rhtml);
2385 
2386  $tpl->setVariable("TXT_NEW", $lng->txt("cont_pc_new"));
2387  $tpl->setVariable("TXT_MODIFIED", $lng->txt("cont_pc_modified"));
2388  $tpl->setVariable("TXT_DELETED", $lng->txt("cont_pc_deleted"));
2389 
2390 //var_dump($left);
2391 //var_dump($right);
2392 
2393  return $tpl->get();
2394  }
2395 
2396  function replaceDiffTags($a_html)
2397  {
2398  $a_html = str_replace("[ilDiffInsStart]", '<span class="ilDiffIns">', $a_html);
2399  $a_html = str_replace("[ilDiffDelStart]", '<span class="ilDiffDel">', $a_html);
2400  $a_html = str_replace("[ilDiffInsEnd]", '</span>', $a_html);
2401  $a_html = str_replace("[ilDiffDelEnd]", '</span>', $a_html);
2402 
2403  return $a_html;
2404  }
2405 
2409  function editActivation()
2410  {
2411  global $ilCtrl, $lng, $tpl;
2412 
2413  $atpl = new ilTemplate("tpl.page_activation.php", true, true, "Services/COPage");
2414  $this->initActivationForm();
2415  $this->getActivationFormValues();
2416  $atpl->setVariable("FORM", $this->form->getHTML());
2417  $atpl->setCurrentBlock("updater");
2418  $atpl->setVariable("UPDATER_FRAME", $this->exp_frame);
2419  $atpl->setVariable("EXP_ID_UPDATER", $this->exp_id);
2420  $atpl->setVariable("HREF_UPDATER", $this->exp_target_script);
2421  $atpl->parseCurrentBlock();
2422  $tpl->setContent($atpl->get());
2423  }
2424 
2429  {
2430  global $ilCtrl, $lng;
2431 
2432  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
2433  $this->form = new ilPropertyFormGUI();
2434  $this->form->setFormAction($ilCtrl->getFormAction($this));
2435  $this->form->setTitle($lng->txt("cont_page_activation"));
2436 
2437  // activation type radio
2438  $rad = new ilRadioGroupInputGUI($lng->txt("cont_activation"), "activation");
2439  $rad_op1 = new ilRadioOption($lng->txt("cont_activated"), "activated");
2440 
2441  $rad->addOption($rad_op1);
2442  $rad_op2 = new ilRadioOption($lng->txt("cont_deactivated"), "deactivated");
2443  $rad->addOption($rad_op2);
2444  $rad_op3 = new ilRadioOption($lng->txt("cont_scheduled_activation"), "scheduled");
2445 
2446  $dt_prop = new ilDateTimeInputGUI($lng->txt("cont_start"), "start");
2447  $dt_prop->setShowTime(true);
2448  $rad_op3->addSubItem($dt_prop);
2449  $dt_prop2 = new ilDateTimeInputGUI($lng->txt("cont_end"), "end");
2450  $dt_prop2->setShowTime(true);
2451  $rad_op3->addSubItem($dt_prop2);
2452 
2453  $rad->addOption($rad_op3);
2454 
2455  $this->form->addCommandButton("saveActivation", $lng->txt("save"));
2456 
2457  $this->form->addItem($rad);
2458  }
2459 
2464  {
2465  $values = array();
2466  $values["activation"] = "deactivated";
2467  if ($this->getPageObject()->getActive())
2468  {
2469  $values["activation"] = "activated";
2470  }
2471 
2472  $dt_prop = $this->form->getItemByPostVar("start");
2473  if ($this->getPageObject()->getActivationStart() != "")
2474  {
2475  $values["activation"] = "scheduled";
2476  $dt_prop->setDate(new ilDateTime($this->getPageObject()->getActivationStart(),
2477  IL_CAL_DATETIME));
2478  }
2479  $dt_prop = $this->form->getItemByPostVar("end");
2480  if ($this->getPageObject()->getActivationEnd() != "")
2481  {
2482  $values["activation"] = "scheduled";
2483  $dt_prop->setDate(new ilDateTime($this->getPageObject()->getActivationEnd(),
2484  IL_CAL_DATETIME));
2485  }
2486 
2487  $this->form->setValuesByArray($values);
2488  }
2489 
2493  function saveActivation()
2494  {
2495  global $tpl, $lng, $ilCtrl;
2496 
2497  $this->initActivationForm();
2498 
2499  if ($this->form->checkInput())
2500  {
2501  $this->getPageObject()->setActive(true);
2502  $this->getPageObject()->setActivationStart(null);
2503  $this->getPageObject()->setActivationEnd(null);
2504  if ($_POST["activation"] == "deactivated")
2505  {
2506  $this->getPageObject()->setActive(false);
2507  }
2508  if ($_POST["activation"] == "scheduled")
2509  {
2510  $this->getPageObject()->setActive(false);
2511  $this->getPageObject()->setActivationStart(
2512  $this->form->getItemByPostVar("start")->getDate()->get(IL_CAL_DATETIME));
2513  $this->getPageObject()->setActivationEnd(
2514  $this->form->getItemByPostVar("end")->getDate()->get(IL_CAL_DATETIME));
2515  }
2516  $this->getPageObject()->update();
2517  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
2518  $ilCtrl->redirect($this, "editActivation");
2519  }
2520  $this->form->getValuesByPost();
2521  $tpl->setContent($this->form->getHTML());
2522  }
2523 
2527  function getNotesHTML($a_mode = "")
2528  {
2529  global $ilCtrl;
2530 
2531  // notes
2532  $ilCtrl->setParameter($this, "nodes_mode", $a_mode);
2533  include_once("Services/Notes/classes/class.ilNoteGUI.php");
2534  $notes_gui = new ilNoteGUI($this->notes_parent_id,
2535  (int) $this->obj->getId(), "pg");
2536 // if ($ilAccess->checkAccess("write", "", $_GET["ref_id"]))
2537 // {
2538 // $notes_gui->enablePublicNotesDeletion(true);
2539 // }
2540  $notes_gui->enablePrivateNotes();
2541  $notes_gui->enablePublicNotes();
2542 
2543  $next_class = $ilCtrl->getNextClass($this);
2544  if ($next_class == "ilnotegui")
2545  {
2546  $html = $this->ctrl->forwardCommand($notes_gui);
2547  }
2548  else
2549  {
2550  $html = $notes_gui->getNotesHTML();
2551  }
2552  return $html;
2553  }
2554 
2555 }
2556 ?>