showinframes.php 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * This file will show documents in a separate frame.
  5. * We don't like frames, but it was the best of two bad things.
  6. *
  7. * display html files within Dokeos - html files have the Dokeos header.
  8. *
  9. * --- advantages ---
  10. * users "feel" like they are in Dokeos,
  11. * and they can use the navigation context provided by the header.
  12. *
  13. * --- design ---
  14. * a file gets a parameter (an html file)
  15. * and shows
  16. * - dokeos header
  17. * - html file from parameter
  18. * - (removed) dokeos footer
  19. *
  20. * @version 0.6
  21. * @author Roan Embrechts (roan.embrechts@vub.ac.be)
  22. * @package dokeos.document
  23. */
  24. /* INITIALIZATION */
  25. $language_file[] = 'document';
  26. require_once '../inc/global.inc.php';
  27. require_once api_get_path(LIBRARY_PATH).'glossary.lib.php';
  28. $noPHP_SELF = true;
  29. $header_file = Security::remove_XSS($_GET['file']);
  30. $path_array = explode('/', str_replace('\\', '/', $header_file));
  31. $path_array = array_map('urldecode', $path_array);
  32. $header_file = implode('/', $path_array);
  33. $nameTools = $header_file;
  34. if (isset($_SESSION['_gid']) && $_SESSION['_gid'] != '') {
  35. $req_gid = '&amp;gidReq='.$_SESSION['_gid'];
  36. $interbreadcrumb[] = array('url' => '../group/group_space.php?gidReq='.$_SESSION['_gid'], 'name' => get_lang('GroupSpace'));
  37. }
  38. $interbreadcrumb[] = array('url' => './document.php?curdirpath='.dirname($header_file).$req_gid, 'name' => get_lang('Documents'));
  39. $interbreadcrumb[] = array('url' => 'showinframes.php?file='.$header_file, 'name' => $header_file);
  40. $file_url_sys = api_get_path(SYS_COURSE_PATH).'document'.$header_file;
  41. $path_info = pathinfo($file_url_sys);
  42. $this_section = SECTION_COURSES;
  43. /*
  44. if (!empty($_GET['nopages'])) {
  45. $nopages = Security::remove_XSS($_GET['nopages']);
  46. if ($nopages == 1) {
  47. require_once api_get_path(INCLUDE_PATH).'reduced_header.inc.php';
  48. Display::display_error_message(get_lang('FileNotFound'));
  49. }
  50. exit;
  51. }
  52. */
  53. $_SESSION['whereami'] = 'document/view';
  54. $interbreadcrumb[] = array('url' => './document.php', 'name' => get_lang('Documents'));
  55. $nameTools = get_lang('Documents');
  56. $file = Security::remove_XSS(urldecode($_GET['file']));
  57. /* Main section */
  58. header('Expires: Wed, 01 Jan 1990 00:00:00 GMT');
  59. //header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
  60. header('Last-Modified: Wed, 01 Jan 2100 00:00:00 GMT');
  61. header('Cache-Control: no-cache, must-revalidate');
  62. header('Pragma: no-cache');
  63. $browser_display_title = 'Documents - '.Security::remove_XSS($_GET['cidReq']).' - '.$file;
  64. // Only admins get to see the "no frames" link in pageheader.php, so students get a header that's not so high
  65. $frameheight = 135;
  66. if ($is_courseAdmin) {
  67. $frameheight = 165;
  68. }
  69. $file_root = $_course['path'].'/document'.str_replace('%2F', '/', $file);
  70. $file_url_sys = api_get_path(SYS_COURSE_PATH).$file_root;
  71. $file_url_web = api_get_path(WEB_COURSE_PATH).$file_root;
  72. $path_info = pathinfo($file_url_sys);
  73. $js_glossary_in_documents = '';
  74. if (api_get_setting('show_glossary_in_documents') == 'ismanual') {
  75. $js_glossary_in_documents = ' // $(document).ready(function() {
  76. $.frameReady(function() {
  77. // $("<div>I am a div courses</div>").prependTo("body");
  78. }, "top.mainFrame",
  79. { load: [
  80. {type:"script", id:"_fr1", src:"'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js"},
  81. {type:"script", id:"_fr2", src:"'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.highlight.js"},
  82. {type:"script", id:"_fr3", src:"'.api_get_path(WEB_LIBRARY_PATH).'fckeditor/editor/plugins/glossary/fck_glossary_manual.js"}
  83. ]
  84. }
  85. );
  86. //});';
  87. } elseif (api_get_setting('show_glossary_in_documents') == 'isautomatic') {
  88. $js_glossary_in_documents = '// $(document).ready(function() {
  89. $.frameReady(function(){
  90. // $("<div>I am a div courses</div>").prependTo("body");
  91. }, "top.mainFrame",
  92. { load: [
  93. {type:"script", id:"_fr1", src:"'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js"},
  94. {type:"script", id:"_fr2", src:"'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.highlight.js"},
  95. {type:"script", id:"_fr3", src:"'.api_get_path(WEB_LIBRARY_PATH).'fckeditor/editor/plugins/glossary/fck_glossary_automatic.js"}
  96. ]
  97. }
  98. );
  99. // });';
  100. }
  101. $htmlHeadXtra[] = '<script language="javascript" src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js"></script>';
  102. $htmlHeadXtra[] = '<script language="javascript" src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.frameready.js"></script>';
  103. $htmlHeadXtra[] = '<script type="text/javascript">
  104. <!--
  105. var updateContentHeight = function() {
  106. HeaderHeight = document.getElementById("header").offsetHeight;
  107. FooterHeight = document.getElementById("footer").offsetHeight;
  108. docHeight = document.body.clientHeight;
  109. document.getElementById("mainFrame").style.height = ((docHeight-(parseInt(HeaderHeight)+parseInt(FooterHeight)))-60)+"px";
  110. };
  111. // Fixes the content height of the frame
  112. window.onload = function() {
  113. updateContentHeight();
  114. '.$js_glossary_in_documents.'
  115. }
  116. -->
  117. </script>';
  118. //Display::display_header($tool_name, 'User');
  119. Display::display_header(null, 'Doc');
  120. echo "<div align=\"center\">";
  121. $file_url_web = api_get_path('WEB_COURSE_PATH').$_course['path'].'/document'.$header_file.'?'.api_get_cidreq();
  122. echo '<a href="'.$file_url_web.'" target="_blank">'.get_lang('_cut_paste_link').'</a></div>';
  123. //echo '<div>';
  124. if (file_exists($file_url_sys)) {
  125. echo '<iframe border="0" frameborder="0" scrolling="auto" style="width:100%;" id="mainFrame" name="mainFrame" src="'.$file_url_web.'?'.api_get_cidreq().'&rand='.mt_rand(1, 10000).'"></iframe>';
  126. } else {
  127. echo '<frame name="mainFrame" id="mainFrame" src=showinframes.php?nopages=1 />';
  128. }
  129. //echo '</div>';
  130. Display::display_footer();