Debug website module
This commit is contained in:
parent
e362a0e9df
commit
8247bb683c
@ -31,6 +31,7 @@
|
||||
* @param string $content Content to replace
|
||||
* @param int $removephppart 0=Replace PHP sections with a PHP badge. 1=Remove completely PHP sections.
|
||||
* @return boolean True if OK
|
||||
* @see dolWebsiteOutput for function used to replace content in a web server context
|
||||
*/
|
||||
function dolWebsiteReplacementOfLinks($website, $content, $removephppart=0)
|
||||
{
|
||||
@ -48,10 +49,16 @@ function dolWebsiteReplacementOfLinks($website, $content, $removephppart=0)
|
||||
// Replace relative link /xxx.php with dolibarr URL
|
||||
$content = preg_replace('/(href=")\/?([^:\"]*)(\.php\")/', '\1'.DOL_URL_ROOT.'/website/index.php?website='.$website->ref.'&pageref=\2"', $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);
|
||||
$content = preg_replace('/data-slide-bg=(["\']?)medias\//', 'data-slide-bg=\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
|
||||
|
||||
// <img src="medias/image.png... => <img src="dolibarr/viewimage.php/modulepart=medias&file=image.png...
|
||||
$content = preg_replace('/(<img[^>]*src=")(medias\/)/', '\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
|
||||
// <img src="image.png... => <img src="dolibarr/viewimage.php/modulepart=medias&file=image.png...
|
||||
$content = preg_replace('/(<img[^>]*src=")(?!(http|'.preg_quote(DOL_URL_ROOT,'/').'\/viewimage))/', '\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
|
||||
$content = preg_replace('/(<img[^>]*src=")(?!(http|\/?viewimage|'.preg_quote(DOL_URL_ROOT,'/').'\/viewimage))/', '\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
|
||||
// <img src="viewimage.php/modulepart=medias&file=image.png" => <img src="dolibarr/viewimage.php/modulepart=medias&file=image.png"
|
||||
$content = preg_replace('/(<img[^>]*src=")(\/?viewimage\.php)/', '\1'.DOL_URL_ROOT.'/viewimage.php', $content, -1, $nbrep);
|
||||
|
||||
// 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);
|
||||
@ -70,7 +77,7 @@ function dolWebsiteReplacementOfLinks($website, $content, $removephppart=0)
|
||||
*
|
||||
* @param string $content Content string
|
||||
* @return void
|
||||
* @see dolWebsiteSaveContent
|
||||
* @see dolWebsiteReplacementOfLinks for function used to replace content in the backoffice editor context
|
||||
*/
|
||||
function dolWebsiteOutput($content)
|
||||
{
|
||||
@ -98,15 +105,24 @@ function dolWebsiteOutput($content)
|
||||
$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="
|
||||
// Fix relative link /document.php with correct URL after the DOL_URL_ROOT: href="/document.php?modulepart=" => href="/dolibarr/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);
|
||||
|
||||
// Fix relative link /viewimage.php with correct URL after the DOL_URL_ROOT: ...href="/viewimage.php?modulepart="
|
||||
// Fix relative link /viewimage.php with correct URL after the DOL_URL_ROOT: href="/viewimage.php?modulepart=" => href="/dolibarr/viewimage.php?modulepart="
|
||||
$content=preg_replace('/(href=")(\/?viewimage\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep);
|
||||
$content=preg_replace('/(src=")(\/?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);
|
||||
$content=preg_replace('/data-slide-bg=(["\']?)medias\//', 'data-slide-bg=\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
|
||||
|
||||
// <img src="medias/image.png... => <img src="dolibarr/viewimage.php/modulepart=medias&file=image.png...
|
||||
$content = preg_replace('/(<img[^>]*src=")(medias\/)/', '\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
|
||||
// <img src="image.png... => <img src="dolibarr/viewimage.php/modulepart=medias&file=image.png...
|
||||
$content = preg_replace('/(<img[^>]*src=")(?!(http|\/?viewimage|'.preg_quote(DOL_URL_ROOT,'/').'\/viewimage))/', '\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
|
||||
// <img src="viewimage.php/modulepart=medias&file=image.png" => <img src="dolibarr/viewimage.php/modulepart=medias&file=image.png"
|
||||
$content = preg_replace('/(<img[^>]*src=")(\/?viewimage\.php)/', '\1'.DOL_URL_ROOT.'/viewimage.php', $content, -1, $nbrep);
|
||||
|
||||
// action="newpage.php" => action="dolibarr/website/index.php?website=...&pageref=newpage
|
||||
$content = preg_replace('/(action=")\/?([^:\"]*)(\.php\")/', '\1'.DOL_URL_ROOT.'/public/website/index.php?website='.$website->ref.'&pageref=\2"', $content, -1, $nbrep);
|
||||
|
||||
@ -22,6 +22,7 @@ EditCss=Edit Style/CSS or HTML header
|
||||
EditMenu=Edit menu
|
||||
EditMedias=Edit medias
|
||||
EditPageMeta=Edit Meta
|
||||
EditInline=Edit inline
|
||||
AddWebsite=Add website
|
||||
Webpage=Web page/container
|
||||
AddPage=Add page/container
|
||||
|
||||
@ -1651,16 +1651,29 @@ if (count($object->records) > 0)
|
||||
print ' ';
|
||||
|
||||
print '<input type="submit" class="button nobordertransp"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("EditPageMeta")).'" name="editmeta">';
|
||||
|
||||
print '<input type="submit" class="button nobordertransp"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("EditHTMLSource")).'" name="editsource">';
|
||||
|
||||
if ($websitepage->grabbed_from)
|
||||
{
|
||||
print '<input type="submit" class="button nobordertransp" disabled="disabled" title="'.dol_escape_htmltag($langs->trans("OnlyEditionOfSourceForGrabbedContent")).'" value="'.dol_escape_htmltag($langs->trans("EditWithEditor")).'" name="editcontent">';
|
||||
//print '<input type="submit" class="button nobordertransp" disabled="disabled" title="'.dol_escape_htmltag($langs->trans("OnlyEditionOfSourceForGrabbedContent")).'" value="'.dol_escape_htmltag($langs->trans("EditWithEditor")).'" name="editcontent">';
|
||||
print '<a class="button nobordertransp"'.$disabled.' href="#" disabled="disabled" title="'.dol_escape_htmltag($langs->trans("OnlyEditionOfSourceForGrabbedContent")).'">'.dol_escape_htmltag($langs->trans("EditInLine")).'</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input type="submit" class="button nobordertransp"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("EditWithEditor")).'" name="editcontent">';
|
||||
//print '<input type="submit" class="button nobordertransp"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("EditWithEditor")).'" name="editcontent">';
|
||||
if (empty($conf->global->WEBSITE_EDITINLINE))
|
||||
{
|
||||
print '<a class="button nobordertransp"'.$disabled.' href="'.$_SERVER["PHP_SELF"].'?website='.$object->id.'&pageid='.$websitepage->id.'&action=seteditinline">'.dol_escape_htmltag($langs->trans("EditInLine")).'</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<a class="button nobordertransp"'.$disabled.' href="'.$_SERVER["PHP_SELF"].'?website='.$object->id.'&pageid='.$websitepage->id.'&action=unseteditinline">'.dol_escape_htmltag($langs->trans("EditInLine")).'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
print '<input type="submit" class="button nobordertransp"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("EditHTMLSource")).'" name="editsource">';
|
||||
print ' ';
|
||||
|
||||
if ($object->fk_default_home > 0 && $pageid == $object->fk_default_home) print '<input type="submit" class="button nobordertransp" disabled="disabled" value="'.dol_escape_htmltag($langs->trans("SetAsHomePage")).'" name="setashome">';
|
||||
else print '<input type="submit" class="button nobordertransp"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("SetAsHomePage")).'" name="setashome">';
|
||||
print '<input type="submit" class="button nobordertransp"'.$disabled.' value="'.dol_escape_htmltag($langs->trans("ClonePage")).'" name="createpagefromclone">';
|
||||
@ -2305,8 +2318,6 @@ if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpa
|
||||
|
||||
$out.='<div id="websitecontentundertopmenu" class="websitecontentundertopmenu">'."\n";
|
||||
|
||||
// Note: <div> or <section> with contenteditable="true" inside this can be edited with inline ckeditor
|
||||
|
||||
// REPLACEMENT OF LINKS When page called by website editor
|
||||
|
||||
$out.='<style scoped>'."\n"; // "scoped" means "apply to parent element only". No more supported by browsers, snif !
|
||||
@ -2329,12 +2340,25 @@ if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpa
|
||||
$out.=$tmpout;
|
||||
$out.='</style>'."\n";
|
||||
|
||||
// Note: <div> or <section> with contenteditable="true" inside this can be edited with inline ckeditor
|
||||
|
||||
// Do not enable the contenteditable when page was grabbed, ckeditor is removing span and adding borders,
|
||||
// so editable will be available only from container created from scratch
|
||||
//$out.='<div id="bodywebsite" class="bodywebsite"'.($objectpage->grabbed_from ? ' contenteditable="true"' : '').'>'."\n";
|
||||
$out.='<div id="bodywebsite" class="bodywebsite">'."\n";
|
||||
|
||||
$out.=dolWebsiteReplacementOfLinks($object, $objectpage->content)."\n";
|
||||
// TODO Add the contenteditable="true" when mode Edit Inline is on
|
||||
$newcontent = $objectpage->content;
|
||||
if (empty($conf->global->WEBSITE_EDITINLINE_ON))
|
||||
{
|
||||
$newcontent = preg_replace('/(div|section) contenteditable="true"/', '\1', $newcontent);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
$out.=dolWebsiteReplacementOfLinks($object, $newcontent)."\n";
|
||||
|
||||
$out.='</div>';
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user