ILIAS  Release_4_2_x_branch Revision 61807
 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 $enabledpctabs = false;
59  var $link_xml_set = false;
60  var $enableediting = true;
61  var $rawpagecontent = false;
62  var $layoutmode = false;
64  var $compare_mode = false;
65  var $page_config = null;
66  var $enable_keywords = false;
67  var $enable_anchors = false;
68  var $tabs_enabled = true;
69  private $abstract_only = false;
70  private $enabledloginpage = false;
71 
72  //var $pl_start = "&#123;&#123;&#123;&#123;&#123;";
73  //var $pl_end = "&#125;&#125;&#125;&#125;&#125;";
74  var $pl_start = "{{{{{";
75  var $pl_end = "}}}}}";
76 
77  // name keys like pc class names!
78  var $pc_types = array(
79  "ContentInclude" => array(
80  "enabled" => false),
81  "DataTable" => array(
82  "enabled" => true),
83  "FileList" => array(
84  "enabled" => true),
85  "InteractiveImage" => array(
86  "enabled" => true),
87  "List" => array(
88  "enabled" => true),
89  "LoginPageElement" => array(
90  "enabled" => false),
91  "Map" => array(
92  "enabled" => false),
93  "MediaObject" => array(
94  "enabled" => true),
95  "Paragraph" => array(
96  "enabled" => true),
97  "PlaceHolder" => array(
98  "enabled" => false),
99  "Question" => array(
100  "enabled" => false),
101  "Resources" => array(
102  "enabled" => false),
103  "Section" => array(
104  "enabled" => true),
105  "SourceCode" => array(
106  "enabled" => true),
107  "Table" => array(
108  "enabled" => true),
109  "Tabs" => array(
110  "enabled" => true),
111  "Profile" => array(
112  "enabled" => false),
113  "Verification" => array(
114  "enabled" => false),
115  "Blog" => array(
116  "enabled" => false),
117  "QuestionOverview" => array(
118  "enabled" => false),
119  "Skills" => array(
120  "enabled" => false)
121  );
122 
123 
124 
129  function ilPageObjectGUI($a_parent_type, $a_id = 0, $a_old_nr = 0,
130  $a_prevent_get_id = false)
131  {
132  global $ilias, $tpl, $lng, $ilCtrl,$ilTabs;
133  $this->ctrl =& $ilCtrl;
134 
135  if ($a_old_nr == 0 && !$a_prevent_get_id && $_GET["old_nr"] > 0)
136  {
137  $a_old_nr = $_GET["old_nr"];
138  }
139 
140  $this->ilias =& $ilias;
141  $this->tpl =& $tpl;
142  $this->ctrl =& $ilCtrl;
143  $this->lng =& $lng;
145 
146  // defaults (as in learning modules)
147  $this->setEnabledMaps(false);
148  $this->setEnabledFileLists(true);
149  $this->setEnabledRepositoryObjects(false);
150  $this->setEnabledLoginPage(false);
151  $this->setEnabledSelfAssessment(false);
152  $this->setEnabledPageFocus(true);
153  $this->setLayoutMode(false);
154 
155  include_once("./Services/COPage/classes/class.ilPageConfig.php");
156  $this->setPageConfig(new ilPageConfig());
157 
158 
159  if ($a_id > 0)
160  {
161  $this->initPageObject($a_parent_type, $a_id, $a_old_nr);
162  }
163 
164  $this->output2template = true;
165  $this->question_xml = "";
166  $this->question_html = "";
167  $this->tabs_gui =& $ilTabs;
168 
169  // USED FOR TRANSLATIONS
170  $this->template_output_var = "PAGE_CONTENT";
171  $this->citation = false;
172  $this->change_comments = false;
173  $this->page_back_title = $this->lng->txt("page");
174  $lng->loadLanguageModule("content");
175  $this->setPreventHTMLUnmasking(false);
176  $this->setEnabledWikiLinks(false);
177 
178  $this->setTemplateOutput(false);
179  }
180 
186  function setEnablePCType($a_pc_type, $a_val)
187  {
188  if (isset($a_pc_type))
189  {
190  $this->pc_types[$a_pc_type]["enabled"] = $a_val;
191  }
192  }
193 
199  function getEnablePCType($a_pc_type)
200  {
201  return $this->pc_types[$a_pc_type]["enabled"];
202  }
203 
209  function setPageConfig($a_val)
210  {
211  $this->page_config = $a_val;
212  }
213 
219  function getPageConfig()
220  {
221  return $this->page_config;
222  }
223 
224  function initPageObject($a_parent_type, $a_id, $a_old_nr)
225  {
226  $page = new ilPageObject($a_parent_type, $a_id, $a_old_nr);
227  $this->setPageObject($page);
228  }
229 
233  function setBibId($a_id)
234  {
235  // USED FOR SELECTION WHICH PAGE TURNS AND LATER PAGES SHOULD BE SHOWN
236  $this->bib_id = $a_id;
237  }
238 
242  function getBibId()
243  {
244  return $this->bib_id ? $this->bib_id : 0;
245  }
246 
252  function setPageObject($a_pg_obj)
253  {
254  $this->obj = $a_pg_obj;
255  }
256 
262  function getPageObject()
263  {
264  return $this->obj;
265  }
266 
273  {
274  $this->output_mode = $a_mode;
275  }
276 
277  function getOutputMode()
278  {
279  return $this->output_mode;
280  }
281 
282  function setTemplateOutput($a_output = true)
283  {
284  $this->output2template = $a_output;
285  }
286 
287  function outputToTemplate()
288  {
289  return $this->output2template;
290  }
291 
292  function setPresentationTitle($a_title = "")
293  {
294  $this->presentation_title = $a_title;
295  }
296 
298  {
300  }
301 
302  function setHeader($a_title = "")
303  {
304  $this->header = $a_title;
305  }
306 
307  function getHeader()
308  {
309  return $this->header;
310  }
311 
312  function setLinkParams($l_params = "")
313  {
314  $this->link_params = $l_params;
315  }
316 
317  function getLinkParams()
318  {
319  return $this->link_params;
320  }
321 
322  function setLinkFrame($l_frame = "")
323  {
324  $this->link_frame = $l_frame;
325  }
326 
327  function getLinkFrame()
328  {
329  return $this->link_frame;
330  }
331 
332  function setLinkXML($link_xml)
333  {
334  $this->link_xml = $link_xml;
335  $this->link_xml_set = true;
336  }
337 
338  function getLinkXML()
339  {
340  return $this->link_xml;
341  }
342 
343  function setQuestionXML($question_xml)
344  {
345  $this->question_xml = $question_xml;
346  }
347 
349  {
350  $this->question_html = $question_html;
351  }
352 
353  function getQuestionXML()
354  {
355  return $this->question_xml;
356  }
357 
358  function getQuestionHTML()
359  {
360  return $this->question_html;
361  }
362 
363  function setTemplateTargetVar($a_variable)
364  {
365  $this->target_var = $a_variable;
366  }
367 
369  {
370  return $this->target_var;
371  }
372 
373  function setTemplateOutputVar($a_value)
374  {
375  // USED FOR TRANSLATION PRESENTATION OF dbk OBJECTS
376  $this->template_output_var = $a_value;
377  }
378 
380  {
382  }
383 
384  function setOutputSubmode($a_mode)
385  {
386  // USED FOR TRANSLATION PRESENTATION OF dbk OBJECTS
387  $this->output_submode = $a_mode;
388  }
389 
390  function getOutputSubmode()
391  {
392  return $this->output_submode;
393  }
394 
395 
397  $this->sourcecode_download_script = $script_name;
398  }
399 
402  }
403 
404  function enableCitation($a_enabled)
405  {
406  $this->citation = $a_enabled;
407  }
408 
409  function isEnabledCitation()
410  {
411  return $this->citation;
412  }
413 
414  function setLocator(&$a_locator)
415  {
416  $this->locator =& $a_locator;
417  }
418 
419  function setTabs($a_tabs)
420  {
421  $this->tabs_gui = $a_tabs;
422  }
423 
424  function setPageBackTitle($a_title)
425  {
426  $this->page_back_title = $a_title;
427  }
428 
429  function setFileDownloadLink($a_download_link)
430  {
431  $this->file_download_link = $a_download_link;
432  }
433 
435  {
436  return $this->file_download_link;
437  }
438 
439  function setFullscreenLink($a_fullscreen_link)
440  {
441  $this->fullscreen_link = $a_fullscreen_link;
442  }
443 
444  function getFullscreenLink()
445  {
446  return $this->fullscreen_link;
447  }
448 
454  function setEnableKeywords($a_val)
455  {
456  $this->enable_keywords = $a_val;
457  }
458 
464  function getEnableKeywords()
465  {
466  return $this->enable_keywords;
467  }
468 
474  function setEnableAnchors($a_val)
475  {
476  $this->enable_anchors = $a_val;
477  }
478 
484  function getEnableAnchors()
485  {
486  return $this->enable_anchors;
487  }
488 
489  function setIntLinkHelpDefault($a_type, $a_id)
490  {
491  $this->int_link_def_type = $a_type;
492  $this->int_link_def_id = $a_id;
493  }
494 
495  function setIntLinkReturn($a_return)
496  {
497  $this->int_link_return = $a_return;
498  }
499 
500  function enableChangeComments($a_enabled)
501  {
502  $this->change_comments = $a_enabled;
503  }
504 
506  {
507  return $this->change_comments;
508  }
509 
510  function enableNotes($a_enabled, $a_parent_id)
511  {
512  $this->notes_enabled = $a_enabled;
513  $this->notes_parent_id = $a_parent_id;
514  }
515 
516  function isEnabledNotes()
517  {
518  return $this->notes_enabled;
519  }
520 
524  function enableContentIncludes($a_enable)
525  {
526  $this->setEnablePCType("ContentInclude", (bool) $a_enable);
527  }
528 
533  {
534  return $this->getEnablePCType("ContentInclude");
535  }
536 
542  function setOfflineDirectory ($offdir) {
543  $this->offline_directory = $offdir;
544  }
545 
546 
551  function getOfflineDirectory () {
552  return $this->offline_directory;
553  }
554 
555 
562  function setViewPageLink($a_link, $a_target = "")
563  {
564  $this->view_page_link = $a_link;
565  $this->view_page_target = $a_target;
566  }
567 
571  function getViewPageLink()
572  {
573  return $this->view_page_link;
574  }
575 
579  function getViewPageTarget()
580  {
581  return $this->view_page_target;
582  }
583 
584  function setActivationListener(&$a_obj, $a_meth)
585  {
586  $this->act_obj =& $a_obj;
587  $this->act_meth = $a_meth;
588  }
589 
590  function setEnabledActivation($a_act)
591  {
592  $this->activation = $a_act;
593  }
594 
596  {
597  return $this->activation;
598  }
599 
601  {
602  $this->scheduled_activation = $a_act;
603  }
604 
606  {
607  return $this->scheduled_activation;
608  }
609 
615  public function setPageToc($a_val)
616  {
617  $this->page_toc = $a_val;
618  }
619 
625  public function getPageToc()
626  {
627  return $this->page_toc;
628  }
629 
635  function setEnabledNews($a_enabled, $a_news_obj_id = 0, $a_news_obj_type = 0)
636  {
637  $this->enabled_news = $a_enabled;
638  $this->news_obj_id = $a_news_obj_id;
639  $this->news_obj_type = $a_news_obj_type;
640  }
641 
647  function getEnabledNews()
648  {
649  return $this->enabled_news;
650  }
651 
655  function setTabHook($a_object, $a_function)
656  {
657  $this->tab_hook = array("obj" => $a_object, "func" => $a_function);
658  }
659 
660 
666  function setEnabledInternalLinks($a_enabledinternallinks)
667  {
668  $this->enabledinternallinks = $a_enabledinternallinks;
669  }
670 
677  {
679  }
680 
686  function setEditPreview($a_editpreview)
687  {
688  $this->editpreview = $a_editpreview;
689  }
690 
696  function getEditPreview()
697  {
698  return $this->editpreview;
699  }
700 
706  function setPreventHTMLUnmasking($a_preventhtmlunmasking)
707  {
708  $this->preventhtmlunmasking = $a_preventhtmlunmasking;
709  }
710 
717  {
718  return $this->preventhtmlunmasking;
719  }
720 
726  function setEnabledTabs($a_enabledtabs)
727  {
728  $this->tabs_enabled = $a_enabledtabs;
729  }
730 
736  function getEnabledTabs()
737  {
738  return $this->tabs_enabled;
739  }
740 
746  function setEnabledRepositoryObjects($a_enabledrepositoryobjects)
747  {
748  $this->setEnablePCType("Resources", $a_enabledrepositoryobjects);
749  }
750 
757  {
758  return $this->getEnablePCType("Resources");
759  }
760 
765  public function setEnabledLoginPage($a_enablegloginpage)
766  {
767  $this->setEnablePCType("LoginPageElement", (bool) $a_enablegloginpage);
768  }
769 
774  public function getEnabledLoginPage()
775  {
776  return $this->getEnablePCType("LoginPageElement");
777  }
778 
784  function setEnabledMaps($a_enabledmaps)
785  {
786  $this->setEnablePCType("Map", (bool) $a_enabledmaps);
787  }
788 
794  function getEnabledMaps()
795  {
796  return $this->getEnablePCType("Map");
797  }
798 
804  function setEnabledPCTabs($a_enabledpctabs)
805  {
806  $this->setEnablePCType("Tabs", (bool) $a_enabledpctabs);
807  }
808 
814  function getEnabledPCTabs()
815  {
816  return $this->getEnablePCType("Tabs");
817  }
818 
824  function setEnabledFileLists($a_enabledfilelists)
825  {
826  $this->setEnablePCType("FileList", (bool) $a_enabledfilelists);
827  }
828 
835  {
836  return $this->getEnablePCType("FileList");
837  }
838 
844  function setEnabledPageFocus($a_enabledpagefocus)
845  {
846  $this->enabledpagefocus = $a_enabledpagefocus;
847  }
848 
855  {
856  return $this->enabledpagefocus;
857  }
858 
864  function getEnabledProfile()
865  {
866  return $this->getEnablePCType("Profile");
867  }
868 
873  public function setEnabledProfile($a_enableprofile)
874  {
875  $this->setEnablePCType("Profile", (bool)$a_enableprofile);
876  }
877 
884  {
885  return $this->getEnablePCType("Verification");
886  }
887 
892  public function setEnabledVerification($a_enableverification)
893  {
894  $this->setEnablePCType("Verification", (bool)$a_enableverification);
895  }
896 
902  function getEnabledBlog()
903  {
904  return $this->getEnablePCType("Blog");
905  }
906 
911  public function setEnabledBlog($a_enableblog)
912  {
913  $this->setEnablePCType("Blog", (bool)$a_enableblog);
914  }
915 
921  function getEnabledSkills()
922  {
923  return $this->getEnablePCType("Skills");
924  }
925 
930  public function setEnabledSkills($a_enableskills)
931  {
932  $this->setEnablePCType("Skills", (bool)$a_enableskills);
933  }
934 
940  function setExplorerUpdater($a_exp_frame, $a_exp_id, $a_exp_target_script)
941  {
942  $this->exp_frame = $a_exp_frame;
943  $this->exp_id = $a_exp_id;
944  $this->exp_target_script = $a_exp_target_script;
945  }
946 
952  function setPrependingHtml($a_prependinghtml)
953  {
954  $this->prependinghtml = $a_prependinghtml;
955  }
956 
962  function getPrependingHtml()
963  {
964  return $this->prependinghtml;
965  }
966 
972  function setEnabledWikiLinks($a_enablewikilinks)
973  {
974  $this->enablewikilinks = $a_enablewikilinks;
975  }
976 
983  {
984  return $this->enablewikilinks;
985  }
986 
992  function setEnableEditing($a_enableediting)
993  {
994  $this->enableediting = $a_enableediting;
995  }
996 
1002  function getEnableEditing()
1003  {
1004  return $this->enableediting;
1005  }
1006 
1012  function setRawPageContent($a_rawpagecontent)
1013  {
1014  $this->rawpagecontent = $a_rawpagecontent;
1015  }
1016 
1023  {
1024  return $this->rawpagecontent;
1025  }
1026 
1032  function setLayoutMode($a_layout_mode)
1033  {
1034  $this->layout_mode = $a_layout_mode;
1035  }
1036 
1042  function getLayoutMode()
1043  {
1044  return $this->layout_mode;
1045  }
1046 
1052  function setStyleId($a_styleid)
1053  {
1054  $this->styleid = $a_styleid;
1055  }
1056 
1062  function getStyleId()
1063  {
1064  return $this->styleid;
1065  }
1066 
1072  function setEnabledSelfAssessment($a_enabledselfassessment, $a_scorm = true)
1073  {
1074  $this->setEnablePCType("Question", (bool) $a_enabledselfassessment);
1075  $this->enabledselfassessment = $a_enabledselfassessment;
1076  $this->enabledselfassessment_scorm = $a_scorm;
1077  }
1078 
1079 
1086  {
1087  return $this->enabledselfassessment;
1088  }
1089 
1096  {
1097  return $this->enabledselfassessment_scorm;
1098  }
1099 
1105  function setCompareMode($a_val)
1106  {
1107  $this->compare_mode = $a_val;
1108  }
1109 
1115  function getCompareMode()
1116  {
1117  return $this->compare_mode;
1118  }
1119 
1125  function setAbstractOnly($a_val)
1126  {
1127  $this->abstract_only = $a_val;
1128  }
1129 
1135  function getAbstractOnly()
1136  {
1137  return $this->abstract_only;
1138  }
1139 
1149  function activateMetaDataEditor($a_rep_obj_id, $a_sub_obj_id, $a_type,
1150  $a_observer_obj = NULL, $a_observer_func = "")
1151  {
1152  $this->use_meta_data = true;
1153  $this->meta_data_rep_obj_id = $a_rep_obj_id;
1154  $this->meta_data_sub_obj_id = $a_sub_obj_id;
1155  $this->meta_data_type = $a_type;
1156  $this->meta_data_observer_obj = $a_observer_obj;
1157  $this->meta_data_observer_func = $a_observer_func;
1158  }
1159 
1166  {
1167  global $ilCtrl;
1168 
1169  $file_download_link = $this->getFileDownloadLink();
1170  if ($this->getFileDownloadLink() == "" && $this->getOutputMode() != "offline")
1171  {
1172  $file_download_link = $ilCtrl->getLinkTarget($this, "downloadFile");
1173  }
1174  return $file_download_link;
1175  }
1176 
1183  {
1184  global $ilCtrl;
1185 
1186  $fullscreen_link = $this->getFullscreenLink();
1187  if ($this->getFullscreenLink() == "" && $this->getOutputMode() != "offline")
1188  {
1189  $fullscreen_link = $ilCtrl->getLinkTarget($this, "displayMediaFullscreen", "", false, false);
1190  }
1191  return $fullscreen_link;
1192  }
1193 
1200  {
1201  global $ilCtrl;
1202 
1204  if ($this->sourcecode_download_script == "" && $this->getOutputMode() != "offline")
1205  {
1206  $l = $ilCtrl->getLinkTarget($this, "");
1207  }
1208  return $l;
1209  }
1210 
1215  {
1216  $xml = "";
1217  if($this->getOutputMode() == "edit")
1218  {
1219  global $ilPluginAdmin;
1220 
1221  $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_SERVICE,
1222  "COPage", "pgcp");
1223  foreach ($pl_names as $pl_name)
1224  {
1225  $plugin = $ilPluginAdmin->getPluginObject(IL_COMP_SERVICE,
1226  "COPage", "pgcp", $pl_name);
1227  if ($plugin->isValidParentType($this->getPageObject()->getParentType()))
1228  {
1229  $xml = '<ComponentPlugin Name="'.$plugin->getPluginName().
1230  '" InsertText="'.$plugin->getUIText(ilPageComponentPlugin::TXT_CMD_INSERT).'" />';
1231  }
1232  }
1233  }
1234  if ($xml != "")
1235  {
1236  $xml = "<ComponentPlugins>".$xml."</ComponentPlugins>";
1237  }
1238 
1239  return $xml;
1240  }
1241 
1242 
1246  function &executeCommand()
1247  {
1248  global $ilCtrl, $ilTabs, $lng;
1249 
1250  $next_class = $this->ctrl->getNextClass($this);
1251 
1252  $cmd = $this->ctrl->getCmd();
1253  //$this->ctrl->addTab("clipboard", $this->ctrl->getLinkTargetByClass("ilEditClipboardGUI", "view")
1254  // , "view", "ilEditClipboardGUI");
1255  $this->getTabs();
1256 
1257  $ilCtrl->setReturn($this, "edit");
1258 //echo "-".$next_class."-";
1259  switch($next_class)
1260  {
1261  case 'ilmdeditorgui':
1262  //$this->setTabs();
1263  $ilTabs->setTabActive("meta_data");
1264  include_once 'Services/MetaData/classes/class.ilMDEditorGUI.php';
1265  $md_gui =& new ilMDEditorGUI($this->meta_data_rep_obj_id,
1266  $this->meta_data_sub_obj_id, $this->meta_data_type);
1267  if (is_object($this->meta_data_observer_obj))
1268  {
1269  $md_gui->addObserver($this->meta_data_observer_obj,
1270  $this->meta_data_observer_func, "General");
1271  }
1272  $this->ctrl->forwardCommand($md_gui);
1273  break;
1274 
1275  case "ileditclipboardgui":
1276  //$this->tabs_gui->clearTargets();
1277  //$this->ctrl->setReturn($this, "view");
1278  $clip_gui = new ilEditClipboardGUI();
1279  $clip_gui->setPageBackTitle($this->page_back_title);
1280  //$ret =& $clip_gui->executeCommand();
1281  $ret =& $this->ctrl->forwardCommand($clip_gui);
1282  break;
1283 
1284  // notes
1285  case "ilnotegui":
1286  switch($_GET["notes_mode"])
1287  {
1288  default:
1289  $html = $this->edit();
1290  $ilTabs->setTabActive("edit");
1291  return $html;
1292  }
1293  break;
1294 
1295  case 'ilpublicuserprofilegui':
1296  require_once './Services/User/classes/class.ilPublicUserProfileGUI.php';
1297  $profile_gui = new ilPublicUserProfileGUI($_GET["user"]);
1298  $ret = $this->ctrl->forwardCommand($profile_gui);
1299  break;
1300 
1301  case "ilpageeditorgui":
1302  if (!$this->getEnableEditing())
1303  {
1304  ilUtil::sendFailure($lng->txt("permission_denied"), true);
1305  $ilCtrl->redirect($this, "preview");
1306  }
1307  $page_editor =& new ilPageEditorGUI($this->getPageObject(), $this);
1308  $page_editor->setLocator($this->locator);
1309  $page_editor->setHeader($this->getHeader());
1310  $page_editor->setPageBackTitle($this->page_back_title);
1311  $page_editor->setEnableInternalLinks($this->getEnabledInternalLinks());
1312  $page_editor->setEnableKeywords($this->getEnableKeywords());
1313  $page_editor->setEnableAnchors($this->getEnableAnchors());
1314  $page_editor->setIntLinkHelpDefault($this->int_link_def_type,
1315  $this->int_link_def_id);
1316  $page_editor->setIntLinkReturn($this->int_link_return);
1317  //$page_editor->executeCommand();
1318  $ret =& $this->ctrl->forwardCommand($page_editor);
1319  break;
1320 
1321  case 'ilnewsitemgui':
1322  include_once("./Services/News/classes/class.ilNewsItemGUI.php");
1323  $news_item_gui = new ilNewsItemGUI();
1324  $news_item_gui->setEnableEdit(true);
1325  $news_item_gui->setContextObjId($this->news_obj_id);
1326  $news_item_gui->setContextObjType($this->news_obj_type);
1327  $news_item_gui->setContextSubObjId($this->obj->getId());
1328  $news_item_gui->setContextSubObjType("pg");
1329 
1330  $ret = $ilCtrl->forwardCommand($news_item_gui);
1331  break;
1332 
1333  $profile_gui = new ilPublicUserProfileGUI($_GET["user"]);
1334  $ret = $this->ctrl->forwardCommand($profile_gui);
1335  break;
1336 
1337  default:
1338  $cmd = $this->ctrl->getCmd("preview");
1339  $ret = $this->$cmd();
1340  break;
1341  }
1342 //echo "+$ret+";
1343  return $ret;
1344  }
1345 
1346  function deactivatePage()
1347  {
1348  $this->getPageObject()->setActivationStart(null);
1349  $this->getPageObject()->setActivationEnd(null);
1350  $this->getPageObject()->setActive(false);
1351  $this->getPageObject()->update();
1352  $this->ctrl->redirect($this, "edit");
1353  }
1354 
1355  function activatePage()
1356  {
1357  $this->getPageObject()->setActivationStart(null);
1358  $this->getPageObject()->setActivationEnd(null);
1359  $this->getPageObject()->setActive(true);
1360  $this->getPageObject()->update();
1361  $this->ctrl->redirect($this, "edit");
1362  }
1363 
1364  /*
1365  * display content of page
1366  */
1367  function showPage()
1368  {
1369  global $tree, $ilUser, $ilias, $lng, $ilCtrl, $ilBench, $ilSetting, $ilTabs;
1370 
1371  $ilBench->start("ContentPresentation", "ilPageObjectGUI_showPage");
1372 
1373  $this->initSelfAssessmentRendering();
1374 
1375  $GLOBALS["tpl"]->addJavaScript("./Services/COPage/js/ilCOPagePres.js");
1376 
1377  // init template
1378  //if($this->outputToTemplate())
1379  //{
1380  if($this->getOutputMode() == "edit")
1381  {
1382 //echo ":".$this->getTemplateTargetVar().":";
1383  $tpl = new ilTemplate("tpl.page_edit_wysiwyg.html", true, true, "Services/COPage");
1384  //$this->tpl->addBlockFile($this->getTemplateTargetVar(), "adm_content", "tpl.page_edit_wysiwyg.html", "Services/COPage");
1385 
1386  // to do: status dependent class
1387  $tpl->setVariable("CLASS_PAGE_TD", "ilc_Page");
1388 
1389  // user comment
1390  if ($this->isEnabledChangeComments())
1391  {
1392  $tpl->setCurrentBlock("change_comment");
1393  $tpl->setVariable("TXT_ADD_COMMENT", $this->lng->txt("cont_add_change_comment"));
1394  $tpl->parseCurrentBlock();
1395  $tpl->setCurrentBlock("adm_content");
1396  }
1397 
1398  // explorer updater
1399  if ($this->exp_frame != "")
1400  {
1401  $tpl->setCurrentBlock("updater");
1402  $tpl->setVariable("UPDATER_FRAME", $this->exp_frame);
1403  $tpl->setVariable("EXP_ID_UPDATER", $this->exp_id);
1404  $tpl->setVariable("HREF_UPDATER", $this->exp_target_script);
1405  $tpl->parseCurrentBlock();
1406  }
1407 
1408 /* $tpl->setVariable("TXT_INSERT_BEFORE", $this->lng->txt("cont_set_before"));
1409  $tpl->setVariable("TXT_INSERT_AFTER", $this->lng->txt("cont_set_after"));
1410  $tpl->setVariable("TXT_INSERT_CANCEL", $this->lng->txt("cont_set_cancel"));
1411  $tpl->setVariable("TXT_CONFIRM_DELETE", $this->lng->txt("cont_confirm_delete"));
1412 */
1413  $tpl->setVariable("WYSIWYG_ACTION",
1414  $ilCtrl->getFormActionByClass("ilpageeditorgui", "", "", true));
1415 
1416 
1417  // determine media, html and javascript mode
1418  $sel_media_mode = ($ilUser->getPref("ilPageEditor_MediaMode") == "disable")
1419  ? "disable"
1420  : "enable";
1421  $sel_html_mode = ($ilUser->getPref("ilPageEditor_HTMLMode") == "disable")
1422  ? "disable"
1423  : "enable";
1424  $sel_js_mode = "disable";
1425  //if($ilSetting->get("enable_js_edit", 1))
1426  //{
1427  $sel_js_mode = (ilPageEditorGUI::_doJSEditing())
1428  ? "enable"
1429  : "disable";
1430  //}
1431 
1432  // show prepending html
1433  $tpl->setVariable("PREPENDING_HTML", $this->getPrependingHtml());
1434  $tpl->setVariable("TXT_CONFIRM_DELETE", $lng->txt("cont_confirm_delete"));
1435 
1436  // presentation view
1437  if ($this->getViewPageLink() != "")
1438  {
1439  $ilTabs->addNonTabbedLink("pres_view", $this->lng->txt("cont_presentation_view"),
1440  $this->getViewPageLink(), $this->getViewPageTarget());
1441  }
1442 
1443  // show actions drop down
1444  $this->addActionsMenu($tpl, $sel_media_mode, $sel_html_mode, $sel_js_mode);
1445 
1446  // get js files for JS enabled editing
1447  if ($sel_js_mode == "enable")
1448  {
1449  $this->insertHelp($tpl);
1450  include_once("./Services/YUI/classes/class.ilYuiUtil.php");
1453  ilYuiUtil::initPanel(false);
1454  $GLOBALS["tpl"]->addJavaScript("./Services/COPage/js/ilcopagecallback.js");
1455  $GLOBALS["tpl"]->addJavascript("Services/COPage/js/page_editing.js");
1456 
1457  include_once './Services/Style/classes/class.ilObjStyleSheet.php';
1458  $GLOBALS["tpl"]->addOnloadCode("var preloader = new Image();
1459  preloader.src = './templates/default/images/loader.gif';
1460  ilCOPage.setContentCss('".
1463  ", ./Services/COPage/css/tiny_extra.css".
1464  "')");
1465 
1466  $GLOBALS["tpl"]->addJavascript("Services/RTE/tiny_mce_3_3_9_2/il_tiny_mce_src.js");
1467  $tpl->touchBlock("init_dragging");
1468 
1469  $tpl->setVariable("IL_TINY_MENU",
1470  self::getTinyMenu(
1471  $this->getPageObject()->getParentType(),
1472  $this->getEnabledInternalLinks(),
1473  $this->getPageObject()->getParentType() == "wpg",
1474  $this->getEnableKeywords(), $this->getStyleId(), true, true,
1475  $this->getEnableAnchors()
1476  ));
1477 
1478  // add int link parts
1479  include_once("./Modules/LearningModule/classes/class.ilInternalLinkGUI.php");
1480  $tpl->setCurrentBlock("int_link_prep");
1481  $tpl->setVariable("INT_LINK_PREP", ilInternalLinkGUI::getInitHTML(
1482  $ilCtrl->getLinkTargetByClass(array("ilpageeditorgui", "ilinternallinkgui"),
1483  "", false, true, false)));
1484  $tpl->parseCurrentBlock();
1485 
1486  // internal links per js
1487  //$tpl->setVariable("IL_INT_LINK_URL",
1488  // $ilCtrl->getLinkTargetByClass(array("ilpageeditorgui", "ilinternallinkgui"),
1489  // "showLinkHelp", false, true, false));
1490 
1491  include_once("./Services/YUI/classes/class.ilYuiUtil.php");
1493  $GLOBALS["tpl"]->addJavaScript("./Services/Explorer/js/ilexplorercallback.js");
1494 
1495  }
1496 
1497  // multiple actions
1498  $cnt_pcs = $this->getPageObject()->countPageContents();
1499  if ($cnt_pcs > 1 ||
1500  ($this->getPageObject()->getParentType() != "qpl" && $cnt_pcs > 0))
1501  {
1502  $tpl->setCurrentBlock("multi_actions");
1503  if ($sel_js_mode == "enable")
1504  {
1505  $tpl->setVariable("ONCLICK_DE_ACTIVATE_SELECTED", 'onclick="return ilEditMultiAction(\'activateSelected\');"');
1506  $tpl->setVariable("ONCLICK_DELETE_SELECTED", 'onclick="return ilEditMultiAction(\'deleteSelected\');"');
1507  $tpl->setVariable("ONCLICK_ASSIGN_CHARACTERISTIC", 'onclick="return ilEditMultiAction(\'assignCharacteristicForm\');"');
1508  $tpl->setVariable("ONCLICK_COPY_SELECTED", 'onclick="return ilEditMultiAction(\'copySelected\');"');
1509  $tpl->setVariable("ONCLICK_CUT_SELECTED", 'onclick="return ilEditMultiAction(\'cutSelected\');"');
1510  $tpl->setVariable("TXT_SELECT_ALL", $this->lng->txt("select_all"));
1511  $tpl->setVariable("ONCLICK_SELECT_ALL", 'onclick="return ilEditMultiAction(\'selectAll\');"');
1512  }
1513  $tpl->setVariable("TXT_DE_ACTIVATE_SELECTED", $this->lng->txt("cont_ed_enable"));
1514  $tpl->setVariable("TXT_ASSIGN_CHARACTERISTIC", $this->lng->txt("cont_assign_characteristic"));
1515  $tpl->setVariable("TXT_DELETE_SELECTED", $this->lng->txt("cont_delete_selected"));
1516  $tpl->setVariable("TXT_COPY_SELECTED", $this->lng->txt("copy"));
1517  $tpl->setVariable("TXT_CUT_SELECTED", $this->lng->txt("cut"));
1518  $tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
1519  $tpl->parseCurrentBlock();
1520  }
1521  }
1522  else
1523  {
1524  if($this->getOutputSubmode() == 'translation')
1525  {
1526  $tpl = new ilTemplate("tpl.page_translation_content.html", true, true, "Services/COPage");
1527  }
1528  else
1529  {
1530  // presentation
1531  if ($this->getOutputMode() != IL_PAGE_PREVIEW)
1532  {
1533  $tpl = new ilTemplate("tpl.page_content.html", true, true, "Services/COPage");
1534  if ($this->getEnabledPageFocus())
1535  {
1536  $tpl->touchBlock("page_focus");
1537  }
1538  }
1539  else // preview
1540  {
1541  $tpl = new ilTemplate("tpl.page_preview.html", true, true, "Services/COPage");
1542  include_once("./Services/User/classes/class.ilUserUtil.php");
1543 
1544  $c_old_nr = $this->getPageObject()->old_nr;
1545  if ($c_old_nr > 0)
1546  {
1547  $hist_info =
1548  $this->getPageObject()->getHistoryInfo($c_old_nr);
1549 
1550  if (!$this->getCompareMode())
1551  {
1552  // previous revision
1553  if (is_array($hist_info["previous"]))
1554  {
1555  $tpl->setCurrentBlock("previous_rev");
1556  $tpl->setVariable("TXT_PREV_REV", $lng->txt("cont_previous_rev"));
1557  $ilCtrl->setParameter($this, "old_nr", $hist_info["previous"]["nr"]);
1558  $tpl->setVariable("HREF_PREV",
1559  $ilCtrl->getLinkTarget($this, "preview"));
1560  $tpl->parseCurrentBlock();
1561  }
1562  else
1563  {
1564  $tpl->setCurrentBlock("previous_rev_disabled");
1565  $tpl->setVariable("TXT_PREV_REV", $lng->txt("cont_previous_rev"));
1566  $tpl->parseCurrentBlock();
1567  }
1568 
1569  // next revision
1570  $tpl->setCurrentBlock("next_rev");
1571  $tpl->setVariable("TXT_NEXT_REV", $lng->txt("cont_next_rev"));
1572  $ilCtrl->setParameter($this, "old_nr", $hist_info["next"]["nr"]);
1573  $tpl->setVariable("HREF_NEXT",
1574  $ilCtrl->getLinkTarget($this, "preview"));
1575  $tpl->parseCurrentBlock();
1576 
1577  // latest revision
1578  $tpl->setCurrentBlock("latest_rev");
1579  $tpl->setVariable("TXT_LATEST_REV", $lng->txt("cont_latest_rev"));
1580  $ilCtrl->setParameter($this, "old_nr", "");
1581  $tpl->setVariable("HREF_LATEST",
1582  $ilCtrl->getLinkTarget($this, "preview"));
1583  $tpl->parseCurrentBlock();
1584 
1585  // rollback
1586  if ($c_old_nr > 0 && $ilUser->getId() != ANONYMOUS_USER_ID)
1587  {
1588  $tpl->setCurrentBlock("rollback");
1589  $ilCtrl->setParameter($this, "old_nr", $c_old_nr);
1590  $tpl->setVariable("HREF_ROLLBACK",
1591  $ilCtrl->getLinkTarget($this, "rollbackConfirmation"));
1592  $ilCtrl->setParameter($this, "old_nr", "");
1593  $tpl->setVariable("TXT_ROLLBACK",
1594  $lng->txt("cont_rollback"));
1595  $tpl->parseCurrentBlock();
1596  }
1597  }
1598 
1599  $tpl->setCurrentBlock("hist_nav");
1600  $tpl->setVariable("TXT_REVISION", $lng->txt("cont_revision"));
1601  $tpl->setVariable("VAL_REVISION_DATE",
1602  ilDatePresentation::formatDate(new ilDateTime($hist_info["current"]["hdate"], IL_CAL_DATETIME)));
1603  $tpl->setVariable("VAL_REV_USER",
1604  ilUserUtil::getNamePresentation($hist_info["current"]["user_id"]));
1605  $tpl->parseCurrentBlock();
1606  }
1607  }
1608  }
1609  }
1610  if ($this->getOutputMode() != IL_PAGE_PRESENTATION &&
1611  $this->getOutputMode() != IL_PAGE_OFFLINE &&
1612  $this->getOutputMode() != IL_PAGE_PREVIEW &&
1613  $this->getOutputMode() != IL_PAGE_PRINT)
1614  {
1615  $tpl->setVariable("FORMACTION", $this->ctrl->getFormActionByClass("ilpageeditorgui"));
1616  }
1617 
1618  // output media object edit list (of media links)
1619  if($this->getOutputMode() == "edit")
1620  {
1621  $links = ilInternalLink::_getTargetsOfSource($this->obj->getParentType().":pg",
1622  $this->obj->getId());
1623  $mob_links = array();
1624  foreach($links as $link)
1625  {
1626  if ($link["type"] == "mob")
1627  {
1628  if (ilObject::_exists($link["id"]) && ilObject::_lookupType($link["id"]) == "mob")
1629  {
1630  $mob_links[$link["id"]] = ilObject::_lookupTitle($link["id"])." [".$link["id"]."]";
1631  }
1632  }
1633  }
1634 
1635  // linked media objects
1636  if (count($mob_links) > 0)
1637  {
1638  $tpl->setCurrentBlock("med_link");
1639  $tpl->setVariable("TXT_LINKED_MOBS", $this->lng->txt("cont_linked_mobs"));
1640  $tpl->setVariable("SEL_MED_LINKS",
1641  ilUtil::formSelect(0, "mob_id", $mob_links, false, true));
1642  $tpl->setVariable("TXT_EDIT_MEDIA", $this->lng->txt("cont_edit_mob"));
1643  $tpl->setVariable("TXT_COPY_TO_CLIPBOARD", $this->lng->txt("cont_copy_to_clipboard"));
1644  //$this->tpl->setVariable("TXT_COPY_TO_POOL", $this->lng->txt("cont_copy_to_mediapool"));
1645  $tpl->parseCurrentBlock();
1646  }
1647 
1648  // content snippets used
1649  $snippets = $this->getPageObject()->collectContentIncludes();
1650  if (count($snippets) > 0)
1651  {
1652  foreach ($snippets as $s)
1653  {
1654  include_once("./Modules/MediaPool/classes/class.ilMediaPoolPage.php");
1655  $sn_arr[$s["id"]] = ilMediaPoolPage::lookupTitle($s["id"]);
1656  }
1657  $tpl->setCurrentBlock("med_link");
1658  $tpl->setVariable("TXT_CONTENT_SNIPPETS_USED", $this->lng->txt("cont_snippets_used"));
1659  $tpl->setVariable("SEL_SNIPPETS",
1660  ilUtil::formSelect(0, "ci_id", $sn_arr, false, true));
1661  $tpl->setVariable("TXT_SHOW_INFO", $this->lng->txt("cont_show_info"));
1662  $tpl->parseCurrentBlock();
1663  }
1664 
1665  // scheduled activation?
1666  if (!$this->getPageObject()->getActive() &&
1667  $this->getPageObject()->getActivationStart() != "" &&
1669  {
1670  $tpl->setCurrentBlock("activation_txt");
1671  $tpl->setVariable("TXT_SCHEDULED_ACTIVATION", $lng->txt("cont_scheduled_activation"));
1672  $tpl->setVariable("SA_FROM",
1674  new ilDateTime($this->getPageObject()->getActivationStart(),
1675  IL_CAL_DATETIME)));
1676  $tpl->setVariable("SA_TO",
1678  new ilDateTime($this->getPageObject()->getActivationEnd(),
1679  IL_CAL_DATETIME)));
1680  $tpl->parseCurrentBlock();
1681  }
1682  }
1683 
1684  if ($_GET["reloadTree"] == "y")
1685  {
1686  $tpl->setCurrentBlock("reload_tree");
1687  if ($this->obj->getParentType() == "dbk")
1688  {
1689  $tpl->setVariable("LINK_TREE",
1690  $this->ctrl->getLinkTargetByClass("ilobjdlbookgui", "explorer", "", false, false));
1691  }
1692  else
1693  {
1694  $tpl->setVariable("LINK_TREE",
1695  $this->ctrl->getLinkTargetByClass("ilobjlearningmodulegui", "explorer", "", false, false));
1696  }
1697  $tpl->parseCurrentBlock();
1698  }
1699 // }
1700  // get content
1701  $builded = $this->obj->buildDom();
1702 
1703  // manage hierarchical ids
1704  if($this->getOutputMode() == "edit")
1705  {
1706 
1707  // add pc ids, if necessary
1708  if (!$this->obj->checkPCIds())
1709  {
1710  $this->obj->insertPCIds();
1711  $this->obj->update(true, true);
1712  }
1713 
1714  $this->obj->addFileSizes();
1715  $this->obj->addHierIDs();
1716 
1717  $hids = $this->obj->getHierIds();
1718  $row1_ids = $this->obj->getFirstRowIds();
1719  $col1_ids = $this->obj->getFirstColumnIds();
1720  $litem_ids = $this->obj->getListItemIds();
1721  $fitem_ids = $this->obj->getFileItemIds();
1722 
1723  // standard menues
1724  $hids = $this->obj->getHierIds();
1725  foreach($hids as $hid)
1726  {
1727  $tpl->setCurrentBlock("add_dhtml");
1728  $tpl->setVariable("CONTEXTMENU", "contextmenu_".$hid);
1729  $tpl->parseCurrentBlock();
1730  }
1731 
1732  // column menues for tables
1733  foreach($col1_ids as $hid)
1734  {
1735  $tpl->setCurrentBlock("add_dhtml");
1736  $tpl->setVariable("CONTEXTMENU", "contextmenu_r".$hid);
1737  $tpl->parseCurrentBlock();
1738  }
1739 
1740  // row menues for tables
1741  foreach($row1_ids as $hid)
1742  {
1743  $tpl->setCurrentBlock("add_dhtml");
1744  $tpl->setVariable("CONTEXTMENU", "contextmenu_c".$hid);
1745  $tpl->parseCurrentBlock();
1746  }
1747 
1748  // list item menues
1749  foreach($litem_ids as $hid)
1750  {
1751  $tpl->setCurrentBlock("add_dhtml");
1752  $tpl->setVariable("CONTEXTMENU", "contextmenu_i".$hid);
1753  $tpl->parseCurrentBlock();
1754  }
1755 
1756  // file item menues
1757  foreach($fitem_ids as $hid)
1758  {
1759  $tpl->setCurrentBlock("add_dhtml");
1760  $tpl->setVariable("CONTEXTMENU", "contextmenu_i".$hid);
1761  $tpl->parseCurrentBlock();
1762  }
1763  }
1764  else
1765  {
1766  $this->obj->addFileSizes();
1767  }
1768 
1769 //echo "<br>-".htmlentities($this->obj->getXMLContent())."-<br><br>";
1770 //echo "<br>-".htmlentities($this->getLinkXML())."-";
1771 
1772  // set default link xml, if nothing was set yet
1773  if (!$this->link_xml_set)
1774  {
1775  $this->setDefaultLinkXml();
1776  }
1777 
1778  //$content = $this->obj->getXMLFromDom(false, true, true,
1779  // $this->getLinkXML().$this->getQuestionXML().$this->getComponentPluginsXML());
1780  $link_xml = $this->getLinkXML();
1781 
1782  // disable/enable auto margins
1783  if ($this->getStyleId() > 0)
1784  {
1785  if (ilObject::_lookupType($this->getStyleId()) == "sty")
1786  {
1787  include_once("./Services/Style/classes/class.ilObjStyleSheet.php");
1788  $style = new ilObjStyleSheet($this->getStyleId());
1789  $template_xml = $style->getTemplateXML();
1790  $disable_auto_margins = "n";
1791  if ($style->lookupStyleSetting("disable_auto_margins"))
1792  {
1793  $disable_auto_margins = "y";
1794  }
1795  }
1796  }
1797 
1798  if ($this->getAbstractOnly())
1799  {
1800  $content = "<dummy><PageObject><PageContent><Paragraph>".
1801  $this->obj->getFirstParagraphText().$link_xml.
1802  "</Paragraph></PageContent></PageObject></dummy>";
1803  }
1804  else
1805  {
1806  $content = $this->obj->getXMLFromDom(false, true, true,
1807  $link_xml.$this->getQuestionXML().$template_xml);
1808  }
1809 
1810  // check validation errors
1811  if($builded !== true)
1812  {
1813  $this->displayValidationError($builded);
1814  }
1815  else
1816  {
1817  $this->displayValidationError($_SESSION["il_pg_error"]);
1818  }
1819  unset($_SESSION["il_pg_error"]);
1820 
1821  if(isset($_SESSION["citation_error"]))
1822  {
1823  ilUtil::sendFailure($this->lng->txt("cont_citation_selection_not_valid"));
1824  session_unregister("citation_error");
1825  unset($_SESSION["citation_error"]);
1826  }
1827 
1828  // get title
1829  $pg_title = $this->getPresentationTitle();
1830 
1831  $add_path = ilUtil::getImagePath("add.gif");
1832  $col_path = ilUtil::getImagePath("col.gif");
1833  $row_path = ilUtil::getImagePath("row.gif");
1834  $item_path = ilUtil::getImagePath("item.gif");
1835  $med_disabled_path = ilUtil::getImagePath("media_disabled.gif");
1836 
1837  if ($this->getOutputMode() != "offline")
1838  {
1839  $enlarge_path = ilUtil::getImagePath("enlarge.gif");
1840  $wb_path = ilUtil::getWebspaceDir("output")."/";
1841  }
1842  else
1843  {
1844  $enlarge_path = "images/enlarge.gif";
1845  $wb_path = "";
1846  }
1847  $pg_title_class = ($this->getOutputMode() == "print")
1848  ? "ilc_PrintPageTitle"
1849  : "";
1850 
1851  // page splitting only for learning modules and
1852  // digital books
1853  $enable_split_new = ($this->obj->getParentType() == "lm" ||
1854  $this->obj->getParentType() == "dbk")
1855  ? "y"
1856  : "n";
1857 
1858  // page splitting to next page only for learning modules and
1859  // digital books if next page exists in tree
1860  if (($this->obj->getParentType() == "lm" ||
1861  $this->obj->getParentType() == "dbk") &&
1862  ilObjContentObject::hasSuccessorPage($this->obj->getParentId(),
1863  $this->obj->getId()))
1864  {
1865  $enable_split_next = "y";
1866  }
1867  else
1868  {
1869  $enable_split_next = "n";
1870  }
1871 
1872 
1873  $paragraph_plugins = new ilParagraphPlugins();
1874  $paragraph_plugins->initialize ();
1875 
1876  if ($this->getOutputMode() == IL_PAGE_PRESENTATION)
1877  {
1878  $paragraph_plugin_string = $paragraph_plugins->serializeToString();
1879  $_SESSION ["paragraph_plugins"] = $paragraph_plugins;
1880  }
1881 
1882  $img_path = ilUtil::getImagePath("", false, $this->getOutputMode(), $this->getOutputMode() == "offline");
1883 
1884  //$wb_path = "../".$this->ilias->ini->readVariable("server","webspace_dir");
1885  //echo "-".$this->sourcecode_download_script.":";
1886 
1887  if ($this->getEnabledPCTabs())
1888  {
1889  //include_once("./Services/YUI/classes/class.ilYuiUtil.php");
1890  //ilYuiUtil::initTabView();
1891  include_once("./Services/Accordion/classes/class.ilAccordionGUI.php");
1894  }
1895 
1896  $file_download_link = $this->determineFileDownloadLink();
1897  $fullscreen_link = $this->determineFullscreenLink();
1898  $this->sourcecode_download_script = $this->determineSourcecodeDownloadScript();
1899 
1900  // default values for various parameters (should be used by
1901  // all instances in the future)
1902  $media_mode = ($this->getOutputMode() == "edit")
1903  ? $ilUser->getPref("ilPageEditor_MediaMode")
1904  : "enable";
1905 
1906  include_once("./Modules/LearningModule/classes/class.ilEditClipboard.php");
1907  $paste = (ilEditClipboard::getAction() == "copy" &&
1908  $this->getOutputMode() == "edit");
1909 
1910  // added UTF-8 encoding otherwise umlaute are converted too
1911  $params = array ('mode' => $this->getOutputMode(), 'pg_title' => htmlentities($pg_title,ENT_QUOTES,"UTF-8"),
1912  'layout_mode' => $this->getLayoutMode() ? "y" : "n",
1913  'pg_id' => $this->obj->getId(), 'pg_title_class' => $pg_title_class,
1914  'webspace_path' => $wb_path, 'enlarge_path' => $enlarge_path,
1915  'img_add' => $add_path,
1916  'img_col' => $col_path,
1917  'img_row' => $row_path,
1918  'img_item' => $item_path,
1919  'enable_split_new' => $enable_split_new,
1920  'enable_split_next' => $enable_split_next,
1921  'link_params' => $this->link_params,
1922  'file_download_link' => $file_download_link,
1923  'fullscreen_link' => $fullscreen_link,
1924  'med_disabled_path' => $med_disabled_path,
1925  'img_path' => $img_path,
1926  'parent_id' => $this->obj->getParentId(),
1927  'download_script' => $this->sourcecode_download_script,
1928  'encoded_download_script' => urlencode($this->sourcecode_download_script),
1929  // digilib
1930  'bib_id' => $this->getBibId(),'citation' => (int) $this->isEnabledCitation(),
1931  'pagebreak' => $this->lng->txt('dgl_pagebreak'),
1932  'page' => $this->lng->txt('page'),
1933  'citate_page' => $this->lng->txt('citate_page'),
1934  'citate_from' => $this->lng->txt('citate_from'),
1935  'citate_to' => $this->lng->txt('citate_to'),
1936  'citate' => $this->lng->txt('citate'),
1937  'enable_rep_objects' => $this->getEnabledRepositoryObjects() ? "y" : "n",
1938  'enable_login_page' => $this->getEnabledLoginPage() ? "y" : "n",
1939  'enable_map' => $this->getEnabledMaps() ? "y" : "n",
1940  'enable_tabs' => $this->getEnabledPCTabs() ? "y" : "n",
1941  'enable_sa_qst' => $this->getEnabledSelfAssessment() ? "y" : "n",
1942  'enable_file_list' => $this->getEnabledFileLists() ? "y" : "n",
1943  'enable_content_includes' => $this->isEnabledContentIncludes() ? "y" : "n",
1944  'paste' => $paste ? "y" : "n",
1945  'media_mode' => $media_mode,
1946  'javascript' => $sel_js_mode,
1947  'paragraph_plugins' => $paragraph_plugin_string,
1948  'disable_auto_margins' => $disable_auto_margins,
1949  'page_toc' => $this->getPageToc() ? "y" : "n",
1950  'enable_profile' => $this->getEnabledProfile() ? "y" : "n",
1951  'enable_verification' => $this->getEnabledVerification() ? "y" : "n",
1952  'enable_blog' => $this->getEnabledBlog() ? "y" : "n",
1953  'enable_skills' => $this->getEnabledSkills() ? "y" : "n",
1954  'enable_qover' => $this->getEnablePCType("QuestionOverview") ? "y" : "n"
1955  );
1956  if($this->link_frame != "") // todo other link types
1957  $params["pg_frame"] = $this->link_frame;
1958 
1959  //$content = str_replace("&nbsp;", "", $content);
1960 
1961  // this ensures that cache is emptied with every update
1962  $params["version"] = ILIAS_VERSION;
1963 
1964  // ensure no cache hit, if included files/media objects have been changed
1965  $params["incl_elements_date"] = $this->obj->getLastUpdateOfIncludedElements();
1966 
1967  // run xslt
1968  $md5 = md5(serialize($params).$link_xml.$template_xml);
1969 
1970 //$a = microtime();
1971 
1972  // check cache (same parameters, non-edit mode and rendered time
1973  // > last change
1974  if (($this->getOutputMode() == "preview" || $this->getOutputMode() == "presentation") &&
1975  !$this->getAbstractOnly() &&
1976  $md5 == $this->obj->getRenderMd5() &&
1977  ($this->obj->getLastChange() < $this->obj->getRenderedTime()) &&
1978  $this->obj->getRenderedTime() != "" &&
1979  $this->obj->old_nr == 0)
1980  {
1981  // cache hit
1982  $output = $this->obj->getRenderedContent();
1983  }
1984  else
1985  {
1986  if ($this->getLayoutMode() == true)
1987  {
1988 // $xsl = file_get_contents("./Services/COPage/xsl/page_layout.xsl");
1989  $xsl = file_get_contents("./Services/COPage/xsl/page.xsl");
1990  }
1991  else
1992  {
1993  $xsl = file_get_contents("./Services/COPage/xsl/page.xsl");
1994  }
1995 //echo htmlentities($content); exit;
1996  $args = array( '/_xml' => $content, '/_xsl' => $xsl );
1997  $xh = xslt_create();
1998  // echo "<b>XSLT</b>:".htmlentities($xsl).":<br>";
1999  // echo "mode:".$this->getOutputMode().":<br>";
2000  $output = xslt_process($xh, "arg:/_xml","arg:/_xsl", NULL, $args, $params);
2001 
2002  if (($this->getOutputMode() == "presentation" || $this->getOutputMode() == "preview")
2003  && !$this->getAbstractOnly()
2004  && $this->obj->old_nr == 0)
2005  {
2006 //echo "writerenderedcontent";
2007  $this->obj->writeRenderedContent($output, $md5);
2008  }
2009  //echo xslt_error($xh);
2010  xslt_free($xh);
2011  }
2012 
2013 //$b = microtime();
2014 //echo "$a - $b";
2015 //echo "<pre>".htmlentities($output)."</pre>";
2016 
2017  // unmask user html
2018  if (($this->getOutputMode() != "edit" ||
2019  $ilUser->getPref("ilPageEditor_HTMLMode") != "disable")
2020  && !$this->getPreventHTMLUnmasking())
2021  {
2022  $output = str_replace("&lt;","<",$output);
2023  $output = str_replace("&gt;",">",$output);
2024  }
2025  $output = str_replace("&amp;", "&", $output);
2026 
2027  // replace latex code: todo: finish
2028  if ($this->getOutputMode() != "offline")
2029  {
2030  $output = ilUtil::insertLatexImages($output);
2031  }
2032  else
2033  {
2034  $output = ilUtil::buildLatexImages($output,
2035  $this->getOfflineDirectory());
2036  }
2037 
2038  // insert page snippets
2039  $output = $this->insertContentIncludes($output);
2040 
2041  // insert page toc
2042  if ($this->getPageToc())
2043  {
2044  $output = $this->insertPageToc($output);
2045  }
2046 
2047  // workaround for preventing template engine
2048  // from hiding paragraph text that is enclosed
2049  // in curly brackets (e.g. "{a}", see ilLMEditorGUI::executeCommand())
2050  $output = $this->replaceCurlyBrackets($output);
2051 
2052  // remove all newlines (important for code / pre output)
2053  $output = str_replace("\n", "", $output);
2054 
2055  // add question HTML (always after the cache!)
2056  $qhtml = $this->getQuestionHTML();
2057  if (is_array($qhtml))
2058  {
2059  foreach ($qhtml as $k => $h)
2060  {
2061  $output = str_replace($this->pl_start."Question;il__qst_$k".$this->pl_end, " ".$h, $output);
2062  }
2063  }
2064 
2065 //echo htmlentities($output);
2066  $output = $this->postOutputProcessing($output);
2067 //echo htmlentities($output);
2068  if($this->getOutputMode() == "edit" && !$this->getPageObject()->getActive($this->getEnabledScheduledActivation()))
2069  {
2070  $output = '<div class="il_editarea_disabled">'.$output.'</div>';
2071  }
2072 
2073  $output = $this->insertMaps($output);
2074  $output = $this->obj->insertSourceCodeParagraphs($output, $this->getOutputMode());
2075 
2076  $ilBench->stop("ContentPresentation", "ilPageObjectGUI_showPage");
2077 
2078  $output = $this->selfAssessmentRendering($output);
2079 
2080  // output
2081  if ($ilCtrl->isAsynch() && !$this->getRawPageContent() &&
2082  $this->getOutputMode() == "edit")
2083  {
2084  if ($_GET["updated_pc_id_str"] != "")
2085  {
2086  echo $_GET["updated_pc_id_str"];
2087  }
2088  $tpl->setVariable($this->getTemplateOutputVar(), $output);
2089  $tpl->setCurrentBlock("edit_page");
2090  $tpl->parseCurrentBlock();
2091  echo $tpl->get("edit_page");
2092  exit;
2093  }
2094  if ($this->outputToTemplate())
2095  {
2096  $tpl->setVariable($this->getTemplateOutputVar(), $output);
2097  $this->tpl->setVariable($this->getTemplateTargetVar(), $tpl->get());
2098  return $output;
2099  }
2100  else
2101  {
2102  if ($this->getRawPageContent()) // e.g. needed in glossaries
2103  {
2104  return $output;
2105  }
2106  else
2107  {
2108  $tpl->setVariable($this->getTemplateOutputVar(), $output);
2109  return $tpl->get();
2110  }
2111  }
2112  }
2113 
2120  function replaceCurlyBrackets($output)
2121  {
2122 //echo "<br><br>".htmlentities($output);
2123 
2124  while (is_int($start = strpos($output, "<!--ParStart-->")) &&
2125  is_int($end = strpos($output, "<!--ParEnd-->", $start)))
2126  {
2127  $output = substr($output, 0, $start).
2128  str_replace(array("{","}"), array("&#123;","&#125;"),
2129  substr($output, $start + 15, $end - ($start + 15))).
2130  substr($output, $end + 13);
2131  }
2132 
2133 // $output = str_replace("{", "&#123;", $output);
2134 // $output = str_replace("}", "&#125;", $output);
2135 //echo "<br><br>".htmlentities($output);
2136  return $output;
2137  }
2138 
2142  protected function getActivationCaptions()
2143  {
2144  global $lng;
2145 
2146  return array("deactivatePage" => $lng->txt("cont_deactivate_page"),
2147  "activatePage" => $lng->txt("cont_activate_page"));
2148  }
2149 
2153  function addActionsMenu($a_tpl, $sel_media_mode, $sel_html_mode, $sel_js_mode)
2154  {
2155  global $lng, $ilCtrl;
2156 
2157  // actions
2158  include_once("./Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php");
2159 
2160  // activate/deactivate
2161  if ($this->getEnabledActivation())
2162  {
2163  $list = new ilAdvancedSelectionListGUI();
2164  $list->setListTitle($lng->txt("actions"));
2165  $list->setId("copage_act");
2166 
2167  $captions = $this->getActivationCaptions();
2168  if ($this->getPageObject()->getActive())
2169  {
2170  $list->addItem($captions["deactivatePage"], "",
2171  $ilCtrl->getLinkTarget($this, "deactivatePage"));
2172  }
2173  else
2174  {
2175  $list->addItem($captions["activatePage"], "",
2176  $ilCtrl->getLinkTarget($this, "activatePage"));
2177  }
2178 
2179  $a_tpl->setVariable("PAGE_ACTIONS", $list->getHTML());
2180  }
2181 
2182  $lng->loadLanguageModule("content");
2183  $list = new ilAdvancedSelectionListGUI();
2184  $list->setListTitle($lng->txt("cont_edit_mode"));
2185  $list->setId("copage_ed_mode");
2186 
2187  // media mode
2188  if ($sel_media_mode == "enable")
2189  {
2190  $ilCtrl->setParameter($this, "media_mode", "disable");
2191  $list->addItem($lng->txt("cont_deactivate_media"), "",
2192  $ilCtrl->getLinkTarget($this, "setEditMode"));
2193  }
2194  else
2195  {
2196  $ilCtrl->setParameter($this, "media_mode", "enable");
2197  $list->addItem($lng->txt("cont_activate_media"), "",
2198  $ilCtrl->getLinkTarget($this, "setEditMode"));
2199  }
2200  $ilCtrl->setParameter($this, "media_mode", "");
2201 
2202  // html mode
2203  if (!$this->getPreventHTMLUnmasking())
2204  {
2205  if ($sel_html_mode == "enable")
2206  {
2207  $ilCtrl->setParameter($this, "html_mode", "disable");
2208  $list->addItem($lng->txt("cont_deactivate_html"), "",
2209  $ilCtrl->getLinkTarget($this, "setEditMode"));
2210  }
2211  else
2212  {
2213  $ilCtrl->setParameter($this, "html_mode", "enable");
2214  $list->addItem($lng->txt("cont_activate_html"), "",
2215  $ilCtrl->getLinkTarget($this, "setEditMode"));
2216  }
2217  }
2218  $ilCtrl->setParameter($this, "html_mode", "");
2219 
2220  // js mode
2221  if ($sel_js_mode == "enable")
2222  {
2223  $ilCtrl->setParameter($this, "js_mode", "disable");
2224  $list->addItem($lng->txt("cont_deactivate_js"), "",
2225  $ilCtrl->getLinkTarget($this, "setEditMode"));
2226  }
2227  else
2228  {
2229  $ilCtrl->setParameter($this, "js_mode", "enable");
2230  $list->addItem($lng->txt("cont_activate_js"), "",
2231  $ilCtrl->getLinkTarget($this, "setEditMode"));
2232  }
2233  $ilCtrl->setParameter($this, "js_mode", "");
2234 
2235  $a_tpl->setVariable("EDIT_MODE", $list->getHTML());
2236  }
2237 
2241  function setEditMode()
2242  {
2243  global $ilCtrl, $ilUser;
2244 
2245  if ($_GET["media_mode"] != "")
2246  {
2247  if ($_GET["media_mode"] == "disable")
2248  {
2249  $ilUser->writePref("ilPageEditor_MediaMode", "disable");
2250  }
2251  else
2252  {
2253  $ilUser->writePref("ilPageEditor_MediaMode", "");
2254  }
2255  }
2256  if ($_GET["html_mode"] != "")
2257  {
2258  if ($_GET["html_mode"] == "disable")
2259  {
2260  $ilUser->writePref("ilPageEditor_HTMLMode", "disable");
2261  }
2262  else
2263  {
2264  $ilUser->writePref("ilPageEditor_HTMLMode", "");
2265  }
2266  }
2267  if ($_GET["js_mode"] != "")
2268  {
2269  if ($_GET["js_mode"] == "disable")
2270  {
2271  $ilUser->writePref("ilPageEditor_JavaScript", "disable");
2272  }
2273  else
2274  {
2275  $ilUser->writePref("ilPageEditor_JavaScript", "");
2276  }
2277  }
2278 
2279  $ilCtrl->redirect($this, "edit");
2280  }
2281 
2282 
2286  static function getTinyMenu($a_par_type,
2287  $a_int_links = false, $a_wiki_links = false, $a_keywords = false,
2288  $a_style_id = 0, $a_paragraph_styles = true, $a_save_return = true,
2289  $a_anchors = false)
2290  {
2291  global $lng;
2292 
2293  $jsMathSetting = new ilSetting("jsMath");
2294 
2295  include_once("./Services/COPage/classes/class.ilPageEditorSettings.php");
2296 
2297  include_once("./Services/UIComponent/Tooltip/classes/class.ilTooltipGUI.php");
2298 
2299  $btpl = new ilTemplate("tpl.tiny_menu.html", true, true, "Services/COPage");
2300 
2301  // debug ghost element
2302  if (DEVMODE == 1)
2303  {
2304  $btpl->touchBlock("debug_ghost");
2305  }
2306 
2307  // paste from word
2308  $btpl->setCurrentBlock("pword_button");
2309  $btpl->setVariable("IMG_PWORD", ilUtil::img(ilUtil::getImagePath("tn_pword.gif"),
2310  "", 20, 20));
2311  $btpl->parseCurrentBlock();
2312  ilTooltipGUI::addTooltip("il_edm_pword",
2313  $lng->txt("cont_pword"),
2314  "iltinymenu_bd");
2315 
2316  // bullet list
2317  $btpl->setCurrentBlock("blist_button");
2318  $btpl->setVariable("IMG_BLIST", ilUtil::img(ilUtil::getImagePath("tn_blist.gif"),
2319  "", 20, 20));
2320  $btpl->parseCurrentBlock();
2321  ilTooltipGUI::addTooltip("il_edm_blist",
2322  $lng->txt("cont_blist"),
2323  "iltinymenu_bd");
2324 
2325  // numbered list
2326  $btpl->setCurrentBlock("nlist_button");
2327  $btpl->setVariable("IMG_NLIST", ilUtil::img(ilUtil::getImagePath("tn_nlist.gif"),
2328  "", 20, 20));
2329  $btpl->parseCurrentBlock();
2330  ilTooltipGUI::addTooltip("il_edm_nlist",
2331  $lng->txt("cont_nlist"),
2332  "iltinymenu_bd");
2333 
2334  // list indent
2335  $btpl->setCurrentBlock("list_indent");
2336  $btpl->setVariable("IMG_LIST_INDENT", ilUtil::img(ilUtil::getImagePath("tn_indent.gif"),
2337  "", 20, 20));
2338  $btpl->parseCurrentBlock();
2339  ilTooltipGUI::addTooltip("ilIndentBut",
2340  $lng->txt("cont_list_indent"),
2341  "iltinymenu_bd");
2342 
2343 
2344  // list outdent
2345  $btpl->setCurrentBlock("list_outdent");
2346  $btpl->setVariable("IMG_LIST_OUTDENT", ilUtil::img(ilUtil::getImagePath("tn_outdent.gif"),
2347  "", 20, 20));
2348  $btpl->parseCurrentBlock();
2349  ilTooltipGUI::addTooltip("ilOutdentBut",
2350  $lng->txt("cont_list_outdent"),
2351  "iltinymenu_bd");
2352 
2353  if ($a_int_links)
2354  {
2355  $btpl->touchBlock("bb_ilink_button");
2356  ilTooltipGUI::addTooltip("iosEditInternalLinkTrigger", $lng->txt("cont_link_to_internal"),
2357  "iltinymenu_bd");
2358  }
2359  ilTooltipGUI::addTooltip("il_edm_xlink", $lng->txt("cont_link_to_external"),
2360  "iltinymenu_bd");
2361 
2362  // remove format
2363  $btpl->setCurrentBlock("rformat_button");
2364  $btpl->setVariable("IMG_RFORMAT", ilUtil::img(ilUtil::getImagePath("tn_rformat.gif"),
2365  "", 20, 20));
2366  $btpl->parseCurrentBlock();
2367  ilTooltipGUI::addTooltip("il_edm_rformat", $lng->txt("cont_remove_format"),
2368  "iltinymenu_bd");
2369 
2370  if ($a_paragraph_styles)
2371  {
2372  // new paragraph
2373  $btpl->setCurrentBlock("new_par");
2374  $btpl->setVariable("IMG_NEWPAR", "+");
2375  $btpl->parseCurrentBlock();
2376  ilTooltipGUI::addTooltip("il_edm_newpar", $lng->txt("cont_insert_new_paragraph"),
2377  "iltinymenu_bd");
2378 
2379  $btpl->setCurrentBlock("par_edit");
2380  $btpl->setVariable("TXT_PAR_FORMAT", $lng->txt("cont_par_format"));
2381  include_once("./Services/COPage/classes/class.ilPCParagraphGUI.php");
2382  $btpl->setVariable("STYLE_SELECTOR", ilPCParagraphGUI::getStyleSelector($a_selected,
2383  ilPCParagraphGUI::_getCharacteristics($a_style_id), true));
2384 
2385  ilTooltipGUI::addTooltip("ilAdvSelListAnchorText_style_selection",
2386  $lng->txt("cont_paragraph_styles"), "iltinymenu_bd");
2387 
2388  $btpl->parseCurrentBlock();
2389  }
2390 
2391  if ($a_keywords)
2392  {
2393  $btpl->setCurrentBlock("bb_kw_button");
2394  $btpl->setVariable("CC_KW", "kw");
2395  $btpl->parseCurrentBlock();
2396  ilTooltipGUI::addTooltip("il_edm_kw", $lng->txt("cont_text_keyword"),
2397  "iltinymenu_bd");
2398 
2399  }
2400 
2401  if ($a_wiki_links)
2402  {
2403  $btpl->setCurrentBlock("bb_wikilink_button");
2404  $btpl->setVariable("TXT_WLN2", $lng->txt("obj_wiki"));
2405  $btpl->parseCurrentBlock();
2406  ilTooltipGUI::addTooltip("il_edm_wlink", $lng->txt("cont_link_to_wiki"),
2407  "iltinymenu_bd");
2408  }
2409 // $jsMathSetting = new ilSetting("jsMath");
2410 // $style = $this->getStyle();
2411 
2412  $aset = new ilSetting("adve");
2413 
2414  include_once("./Services/COPage/classes/class.ilPageContentGUI.php");
2415  foreach (ilPageContentGUI::_getCommonBBButtons() as $c => $st)
2416  {
2417  // these are handled via drop down now...
2418  if (in_array($c, array("com", "quot", "acc", "code")))
2419  {
2420  continue;
2421  }
2423  $a_par_type, "active_".$c, true))
2424  {
2425  $cc_code = $c;
2426  if ($aset->get("use_physical"))
2427  {
2428  $cc_code = str_replace(array("str", "emp", "imp"), array("B", "I", "U"), $cc_code);
2429  }
2430 
2431  if ($c != "tex" || $jsMathSetting->get("enable") || defined("URL_TO_LATEX"))
2432  {
2433  $btpl->setCurrentBlock("bb_".$c."_button");
2434  $btpl->setVariable("CC_".strtoupper($c), $cc_code);
2435  $btpl->parseCurrentBlock();
2436  ilTooltipGUI::addTooltip("il_edm_cc_".$c,
2437  $lng->txt("cont_cc_".$c),
2438  "iltinymenu_bd");
2439 
2440 // $btpl->setVariable("TXT_".strtoupper($c), $this->lng->txt("cont_text_".$c));
2441  }
2442  }
2443  }
2444 
2445  if ($jsMathSetting->get("enable") || defined("URL_TO_LATEX"))
2446  {
2447  ilTooltipGUI::addTooltip("il_edm_tex", $lng->txt("cont_tex"),
2448  "iltinymenu_bd");
2449  }
2450  ilTooltipGUI::addTooltip("il_edm_fn", $lng->txt("cont_fn"),
2451  "iltinymenu_bd");
2452 
2453  if ($a_save_return)
2454  {
2455  $btpl->setCurrentBlock("save_return");
2456  $btpl->setVariable("TXT_SAVE_RETURN", $lng->txt("save_return"));
2457  $btpl->parseCurrentBlock();
2458  }
2459 
2460  if ($a_anchors)
2461  {
2462  $btpl->setCurrentBlock("bb_anc_button");
2463  $btpl->setVariable("CC_ANC", "anc");
2464  $btpl->parseCurrentBlock();
2465  ilTooltipGUI::addTooltip("il_edm_anc", $lng->txt("cont_anchor"),
2466  "iltinymenu_bd");
2467  }
2468 
2469 /* // footnote
2470  $btpl->setVariable("TXT_ILN", $this->lng->txt("cont_text_iln"));
2471  $btpl->setVariable("TXT_BB_TIP", $this->lng->txt("cont_bb_tip"));
2472  $btpl->setVariable("TXT_WLN", $lng->txt("wiki_wiki_page"));
2473 */
2474 // $btpl->setVariable("PAR_TA_NAME", $a_ta_name);
2475 
2476  $btpl->setVariable("TXT_SAVE", $lng->txt("save"));
2477  $btpl->setVariable("TXT_CANCEL", $lng->txt("cancel"));
2478 
2479  $btpl->setVariable("TXT_CHAR_FORMAT", $lng->txt("cont_char_format"));
2480  $btpl->setVariable("TXT_LISTS", $lng->txt("cont_lists"));
2481  $btpl->setVariable("TXT_LINKS", $lng->txt("cont_links"));
2482  $btpl->setVariable("TXT_MORE_FUNCTIONS", $lng->txt("cont_more_functions"));
2483  $btpl->setVariable("TXT_SAVING", $lng->txt("cont_saving"));
2484 
2485  include_once("./Services/COPage/classes/class.ilPCParagraphGUI.php");
2486  $btpl->setVariable("CHAR_STYLE_SELECTOR", ilPCParagraphGUI::getCharStyleSelector($a_par_type));
2487  ilTooltipGUI::addTooltip("ilAdvSelListAnchorElement_char_style_selection",
2488  $lng->txt("cont_more_character_styles"), "iltinymenu_bd");
2489 
2490  return $btpl->get();
2491  }
2492 
2497  {
2498  global $ilCtrl;
2499 
2500  $int_links = $this->getPageObject()->getInternalLinks();
2501 //var_dump($int_links);
2502  $link_info = "<IntLinkInfos>";
2503  $targetframe = "None";
2504  foreach ($int_links as $int_link)
2505  {
2506  $target = $int_link["Target"];
2507  if (substr($target, 0, 4) == "il__")
2508  {
2509  $target_arr = explode("_", $target);
2510  $target_id = $target_arr[count($target_arr) - 1];
2511  $type = $int_link["Type"];
2512 
2513  $targetframe = ($int_link["TargetFrame"] != "")
2514  ? $int_link["TargetFrame"]
2515  : "None";
2516 
2517  $ltarget="_top";
2518  if ($targetframe != "None")
2519  {
2520  $ltarget="_blank";
2521  }
2522 
2523  // anchor
2524  $anc = $anc_add = "";
2525  if ($int_link["Anchor"] != "")
2526  {
2527  $anc = $int_link["Anchor"];
2528  $anc_add = "_".rawurlencode($int_link["Anchor"]);
2529  }
2530 
2531  $href = "";
2532  switch($type)
2533  {
2534  case "PageObject":
2535  case "StructureObject":
2537  if ($type == "PageObject")
2538  {
2539  $href = "./goto.php?target=pg_".$target_id.$anc_add;
2540  }
2541  else
2542  {
2543  $href = "./goto.php?target=st_".$target_id;
2544  }
2545  break;
2546 
2547  case "GlossaryItem":
2548  if ($targetframe == "None")
2549  {
2550  $targetframe = "Glossary";
2551  }
2552  $href = "./goto.php?target=git_".$target_id;
2553  break;
2554 
2555  case "MediaObject":
2556  $ilCtrl->setParameter($this, "mob_id", $target_id);
2557  //$ilCtrl->setParameter($this, "pg_id", $this->obj->getId());
2558  $href = $ilCtrl->getLinkTarget($this, "displayMedia");
2559  $ilCtrl->setParameter($this, "mob_id", "");
2560  break;
2561 
2562  case "RepositoryItem":
2563  $obj_type = ilObject::_lookupType($target_id, true);
2565  $href = "./goto.php?target=".$obj_type."_".$target_id;
2566  break;
2567 
2568 
2569  }
2570  $anc_par = 'Anchor="'.$anc.'"';
2571  $link_info.="<IntLinkInfo Target=\"$target\" Type=\"$type\" ".$anc_par." ".
2572  "TargetFrame=\"$targetframe\" LinkHref=\"$href\" LinkTarget=\"$ltarget\" />";
2573  }
2574  }
2575  $link_info.= "</IntLinkInfos>";
2576  $this->setLinkXML($link_info);
2577  }
2578 
2582  function downloadFile()
2583  {
2584  $this->obj->buildDom();
2585  $files = $this->obj->collectFileItems();
2586 
2587  $file = explode("_", $_GET["file_id"]);
2588  require_once("./Modules/File/classes/class.ilObjFile.php");
2589  $file_id = $file[count($file) - 1];
2590 
2591  // file must be in page
2592  if (!in_array($file_id, $files))
2593  {
2594  exit;
2595  }
2596  $fileObj =& new ilObjFile($file_id, false);
2597  $fileObj->sendFile();
2598  exit;
2599  }
2600 
2605  {
2606  $this->displayMedia(true);
2607  }
2608 
2612  function displayMedia($a_fullscreen = false)
2613  {
2614  $tpl = new ilTemplate("tpl.fullscreen.html", true, true, "Modules/LearningModule");
2615  $tpl->setCurrentBlock("ilMedia");
2616 
2617  //$int_links = $page_object->getInternalLinks();
2618  $med_links = ilMediaItem::_getMapAreasIntLinks($_GET["mob_id"]);
2619 
2620  // @todo
2621  //$link_xml = $this->getLinkXML($med_links, $this->getLayoutLinkTargets());
2622 
2623  require_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
2624  $media_obj = new ilObjMediaObject($_GET["mob_id"]);
2625  require_once("./Services/COPage/classes/class.ilPageObject.php");
2626  $pg_obj = $this->getPageObject();
2627  $pg_obj->buildDom();
2628 
2629  if (!empty ($_GET["pg_id"]))
2630  {
2631  $xml = "<dummy>";
2632  $xml.= $pg_obj->getMediaAliasElement($_GET["mob_id"]);
2633  $xml.= $media_obj->getXML(IL_MODE_OUTPUT);
2634  $xml.= $link_xml;
2635  $xml.="</dummy>";
2636  }
2637  else
2638  {
2639  $xml = "<dummy>";
2640  $xml.= $media_obj->getXML(IL_MODE_ALIAS);
2641  $xml.= $media_obj->getXML(IL_MODE_OUTPUT);
2642  $xml.= $link_xml;
2643  $xml.="</dummy>";
2644  }
2645 
2646  $xsl = file_get_contents("./Services/COPage/xsl/page.xsl");
2647  $args = array( '/_xml' => $xml, '/_xsl' => $xsl );
2648  $xh = xslt_create();
2649 
2650  $mode = "media";
2651  if ($a_fullscreen)
2652  {
2653  $mode = "fullscreen";
2654  }
2655 
2656 //echo "<b>XML:</b>".htmlentities($xml);
2657  // determine target frames for internal links
2658  $wb_path = ilUtil::getWebspaceDir("output")."/";
2659  $enlarge_path = ilUtil::getImagePath("enlarge.gif");
2660  $params = array ('mode' => $mode, 'enlarge_path' => $enlarge_path,
2661  'link_params' => "ref_id=".$_GET["ref_id"],'fullscreen_link' => "",
2662  'ref_id' => $_GET["ref_id"], 'webspace_path' => $wb_path);
2663  $output = xslt_process($xh,"arg:/_xml","arg:/_xsl",NULL,$args, $params);
2664 //echo "<br><br>".htmlentities($output);
2665  //echo xslt_error($xh);
2666  xslt_free($xh);
2667 
2668  // unmask user html
2669  $tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
2671  $tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
2672  $tpl->setVariable("MEDIA_CONTENT", $output);
2673  echo $tpl->get();
2674  exit;
2675  }
2676 
2681  {
2682  $pg_obj = $this->getPageObject();
2683  $pg_obj->send_paragraph($_GET["par_id"], $_GET["downloadtitle"]);
2684  }
2685 
2689  function insertMaps($a_html)
2690  {
2691  $c_pos = 0;
2692  $start = strpos($a_html, "[[[[[Map;");
2693  if (is_int($start))
2694  {
2695  $end = strpos($a_html, "]]]]]", $start);
2696  }
2697  $i = 1;
2698  while ($end > 0)
2699  {
2700  $param = substr($a_html, $start + 9, $end - $start - 9);
2701 
2702  $param = explode(";", $param);
2703  if (is_numeric($param[0]) && is_numeric($param[1]) && is_numeric($param[2]))
2704  {
2705  include_once("./Services/GoogleMaps/classes/class.ilGoogleMapGUI.php");
2706  $map_gui = new ilGoogleMapGUI();
2707  $map_gui->setMapId("map_".$i);
2708  $map_gui->setLatitude($param[0]);
2709  $map_gui->setLongitude($param[1]);
2710  $map_gui->setZoom($param[2]);
2711  $map_gui->setWidth($param[3]."px");
2712  $map_gui->setHeight($param[4]."px");
2713  $map_gui->setEnableTypeControl(true);
2714  $map_gui->setEnableNavigationControl(true);
2715  $map_gui->setEnableCentralMarker(true);
2716  $h2 = substr($a_html, 0, $start).
2717  $map_gui->getHtml().
2718  substr($a_html, $end + 5);
2719  $a_html = $h2;
2720  $i++;
2721  }
2722  $start = strpos($a_html, "[[[[[Map;", $start + 5);
2723  $end = 0;
2724  if (is_int($start))
2725  {
2726  $end = strpos($a_html, "]]]]]", $start);
2727  }
2728  }
2729 
2730  return $a_html;
2731  }
2732 
2736  function insertContentIncludes($a_html)
2737  {
2738  global $ilCtrl, $lng;
2739 
2740  $c_pos = 0;
2741  $start = strpos($a_html, "{{{{{ContentInclude;");
2742  if (is_int($start))
2743  {
2744  $end = strpos($a_html, "}}}}}", $start);
2745  }
2746  $i = 1;
2747  while ($end > 0)
2748  {
2749  $param = substr($a_html, $start + 20, $end - $start - 20);
2750  $param = explode(";", $param);
2751 
2752  if ($param[0] == "mep" && is_numeric($param[1]) && $param[2] <= 0)
2753  {
2754  include_once("./Modules/MediaPool/classes/class.ilMediaPoolPageGUI.php");
2755 
2756  if (ilMediaPoolPage::_exists($param[1]))
2757  {
2758  $page_gui = new ilMediaPoolPageGUI($param[1], 0, true);
2759  if ($this->getOutputMode() != "offline")
2760  {
2761  $page_gui->setFileDownloadLink($this->determineFileDownloadLink());
2762  $page_gui->setFullscreenLink($this->determineFullscreenLink());
2763  $page_gui->setSourceCodeDownloadScript($this->determineSourcecodeDownloadScript());
2764  }
2765  else
2766  {
2767  $page_gui->setOutputMode(IL_PAGE_OFFLINE);
2768  }
2769 
2770  $html = $page_gui->getRawContent();
2771  }
2772  else
2773  {
2774  if ($this->getOutputMode() == "edit")
2775  {
2776  $html = "// ".$lng->txt("cont_missing_snippet")." //";
2777  }
2778  }
2779  $h2 = substr($a_html, 0, $start).
2780  $html.
2781  substr($a_html, $end + 5);
2782  $a_html = $h2;
2783  $i++;
2784  }
2785  $start = strpos($a_html, "{{{{{ContentInclude;", $start + 5);
2786  $end = 0;
2787  if (is_int($start))
2788  {
2789  $end = strpos($a_html, "}}}}}", $start);
2790  }
2791  }
2792  return $a_html;
2793  }
2794 
2801  function insertPageToc($a_output)
2802  {
2803  global $lng;
2804 
2805  include_once("./Services/Utilities/classes/class.ilStr.php");
2806 
2807  // extract all headings
2808  $offsets = ilStr::strPosAll($a_output, "ilPageTocH");
2809  $page_heads = array();
2810  foreach ($offsets as $os)
2811  {
2812  $level = (int) substr($a_output, $os + 10, 1);
2813  if (in_array($level, array(1,2,3)))
2814  {
2815  $anchor = str_replace("TocH", "TocA",
2816  substr($a_output, $os, strpos($a_output, "<", $os) - $os - 3)
2817  );
2818 
2819  // get heading
2820  $tag_start = stripos($a_output, "<h".$level." ", $os);
2821  $tag_end = stripos($a_output, "</h".$level.">", $tag_start);
2822  $head = substr($a_output, $tag_start, $tag_end - $tag_start);
2823 
2824  // get headings text
2825  $text_start = stripos($head, ">") + 1;
2826  $text_end = strripos($head, "<!--", $text_start);
2827  $text = substr($head, $text_start, $text_end - $text_start);
2828  $page_heads[] = array("level" => $level, "text" => $text,
2829  "anchor" => $anchor);
2830  }
2831  }
2832 
2833  if (count($page_heads) > 1)
2834  {
2835  include_once("./Services/UIComponent/NestedList/classes/class.ilNestedList.php");
2836  $list = new ilNestedList();
2837  $list->setAutoNumbering(true);
2838  $list->setListClass("ilc_page_toc_PageTOCList");
2839  $list->setItemClass("ilc_page_toc_PageTOCItem");
2840  $i = 0;
2841  $c_depth = 1;
2842  $c_par[1] = 0;
2843  $c_par[2] = 0;
2844  $nr[1] = 1;
2845  $nr[2] = 1;
2846  $nr[3] = 1;
2847  foreach ($page_heads as $ind => $h)
2848  {
2849  $i++;
2850  $par = 0;
2851 
2852  // check if we have a parent for one level up
2853  $par = 0;
2854  if ($h["level"] == 2 && $c_par[1] > 0)
2855  {
2856  $par = $c_par[1];
2857  }
2858  if ($h["level"] == 3 && $c_par[2] > 0)
2859  {
2860  $par = $c_par[2];
2861  }
2862 
2863  $h["text"] = str_replace("<!--PageTocPH-->", "", $h["text"]);
2864 
2865  // add the list node
2866  $list->addListNode(
2867  "<a href='#".$h["anchor"]."' class='ilc_page_toc_PageTOCLink'>".$h["text"]."</a>",
2868  $i, $par);
2869 
2870  // set the node as current parent of the level
2871  if ($h["level"] == 1)
2872  {
2873  $c_par[1] = $i;
2874  $c_par[2] = 0;
2875  }
2876  if ($h["level"] == 2)
2877  {
2878  $c_par[2] = $i;
2879  }
2880  }
2881 
2882  $tpl = new ilTemplate("tpl.page_toc.html", true, true,
2883  "Services/COPage");
2884  $tpl->setVariable("PAGE_TOC", $list->getHTML());
2885  $tpl->setVariable("TXT_PAGE_TOC", $lng->txt("cont_page_toc"));
2886  $tpl->setVariable("TXT_HIDE", $lng->txt("hide"));
2887  $tpl->setVariable("TXT_SHOW", $lng->txt("show"));
2888 
2889  $a_output = str_replace("{{{{{PageTOC}}}}}",
2890  $tpl->get(), $a_output);
2891  $numbers = $list->getNumbers();
2892 
2893  if (count($numbers) > 0)
2894  {
2895  include_once("./Services/Utilities/classes/class.ilStr.php");
2896  foreach ($numbers as $n)
2897  {
2898  $a_output =
2899  ilStr::replaceFirsOccurence("<!--PageTocPH-->", $n." ", $a_output);
2900  }
2901  }
2902  }
2903  else
2904  {
2905  $a_output = str_replace("{{{{{PageTOC}}}}}",
2906  "", $a_output);
2907  }
2908 
2909  return $a_output;
2910  }
2911 
2916  function postOutputProcessing($a_output)
2917  {
2918  return $a_output;
2919  }
2920 
2924  function insertHelp($a_tpl)
2925  {
2926  global $lng;
2927 
2928  $a_tpl->setCurrentBlock("help_img");
2929  $a_tpl->setVariable("IMG_HELP", ilUtil::getImagePath("streaked_area.gif"));
2930  $a_tpl->parseCurrentBlock();
2931  $a_tpl->setCurrentBlock("help_item");
2932  $a_tpl->setVariable("TXT_HELP", $lng->txt("cont_add_elements"));
2933  $a_tpl->parseCurrentBlock();
2934 
2935  $a_tpl->setCurrentBlock("help_img");
2936  $a_tpl->setVariable("IMG_HELP", ilUtil::getImagePath("icon_cont_el_s.gif"));
2937  $a_tpl->parseCurrentBlock();
2938  $a_tpl->setCurrentBlock("help_img");
2939  $a_tpl->setVariable("IMG_HELP", ilUtil::getImagePath("drop_streaked_area.gif"));
2940  $a_tpl->parseCurrentBlock();
2941  $a_tpl->setCurrentBlock("help_item");
2942  $a_tpl->setVariable("TXT_HELP", $lng->txt("cont_drag_and_drop_elements"));
2943  $a_tpl->parseCurrentBlock();
2944 
2945  $a_tpl->setCurrentBlock("help_img");
2946  $a_tpl->setVariable("IMG_HELP", ilUtil::getImagePath("icon_cont_el_s.gif"));
2947  $a_tpl->parseCurrentBlock();
2948  $a_tpl->setCurrentBlock("help_item");
2949  $a_tpl->setVariable("TXT_HELP", $lng->txt("cont_double_click_to_delete"));
2950  $a_tpl->parseCurrentBlock();
2951 
2952  $a_tpl->setCurrentBlock("help");
2953  $a_tpl->parseCurrentBlock();
2954  }
2955 
2956  /*
2957  * preview
2958  */
2959  function preview()
2960  {
2961  global $tree;
2963  return $this->showPage();
2964  }
2965 
2969  function edit()
2970  {
2971  global $tree, $lng, $ilCtrl;
2972 
2973  if (!$this->getEnableEditing())
2974  {
2975  ilUtil::sendFailure($lng->txt("permission_denied"), true);
2976  $ilCtrl->redirect($this, "preview");
2977  }
2978 
2979  $this->setOutputMode(IL_PAGE_EDIT);
2980 
2981  $html = $this->showPage();
2982 
2983  if ($this->isEnabledNotes())
2984  {
2985  $html.= "<br /><br />".$this->getNotesHTML();
2986  }
2987 
2988  return $html;
2989  }
2990 
2998  {
2999  global $tpl;
3000 
3001 // 'pl_hier_id' => string '2_1_1_1' (length=7)
3002 // 'pl_pc_id' => string '1f77eb1d8a478497d69b99d938fda8f' (length=31)
3003  $html = $this->edit();
3004 
3005  $tpl->addOnLoadCode("ilCOPage.insertJSAtPlaceholder('".
3006  $_GET["pl_hier_id"].":".$_GET["pl_pc_id"].
3007  "');", 3);
3008 
3009  return $html;
3010  }
3011 
3012 
3013  /*
3014  * presentation
3015  */
3017  {
3018  global $tree;
3019  $this->setOutputMode($a_mode);
3020 
3021  return $this->showPage();
3022  }
3023 
3024  function getHTML()
3025  {
3026  $this->getTabs("preview");
3027  return $this->showPage();
3028  }
3029 
3033  function showMediaFullscreen($a_style_id = 0)
3034  {
3035  $this->tpl = new ilTemplate("tpl.fullscreen.html", true, true, "Services/COPage");
3036  $this->tpl->setCurrentBlock("ContentStyle");
3037  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", 0);
3038  $this->tpl->parseCurrentBlock();
3039 
3040  $this->tpl->setVariable("PAGETITLE", " - ".ilObject::_lookupTitle($_GET["mob_id"]));
3041  $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
3042  $this->tpl->setCurrentBlock("ilMedia");
3043 
3044  require_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
3045  $media_obj =& new ilObjMediaObject($_GET["mob_id"]);
3046  if (!empty ($_GET["pg_id"]))
3047  {
3048  require_once("./Services/COPage/classes/class.ilPageObject.php");
3049  $pg_obj =& new ilPageObject($this->obj->getParentType(), $_GET["pg_id"]);
3050  $pg_obj->buildDom();
3051 
3052  $xml = "<dummy>";
3053  // todo: we get always the first alias now (problem if mob is used multiple
3054  // times in page)
3055  $xml.= $pg_obj->getMediaAliasElement($_GET["mob_id"]);
3056  $xml.= $media_obj->getXML(IL_MODE_OUTPUT);
3057  $xml.="</dummy>";
3058  }
3059  else
3060  {
3061  $xml = "<dummy>";
3062  $xml.= $media_obj->getXML(IL_MODE_ALIAS);
3063  $xml.= $media_obj->getXML(IL_MODE_OUTPUT);
3064  $xml.="</dummy>";
3065  }
3066 
3067 //echo htmlentities($xml); exit;
3068 
3069  $xsl = file_get_contents("./Services/COPage/xsl/page.xsl");
3070  $args = array( '/_xml' => $xml, '/_xsl' => $xsl );
3071  $xh = xslt_create();
3072 
3073 //echo "<b>XML:</b>".htmlentities($xml);
3074  // determine target frames for internal links
3075  //$pg_frame = $_GET["frame"];
3076  $wb_path = ilUtil::getWebspaceDir("output")."/";
3077 // $wb_path = "../".$this->ilias->ini->readVariable("server","webspace_dir");
3078  $mode = "fullscreen";
3079  $params = array ('mode' => $mode, 'webspace_path' => $wb_path);
3080  $output = xslt_process($xh,"arg:/_xml","arg:/_xsl",NULL,$args, $params);
3081  echo xslt_error($xh);
3082  xslt_free($xh);
3083 
3084  // unmask user html
3085  $this->tpl->setVariable("MEDIA_CONTENT", $output);
3086  }
3087 
3093  function displayValidationError($a_error)
3094  {
3095  if(is_array($a_error))
3096  {
3097  $error_str = "<b>Validation Error(s):</b><br>";
3098  foreach ($a_error as $error)
3099  {
3100  $err_mess = implode($error, " - ");
3101  if (!is_int(strpos($err_mess, ":0:")))
3102  {
3103  $error_str .= htmlentities($err_mess)."<br />";
3104  }
3105  }
3106  $this->tpl->setVariable("MESSAGE", $error_str);
3107  }
3108  }
3109 
3113  function history()
3114  {
3115  global $tpl, $lng, $ilAccess;
3116 
3117  if (!$this->getEnableEditing())
3118  {
3119  return;
3120  }
3121 
3122  $tpl->addJavaScript("./Services/COPage/js/page_history.js");
3123 
3124  include_once("./Services/COPage/classes/class.ilPageHistoryTableGUI.php");
3125  $table_gui = new ilPageHistoryTableGUI($this, "history");
3126  $table_gui->setId("hist_table");
3127  $entries = $this->getPageObject()->getHistoryEntries();
3128  $entries[] = array('page_id' => $this->getPageObject()->getId(),
3129  'parent_type' => $this->getPageObject()->getParentType(),
3130  'hdate' => $this->getPageObject()->getLastChange(),
3131  'parent_id' => $this->getPageObject()->getParentId(),
3132  'nr' => 0,
3133  'sortkey' => 999999,
3134  'user' => $this->getPageObject()->last_change_user);
3135  $table_gui->setData($entries);
3136  return $table_gui->getHTML();
3137  }
3138 
3143  {
3144  global $tpl, $lng, $ilAccess, $ilCtrl;
3145 
3146  if (!$this->getEnableEditing())
3147  {
3148  return;
3149  }
3150 
3151  include_once("Services/Utilities/classes/class.ilConfirmationGUI.php");
3152  $c_gui = new ilConfirmationGUI();
3153 
3154  // set confirm/cancel commands
3155  $ilCtrl->setParameter($this, "rollback_nr", $_GET["old_nr"]);
3156  $c_gui->setFormAction($ilCtrl->getFormAction($this, "rollback"));
3157  $c_gui->setHeaderText($lng->txt("cont_rollback_confirmation"));
3158  $c_gui->setCancel($lng->txt("cancel"), "history");
3159  $c_gui->setConfirm($lng->txt("confirm"), "rollback");
3160 
3161  $hentry = $this->obj->getHistoryEntry($_GET["old_nr"]);
3162 
3163  $c_gui->addItem("id[]", $_GET["old_nr"],
3165 
3166  $tpl->setContent($c_gui->getHTML());
3167  }
3168 
3172  function rollback()
3173  {
3174  global $ilCtrl;
3175 
3176  if (!$this->getEnableEditing())
3177  {
3178  return;
3179  }
3180 
3181  $hentry = $this->obj->getHistoryEntry($_GET["rollback_nr"]);
3182 
3183  if ($hentry["content"] != "")
3184  {
3185  $this->obj->setXMLContent($hentry["content"]);
3186  $this->obj->buildDom(true);
3187  if ($this->obj->update())
3188  {
3189  $ilCtrl->redirect($this, "history");
3190  }
3191  }
3192  $ilCtrl->redirect($this, "history");
3193  }
3194 
3200  function getTabs($a_activate = "")
3201  {
3202  global $ilTabs, $ilCtrl;
3203 
3204  if (!$this->getEnabledTabs())
3205  {
3206  return;
3207  }
3208 
3209 //echo "-".$ilCtrl->getNextClass()."-".$ilCtrl->getCmd()."-";
3210  // back to upper context
3211 
3212  if (!$this->getEditPreview())
3213  {
3214  $ilTabs->addTarget("pg", $ilCtrl->getLinkTarget($this, "preview")
3215  , array("", "preview"));
3216 
3217  if ($this->getEnableEditing())
3218  {
3219  $ilTabs->addTarget("edit", $ilCtrl->getLinkTarget($this, "edit")
3220  , array("", "edit"));
3221  }
3222  }
3223  else
3224  {
3225  if ($this->getEnableEditing())
3226  {
3227  $ilTabs->addTarget("edit", $ilCtrl->getLinkTarget($this, "edit")
3228  , array("", "edit"));
3229  }
3230 
3231  $ilTabs->addTarget("cont_preview", $ilCtrl->getLinkTarget($this, "preview")
3232  , array("", "preview"));
3233  }
3234 
3235  //$tabs_gui->addTarget("properties", $this->ctrl->getLinkTarget($this, "properties")
3236  // , "properties", get_class($this));
3237 
3238  if ($this->use_meta_data && !$this->layout_mode)
3239  {
3240  $ilTabs->addTarget("meta_data",
3241  $this->ctrl->getLinkTargetByClass('ilmdeditorgui',''),
3242  "", "ilmdeditorgui");
3243  }
3244 
3245  $lm_set = new ilSetting("lm");
3246 
3247  if ($this->getEnableEditing() && !$this->layout_mode &&
3248  $lm_set->get("page_history", 1))
3249  {
3250  $ilTabs->addTarget("history", $this->ctrl->getLinkTarget($this, "history")
3251  , "history", get_class($this));
3252  }
3253 
3254 /* $tabs = $this->ctrl->getTabs();
3255  foreach ($tabs as $tab)
3256  {
3257  $tabs_gui->addTarget($tab["lang_var"], $tab["link"]
3258  , $tab["cmd"], $tab["class"]);
3259  }
3260 */
3261  if ($this->getEnableEditing())
3262  {
3263  $ilTabs->addTarget("clipboard", $this->ctrl->getLinkTargetByClass("ilEditClipboardGUI", "view")
3264  , "view", "ilEditClipboardGUI");
3265  }
3266 
3267  if ($this->getEnabledScheduledActivation())
3268  {
3269  $ilTabs->addTarget("cont_activation", $this->ctrl->getLinkTarget($this, "editActivation"),
3270  "editActivation", get_class($this));
3271  }
3272 
3273  if ($this->getEnabledNews())
3274  {
3275  $ilTabs->addTarget("news",
3276  $this->ctrl->getLinkTargetByClass("ilnewsitemgui", "editNews"),
3277  "", "ilnewsitemgui");
3278  }
3279 
3280  // external hook to add tabs
3281  if (is_array($this->tab_hook))
3282  {
3283  $func = $this->tab_hook["func"];
3284  $this->tab_hook["obj"]->$func();
3285  }
3286  //$ilTabs->setTabActive("pg");
3287  }
3288 
3292  function compareVersion()
3293  {
3294  global $lng;
3295 
3296  if (!$this->getEnableEditing())
3297  {
3298  return;
3299  }
3300 
3301  $tpl = new ilTemplate("tpl.page_compare.html", true, true, "Services/COPage");
3302  $compare = $this->obj->compareVersion($_POST["left"], $_POST["right"]);
3303 
3304  // left page
3305  $lpage = $compare["l_page"];
3306  $lpage_gui = new ilPageObjectGUI("wpg");
3307  $lpage_gui->setOutputMode(IL_PAGE_PREVIEW);
3308  $lpage_gui->setPageObject($lpage);
3309  $lpage_gui->setPreventHTMLUnmasking(true);
3310  $lpage_gui->setPresentationTitle($this->getPresentationTitle());
3311  $lpage_gui->setCompareMode(true);
3312  $lhtml = $lpage_gui->showPage();
3313  $lhtml = $this->replaceDiffTags($lhtml);
3314  $lhtml = str_replace("&lt;br /&gt;", "<br />", $lhtml);
3315  $tpl->setVariable("LEFT", $lhtml);
3316 
3317  // right page
3318  $rpage = $compare["r_page"];
3319  $rpage_gui = new ilPageObjectGUI("wpg");
3320  $rpage_gui->setOutputMode(IL_PAGE_PREVIEW);
3321  $rpage_gui->setPageObject($rpage);
3322  $rpage_gui->setPreventHTMLUnmasking(true);
3323  $rpage_gui->setPresentationTitle($this->getPresentationTitle());
3324  $rpage_gui->setCompareMode(true);
3325  $rhtml = $rpage_gui->showPage();
3326  $rhtml = $this->replaceDiffTags($rhtml);
3327  $rhtml = str_replace("&lt;br /&gt;", "<br />", $rhtml);
3328  $tpl->setVariable("RIGHT", $rhtml);
3329 
3330  $tpl->setVariable("TXT_NEW", $lng->txt("cont_pc_new"));
3331  $tpl->setVariable("TXT_MODIFIED", $lng->txt("cont_pc_modified"));
3332  $tpl->setVariable("TXT_DELETED", $lng->txt("cont_pc_deleted"));
3333 
3334 //var_dump($left);
3335 //var_dump($right);
3336 
3337  return $tpl->get();
3338  }
3339 
3340  function replaceDiffTags($a_html)
3341  {
3342  $a_html = str_replace("[ilDiffInsStart]", '<span class="ilDiffIns">', $a_html);
3343  $a_html = str_replace("[ilDiffDelStart]", '<span class="ilDiffDel">', $a_html);
3344  $a_html = str_replace("[ilDiffInsEnd]", '</span>', $a_html);
3345  $a_html = str_replace("[ilDiffDelEnd]", '</span>', $a_html);
3346 
3347  return $a_html;
3348  }
3349 
3353  function editActivation()
3354  {
3355  global $ilCtrl, $lng, $tpl;
3356 
3357  $atpl = new ilTemplate("tpl.page_activation.php", true, true, "Services/COPage");
3358  $this->initActivationForm();
3359  $this->getActivationFormValues();
3360  $atpl->setVariable("FORM", $this->form->getHTML());
3361  $atpl->setCurrentBlock("updater");
3362  $atpl->setVariable("UPDATER_FRAME", $this->exp_frame);
3363  $atpl->setVariable("EXP_ID_UPDATER", $this->exp_id);
3364  $atpl->setVariable("HREF_UPDATER", $this->exp_target_script);
3365  $atpl->parseCurrentBlock();
3366  $tpl->setContent($atpl->get());
3367  }
3368 
3373  {
3374  global $ilCtrl, $lng;
3375 
3376  include_once("./Services/Form/classes/class.ilPropertyFormGUI.php");
3377  $this->form = new ilPropertyFormGUI();
3378  $this->form->setFormAction($ilCtrl->getFormAction($this));
3379  $this->form->setTitle($lng->txt("cont_page_activation"));
3380 
3381  // activation type radio
3382  $rad = new ilRadioGroupInputGUI($lng->txt("cont_activation"), "activation");
3383  $rad_op1 = new ilRadioOption($lng->txt("cont_activated"), "activated");
3384 
3385  $rad->addOption($rad_op1);
3386  $rad_op2 = new ilRadioOption($lng->txt("cont_deactivated"), "deactivated");
3387  $rad->addOption($rad_op2);
3388  $rad_op3 = new ilRadioOption($lng->txt("cont_scheduled_activation"), "scheduled");
3389 
3390  $dt_prop = new ilDateTimeInputGUI($lng->txt("cont_start"), "start");
3391  $dt_prop->setShowTime(true);
3392  $rad_op3->addSubItem($dt_prop);
3393  $dt_prop2 = new ilDateTimeInputGUI($lng->txt("cont_end"), "end");
3394  $dt_prop2->setShowTime(true);
3395  $rad_op3->addSubItem($dt_prop2);
3396 
3397  $rad->addOption($rad_op3);
3398 
3399  $this->form->addCommandButton("saveActivation", $lng->txt("save"));
3400 
3401  $this->form->addItem($rad);
3402  }
3403 
3408  {
3409  $values = array();
3410  $values["activation"] = "deactivated";
3411  if ($this->getPageObject()->getActive())
3412  {
3413  $values["activation"] = "activated";
3414  }
3415 
3416  $dt_prop = $this->form->getItemByPostVar("start");
3417  if ($this->getPageObject()->getActivationStart() != "")
3418  {
3419  $values["activation"] = "scheduled";
3420  $dt_prop->setDate(new ilDateTime($this->getPageObject()->getActivationStart(),
3421  IL_CAL_DATETIME));
3422  }
3423  $dt_prop = $this->form->getItemByPostVar("end");
3424  if ($this->getPageObject()->getActivationEnd() != "")
3425  {
3426  $values["activation"] = "scheduled";
3427  $dt_prop->setDate(new ilDateTime($this->getPageObject()->getActivationEnd(),
3428  IL_CAL_DATETIME));
3429  }
3430 
3431  $this->form->setValuesByArray($values);
3432  }
3433 
3437  function saveActivation()
3438  {
3439  global $tpl, $lng, $ilCtrl;
3440 
3441  $this->initActivationForm();
3442 
3443  if ($this->form->checkInput())
3444  {
3445  $this->getPageObject()->setActive(true);
3446  $this->getPageObject()->setActivationStart(null);
3447  $this->getPageObject()->setActivationEnd(null);
3448  if ($_POST["activation"] == "deactivated")
3449  {
3450  $this->getPageObject()->setActive(false);
3451  }
3452  if ($_POST["activation"] == "scheduled")
3453  {
3454  $this->getPageObject()->setActive(false);
3455  $this->getPageObject()->setActivationStart(
3456  $this->form->getItemByPostVar("start")->getDate()->get(IL_CAL_DATETIME));
3457  $this->getPageObject()->setActivationEnd(
3458  $this->form->getItemByPostVar("end")->getDate()->get(IL_CAL_DATETIME));
3459  }
3460  $this->getPageObject()->update();
3461  ilUtil::sendSuccess($lng->txt("msg_obj_modified"), true);
3462  $ilCtrl->redirect($this, "editActivation");
3463  }
3464  $this->form->getValuesByPost();
3465  $tpl->setContent($this->form->getHTML());
3466  }
3467 
3477  function getNotesHTML($a_content_object = null, $a_enable_private_notes = true, $a_enable_public_notes = false, $a_enable_notes_deletion = false, $a_callback = null)
3478  {
3479  global $ilCtrl;
3480 
3481  include_once("Services/Notes/classes/class.ilNoteGUI.php");
3482 
3483  // scorm 2004 page gui
3484  if(!$a_content_object)
3485  {
3486  $notes_gui = new ilNoteGUI($this->notes_parent_id,
3487  (int)$this->obj->getId(), "pg");
3488 
3489  $a_enable_private_notes = true;
3490  $a_enable_public_notes = true;
3491  $a_enable_notes_deletion = false;
3492  }
3493  // wiki page gui, blog posting gui
3494  else
3495  {
3496  $notes_gui = new ilNoteGUI($a_content_object->getParentId(),
3497  $a_content_object->getId(), $a_content_object->getParentType());
3498  }
3499 
3500  if($a_enable_private_notes)
3501  {
3502  $notes_gui->enablePrivateNotes();
3503  }
3504  if ($a_enable_public_notes)
3505  {
3506  $notes_gui->enablePublicNotes();
3507  if ((bool)$a_enable_notes_deletion)
3508  {
3509  $notes_gui->enablePublicNotesDeletion(true);
3510  }
3511  }
3512 
3513  if($a_callback)
3514  {
3515  $notes_gui->addObserver($a_callback);
3516  }
3517 
3518  $next_class = $this->ctrl->getNextClass($this);
3519  if ($next_class == "ilnotegui")
3520  {
3521  $html = $this->ctrl->forwardCommand($notes_gui);
3522  }
3523  else
3524  {
3525  $html = $notes_gui->getNotesHTML();
3526  }
3527  return $html;
3528  }
3529 
3533  function getQuestionJsOfPage($a_no_interaction = false)
3534  {
3535  require_once './Modules/Scorm2004/classes/class.ilQuestionExporter.php';
3536  $q_ids = $this->getPageObject()->getQuestionIds();
3537  $js = array();
3538  if (count($q_ids) > 0)
3539  {
3540  foreach ($q_ids as $q_id)
3541  {
3542  $q_exporter = new ilQuestionExporter($a_no_interaction);
3543  $js[$q_id] = $q_exporter->exportQuestion($q_id);
3544  }
3545  }
3546  return $js;
3547  }
3548 
3552  function initSelfAssessmentRendering($a_force_no_form = false)
3553  {
3554  global $tpl, $ilCtrl, $lng;
3555 
3556  if ($this->getEnabledSelfAssessment())
3557  {
3558  $qhtml = $this->getQuestionJsOfPage(($this->getOutputMode()=="edit" || $a_force_no_form)
3559  ? true
3560  : false);
3561 // $qhtml = $this->getQuestionJsOfPage(true);
3562  $this->setQuestionHTML($qhtml);
3563  //include JQuery Libraries before Prototpye
3564 // $tpl->addJavaScript("./Modules/Scorm2004/scripts/questions/jquery.js");
3565 // $tpl->addJavaScript("./Modules/Scorm2004/scripts/questions/jquery-ui-min.js");
3566  include_once("./Services/jQuery/classes/class.iljQueryUtil.php");
3569  $tpl->addJavaScript("./Modules/Scorm2004/scripts/questions/pure.js");
3570  $tpl->addJavaScript("./Modules/Scorm2004/scripts/questions/question_handling.js");
3571  $tpl->addCss("./Modules/Scorm2004/templates/default/question_handling.css");
3572  if (!$this->getEnabledSelfAssessmentScorm() && $this->getOutputMode() != IL_PAGE_PREVIEW
3573  && $this->getOutputMode() != "offline")
3574  {
3575  $tpl->addJavaScript("./Services/COPage/js/ilCOPageQuestionHandler.js");
3576  $url = $ilCtrl->getLinkTarget($this, "processAnswer", "", true, false);
3577  $tpl->addOnloadCode("ilCOPageQuestionHandler.initCallback('".$url."');");
3578  }
3579 
3580  $lk = $this->getPageConfig()->getLocalizationLanguage();
3581  self::addPreparationJavascript($tpl, $lk);
3582  }
3583  }
3584 
3591  static function addPreparationJavascript($a_tpl, $a_lang)
3592  {
3593  global $lng;
3594 
3595  $a_tpl->addOnloadCode(self::getJSTextInitCode($a_lang).
3596  'ilCOPagePres.updateQuestionOverviews();
3597  ');
3598  }
3599 
3606  static function getJSTextInitCode($a_lang)
3607  {
3608  global $lng, $ilUser;
3609 
3610  if ($a_lang == "")
3611  {
3612  $a_lang = $ilUser->getLanguage();
3613  }
3614 
3615  return
3616  '
3617  ilias.questions.txt.wrong_answers = "'.$lng->txtlng("content", "cont_wrong_answers", $a_lang).'";
3618  ilias.questions.txt.wrong_answers_single = "'.$lng->txtlng("content", "cont_wrong_answers_single", $a_lang).'";
3619  ilias.questions.txt.tries_remaining = "'.$lng->txtlng("content", "cont_tries_remaining", $a_lang).'";
3620  ilias.questions.txt.please_try_again = "'.$lng->txtlng("content", "cont_please_try_again", $a_lang).'";
3621  ilias.questions.txt.all_answers_correct = "'.$lng->txtlng("content", "cont_all_answers_correct", $a_lang).'";
3622  ilias.questions.txt.nr_of_tries_exceeded = "'.$lng->txtlng("content", "cont_nr_of_tries_exceeded", $a_lang).'";
3623  ilias.questions.txt.correct_answers_shown = "'.$lng->txtlng("content", "cont_correct_answers_shown", $a_lang).'";
3624  ilias.questions.txt.correct_answers_also = "'.$lng->txtlng("content", "cont_correct_answers_also", $a_lang).'";
3625  ilias.questions.txt.correct_answer_also = "'.$lng->txtlng("content", "cont_correct_answer_also", $a_lang).'";
3626  ilias.questions.txt.ov_all_correct = "'.$lng->txtlng("content", "cont_ov_all_correct", $a_lang).'";
3627  ilias.questions.txt.ov_some_correct = "'.$lng->txtlng("content", "cont_ov_some_correct", $a_lang).'";
3628  ilias.questions.txt.ov_wrong_answered = "'.$lng->txtlng("content", "cont_ov_wrong_answered", $a_lang).'";
3629  ';
3630 
3631  }
3632 
3633 
3637  function processAnswer()
3638  {
3639  global $ilLog;
3640 
3641  /*$ilLog->write($_POST);
3642  $ilLog->write($_POST["id"]);
3643  $ilLog->write($_POST["type"]);
3644  $ilLog->write($_POST["answer"]);
3645  $ilLog->write($_GET);*/
3646 
3647  include_once("./Services/COPage/classes/class.ilPageQuestionProcessor.php");
3649  ilUtil::stripSlashes($_POST["type"]),
3651  ilUtil::stripSlashes($_POST["answer"]));
3652  }
3653 
3660  function selfAssessmentRendering($a_output)
3661  {
3662  if ($this->getEnabledSelfAssessment())
3663  {
3664  require_once './Modules/Scorm2004/classes/class.ilQuestionExporter.php';
3665  $a_output = "<script>var ScormApi=null;".ilQuestionExporter::questionsJS()."</script>".$a_output;
3666  }
3667  return $a_output;
3668  }
3669 
3670 
3671 }
3672 ?>