edit_odf.php 3.3 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 __DIR__.'/../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::check_visibility_tree(
  21. $document_id,
  22. api_get_course_id(),
  23. api_get_session_id(),
  24. api_get_user_id(),
  25. api_get_group_id()
  26. );
  27. if (!api_is_allowed_to_edit() && !$is_visible) {
  28. api_not_allowed(true);
  29. }
  30. $header_file = $document_data['path'];
  31. $pathinfo = pathinfo($header_file);
  32. $show_web_odf = false;
  33. $web_odf_supported_files = DocumentManager::get_web_odf_extension_list();
  34. if (in_array(strtolower($pathinfo['extension']), $web_odf_supported_files)) {
  35. $show_web_odf = true;
  36. }
  37. $file_url_web = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document'.$header_file;
  38. if ($show_web_odf) {
  39. //$htmlHeadXtra[] = api_get_js('webodf/webodf.js');
  40. $htmlHeadXtra[] = api_get_js('wodotexteditor/wodotexteditor.js');
  41. $htmlHeadXtra[] = api_get_js('wodotexteditor/localfileeditor.js');
  42. $htmlHeadXtra[] = api_get_js('wodotexteditor/FileSaver.js');
  43. //$htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH).'javascript/webodf/webodf.css');
  44. /*$htmlHeadXtra[] = '
  45. <script type="text/javascript" charset="utf-8">
  46. function init() {
  47. var odfelement = document.getElementById("odf"),
  48. odfcanvas = new odf.OdfCanvas(odfelement);
  49. odfcanvas.load("'.$file_url_web.'");
  50. createEditor();
  51. }
  52. $(document).ready(function() {
  53. //createEditor();
  54. window.setTimeout(init, 0);
  55. });
  56. </script>';
  57. */
  58. $htmlHeadXtra[] = '
  59. <script type="text/javascript" charset="utf-8">
  60. $(document).ready(function() {
  61. createEditor("'.$file_url_web.'");
  62. });
  63. </script>';
  64. }
  65. /*
  66. $interbreadcrumb[]=array("url"=>"./document.php?curdirpath=".urlencode($my_cur_dir_path).$req_gid, "name"=> get_lang('Documents'));
  67. // Interbreadcrumb for the current directory root path
  68. if (empty($document_data['parents'])) {
  69. $interbreadcrumb[] = array('url' => '#', 'name' => $document_data['title']);
  70. } else {
  71. foreach($document_data['parents'] as $document_sub_data) {
  72. if ($document_data['title'] == $document_sub_data['title']) {
  73. continue;
  74. }
  75. $interbreadcrumb[] = array('url' => $document_sub_data['document_url'], 'name' => $document_sub_data['title']);
  76. }
  77. }
  78. */
  79. //
  80. echo Display::display_header('');
  81. echo '<div class="actions">';
  82. echo '<a href="document.php?id='.$parent_id.'">'.Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('DocumentsOverview'), '', ICON_SIZE_MEDIUM).'</a>';
  83. 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>';
  84. echo '</div>';
  85. // echo '<div id="odf"></div>';
  86. echo '<div id="editorContainer" style="width:100%; height:600px; margin:0px; padding:0px"></div>';
  87. Display::display_footer();