edit_odf.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * ODF document editor script (maybe unused)
  5. * @package chamilo.document
  6. */
  7. /**
  8. * Init
  9. */
  10. require_once '../inc/global.inc.php';
  11. exit;
  12. $document_id = $_GET['id'];
  13. if ($document_id) {
  14. $document_data = DocumentManager::get_document_data_by_id($document_id);
  15. if (empty($document_data)) {
  16. api_not_allowed();
  17. }
  18. } else {
  19. api_not_allowed();
  20. }
  21. //Check user visibility
  22. //$is_visible = DocumentManager::is_visible_by_id($document_id, $course_info, api_get_session_id(), api_get_user_id());
  23. $is_visible = DocumentManager::check_visibility_tree($document_id, api_get_course_id(), api_get_session_id(), api_get_user_id());
  24. if (!api_is_allowed_to_edit() && !$is_visible) {
  25. api_not_allowed(true);
  26. }
  27. $header_file = $document_data['path'];
  28. $pathinfo = pathinfo($header_file);
  29. $show_web_odf = false;
  30. $web_odf_supported_files = DocumentManager::get_web_odf_extension_list();
  31. if (in_array(strtolower($pathinfo['extension']), $web_odf_supported_files)) {
  32. $show_web_odf = true;
  33. }
  34. $file_url_web = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document'.$header_file.'?'.api_get_cidreq();
  35. if ($show_web_odf) {
  36. $htmlHeadXtra[] = api_get_js('webodf/webodf.js');
  37. $htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH).'javascript/webodf/webodf.css');
  38. $htmlHeadXtra[] = '
  39. <script type="text/javascript" charset="utf-8">
  40. function init() {
  41. var odfelement = document.getElementById("odf"),
  42. odfcanvas = new odf.OdfCanvas(odfelement);
  43. odfcanvas.load("'.$file_url_web.'");
  44. }
  45. $(document).ready(function() {
  46. window.setTimeout(init, 0);
  47. });
  48. </script>';
  49. }
  50. $interbreadcrumb[]=array("url"=>"./document.php?curdirpath=".urlencode($my_cur_dir_path).$req_gid, "name"=> get_lang('Documents'));
  51. // Interbreadcrumb for the current directory root path
  52. if (empty($document_data['parents'])) {
  53. $interbreadcrumb[] = array('url' => '#', 'name' => $document_data['title']);
  54. } else {
  55. foreach($document_data['parents'] as $document_sub_data) {
  56. if ($document_data['title'] == $document_sub_data['title']) {
  57. continue;
  58. }
  59. $interbreadcrumb[] = array('url' => $document_sub_data['document_url'], 'name' => $document_sub_data['title']);
  60. }
  61. }
  62. Display::display_header('');
  63. echo '<div id="odf"></div>';
  64. Display::display_footer();