edit_odf.php 3.4 KB

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