showinframes.php 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. <?php // $Id: showinframes.php 22177 2009-07-16 22:30:39Z iflorespaz $
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2004-2008 Dokeos S.A.
  6. Copyright (c) 2003 Ghent University (UGent)
  7. Copyright (c) 2001 Universite catholique de Louvain (UCL)
  8. Copyright (c) Hugues Peeters
  9. Copyright (c) Roan Embrechts
  10. For a full list of contributors, see "credits.txt".
  11. The full license can be read in "license.txt".
  12. This program is free software; you can redistribute it and/or
  13. modify it under the terms of the GNU General Public License
  14. as published by the Free Software Foundation; either version 2
  15. of the License, or (at your option) any later version.
  16. See the GNU General Public License for more details.
  17. Contact address: Dokeos, rue du Corbeau, 108, B-1030 Brussels, Belgium
  18. Mail: info@dokeos.com
  19. ==============================================================================
  20. */
  21. /**
  22. ==============================================================================
  23. * This file will show documents in a separate frame.
  24. * We don't like frames, but it was the best of two bad things.
  25. *
  26. * display html files within Dokeos - html files have the Dokeos header.
  27. *
  28. * --- advantages ---
  29. * users "feel" like they are in Dokeos,
  30. * and they can use the navigation context provided by the header.
  31. *
  32. * --- design ---
  33. * a file gets a parameter (an html file)
  34. * and shows
  35. * - dokeos header
  36. * - html file from parameter
  37. * - (removed) dokeos footer
  38. *
  39. * @version 0.6
  40. * @author Roan Embrechts (roan.embrechts@vub.ac.be)
  41. * @package dokeos.document
  42. ==============================================================================
  43. */
  44. /*
  45. ==============================================================================
  46. DOKEOS INIT
  47. ==============================================================================
  48. */
  49. $language_file[] = 'document';
  50. require_once '../inc/global.inc.php';
  51. require_once '../glossary/glossary.class.php';
  52. $language_file = 'document';
  53. require_once '../inc/global.inc.php';
  54. $noPHP_SELF=true;
  55. $header_file= Security::remove_XSS($_GET['file']);
  56. $path_array=explode('/',str_replace('\\','/',$header_file));
  57. $path_array = array_map('urldecode',$path_array);
  58. $header_file=implode('/',$path_array);
  59. $nameTools = $header_file;
  60. if(isset($_SESSION['_gid']) && $_SESSION['_gid']!='') {
  61. $req_gid = '&amp;gidReq='.$_SESSION['_gid'];
  62. $interbreadcrumb[]= array ("url"=>"../group/group_space.php?gidReq=".$_SESSION['_gid'], "name"=> get_lang('GroupSpace'));
  63. }
  64. $interbreadcrumb[]= array ("url"=>"./document.php?curdirpath=".dirname($header_file).$req_gid, "name"=> get_lang('Documents'));
  65. $interbreadcrumb[]= array ("url"=>"showinframes.php?file=".$header_file, "name"=>$header_file);
  66. $file_url_sys=api_get_path(SYS_COURSE_PATH).'document'.$header_file;
  67. $path_info= pathinfo($file_url_sys);
  68. $this_section = SECTION_COURSES;
  69. /*
  70. if (!empty($_GET['nopages'])) {
  71. $nopages=Security::remove_XSS($_GET['nopages']);
  72. if ($nopages==1) {
  73. require_once api_get_path(INCLUDE_PATH).'reduced_header.inc.php';
  74. Display::display_error_message(get_lang('FileNotFound'));
  75. }
  76. exit;
  77. }
  78. */
  79. $_SESSION['whereami'] = 'document/view';
  80. $interbreadcrumb[]= array ('url'=>'./document.php', 'name'=> get_lang('Documents'));
  81. $nameTools = get_lang('Documents');
  82. $file = Security::remove_XSS(urldecode($_GET['file']));
  83. /*
  84. ==============================================================================
  85. Main section
  86. ==============================================================================
  87. */
  88. header('Expires: Wed, 01 Jan 1990 00:00:00 GMT');
  89. //header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
  90. header('Last-Modified: Wed, 01 Jan 2100 00:00:00 GMT');
  91. header('Cache-Control: no-cache, must-revalidate');
  92. header('Pragma: no-cache');
  93. $browser_display_title = "Dokeos Documents - " . Security::remove_XSS($_GET['cidReq']) . " - " . $file;
  94. //only admins get to see the "no frames" link in pageheader.php, so students get a header that's not so high
  95. $frameheight = 135;
  96. if($is_courseAdmin) {
  97. $frameheight = 165;
  98. }
  99. $file_root=$_course['path'].'/document'.str_replace('%2F', '/',$file);
  100. $file_url_sys=api_get_path(SYS_COURSE_PATH).$file_root;
  101. $file_url_web=api_get_path(WEB_COURSE_PATH).$file_root;
  102. $path_info= pathinfo($file_url_sys);
  103. $js_glossary_in_documents = '';
  104. if (api_get_setting('show_glossary_in_documents') == 'ismanual') {
  105. $js_glossary_in_documents = ' // $(document).ready(function() {
  106. $.frameReady(function() {
  107. // $("<div>I am a div courses</div>").prependTo("body");
  108. }, "top.mainFrame",
  109. { load: [
  110. {type:"script", id:"_fr1", src:"'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js"},
  111. {type:"script", id:"_fr2", src:"'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.highlight.js"},
  112. {type:"script", id:"_fr3", src:"'.api_get_path(WEB_LIBRARY_PATH).'fckeditor/editor/plugins/glossary/fck_glossary_manual.js"}
  113. ]
  114. }
  115. );
  116. //});';
  117. } elseif(api_get_setting('show_glossary_in_documents') == 'isautomatic') {
  118. $js_glossary_in_documents = '// $(document).ready(function() {
  119. $.frameReady(function(){
  120. // $("<div>I am a div courses</div>").prependTo("body");
  121. }, "top.mainFrame",
  122. { load: [
  123. {type:"script", id:"_fr1", src:"'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js"},
  124. {type:"script", id:"_fr2", src:"'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.highlight.js"},
  125. {type:"script", id:"_fr3", src:"'.api_get_path(WEB_LIBRARY_PATH).'fckeditor/editor/plugins/glossary/fck_glossary_automatic.js"}
  126. ]
  127. }
  128. );
  129. // });';
  130. }
  131. $htmlHeadXtra[] = '<script language="javascript" src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.js"></script>';
  132. $htmlHeadXtra[] = '<script language="javascript" src="'.api_get_path(WEB_LIBRARY_PATH).'javascript/jquery.frameready.js"></script>';
  133. $htmlHeadXtra[] = '<script type="text/javascript">
  134. <!--
  135. var updateContentHeight = function() {
  136. HeaderHeight = document.getElementById("header").offsetHeight;
  137. FooterHeight = document.getElementById("footer").offsetHeight;
  138. docHeight = document.body.clientHeight;
  139. document.getElementById("mainFrame").style.height = ((docHeight-(parseInt(HeaderHeight)+parseInt(FooterHeight)))-60)+"px";
  140. };
  141. // Fixes the content height of the frame
  142. window.onload = function() {
  143. updateContentHeight();
  144. '.$js_glossary_in_documents.'
  145. }
  146. -->
  147. </script>';
  148. //Display::display_header($tool_name, "User");
  149. Display::display_header(null,"Doc");
  150. echo "<div align=\"center\">";
  151. $file_url_web=api_get_path('WEB_COURSE_PATH').$_course['path'].'/document'.$header_file."?".api_get_cidreq();
  152. echo "<a href='".$file_url_web."' target='blank'>".get_lang('_cut_paste_link')."</a></div>";
  153. //echo '<div>';
  154. if (file_exists($file_url_sys)) {
  155. 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>';
  156. } else {
  157. echo '<frame name="mainFrame" id="mainFrame" src=showinframes.php?nopages=1 />';
  158. }
  159. //echo '</div>';
  160. Display::display_footer();