From 445db58966ff448a99e2b3effea463c63a82dfe2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 19 Jul 2018 16:06:06 +0200 Subject: [PATCH] FIX website in inline edit mode --- htdocs/core/lib/website.lib.php | 13 +++++++++---- htdocs/website/index.php | 23 ++++++++++++++++++++--- 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index 904f9f57411..4ca0812c9ee 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -56,6 +56,10 @@ function dolWebsiteReplacementOfLinks($website, $content, $removephppart=0) // action="newpage.php" => action="dolibarr/website/index.php?website=...&pageref=newpage $content = preg_replace('/(action=")\/?([^:\"]*)(\.php\")/', '\1'.DOL_URL_ROOT.'/website/index.php?website='.$website->ref.'&pageref=\2"', $content, -1, $nbrep); + // Fix relative link /document.php with correct URL after the DOL_URL_ROOT: ...href="/document.php?modulepart=" + $content=preg_replace('/(href=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep); + $content=preg_replace('/(src=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep); + return $content; } @@ -91,14 +95,15 @@ function dolWebsiteOutput($content) // Replace relative link /xxx.php with dolibarr URL: ...href="....php" $content=preg_replace('/(href=")\/?([^:\"]*)(\.php\")/', '\1'.DOL_URL_ROOT.'/public/website/index.php?website='.$website->ref.'&pageref=\2"', $content, -1, $nbrep); // Replace relative link /xxx with dolibarr URL: ...href="....php" - $content=preg_replace('/(href=")\/?([a-zA-Z0-9\-]+)(["\?]+)/', '\1'.DOL_URL_ROOT.'/public/website/index.php?website='.$website->ref.'&pageref=\2"', $content, -1, $nbrep); + $content=preg_replace('/(href=")\/?([a-zA-Z0-9\-]+)(\")/', '\1'.DOL_URL_ROOT.'/public/website/index.php?website='.$website->ref.'&pageref=\2\3', $content, -1, $nbrep); + $content=preg_replace('/(href=")\/?([a-zA-Z0-9\-]+)(\?)/', '\1'.DOL_URL_ROOT.'/public/website/index.php?website='.$website->ref.'&pageref=\2\3', $content, -1, $nbrep); // Fix relative link /document.php with correct URL after the DOL_URL_ROOT: ...href="/document.php?modulepart=" - $content=preg_replace('/(href=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3"', $content, -1, $nbrep); - $content=preg_replace('/(src=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3"', $content, -1, $nbrep); + $content=preg_replace('/(href=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep); + $content=preg_replace('/(src=")(\/?document\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep); // Fix relative link /viewimage.php with correct URL after the DOL_URL_ROOT: ...href="/viewimage.php?modulepart=" - $content=preg_replace('/(href=")(\/?viewimage\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3"', $content, -1, $nbrep); + $content=preg_replace('/(href=")(\/?viewimage\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep); // Fix relative link into medias with correct URL after the DOL_URL_ROOT: ../url("medias/ $content=preg_replace('/url\((["\']?)medias\//', 'url(\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep); diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 076554dcd76..e1460f497f1 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -157,7 +157,10 @@ $htmlheadercontentdefault.=''."\n"; $htmlheadercontentdefault.=''."\n"; $htmlheadercontentdefault.=''."\n"; +$htmlheadercontentdefault.=''."\n"; /* @@ -2292,9 +2295,17 @@ if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpa $out = ''."\n"; - $out.='
'."\n"; - // TODO Use contenteditable="true" / document.getElementById("myP").contentEditable="true" for part coming from CKEditor + // Include a html so we can benefit of the header of page. + // Note: We can't use iframe as it can be used to include another external html file + // Note: We can't use frame as it is deprecated. + $out.="\n\n"; + $out.=dolWebsiteReplacementOfLinks($object, $objectpage->htmlheader, 1); + $out.="\n"; + $out.="\n"; + $out.='
'."\n"; + + // Note:
or
with contenteditable="true" inside this can be edited with inline ckeditor // REPLACEMENT OF LINKS When page called by website editor @@ -2319,7 +2330,7 @@ if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpa $out.=''."\n"; // Do not enable the contenteditable when page was grabbed, ckeditor is removing span and adding borders, - // so editable will be available from container created from scratch + // so editable will be available only from container created from scratch //$out.='
grabbed_from ? ' contenteditable="true"' : '').'>'."\n"; $out.='
'."\n"; @@ -2329,6 +2340,12 @@ if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpa $out.='
'; + /*if ($includepageintoaframeoradiv == 'iframe') + { + $out .= ""; + }*/ + $out .= "\n\n"; + $out.= "\n".''."\n\n"; // For jqueryscoped (does not work as expected)