ILIAS  Release_3_10_x_branch Revision 61812
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilPageObjectGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2008 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
24 define ("IL_PAGE_PRESENTATION", "presentation");
25 define ("IL_PAGE_EDIT", "edit");
26 define ("IL_PAGE_PREVIEW", "preview");
27 define ("IL_PAGE_OFFLINE", "offline");
28 define ("IL_PAGE_PRINT", "print");
29 
30 include_once ("./Services/COPage/classes/class.ilPageEditorGUI.php");
31 include_once("./Services/COPage/classes/class.ilPageObject.php");
32 include_once("./Services/Clipboard/classes/class.ilEditClipboardGUI.php");
33 include_once("./Services/COPage/classes/class.ilParagraphPlugins.php");
34 include_once("./Services/COPage/classes/class.ilParagraphPlugin.php");
35 include_once("./Services/Utilities/classes/class.ilDOMUtil.php");
36 
37 
53 {
54  var $ilias;
55  var $tpl;
56  var $lng;
57  var $ctrl;
58  var $obj;
68  var $bib_id;
69  var $citation;
73  var $activation = false;
74  var $activated = true;
76  var $editpreview = false;
77  var $use_meta_data = false;
78  var $enabledtabs = true;
79  var $enabledpctabs = false;
80  var $link_xml_set = false;
81  var $enableediting = true;
82  var $rawpagecontent = false;
83 
88  function ilPageObjectGUI($a_parent_type, $a_id = 0, $a_old_nr = 0)
89  {
90  global $ilias, $tpl, $lng, $ilCtrl,$ilTabs;
91 
92  $this->ctrl =& $ilCtrl;
93 
94  if ($a_old_nr == 0 && $_GET["old_nr"] > 0)
95  {
96  $a_old_nr = $_GET["old_nr"];
97  }
98 
99  $this->ilias =& $ilias;
100  $this->tpl =& $tpl;
101  $this->ctrl =& $ilCtrl;
102  $this->lng =& $lng;
104 
105  // defaults (as in learning modules)
106  $this->setEnabledMaps(false);
107  $this->setEnabledPCTabs(false);
108  $this->setEnabledFileLists(true);
109  $this->setEnabledRepositoryObjects(false);
110  $this->setEnabledPageFocus(true);
111 
112  if ($a_id > 0)
113  {
114  $this->initPageObject($a_parent_type, $a_id, $a_old_nr);
115  }
116  $this->output2template = true;
117  $this->question_xml = "";
118  $this->question_html = "";
119  $this->tabs_gui =& $ilTabs;
120 
121  // USED FOR TRANSLATIONS
122  $this->template_output_var = "PAGE_CONTENT";
123  $this->citation = false;
124  $this->change_comments = false;
125  $this->page_back_title = $this->lng->txt("page");
126  $lng->loadLanguageModule("content");
127  $this->setPreventHTMLUnmasking(false);
128  $this->setEnabledWikiLinks(false);
129 
130  $this->setTemplateOutput(false);
131  }
132 
133  function initPageObject($a_parent_type, $a_id, $a_old_nr)
134  {
135  $page = new ilPageObject($a_parent_type, $a_id, $a_old_nr);
136  $this->setPageObject($page);
137  }
138 
142  function setBibId($a_id)
143  {
144  // USED FOR SELECTION WHICH PAGE TURNS AND LATER PAGES SHOULD BE SHOWN
145  $this->bib_id = $a_id;
146  }
147 
151  function getBibId()
152  {
153  return $this->bib_id ? $this->bib_id : 0;
154  }
155 
161  function setPageObject($a_pg_obj)
162  {
163  $this->obj = $a_pg_obj;
164  }
165 
171  function getPageObject()
172  {
173  return $this->obj;
174  }
175 
182  {
183  $this->output_mode = $a_mode;
184  }
185 
186  function getOutputMode()
187  {
188  return $this->output_mode;
189  }
190 
191  function setTemplateOutput($a_output = true)
192  {
193  $this->output2template = $a_output;
194  }
195 
196  function outputToTemplate()
197  {
198  return $this->output2template;
199  }
200 
201  function setPresentationTitle($a_title = "")
202  {
203  $this->presentation_title = $a_title;
204  }
205 
207  {
209  }
210 
211  function setHeader($a_title = "")
212  {
213  $this->header = $a_title;
214  }
215 
216  function getHeader()
217  {
218  return $this->header;
219  }
220 
221  function setLinkParams($l_params = "")
222  {
223  $this->link_params = $l_params;
224  }
225 
226  function getLinkParams()
227  {
228  return $this->link_params;
229  }
230 
231  function setLinkFrame($l_frame = "")
232  {
233  $this->link_frame = $l_frame;
234  }
235 
236  function getLinkFrame()
237  {
238  return $this->link_frame;
239  }
240 
241  function setLinkXML($link_xml)
242  {
243  $this->link_xml = $link_xml;
244  $this->link_xml_set = true;
245  }
246 
247  function getLinkXML()
248  {
249  return $this->link_xml;
250  }
251 
252  function setQuestionXML($question_xml)
253  {
254  $this->question_xml = $question_xml;
255  }
256 
258  {
259  $this->question_html = $question_html;
260  }
261 
262  function getQuestionXML()
263  {
264  return $this->question_xml;
265  }
266 
267  function getQuestionHTML()
268  {
269  return $this->question_html;
270  }
271 
272  function setTemplateTargetVar($a_variable)
273  {
274  $this->target_var = $a_variable;
275  }
276 
278  {
279  return $this->target_var;
280  }
281 
282  function setTemplateOutputVar($a_value)
283  {
284  // USED FOR TRANSLATION PRESENTATION OF dbk OBJECTS
285  $this->template_output_var = $a_value;
286  }
287 
289  {
291  }
292 
293  function setOutputSubmode($a_mode)
294  {
295  // USED FOR TRANSLATION PRESENTATION OF dbk OBJECTS
296  $this->output_submode = $a_mode;
297  }
298 
299  function getOutputSubmode()
300  {
301  return $this->output_submode;
302  }
303 
304 
306  $this->sourcecode_download_script = $script_name;
307  }
308 
311  }
312 
313  function enableCitation($a_enabled)
314  {
315  $this->citation = $a_enabled;
316  }
317 
318  function isEnabledCitation()
319  {
320  return $this->citation;
321  }
322 
323  function setLocator(&$a_locator)
324  {
325  $this->locator =& $a_locator;
326  }
327 
328  function setTabs($a_tabs)
329  {
330  $this->tabs_gui = $a_tabs;
331  }
332 
333  function setPageBackTitle($a_title)
334  {
335  $this->page_back_title = $a_title;
336  }
337 
338  function setFileDownloadLink($a_download_link)
339  {
340  $this->file_download_link = $a_download_link;
341  }
342 
344  {
345  return $this->file_download_link;
346  }
347 
348  function setFullscreenLink($a_fullscreen_link)
349  {
350  $this->fullscreen_link = $a_fullscreen_link;
351  }
352 
353  function getFullscreenLink()
354  {
355  return $this->fullscreen_link;
356  }
357 
358  function setIntLinkHelpDefault($a_type, $a_id)
359  {
360  $this->int_link_def_type = $a_type;
361  $this->int_link_def_id = $a_id;
362  }
363 
364  function setIntLinkReturn($a_return)
365  {
366  $this->int_link_return = $a_return;
367  }
368 
369  function enableChangeComments($a_enabled)
370  {
371  $this->change_comments = $a_enabled;
372  }
373 
375  {
376  return $this->change_comments;
377  }
378 
384  function setOfflineDirectory ($offdir) {
385  $this->offline_directory = $offdir;
386  }
387 
388 
393  function getOfflineDirectory () {
394  return $this->offline_directory;
395  }
396 
397 
404  function setViewPageLink($a_link, $a_target = "")
405  {
406  $this->view_page_link = $a_link;
407  $this->view_page_target = $a_target;
408  }
409 
413  function getViewPageLink()
414  {
415  return $this->view_page_link;
416  }
417 
421  function getViewPageTarget()
422  {
423  return $this->view_page_target;
424  }
425 
426  function setActivationListener(&$a_obj, $a_meth)
427  {
428  $this->act_obj =& $a_obj;
429  $this->act_meth = $a_meth;
430  }
431 
432  function setActivated($a_act)
433  {
434  $this->activated = $a_act;
435  }
436 
437  function getActivated()
438  {
439  return $this->activated;
440  }
441 
442  function setEnabledActivation($a_act)
443  {
444  $this->activation = $a_act;
445  }
446 
448  {
449  return $this->activation;
450  }
451 
452 
458  function setEnabledInternalLinks($a_enabledinternallinks)
459  {
460  $this->enabledinternallinks = $a_enabledinternallinks;
461  }
462 
469  {
471  }
472 
478  function setEditPreview($a_editpreview)
479  {
480  $this->editpreview = $a_editpreview;
481  }
482 
488  function getEditPreview()
489  {
490  return $this->editpreview;
491  }
492 
498  function setPreventHTMLUnmasking($a_preventhtmlunmasking)
499  {
500  $this->preventhtmlunmasking = $a_preventhtmlunmasking;
501  }
502 
509  {
510  return $this->preventhtmlunmasking;
511  }
512 
518  function setEnabledTabs($a_enabledtabs)
519  {
520  $this->enabledtabs = $a_enabledtabs;
521  }
522 
528  function getEnabledTabs()
529  {
530  return $this->enabledtabs;
531  }
532 
538  function setEnabledRepositoryObjects($a_enabledrepositoryobjects)
539  {
540  $this->enabledrepositoryobjects = $a_enabledrepositoryobjects;
541  }
542 
549  {
550  return $this->enabledrepositoryobjects;
551  }
552 
558  function setEnabledMaps($a_enabledmaps)
559  {
560  $this->enabledmaps = $a_enabledmaps;
561  }
562 
568  function getEnabledMaps()
569  {
570  return $this->enabledmaps;
571  }
572 
578  function setEnabledPCTabs($a_enabledpctabs)
579  {
580  $this->enabledpctabs = $a_enabledpctabs;
581  }
582 
588  function getEnabledPCTabs()
589  {
590  return $this->enabledpctabs;
591  }
592 
598  function setEnabledFileLists($a_enabledfilelists)
599  {
600  $this->enabledfilelists = $a_enabledfilelists;
601  }
602 
609  {
610  return $this->enabledfilelists;
611  }
612 
618  function setEnabledPageFocus($a_enabledpagefocus)
619  {
620  $this->enabledpagefocus = $a_enabledpagefocus;
621  }
622 
629  {
630  return $this->enabledpagefocus;
631  }
632 
638  function setExplorerUpdater($a_exp_frame, $a_exp_id, $a_exp_target_script)
639  {
640  $this->exp_frame = $a_exp_frame;
641  $this->exp_id = $a_exp_id;
642  $this->exp_target_script = $a_exp_target_script;
643  }
644 
650  function setPrependingHtml($a_prependinghtml)
651  {
652  $this->prependinghtml = $a_prependinghtml;
653  }
654 
660  function getPrependingHtml()
661  {
662  return $this->prependinghtml;
663  }
664 
670  function setEnabledWikiLinks($a_enablewikilinks)
671  {
672  $this->enablewikilinks = $a_enablewikilinks;
673  }
674 
681  {
682  return $this->enablewikilinks;
683  }
684 
690  function setEnableEditing($a_enableediting)
691  {
692  $this->enableediting = $a_enableediting;
693  }
694 
700  function getEnableEditing()
701  {
702  return $this->enableediting;
703  }
704 
710  function setRawPageContent($a_rawpagecontent)
711  {
712  $this->rawpagecontent = $a_rawpagecontent;
713  }
714 
720  function getRawPageContent()
721  {
722  return $this->rawpagecontent;
723  }
724 
734  function activateMetaDataEditor($a_rep_obj_id, $a_sub_obj_id, $a_type,
735  $a_observer_obj = NULL, $a_observer_func = "")
736  {
737  $this->use_meta_data = true;
738  $this->meta_data_rep_obj_id = $a_rep_obj_id;
739  $this->meta_data_sub_obj_id = $a_sub_obj_id;
740  $this->meta_data_type = $a_type;
741  $this->meta_data_observer_obj = $a_observer_obj;
742  $this->meta_data_observer_func = $a_observer_func;
743  }
744 
749  {
750  $xml = "";
751  if($this->getOutputMode() == "edit")
752  {
753  global $ilPluginAdmin;
754 
755  $pl_names = $ilPluginAdmin->getActivePluginsForSlot(IL_COMP_SERVICE,
756  "COPage", "pgcp");
757  foreach ($pl_names as $pl_name)
758  {
759  $plugin = $ilPluginAdmin->getPluginObject(IL_COMP_SERVICE,
760  "COPage", "pgcp", $pl_name);
761  if ($plugin->isValidParentType($this->getPageObject()->getParentType()))
762  {
763  $xml = '<ComponentPlugin Name="'.$plugin->getPluginName().
764  '" InsertText="'.$plugin->getUIText(ilPageComponentPlugin::TXT_CMD_INSERT).'" />';
765  }
766  }
767  }
768  if ($xml != "")
769  {
770  $xml = "<ComponentPlugins>".$xml."</ComponentPlugins>";
771  }
772 
773  return $xml;
774  }
775 
776 
780  function &executeCommand()
781  {
782  global $ilCtrl, $ilTabs, $lng;
783 
784  $next_class = $this->ctrl->getNextClass($this);
785 
786  $cmd = $this->ctrl->getCmd();
787  //$this->ctrl->addTab("clipboard", $this->ctrl->getLinkTargetByClass("ilEditClipboardGUI", "view")
788  // , "view", "ilEditClipboardGUI");
789  $this->getTabs();
790 
791  $ilCtrl->setReturn($this, "edit");
792 
793  switch($next_class)
794  {
795  case 'ilmdeditorgui':
796  //$this->setTabs();
797  $ilTabs->setTabActive("meta_data");
798  include_once 'Services/MetaData/classes/class.ilMDEditorGUI.php';
799  $md_gui =& new ilMDEditorGUI($this->meta_data_rep_obj_id,
800  $this->meta_data_sub_obj_id, $this->meta_data_type);
801  if (is_object($this->meta_data_observer_obj))
802  {
803  $md_gui->addObserver($this->meta_data_observer_obj,
804  $this->meta_data_observer_func, "General");
805  }
806  $this->ctrl->forwardCommand($md_gui);
807  break;
808 
809  case "ileditclipboardgui":
810  //$this->tabs_gui->clearTargets();
811  //$this->ctrl->setReturn($this, "view");
812  $clip_gui = new ilEditClipboardGUI();
813  $clip_gui->setPageBackTitle($this->page_back_title);
814  //$ret =& $clip_gui->executeCommand();
815  $ret =& $this->ctrl->forwardCommand($clip_gui);
816  break;
817 
818  case 'ilpublicuserprofilegui':
819  require_once './Services/User/classes/class.ilPublicUserProfileGUI.php';
820  $profile_gui = new ilPublicUserProfileGUI($_GET["user"]);
821  $ret = $this->ctrl->forwardCommand($profile_gui);
822  break;
823 
824  case "ilpageeditorgui":
825  if (!$this->getEnableEditing())
826  {
827  ilUtil::sendInfo($lng->txt("permission_denied"), true);
828  $ilCtrl->redirect($this, "preview");
829  }
830  $page_editor =& new ilPageEditorGUI($this->getPageObject(), $this);
831  $page_editor->setLocator($this->locator);
832  $page_editor->setHeader($this->getHeader());
833  $page_editor->setPageBackTitle($this->page_back_title);
834  $page_editor->setIntLinkHelpDefault($this->int_link_def_type,
835  $this->int_link_def_id);
836  $page_editor->setIntLinkReturn($this->int_link_return);
837  //$page_editor->executeCommand();
838  $ret =& $this->ctrl->forwardCommand($page_editor);
839  break;
840 
841  default:
842  $cmd = $this->ctrl->getCmd("preview");
843  $ret = $this->$cmd();
844  break;
845  }
846 //echo "+$ret+";
847  return $ret;
848  }
849 
850  function deactivatePage()
851  {
852  $act_meth = $this->act_meth;
853  $this->act_obj->$act_meth(false);
854  $this->ctrl->redirectByClass("illmpageobjectgui", "edit");
855  }
856 
857  function activatePage()
858  {
859  $act_meth = $this->act_meth;
860  $this->act_obj->$act_meth(true);
861  $this->ctrl->redirectByClass("illmpageobjectgui", "edit");
862  }
863 
864  /*
865  * display content of page
866  */
867  function showPage()
868  {
869  global $tree, $ilUser, $ilias, $lng, $ilCtrl, $ilBench, $ilSetting;
870 
871  $ilBench->start("ContentPresentation", "ilPageObjectGUI_showPage");
872 
873  // init template
874  //if($this->outputToTemplate())
875  //{
876  if($this->getOutputMode() == "edit")
877  {
878 //echo ":".$this->getTemplateTargetVar().":";
879  $tpl = new ilTemplate("tpl.page_edit_wysiwyg.html", true, true, "Services/COPage");
880  //$this->tpl->addBlockFile($this->getTemplateTargetVar(), "adm_content", "tpl.page_edit_wysiwyg.html", "Services/COPage");
881 
882  // to do: status dependent class
883  $tpl->setVariable("CLASS_PAGE_TD", "ilc_Page");
884 
885  // user comment
886  if ($this->isEnabledChangeComments())
887  {
888  $tpl->setCurrentBlock("change_comment");
889  $tpl->setVariable("TXT_ADD_COMMENT", $this->lng->txt("cont_add_change_comment"));
890  $tpl->parseCurrentBlock();
891  $tpl->setCurrentBlock("adm_content");
892  }
893 
894  // explorer updater
895  if ($this->exp_frame != "")
896  {
897  $tpl->setCurrentBlock("updater");
898  $tpl->setVariable("UPDATER_FRAME", $this->exp_frame);
899  $tpl->setVariable("EXP_ID_UPDATER", $this->exp_id);
900  $tpl->setVariable("HREF_UPDATER", $this->exp_target_script);
901  $tpl->parseCurrentBlock();
902  }
903 
904 /* $tpl->setVariable("TXT_INSERT_BEFORE", $this->lng->txt("cont_set_before"));
905  $tpl->setVariable("TXT_INSERT_AFTER", $this->lng->txt("cont_set_after"));
906  $tpl->setVariable("TXT_INSERT_CANCEL", $this->lng->txt("cont_set_cancel"));
907  $tpl->setVariable("TXT_CONFIRM_DELETE", $this->lng->txt("cont_confirm_delete"));
908 */
909  $tpl->setVariable("WYSIWYG_ACTION",
910  $ilCtrl->getFormActionByClass("ilpageeditorgui", "", "", true));
911 
913  {
914  $tpl->setVariable("TXT_JAVA_SCRIPT_CAPABLE", "<br />".$this->lng->txt("cont_browser_not_js_capable"));
915  }
916  $tpl->setVariable("TXT_CHANGE_EDIT_MODE", $this->lng->txt("cont_set_edit_mode"));
917 
918  if ($this->getEnabledActivation())
919  {
920  $tpl->setCurrentBlock("de_activate_page");
921  if ($this->getActivated())
922  {
923  $tpl->setVariable("TXT_DE_ACTIVATE_PAGE", $this->lng->txt("cont_deactivate_page"));
924  $tpl->setVariable("CMD_DE_ACTIVATE_PAGE", "deactivatePage");
925  }
926  else
927  {
928  $tpl->setVariable("TXT_DE_ACTIVATE_PAGE", $this->lng->txt("cont_activate_page"));
929  $tpl->setVariable("CMD_DE_ACTIVATE_PAGE", "activatePage");
930  }
931  $tpl->parseCurrentBlock();
932  }
933 
934  $med_mode = array("enable" => $this->lng->txt("cont_enable_media"),
935  "disable" => $this->lng->txt("cont_disable_media"));
936  $sel_media_mode = ($ilUser->getPref("ilPageEditor_MediaMode") == "disable")
937  ? "disable"
938  : "enable";
939 
940  $js_mode = array("enable" => $this->lng->txt("cont_enable_js"),
941  "disable" => $this->lng->txt("cont_disable_js"));
942 
943  $tpl->setVariable("SEL_MEDIA_MODE",
944  ilUtil::formSelect($sel_media_mode, "media_mode", $med_mode, false, true,
945  0, "ilEditSelect"));
946 
947  // HTML active/inactive
948  $html_mode = array("enable" => $this->lng->txt("cont_enable_html"),
949  "disable" => $this->lng->txt("cont_disable_html"));
950  $sel_html_mode = ($ilUser->getPref("ilPageEditor_HTMLMode") == "disable")
951  ? "disable"
952  : "enable";
953  if (!$this->getPreventHTMLUnmasking())
954  {
955  $tpl->setVariable("SEL_HTML_MODE",
956  ilUtil::formSelect($sel_html_mode, "html_mode", $html_mode, false, true,
957  0, "ilEditSelect"));
958  }
959 
960  $tpl->setVariable("PREPENDING_HTML", $this->getPrependingHtml());
961  $tpl->setVariable("TXT_CONFIRM_DELETE", $lng->txt("cont_confirm_delete"));
962 
963  if ($this->getViewPageLink() != "")
964  {
965  $tpl->setCurrentBlock("view_link");
966  $tpl->setVariable("LINK_VIEW_PAGE",
967  $this->getViewPageLink());
968  $tpl->setVariable("TARGET_VIEW_PAGE",
969  $this->getViewPageTarget());
970  $tpl->setVariable("TXT_VIEW_PAGE", $this->lng->txt("view"));
971  $tpl->parseCurrentBlock();
972  }
973 
974  // javascript activation
975  $sel_js_mode = "disable";
976  if($ilSetting->get("enable_js_edit", 1))
977  {
978  $sel_js_mode = (ilPageEditorGUI::_doJSEditing())
979  ? "enable"
980  : "disable";
981  }
982 
983  // get js files for JS enabled editing
984  if ($sel_js_mode == "enable")
985  {
986  $this->insertHelp($tpl);
987  include_once("./Services/YUI/classes/class.ilYuiUtil.php");
990  $GLOBALS["tpl"]->addJavaScript("./Services/COPage/js/ilcopagecallback.js");
991  //$GLOBALS["tpl"]->addJavaScript("./Services/RTE/tiny_mce/tiny_mce.js");
992  $GLOBALS["tpl"]->addJavaScript("./Services/COPage/js/ilpageedit.js");
993  //$GLOBALS["tpl"]->addJavascript("Services/COPage/js/wz_dragdrop.js");
994  $GLOBALS["tpl"]->addJavascript("Services/COPage/js/page_editing.js");
995  $tpl->touchBlock("init_dragging");
996  }
997 
998  if($ilias->getSetting("enable_js_edit"))
999  {
1000  $tpl->setVariable("SEL_JAVA_SCRIPT",
1001  ilUtil::formSelect($sel_js_mode, "js_mode", $js_mode, false, true,
1002  0, "ilEditSelect"));
1003  }
1004 
1005  // multiple actions
1006  $tpl->setCurrentBlock("multi_actions");
1007  if ($sel_js_mode == "enable")
1008  {
1009  $tpl->setVariable("ONCLICK_DE_ACTIVATE_SELECTED", 'onclick="return ilEditMultiAction(\'activateSelected\');"');
1010  $tpl->setVariable("ONCLICK_DELETE_SELECTED", 'onclick="return ilEditMultiAction(\'deleteSelected\');"');
1011  }
1012  $tpl->setVariable("TXT_DE_ACTIVATE_SELECTED", $this->lng->txt("cont_ed_enable"));
1013  $tpl->setVariable("TXT_DELETE_SELECTED", $this->lng->txt("cont_delete_selected"));
1014  $tpl->setVariable("IMG_ARROW", ilUtil::getImagePath("arrow_downright.gif"));
1015  $tpl->parseCurrentBlock();
1016  }
1017  else
1018  {
1019  if($this->getOutputSubmode() == 'translation')
1020  {
1021  $tpl = new ilTemplate("tpl.page_translation_content.html", true, true, "Services/COPage");
1022  }
1023  else
1024  {
1025  // presentation
1026  if ($this->getOutputMode() != IL_PAGE_PREVIEW)
1027  {
1028  $tpl = new ilTemplate("tpl.page_content.html", true, true, "Services/COPage");
1029  if ($this->getEnabledPageFocus())
1030  {
1031  $tpl->touchBlock("page_focus");
1032  }
1033  }
1034  else // preview
1035  {
1036  $tpl = new ilTemplate("tpl.page_preview.html", true, true, "Services/COPage");
1037 
1038  //
1039  if ($_GET["old_nr"] > 0)
1040  {
1041  $hist_info =
1042  $this->getPageObject()->getHistoryInfo($_GET["old_nr"]);
1043 
1044  // previous revision
1045  if (is_array($hist_info["previous"]))
1046  {
1047  $tpl->setCurrentBlock("previous_rev");
1048  $tpl->setVariable("TXT_PREV_REV", $lng->txt("cont_previous_rev"));
1049  $ilCtrl->setParameter($this, "old_nr", $hist_info["previous"]["nr"]);
1050  $tpl->setVariable("HREF_PREV",
1051  $ilCtrl->getLinkTarget($this, "preview"));
1052  $tpl->parseCurrentBlock();
1053  }
1054  else
1055  {
1056  $tpl->setCurrentBlock("previous_rev_disabled");
1057  $tpl->setVariable("TXT_PREV_REV", $lng->txt("cont_previous_rev"));
1058  $tpl->parseCurrentBlock();
1059  }
1060 
1061  // next revision
1062  $tpl->setCurrentBlock("next_rev");
1063  $tpl->setVariable("TXT_NEXT_REV", $lng->txt("cont_next_rev"));
1064  $ilCtrl->setParameter($this, "old_nr", $hist_info["next"]["nr"]);
1065  $tpl->setVariable("HREF_NEXT",
1066  $ilCtrl->getLinkTarget($this, "preview"));
1067  $tpl->parseCurrentBlock();
1068 
1069  // latest revision
1070  $tpl->setCurrentBlock("latest_rev");
1071  $tpl->setVariable("TXT_LATEST_REV", $lng->txt("cont_latest_rev"));
1072  $ilCtrl->setParameter($this, "old_nr", "");
1073  $tpl->setVariable("HREF_LATEST",
1074  $ilCtrl->getLinkTarget($this, "preview"));
1075  $tpl->parseCurrentBlock();
1076 
1077  $tpl->setCurrentBlock("hist_nav");
1078  $tpl->setVariable("TXT_REVISION", $lng->txt("cont_revision"));
1079  $tpl->setVariable("VAL_REVISION_DATE",
1080  ilDatePresentation::formatDate(new ilDateTime($hist_info["current"]["hdate"], IL_CAL_DATETIME)));
1081  $login = ilObjUser::_lookupLogin($hist_info["current"]["user"]);
1082  $name = ilObjUser::_lookupName($hist_info["current"]["user"]);
1083  $tpl->setVariable("VAL_REV_USER",
1084  $name["lastname"].", ".$name["firstname"]." [".$login."]");
1085  $tpl->parseCurrentBlock();
1086  }
1087  }
1088  }
1089  }
1090  if ($this->getOutputMode() != IL_PAGE_PRESENTATION &&
1091  $this->getOutputMode() != IL_PAGE_OFFLINE &&
1092  $this->getOutputMode() != IL_PAGE_PREVIEW &&
1093  $this->getOutputMode() != IL_PAGE_PRINT)
1094  {
1095  $tpl->setVariable("FORMACTION", $this->ctrl->getFormActionByClass("ilpageeditorgui"));
1096  }
1097 
1098  // output media object edit list (of media links)
1099  if($this->getOutputMode() == "edit")
1100  {
1101  $links = ilInternalLink::_getTargetsOfSource($this->obj->getParentType().":pg",
1102  $this->obj->getId());
1103  $mob_links = array();
1104  foreach($links as $link)
1105  {
1106  if ($link["type"] == "mob")
1107  {
1108  if (ilObject::_exists($link["id"]) && ilObject::_lookupType($link["id"]) == "mob")
1109  {
1110  $mob_links[$link["id"]] = ilObject::_lookupTitle($link["id"])." [".$link["id"]."]";
1111  }
1112  }
1113  }
1114 
1115  if (count($mob_links) > 0)
1116  {
1117  $tpl->setCurrentBlock("med_link");
1118  $tpl->setVariable("TXT_LINKED_MOBS", $this->lng->txt("cont_linked_mobs"));
1119  $tpl->setVariable("SEL_MED_LINKS",
1120  ilUtil::formSelect(0, "mob_id", $mob_links, false, true));
1121  $tpl->setVariable("TXT_EDIT_MEDIA", $this->lng->txt("cont_edit_mob"));
1122  $tpl->setVariable("TXT_COPY_TO_CLIPBOARD", $this->lng->txt("cont_copy_to_clipboard"));
1123  //$this->tpl->setVariable("TXT_COPY_TO_POOL", $this->lng->txt("cont_copy_to_mediapool"));
1124  $tpl->parseCurrentBlock();
1125  }
1126  }
1127 
1128  if ($_GET["reloadTree"] == "y")
1129  {
1130  $tpl->setCurrentBlock("reload_tree");
1131  if ($this->obj->getParentType() == "dbk")
1132  {
1133  $tpl->setVariable("LINK_TREE",
1134  $this->ctrl->getLinkTargetByClass("ilobjdlbookgui", "explorer"));
1135  }
1136  else
1137  {
1138  $tpl->setVariable("LINK_TREE",
1139  $this->ctrl->getLinkTargetByClass("ilobjlearningmodulegui", "explorer"));
1140  }
1141  $tpl->parseCurrentBlock();
1142  }
1143 // }
1144 
1145  // get content
1146  $builded = $this->obj->buildDom();
1147 
1148  // manage hierarchical ids
1149  if($this->getOutputMode() == "edit")
1150  {
1151 
1152  // add pc ids, if necessary
1153  if (!$this->obj->checkPCIds())
1154  {
1155  $this->obj->insertPCIds();
1156  $this->obj->update(true, true);
1157  }
1158 
1159  $this->obj->addFileSizes();
1160  $this->obj->addHierIDs();
1161 
1162  $hids = $this->obj->getHierIds();
1163  $row1_ids = $this->obj->getFirstRowIds();
1164  $col1_ids = $this->obj->getFirstColumnIds();
1165  $litem_ids = $this->obj->getListItemIds();
1166  $fitem_ids = $this->obj->getFileItemIds();
1167 
1168  // standard menues
1169  $hids = $this->obj->getHierIds();
1170  foreach($hids as $hid)
1171  {
1172  $tpl->setCurrentBlock("add_dhtml");
1173  $tpl->setVariable("CONTEXTMENU", "contextmenu_".$hid);
1174  $tpl->parseCurrentBlock();
1175  }
1176 
1177  // column menues for tables
1178  foreach($col1_ids as $hid)
1179  {
1180  $tpl->setCurrentBlock("add_dhtml");
1181  $tpl->setVariable("CONTEXTMENU", "contextmenu_r".$hid);
1182  $tpl->parseCurrentBlock();
1183  }
1184 
1185  // row menues for tables
1186  foreach($row1_ids as $hid)
1187  {
1188  $tpl->setCurrentBlock("add_dhtml");
1189  $tpl->setVariable("CONTEXTMENU", "contextmenu_c".$hid);
1190  $tpl->parseCurrentBlock();
1191  }
1192 
1193  // list item menues
1194  foreach($litem_ids as $hid)
1195  {
1196  $tpl->setCurrentBlock("add_dhtml");
1197  $tpl->setVariable("CONTEXTMENU", "contextmenu_i".$hid);
1198  $tpl->parseCurrentBlock();
1199  }
1200 
1201  // file item menues
1202  foreach($fitem_ids as $hid)
1203  {
1204  $tpl->setCurrentBlock("add_dhtml");
1205  $tpl->setVariable("CONTEXTMENU", "contextmenu_i".$hid);
1206  $tpl->parseCurrentBlock();
1207  }
1208  }
1209  else
1210  {
1211  $this->obj->addFileSizes();
1212  }
1213 
1214 //echo "<br>-".htmlentities($this->obj->getXMLContent())."-<br><br>";
1215 //echo "<br>-".htmlentities($this->getLinkXML())."-";
1216 
1217  // set default link xml, if nothing was set yet
1218  if (!$this->link_xml_set)
1219  {
1220  $this->setDefaultLinkXml();
1221  }
1222 
1223  //$content = $this->obj->getXMLFromDom(false, true, true,
1224  // $this->getLinkXML().$this->getQuestionXML().$this->getComponentPluginsXML());
1225  $link_xml = $this->getLinkXML();
1226  $content = $this->obj->getXMLFromDom(false, true, true,
1227  $link_xml.$this->getQuestionXML());
1228 
1229  // get page component plugins
1230 
1231  // check validation errors
1232  if($builded !== true)
1233  {
1234  $this->displayValidationError($builded);
1235  }
1236  else
1237  {
1238  $this->displayValidationError($_SESSION["il_pg_error"]);
1239  }
1240  unset($_SESSION["il_pg_error"]);
1241 
1242  if(isset($_SESSION["citation_error"]))
1243  {
1244  ilUtil::sendInfo($this->lng->txt("cont_citation_selection_not_valid"));
1245  session_unregister("citation_error");
1246  unset($_SESSION["citation_error"]);
1247  }
1248 
1249  // get title
1250  $pg_title = $this->getPresentationTitle();
1251 
1252  $add_path = ilUtil::getImagePath("add.gif");
1253  $col_path = ilUtil::getImagePath("col.gif");
1254  $row_path = ilUtil::getImagePath("row.gif");
1255  $item_path = ilUtil::getImagePath("item.gif");
1256  $med_disabled_path = ilUtil::getImagePath("media_disabled.gif");
1257 
1258  if ($this->getOutputMode() != "offline")
1259  {
1260  $enlarge_path = ilUtil::getImagePath("enlarge.gif");
1261  $wb_path = ilUtil::getWebspaceDir("output");
1262  }
1263  else
1264  {
1265  $enlarge_path = "images/enlarge.gif";
1266  $wb_path = ".";
1267  }
1268  $pg_title_class = ($this->getOutputMode() == "print")
1269  ? "ilc_PrintPageTitle"
1270  : "";
1271 
1272  // page splitting only for learning modules and
1273  // digital books
1274  $enable_split_new = ($this->obj->getParentType() == "lm" ||
1275  $this->obj->getParentType() == "dbk")
1276  ? "y"
1277  : "n";
1278 
1279  // page splitting to next page only for learning modules and
1280  // digital books if next page exists in tree
1281  if (($this->obj->getParentType() == "lm" ||
1282  $this->obj->getParentType() == "dbk") &&
1283  ilObjContentObject::hasSuccessorPage($this->obj->getParentId(),
1284  $this->obj->getId()))
1285  {
1286  $enable_split_next = "y";
1287  }
1288  else
1289  {
1290  $enable_split_next = "n";
1291  }
1292 
1293 
1294  $paragraph_plugins = new ilParagraphPlugins();
1295  $paragraph_plugins->initialize ();
1296 
1297  if ($this->getOutputMode() == IL_PAGE_PRESENTATION)
1298  {
1299  $paragraph_plugin_string = $paragraph_plugins->serializeToString();
1300  $_SESSION ["paragraph_plugins"] = $paragraph_plugins;
1301  }
1302 
1303  $img_path = ilUtil::getImagePath("", false, $this->getOutputMode(), $this->getOutputMode() == "offline");
1304 
1305  //$wb_path = "../".$this->ilias->ini->readVariable("server","webspace_dir");
1306  //echo "-".$this->sourcecode_download_script.":";
1307 
1308  if ($this->getEnabledPCTabs())
1309  {
1310  include_once("./Services/YUI/classes/class.ilYuiUtil.php");
1312  }
1313 
1314  // default values for various parameters (should be used by
1315  // all instances in the future)
1316  $file_download_link = $this->getFileDownloadLink();
1317  if ($this->getFileDownloadLink() == "" && $this->getOutputMode() != "offline")
1318  {
1319  $file_download_link = $ilCtrl->getLinkTarget($this, "downloadFile");
1320  }
1321 
1322  $fullscreen_link = $this->getFullscreenLink();
1323  if ($this->getFullscreenLink() == "" && $this->getOutputMode() != "offline")
1324  {
1325  $fullscreen_link = $ilCtrl->getLinkTarget($this, "displayMediaFullscreen");
1326  }
1327 
1328  if ($this->sourcecode_download_script == "" && $this->getOutputMode() != "offline")
1329  {
1330  $this->sourcecode_download_script = $ilCtrl->getLinkTarget($this, "");
1331  }
1332  $media_mode = ($this->getOutputMode() == "edit")
1333  ? $ilUser->getPref("ilPageEditor_MediaMode")
1334  : "enable";
1335 
1336  // added UTF-8 encoding otherwise umlaute are converted too
1337  $params = array ('mode' => $this->getOutputMode(), 'pg_title' => htmlentities($pg_title,ENT_QUOTES,"UTF-8"),
1338  'pg_id' => $this->obj->getId(), 'pg_title_class' => $pg_title_class,
1339  'webspace_path' => $wb_path, 'enlarge_path' => $enlarge_path,
1340  'img_add' => $add_path,
1341  'img_col' => $col_path,
1342  'img_row' => $row_path,
1343  'img_item' => $item_path,
1344  'enable_split_new' => $enable_split_new,
1345  'enable_split_next' => $enable_split_next,
1346  'link_params' => $this->link_params,
1347  'file_download_link' => $file_download_link,
1348  'fullscreen_link' => $fullscreen_link,
1349  'med_disabled_path' => $med_disabled_path,
1350  'img_path' => $img_path,
1351  'parent_id' => $this->obj->getParentId(),
1352  'download_script' => $this->sourcecode_download_script,
1353  'encoded_download_script' => urlencode($this->sourcecode_download_script),
1354  // digilib
1355  'bib_id' => $this->getBibId(),'citation' => (int) $this->isEnabledCitation(),
1356  'pagebreak' => $this->lng->txt('dgl_pagebreak'),
1357  'page' => $this->lng->txt('page'),
1358  'citate_page' => $this->lng->txt('citate_page'),
1359  'citate_from' => $this->lng->txt('citate_from'),
1360  'citate_to' => $this->lng->txt('citate_to'),
1361  'citate' => $this->lng->txt('citate'),
1362  'enable_rep_objects' => $this->getEnabledRepositoryObjects() ? "y" : "n",
1363  'enable_map' => $this->getEnabledMaps() ? "y" : "n",
1364  'enable_tabs' => $this->getEnabledPCTabs() ? "n" : "n",
1365  'enable_file_list' => $this->getEnabledFileLists() ? "y" : "n",
1366  'media_mode' => $media_mode,
1367  'javascript' => $sel_js_mode,
1368  'paragraph_plugins' => $paragraph_plugin_string);
1369 
1370  if($this->link_frame != "") // todo other link types
1371  $params["pg_frame"] = $this->link_frame;
1372 
1373  //$content = str_replace("&nbsp;", "", $content);
1374 
1375  // this ensures that cache is emptied with every update
1376  $params["version"] = ILIAS_VERSION;
1377 
1378  // ensure no cache hit, if included files/media objects have been changed
1379  $params["incl_elements_date"] = $this->obj->getLastUpdateOfIncludedElements();
1380 
1381  // run xslt
1382 
1383  $md5 = md5(serialize($params).$link_xml);
1384 
1385 //$a = microtime();
1386 
1387  // check cache (same parameters, non-edit mode and rendered time
1388  // > last change
1389  if (($this->getOutputMode() == "preview" || $this->getOutputMode() == "presentation") &&
1390  $md5 == $this->obj->getRenderMd5() &&
1391  ($this->obj->getLastChange() < $this->obj->getRenderedTime()) &&
1392  $this->obj->getRenderedTime() != "0000-00-00 00:00:00" &&
1393  $this->obj->old_nr == 0)
1394  {
1395  // cache hit
1396  $output = $this->obj->getRenderedContent();
1397  }
1398  else
1399  {
1400  $xsl = file_get_contents("./Services/COPage/xsl/page.xsl");
1401  $args = array( '/_xml' => $content, '/_xsl' => $xsl );
1402  $xh = xslt_create();
1403  // echo "<b>XSLT</b>:".htmlentities($xsl).":<br>";
1404  // echo "mode:".$this->getOutputMode().":<br>";
1405  $output = xslt_process($xh, "arg:/_xml","arg:/_xsl", NULL, $args, $params);
1406 
1407  if (($this->getOutputMode() == "presentation" || $this->getOutputMode() == "preview")
1408  && $this->obj->old_nr == 0)
1409  {
1410 //echo "writerenderedcontent";
1411  $this->obj->writeRenderedContent($output, $md5);
1412  }
1413  //echo xslt_error($xh);
1414  xslt_free($xh);
1415  }
1416 
1417 //$b = microtime();
1418 //echo "$a - $b";
1419 //echo "<pre>".htmlentities($output)."</pre>";
1420  // unmask user html
1421  if (($this->getOutputMode() != "edit" ||
1422  $ilUser->getPref("ilPageEditor_HTMLMode") != "disable")
1423  && !$this->getPreventHTMLUnmasking())
1424  {
1425  $output = str_replace("&lt;","<",$output);
1426  $output = str_replace("&gt;",">",$output);
1427  }
1428  $output = str_replace("&amp;", "&", $output);
1429  // replace latex code: todo: finish
1430  if ($this->getOutputMode() != "offline")
1431  {
1432  $output = ilUtil::insertLatexImages($output);
1433  }
1434  else
1435  {
1436  $output = ilUtil::buildLatexImages($output,
1437  $this->getOfflineDirectory());
1438  }
1439 
1440  // (horrible) workaround for preventing template engine
1441  // from hiding paragraph text that is enclosed
1442  // in curly brackets (e.g. "{a}", see ilLMEditorGUI::executeCommand())
1443  $output = str_replace("{", "&#123;", $output);
1444  $output = str_replace("}", "&#125;", $output);
1445 
1446 
1447 //echo "<b>HTML</b>:".htmlentities($output).":<br>";
1448 
1449  // remove all newlines (important for code / pre output)
1450  $output = str_replace("\n", "", $output);
1451 
1452  $qhtml = $this->getQuestionHTML();
1453  if (strlen($qhtml))
1454  {
1455  // removed simple str_replace with preg_replace because if the question content
1456  // is part of a table, the xmlns isn't added and the question content wasn't visible then
1457  // Helmut Schottmüller, 2006-11-15
1458  //$output = preg_replace("/(<div( xmlns:xhtml\=\"http:\/\/www.w3.org\/1999\/xhtml\"){0,1} class\=\"ilc_Question\">)/ims", "\\1" . $qhtml, $output);
1459  $output = str_replace("[[[[[Question;]]]]]", $qhtml, $output);
1460  // old source code prior to the preg_replace change
1461  // $question_prefix = "<div xmlns:xhtml=\"http://www.w3.org/1999/xhtml\" class=\"ilc_Question\">";
1462  // $output = str_replace($question_prefix, $question_prefix . $qhtml, $output);
1463  }
1464 //echo htmlentities($output);
1465  $output = $this->postOutputProcessing($output);
1466 //echo htmlentities($output);
1467  if($this->getOutputMode() == "edit" && !$this->getActivated())
1468  {
1469  $output = '<div class="il_editarea_disabled">'.$output.'</div>';
1470  }
1471 
1472  $output = $this->insertMaps($output);
1473  $output = $this->obj->insertSourceCodeParagraphs($output, $this->getOutputMode());
1474 
1475  $ilBench->stop("ContentPresentation", "ilPageObjectGUI_showPage");
1476 
1477  // output
1478  if ($ilCtrl->isAsynch())
1479  {
1480  $tpl->setVariable($this->getTemplateOutputVar(), $output);
1481  echo $tpl->get();
1482  exit;
1483 
1484  $tpl->setVariable($this->getTemplateOutputVar(), $output);
1485  $tpl->setCurrentBlock("adm_content");
1486  $tpl->parseCurrentBlock();
1487  echo $tpl->get("adm_content");
1488  exit;
1489  }
1490  if ($this->outputToTemplate())
1491  {
1492  $tpl->setVariable($this->getTemplateOutputVar(), $output);
1493  $this->tpl->setVariable($this->getTemplateTargetVar(), $tpl->get());
1494  return $output;
1495  }
1496  else
1497  {
1498  if ($this->getRawPageContent()) // e.g. needed in glossaries
1499  {
1500  return $output;
1501  }
1502  else
1503  {
1504  $tpl->setVariable($this->getTemplateOutputVar(), $output);
1505  return $tpl->get();
1506  }
1507  }
1508  }
1509 
1514  {
1515  $int_links = $this->getPageObject()->getInternalLinks();
1516 
1517  $link_info = "<IntLinkInfos>";
1518  $targetframe = "None";
1519  foreach ($int_links as $int_link)
1520  {
1521  $target = $int_link["Target"];
1522  if (substr($target, 0, 4) == "il__")
1523  {
1524  $target_arr = explode("_", $target);
1525  $target_id = $target_arr[count($target_arr) - 1];
1526  $type = $int_link["Type"];
1527 
1528  switch($type)
1529  {
1530  case "PageObject":
1531  case "StructureObject":
1533  $ltarget="_top";
1534  if ($type == "PageObject")
1535  {
1536  $href = "./goto.php?target=pg_".$target_id;
1537  }
1538  else
1539  {
1540  $href = "./goto.php?target=st_".$target_id;
1541  }
1542  break;
1543 
1544  case "GlossaryItem":
1545  $ltarget="_blank";
1546  $href = "./goto.php?target=git_".$target_id;
1547  break;
1548 
1549  case "MediaObject":
1550  $ltarget="_blank";
1551  $href = "";
1552  break;
1553 
1554  case "RepositoryItem":
1555  $ltarget="_top";
1556  $obj_type = ilObject::_lookupType($target_id, true);
1558  $href = "./goto.php?target=".$obj_type."_".$target_id;
1559  break;
1560 
1561  }
1562  $link_info.="<IntLinkInfo Target=\"$target\" Type=\"$type\" ".
1563  "TargetFrame=\"$targetframe\" LinkHref=\"$href\" LinkTarget=\"$ltarget\" />";
1564  }
1565  }
1566  $link_info.= "</IntLinkInfos>";
1567  $this->setLinkXML($link_info);
1568  }
1569 
1573  function downloadFile()
1574  {
1575  $file = explode("_", $_GET["file_id"]);
1576  require_once("./Modules/File/classes/class.ilObjFile.php");
1577  $fileObj =& new ilObjFile($file[count($file) - 1], false);
1578  $fileObj->sendFile();
1579  exit;
1580  }
1581 
1586  {
1587  $tpl = new ilTemplate("tpl.fullscreen.html", true, true, "Modules/LearningModule");
1588  $tpl->setCurrentBlock("ilMedia");
1589 
1590  //$int_links = $page_object->getInternalLinks();
1591  $med_links = ilMediaItem::_getMapAreasIntLinks($_GET["mob_id"]);
1592 
1593  // @todo
1594  //$link_xml = $this->getLinkXML($med_links, $this->getLayoutLinkTargets());
1595 
1596  require_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1597  $media_obj = new ilObjMediaObject($_GET["mob_id"]);
1598  require_once("./Services/COPage/classes/class.ilPageObject.php");
1599  $pg_obj = $this->getPageObject();
1600  $pg_obj->buildDom();
1601 
1602  $xml = "<dummy>";
1603  // todo: we get always the first alias now (problem if mob is used multiple
1604  // times in page)
1605  $xml.= $pg_obj->getMediaAliasElement($_GET["mob_id"]);
1606  $xml.= $media_obj->getXML(IL_MODE_OUTPUT);
1607  $xml.= $link_xml;
1608  $xml.="</dummy>";
1609 
1610  $xsl = file_get_contents("./Services/COPage/xsl/page.xsl");
1611  $args = array( '/_xml' => $xml, '/_xsl' => $xsl );
1612  $xh = xslt_create();
1613 
1614 //echo "<b>XML:</b>".htmlentities($xml);
1615  // determine target frames for internal links
1616  $wb_path = ilUtil::getWebspaceDir("output");
1617  $enlarge_path = ilUtil::getImagePath("enlarge.gif");
1618  $params = array ('mode' => "fullscreen", 'enlarge_path' => $enlarge_path,
1619  'link_params' => "ref_id=".$_GET["ref_id"],'fullscreen_link' => "",
1620  'ref_id' => $_GET["ref_id"], 'webspace_path' => $wb_path);
1621  $output = xslt_process($xh,"arg:/_xml","arg:/_xsl",NULL,$args, $params);
1622  //echo xslt_error($xh);
1623  xslt_free($xh);
1624 
1625  // unmask user html
1626  $tpl->setVariable("LOCATION_CONTENT_STYLESHEET",
1628  $tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
1629  $tpl->setVariable("MEDIA_CONTENT", $output);
1630  echo $tpl->get();
1631  exit;
1632  }
1633 
1638  {
1639  $pg_obj = $this->getPageObject();
1640  $pg_obj->send_paragraph($_GET["par_id"], $_GET["downloadtitle"]);
1641  }
1642 
1646  function insertMaps($a_html)
1647  {
1648  $c_pos = 0;
1649  $start = strpos($a_html, "[[[[[Map;");
1650  if (is_int($start))
1651  {
1652  $end = strpos($a_html, "]]]]]", $start);
1653  }
1654  $i = 1;
1655  while ($end > 0)
1656  {
1657  $param = substr($a_html, $start + 9, $end - $start - 9);
1658 
1659  $param = explode(";", $param);
1660  if (is_numeric($param[0]) && is_numeric($param[1]) && is_numeric($param[2]))
1661  {
1662  include_once("./Services/GoogleMaps/classes/class.ilGoogleMapGUI.php");
1663  $map_gui = new ilGoogleMapGUI();
1664  $map_gui->setMapId("map_".$i);
1665  $map_gui->setLatitude($param[0]);
1666  $map_gui->setLongitude($param[1]);
1667  $map_gui->setZoom($param[2]);
1668  $map_gui->setWidth($param[3]."px");
1669  $map_gui->setHeight($param[4]."px");
1670  $map_gui->setEnableTypeControl(true);
1671  $map_gui->setEnableNavigationControl(true);
1672  $map_gui->setEnableCentralMarker(true);
1673  $h2 = substr($a_html, 0, $start).
1674  $map_gui->getHtml().
1675  substr($a_html, $end + 5);
1676  $a_html = $h2;
1677  $i++;
1678  }
1679  $start = strpos($a_html, "[[[[[Map;", $start + 5);
1680  $end = 0;
1681  if (is_int($start))
1682  {
1683  $end = strpos($a_html, "]]]]]", $start);
1684  }
1685  }
1686 
1687  return $a_html;
1688  }
1689 
1694  function postOutputProcessing($a_output)
1695  {
1696  return $a_output;
1697  }
1698 
1702  function insertHelp($a_tpl)
1703  {
1704  global $lng;
1705 
1706  $a_tpl->setCurrentBlock("help_img");
1707  $a_tpl->setVariable("IMG_HELP", ilUtil::getImagePath("streaked_area.gif"));
1708  $a_tpl->parseCurrentBlock();
1709  $a_tpl->setCurrentBlock("help_item");
1710  $a_tpl->setVariable("TXT_HELP", $lng->txt("cont_add_elements"));
1711  $a_tpl->parseCurrentBlock();
1712 
1713  $a_tpl->setCurrentBlock("help_img");
1714  $a_tpl->setVariable("IMG_HELP", ilUtil::getImagePath("icon_cont_el_s.gif"));
1715  $a_tpl->parseCurrentBlock();
1716  $a_tpl->setCurrentBlock("help_img");
1717  $a_tpl->setVariable("IMG_HELP", ilUtil::getImagePath("drop_streaked_area.gif"));
1718  $a_tpl->parseCurrentBlock();
1719  $a_tpl->setCurrentBlock("help_item");
1720  $a_tpl->setVariable("TXT_HELP", $lng->txt("cont_drag_and_drop_elements"));
1721  $a_tpl->parseCurrentBlock();
1722 
1723  $a_tpl->setCurrentBlock("help_img");
1724  $a_tpl->setVariable("IMG_HELP", ilUtil::getImagePath("icon_cont_el_s.gif"));
1725  $a_tpl->parseCurrentBlock();
1726  $a_tpl->setCurrentBlock("help_item");
1727  $a_tpl->setVariable("TXT_HELP", $lng->txt("cont_double_click_to_delete"));
1728  $a_tpl->parseCurrentBlock();
1729 
1730  $a_tpl->setCurrentBlock("help");
1731  $a_tpl->parseCurrentBlock();
1732  }
1733 
1734  /*
1735  * preview
1736  */
1737  function preview()
1738  {
1739  global $tree;
1741  return $this->showPage();
1742  }
1743 
1744  /*
1745  * edit ("view" before)
1746  */
1747  function edit()
1748  {
1749  global $tree, $lng, $ilCtrl;
1750 
1751  if (!$this->getEnableEditing())
1752  {
1753  ilUtil::sendInfo($lng->txt("permission_denied"), true);
1754  $ilCtrl->redirect($this, "preview");
1755  }
1756 
1757  $this->setOutputMode(IL_PAGE_EDIT);
1758  return $this->showPage();
1759  }
1760 
1761  /*
1762  * presentation
1763  */
1765  {
1766  global $tree;
1767  $this->setOutputMode($a_mode);
1768 
1769  return $this->showPage();
1770  }
1771 
1772  function getHTML()
1773  {
1774  $this->getTabs("preview");
1775  return $this->showPage();
1776  }
1777 
1781  function showMediaFullscreen($a_style_id = 0)
1782  {
1783  $this->tpl = new ilTemplate("tpl.fullscreen.html", true, true, "Services/COPage");
1784  $this->tpl->setCurrentBlock("ContentStyle");
1785  $this->tpl->setVariable("LOCATION_CONTENT_STYLESHEET", 0);
1786  $this->tpl->parseCurrentBlock();
1787 
1788  $this->tpl->setVariable("PAGETITLE", " - ".ilObject::_lookupTitle($_GET["mob_id"]));
1789  $this->tpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation());
1790  $this->tpl->setCurrentBlock("ilMedia");
1791 
1792  require_once("./Services/MediaObjects/classes/class.ilObjMediaObject.php");
1793  $media_obj =& new ilObjMediaObject($_GET["mob_id"]);
1794  if (!empty ($_GET["pg_id"]))
1795  {
1796  require_once("./Services/COPage/classes/class.ilPageObject.php");
1797  $pg_obj =& new ilPageObject($this->obj->getParentType(), $_GET["pg_id"]);
1798  $pg_obj->buildDom();
1799 
1800  $xml = "<dummy>";
1801  // todo: we get always the first alias now (problem if mob is used multiple
1802  // times in page)
1803  $xml.= $pg_obj->getMediaAliasElement($_GET["mob_id"]);
1804  $xml.= $media_obj->getXML(IL_MODE_OUTPUT);
1805  $xml.="</dummy>";
1806  }
1807  else
1808  {
1809  $xml = "<dummy>";
1810  $xml.= $media_obj->getXML(IL_MODE_ALIAS);
1811  $xml.= $media_obj->getXML(IL_MODE_OUTPUT);
1812  $xml.="</dummy>";
1813  }
1814 
1815 //echo htmlentities($xml); exit;
1816 
1817  $xsl = file_get_contents("./Services/COPage/xsl/page.xsl");
1818  $args = array( '/_xml' => $xml, '/_xsl' => $xsl );
1819  $xh = xslt_create();
1820 
1821 //echo "<b>XML:</b>".htmlentities($xml);
1822  // determine target frames for internal links
1823  //$pg_frame = $_GET["frame"];
1824  $wb_path = ilUtil::getWebspaceDir("output");
1825 // $wb_path = "../".$this->ilias->ini->readVariable("server","webspace_dir");
1826  $mode = "fullscreen";
1827  $params = array ('mode' => $mode, 'webspace_path' => $wb_path);
1828  $output = xslt_process($xh,"arg:/_xml","arg:/_xsl",NULL,$args, $params);
1829  echo xslt_error($xh);
1830  xslt_free($xh);
1831 
1832  // unmask user html
1833  $this->tpl->setVariable("MEDIA_CONTENT", $output);
1834  }
1835 
1841  function displayValidationError($a_error)
1842  {
1843  if(is_array($a_error))
1844  {
1845  $error_str = "<b>Validation Error(s):</b><br>";
1846  foreach ($a_error as $error)
1847  {
1848  $err_mess = implode($error, " - ");
1849  if (!is_int(strpos($err_mess, ":0:")))
1850  {
1851  $error_str .= htmlentities($err_mess)."<br />";
1852  }
1853  }
1854  $this->tpl->setVariable("MESSAGE", $error_str);
1855  }
1856  }
1857 
1861  function history()
1862  {
1863  global $tpl, $lng, $ilAccess;
1864 
1865  $tpl->addJavaScript("./Services/COPage/js/page_history.js");
1866 
1867  include_once("./Services/COPage/classes/class.ilPageHistoryTableGUI.php");
1868  $table_gui = new ilPageHistoryTableGUI($this, "history");
1869  $table_gui->setId("hist_table");
1870  $entries = $this->getPageObject()->getHistoryEntries();
1871  $entries[] = array('page_id' => $this->getPageObject()->getId(),
1872  'parent_type' => $this->getPageObject()->getParentType(),
1873  'hdate' => $this->getPageObject()->getLastChange(),
1874  'parent_id' => $this->getPageObject()->getParentId(),
1875  'nr' => 0,
1876  'sortkey' => 999999,
1877  'user' => $this->getPageObject()->last_change_user);
1878  $table_gui->setData($entries);
1879  return $table_gui->getHTML();
1880  }
1881 
1886  {
1887  global $tpl, $lng, $ilAccess, $ilCtrl;
1888 
1889  include_once("Services/Utilities/classes/class.ilConfirmationGUI.php");
1890  $c_gui = new ilConfirmationGUI();
1891 
1892  // set confirm/cancel commands
1893  $ilCtrl->setParameter($this, "rollback_nr", $_GET["old_nr"]);
1894  $c_gui->setFormAction($ilCtrl->getFormAction($this, "rollback"));
1895  $c_gui->setHeaderText($lng->txt("cont_rollback_confirmation"));
1896  $c_gui->setCancel($lng->txt("cancel"), "history");
1897  $c_gui->setConfirm($lng->txt("confirm"), "rollback");
1898 
1899  $hentry = $this->obj->getHistoryEntry($_GET["old_nr"]);
1900 
1901  $c_gui->addItem("id[]", $_GET["old_nr"],
1903 
1904  $tpl->setContent($c_gui->getHTML());
1905  }
1906 
1910  function rollback()
1911  {
1912  global $ilCtrl;
1913 
1914  $hentry = $this->obj->getHistoryEntry($_GET["rollback_nr"]);
1915 
1916  if ($hentry["content"] != "")
1917  {
1918  $this->obj->setXMLContent($hentry["content"]);
1919  $this->obj->buildDom(true);
1920  if ($this->obj->update())
1921  {
1922  $ilCtrl->redirect($this, "history");
1923  }
1924  }
1925  $ilCtrl->redirect($this, "history");
1926  }
1927 
1933  function getTabs($a_activate = "")
1934  {
1935  global $ilTabs, $ilCtrl;
1936 
1937  if (!$this->getEnabledTabs())
1938  {
1939  return;
1940  }
1941 
1942 //echo "-".$ilCtrl->getNextClass()."-".$ilCtrl->getCmd()."-";
1943  // back to upper context
1944 
1945  if (!$this->getEditPreview())
1946  {
1947  $ilTabs->addTarget("pg", $ilCtrl->getLinkTarget($this, "preview")
1948  , array("", "preview"));
1949 
1950  if ($this->getEnableEditing())
1951  {
1952  $ilTabs->addTarget("edit", $ilCtrl->getLinkTarget($this, "edit")
1953  , array("", "edit"));
1954  }
1955  }
1956  else
1957  {
1958  if ($this->getEnableEditing())
1959  {
1960  $ilTabs->addTarget("edit", $ilCtrl->getLinkTarget($this, "edit")
1961  , array("", "edit"));
1962  }
1963 
1964  $ilTabs->addTarget("cont_preview", $ilCtrl->getLinkTarget($this, "preview")
1965  , array("", "preview"));
1966  }
1967 
1968  //$tabs_gui->addTarget("properties", $this->ctrl->getLinkTarget($this, "properties")
1969  // , "properties", get_class($this));
1970 
1971  if ($this->use_meta_data)
1972  {
1973  $ilTabs->addTarget("meta_data",
1974  $this->ctrl->getLinkTargetByClass('ilmdeditorgui',''),
1975  "", "ilmdeditorgui");
1976  }
1977 
1978  if ($this->getEnableEditing())
1979  {
1980  $ilTabs->addTarget("history", $this->ctrl->getLinkTarget($this, "history")
1981  , "history", get_class($this));
1982  }
1983 
1984 /* $tabs = $this->ctrl->getTabs();
1985  foreach ($tabs as $tab)
1986  {
1987  $tabs_gui->addTarget($tab["lang_var"], $tab["link"]
1988  , $tab["cmd"], $tab["class"]);
1989  }
1990 */
1991  if ($this->getEnableEditing())
1992  {
1993  $ilTabs->addTarget("clipboard", $this->ctrl->getLinkTargetByClass("ilEditClipboardGUI", "view")
1994  , "view", "ilEditClipboardGUI");
1995  }
1996 
1997  //$ilTabs->setTabActive("pg");
1998  }
1999 
2003  function compareVersion()
2004  {
2005  global $lng;
2006 
2007  $tpl = new ilTemplate("tpl.page_compare.html", true, true, "Services/COPage");
2008  $compare = $this->obj->compareVersion($_POST["left"], $_POST["right"]);
2009 
2010  // left page
2011  $lpage = $compare["l_page"];
2012  $lpage_gui = new ilPageObjectGUI("wpg");
2013  $lpage_gui->setOutputMode(IL_PAGE_PREVIEW);
2014  $lpage_gui->setPageObject($lpage);
2015  $lpage_gui->setPreventHTMLUnmasking(true);
2016  $lhtml = $lpage_gui->showPage();
2017  $lhtml = $this->replaceDiffTags($lhtml);
2018  $lhtml = str_replace("&lt;br /&gt;", "<br />", $lhtml);
2019  $tpl->setVariable("LEFT", $lhtml);
2020 
2021  // right page
2022  $rpage = $compare["r_page"];
2023  $rpage_gui = new ilPageObjectGUI("wpg");
2024  $rpage_gui->setOutputMode(IL_PAGE_PREVIEW);
2025  $rpage_gui->setPageObject($rpage);
2026  $rpage_gui->setPreventHTMLUnmasking(true);
2027  $rhtml = $rpage_gui->showPage();
2028  $rhtml = $this->replaceDiffTags($rhtml);
2029  $rhtml = str_replace("&lt;br /&gt;", "<br />", $rhtml);
2030  $tpl->setVariable("RIGHT", $rhtml);
2031 
2032  $tpl->setVariable("TXT_NEW", $lng->txt("cont_pc_new"));
2033  $tpl->setVariable("TXT_MODIFIED", $lng->txt("cont_pc_modified"));
2034  $tpl->setVariable("TXT_DELETED", $lng->txt("cont_pc_deleted"));
2035 
2036 //var_dump($left);
2037 //var_dump($right);
2038 
2039  return $tpl->get();
2040  }
2041 
2042  function replaceDiffTags($a_html)
2043  {
2044  $a_html = str_replace("[ilDiffInsStart]", '<span class="ilDiffIns">', $a_html);
2045  $a_html = str_replace("[ilDiffDelStart]", '<span class="ilDiffDel">', $a_html);
2046  $a_html = str_replace("[ilDiffInsEnd]", '</span>', $a_html);
2047  $a_html = str_replace("[ilDiffDelEnd]", '</span>', $a_html);
2048 
2049  return $a_html;
2050  }
2051 }
2052 ?>