edit_odf.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * ODF document editor script (maybe unused)
  5. * @package chamilo.document
  6. */
  7. //require_once '../inc/global.inc.php';
  8. //exit;
  9. $document_id = $_GET['id'];
  10. $courseCode = api_get_course_id();
  11. if ($document_id) {
  12. $document_data = DocumentManager::get_document_data_by_id($document_id, $courseCode);
  13. if (empty($document_data)) {
  14. api_not_allowed();
  15. }
  16. } else {
  17. api_not_allowed();
  18. }
  19. //Check user visibility
  20. //$is_visible = DocumentManager::is_visible_by_id($document_id, $course_info, api_get_session_id(), api_get_user_id());
  21. $is_visible = DocumentManager::check_visibility_tree(
  22. $document_id,
  23. api_get_course_id(),
  24. api_get_session_id(),
  25. api_get_user_id(),
  26. api_get_group_id()
  27. );
  28. if (!api_is_allowed_to_edit() && !$is_visible) {
  29. api_not_allowed(true);
  30. }
  31. $header_file = $document_data['path'];
  32. $pathinfo = pathinfo($header_file);
  33. $show_web_odf = false;
  34. $web_odf_supported_files = DocumentManager::get_web_odf_extension_list();
  35. if (in_array(strtolower($pathinfo['extension']), $web_odf_supported_files)) {
  36. $show_web_odf = true;
  37. }
  38. $file_url_web = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document'.$header_file;
  39. if ($show_web_odf) {
  40. //$htmlHeadXtra[] = api_get_js('webodf/webodf.js');
  41. $htmlHeadXtra[] = api_get_js('wodotexteditor/wodotexteditor.js');
  42. $htmlHeadXtra[] = api_get_js('wodotexteditor/localfileeditor.js');
  43. $htmlHeadXtra[] = api_get_js('wodotexteditor/FileSaver.js');
  44. //$htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH).'javascript/webodf/webodf.css');
  45. /*$htmlHeadXtra[] = '
  46. <script type="text/javascript" charset="utf-8">
  47. function init() {
  48. var odfelement = document.getElementById("odf"),
  49. odfcanvas = new odf.OdfCanvas(odfelement);
  50. odfcanvas.load("'.$file_url_web.'");
  51. createEditor();
  52. }
  53. $(document).ready(function() {
  54. //createEditor();
  55. window.setTimeout(init, 0);
  56. });
  57. </script>';
  58. */
  59. $htmlHeadXtra[] = '
  60. <script type="text/javascript" charset="utf-8">
  61. $(document).ready(function() {
  62. createEditor("'.$file_url_web.'");
  63. });
  64. </script>';
  65. }
  66. /*
  67. $interbreadcrumb[]=array("url"=>"./document.php?curdirpath=".urlencode($my_cur_dir_path).$req_gid, "name"=> get_lang('Documents'));
  68. // Interbreadcrumb for the current directory root path
  69. if (empty($document_data['parents'])) {
  70. $interbreadcrumb[] = array('url' => '#', 'name' => $document_data['title']);
  71. } else {
  72. foreach($document_data['parents'] as $document_sub_data) {
  73. if ($document_data['title'] == $document_sub_data['title']) {
  74. continue;
  75. }
  76. $interbreadcrumb[] = array('url' => $document_sub_data['document_url'], 'name' => $document_sub_data['title']);
  77. }
  78. }
  79. */
  80. //
  81. echo Display::display_header('');
  82. echo '<div class="actions">';
  83. echo '<a href="document.php?id='.$parent_id.'">'.Display::return_icon('back.png',get_lang('BackTo').' '.get_lang('DocumentsOverview'),'',ICON_SIZE_MEDIUM).'</a>';
  84. echo '<a href="edit_document.php?'.api_get_cidreq().'&id='.$document_id.$req_gid.'&origin=editodf">'.Display::return_icon('edit.png',get_lang('Rename').'/'.get_lang('Comments'),'',ICON_SIZE_MEDIUM).'</a>';
  85. echo '</div>';
  86. // echo '<div id="odf"></div>';
  87. echo '<div id="editorContainer" style="width:100%; height:600px; margin:0px; padding:0px"></div>';
  88. Display::display_footer();