';
if ($id > 0) {
diff --git a/htdocs/website/index.php b/htdocs/website/index.php
index 300ac8f0b833e..46d428bac93ec 100644
--- a/htdocs/website/index.php
+++ b/htdocs/website/index.php
@@ -454,6 +454,11 @@
exit;
}
if ($action == 'seteditinline') { // Test on permission not required here
+ if (!getDolGlobalString('WEBSITE_EDITINLINE_SAVE_CKEDITOR_EDIT')) {
+ // Show warning for feature not yet ready
+ setEventMessages($langs->trans("FeatureNotYetAvailable"), null, 'warnings');
+ }
+
dolibarr_set_const($db, 'WEBSITE_EDITINLINE', 1);
//dolibarr_set_const($db, 'WEBSITE_SUBCONTAINERSINLINE', 0); // Force disable of 'Include dynamic content'
header("Location: ".$_SERVER["PHP_SELF"].'?website='.urlencode(GETPOST('website')).'&pageid='.GETPOSTINT('pageid'));
@@ -3544,8 +3549,10 @@ function switchEditorOnline(forceenable)
isEditingEnabled = true;
// Trigger the function when clicking outside the elements with contenteditable=true attribute
+ // so we can save the change.
$(document).on(\'click\', function(e) {
var target = $(e.target);
+
// Check if the click is outside the elements with contenteditable=true attribute
if (!target.closest(\'[contenteditable="true"]\').length) {
// Repeat through the elements with contenteditable="true" attribute
@@ -3553,6 +3560,7 @@ function switchEditorOnline(forceenable)
var idToUse = $(this).attr(\'id\');
var elementType = $(this).prop("tagName").toLowerCase(); // Get the tag name (div, section, footer...)
var instance = CKEDITOR.instances[idToUse];
+
// Check if the element has been modified
if ($(this).hasClass(\'modified\')) {
var content = instance.getData();
@@ -3561,13 +3569,18 @@ function switchEditorOnline(forceenable)
// Retrieving the content and ID of the element
var elementId = $(this).attr(\'id\');
- // Sending data via AJAX
+ ';
+ if (getDolGlobalString('WEBSITE_EDITINLINE_SAVE_CKEDITOR_EDIT')) {
+ print '
+ console.log("A change has been detected, we send new content for update with ajax");
+
+ // Sending data via AJAX to update section
$.ajax({
type: \'POST\',
url: \'' . DOL_URL_ROOT . '/core/ajax/editinline.php\',
data: {
- website_ref: \''.$website->ref.'\',
- page_id: \'' . $websitepage->id . '\',
+ website_ref: \''.dol_escape_js($website->ref).'\',
+ page_id: \'' . ((int) $websitepage->id) . '\',
content: content,
element_id: elementId,
element_type: elementType,
@@ -3598,6 +3611,11 @@ function switchEditorOnline(forceenable)
}, 2000);
}
});
+ ';
+ } else {
+ print 'console.log("A change has been detected, but saving is not enabled by option WEBSITE_EDITINLINE_SAVE_CKEDITOR_EDIT, so no ajax update is done");';
+ }
+ print '
$(this).removeClass(\'modified\');
}
@@ -4896,8 +4914,6 @@ function switchEditorOnline(forceenable)
if ($action == 'editfile' || $action == 'file_manager' || $action == 'convertimgwebp' || $action == 'confirmconvertimgwebp') {
print ''."\n";
print '
';
- //print '
'.$langs->trans("FeatureNotYetAvailable").'';
-
$module = 'medias';
$formalreadyopen = 2; // So the form to submit a new file will not be open another time inside the core/tpl/filemanager.tpl.php