Fix enabled_support_odf configuration setting

pull/2487/head
Angel Fernando Quiroz Campos 8 years ago
parent cda36386ca
commit 4071b1aaf3
  1. 138
      main/document/edit_odf.php
  2. 4
      main/inc/lib/document.lib.php
  3. 2
      main/install/configuration.dist.php

@ -7,15 +7,16 @@
require_once __DIR__.'/../inc/global.inc.php';
//exit;
$document_id = $_GET['id'];
$document_id = isset($_GET['id']) ? intval($_GET['id']) : 0;
$courseCode = api_get_course_id();
if ($document_id) {
$document_data = DocumentManager::get_document_data_by_id($document_id, $courseCode);
if (empty($document_data)) {
api_not_allowed();
}
} else {
if (!$document_id) {
api_not_allowed();
}
$document_data = DocumentManager::get_document_data_by_id($document_id, $courseCode, true);
if (empty($document_data)) {
api_not_allowed();
}
@ -34,66 +35,95 @@ if (!api_is_allowed_to_edit() && !$is_visible) {
$header_file = $document_data['path'];
$pathinfo = pathinfo($header_file);
$show_web_odf = false;
$web_odf_supported_files = DocumentManager::get_web_odf_extension_list();
if (in_array(strtolower($pathinfo['extension']), $web_odf_supported_files)) {
if (
in_array(strtolower($pathinfo['extension']), $web_odf_supported_files) &&
api_get_configuration_value('enabled_support_odf') === true
) {
$show_web_odf = true;
}
$file_url_web = api_get_path(WEB_COURSE_PATH).$_course['path'].'/document'.$header_file;
if ($show_web_odf) {
//$htmlHeadXtra[] = api_get_js('webodf/webodf.js');
$htmlHeadXtra[] = api_get_js('wodotexteditor/wodotexteditor.js');
$htmlHeadXtra[] = api_get_js('wodotexteditor/localfileeditor.js');
$htmlHeadXtra[] = api_get_js('wodotexteditor/FileSaver.js');
//$htmlHeadXtra[] = api_get_css(api_get_path(WEB_LIBRARY_PATH).'javascript/webodf/webodf.css');
/*$htmlHeadXtra[] = '
if (!$show_web_odf) {
api_not_allowed(true);
}
$parent_id = $document_data['parent_id'];
if (!$parent_id) {
$testParentId = 0;
// Get parent id from current path
if (!empty($document_data['path'])) {
$testParentId = DocumentManager::get_document_id(
api_get_course_info(),
dirname($document_data['path']),
0
);
}
$parent_id = !empty($testParentId) ? $testParentId : 0;
}
//$htmlHeadXtra[] = api_get_js('webodf/webodf.js');
$htmlHeadXtra[] = api_get_js('wodotexteditor/wodotexteditor.js');
$htmlHeadXtra[] = api_get_js('wodotexteditor/localfileeditor.js');
$htmlHeadXtra[] = api_get_js('wodotexteditor/FileSaver.js');
$htmlHeadXtra[] = '
<script type="text/javascript" charset="utf-8">
function init() {
var odfelement = document.getElementById("odf"),
odfcanvas = new odf.OdfCanvas(odfelement);
odfcanvas.load("'.$file_url_web.'");
createEditor();
}
$(document).ready(function() {
//createEditor();
window.setTimeout(init, 0);
$(document).on(\'ready\', function() {
createEditor(\''.$file_url_web.'\');
});
</script>';
*/
$htmlHeadXtra[] = '
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
createEditor("'.$file_url_web.'");
});
</script>';
}
/*
$interbreadcrumb[]=array("url"=>"./document.php?curdirpath=".urlencode($my_cur_dir_path).$req_gid, "name"=> get_lang('Documents'));
</script>
';
$htmlHeadXtra[] = '
<style>
#editorContainer {
width:100%;
height:100%;
margin:0px;
padding:0px;
}
</style>
';
// Interbreadcrumb for the current directory root path
if (empty($document_data['parents'])) {
$interbreadcrumb[] = array('url' => '#', 'name' => $document_data['title']);
} else {
foreach($document_data['parents'] as $document_sub_data) {
if ($document_data['title'] == $document_sub_data['title']) {
$interbreadcrumb[] = [
'url' => api_get_path(WEB_CODE_PATH).'document/document.php',
'name' => get_lang('Documents')
];
if (!empty($document_data['parents'])) {
foreach($document_data['parents'] as $documentParent) {
if ($document_data['title'] == $documentParent['title']) {
continue;
}
$interbreadcrumb[] = array('url' => $document_sub_data['document_url'], 'name' => $document_sub_data['title']);
$interbreadcrumb[] = [
'url' => $documentParent['document_url'],
'name' => $documentParent['title']
];
}
}
*/
//
echo Display::display_header('');
echo '<div class="actions">';
echo '<a href="document.php?id='.$parent_id.'">'.Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('DocumentsOverview'), '', ICON_SIZE_MEDIUM).'</a>';
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>';
echo '</div>';
// echo '<div id="odf"></div>';
echo '<div id="editorContainer" style="width:100%; height:600px; margin:0px; padding:0px"></div>';
Display::display_footer();
$actionBack = Display::url(
Display::return_icon('back.png', get_lang('BackTo').' '.get_lang('DocumentsOverview'), [], ICON_SIZE_MEDIUM),
'document.php?'.api_get_cidreq(true, true, 'editodf').'&id='.$parent_id
);
$actionEdit = Display::url(
Display::return_icon('edit.png', get_lang('Rename').'/'.get_lang('Comments'), [], ICON_SIZE_MEDIUM),
'edit_document.php?'.api_get_cidreq(true, true, 'editodf').'&id='.$document_id
);
$content = '<div id="editorContainer"></div>';
$view = new Template($document_data['title']);
$view->assign(
'actions',
Display::toolbarAction('actions', [$actionBack.$actionEdit])
);
$view->assign('header', $document_data['title']);
$view->assign('content', $content);
$view->display_one_col_template();

@ -5725,7 +5725,7 @@ class DocumentManager
if (
in_array($extension, $webOdfExtensionList) &&
api_get_setting('enabled_support_odf') === true
api_get_configuration_value('enabled_support_odf') === true
) {
return Display::url($iconEn, "edit_odf.php?$courseParams&id=$document_id");
}
@ -5763,7 +5763,7 @@ class DocumentManager
if (
in_array($extension, $webOdfExtensionList) &&
api_get_setting('enabled_support_odf') === true
api_get_configuration_value('enabled_support_odf') === true
) {
return Display::url($iconEn, "edit_odf.php?$courseParams&id=$document_id");
}

@ -377,3 +377,5 @@ $_configuration['agenda_legend'] = [
//$_configuration['limit_session_admin_role'] = false;
// Course tools visibility edition in sessions
//$_configuration['allow_edit_tool_visibility_in_session'] = false;
// Enable the support to ODF files
//$_configuration['enabled_support_odf'] = true;

Loading…
Cancel
Save