Fix link replaced twice
This commit is contained in:
parent
2d0abebca3
commit
00d7947ee8
@ -219,10 +219,13 @@ function dolWebsiteOutput($content, $contenttype = 'html', $containerid = '')
|
||||
{
|
||||
global $db, $langs, $conf, $user;
|
||||
global $dolibarr_main_url_root, $dolibarr_main_data_root;
|
||||
global $includehtmlcontentopened;
|
||||
|
||||
$nbrep = 0;
|
||||
|
||||
dol_syslog("dolWebsiteOutput start (contenttype=".$contenttype." containerid=".$containerid." USEDOLIBARREDITOR=".(defined('USEDOLIBARREDITOR') ? '1' : '')." USEDOLIBARRSERVER=".(defined('USEDOLIBARRSERVER') ? '1' : '').')');
|
||||
dol_syslog("dolWebsiteOutput start - contenttype=".$contenttype." containerid=".$containerid." USEDOLIBARREDITOR=".(defined('USEDOLIBARREDITOR') ? '1' : '')." USEDOLIBARRSERVER=".(defined('USEDOLIBARRSERVER') ? '1' : '').' includehtmlcontentopened='.$includehtmlcontentopened);
|
||||
|
||||
//print $containerid.' '.$content;
|
||||
|
||||
// Define $urlwithroot
|
||||
$urlwithouturlroot = preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
|
||||
@ -259,6 +262,8 @@ function dolWebsiteOutput($content, $contenttype = 'html', $containerid = '')
|
||||
// Replace relative link /xxx.php#aaa or /xxx.php with dolibarr URL: ...href="....php" (we discard param ?...)
|
||||
$content = preg_replace('/(href=")\/?([^:\"\!]*)\.php(#[^\"<>]*)?\"/', '\1!~!~!~'.DOL_URL_ROOT.'/public/website/index.php?website='.$website->ref.'&pageref=\2\3"', $content, -1, $nbrep);
|
||||
// Replace relative link /xxx.php?a=b&c=d#aaa or /xxx.php?a=b&c=d with dolibarr URL
|
||||
// Warning: we may replace twice if href="..." was inside an include (dolWebsiteOutput called by include and the by final page), that's why
|
||||
// at end we replace the '!~!~!~' only if we are in final parent page.
|
||||
$content = preg_replace('/(href=")\/?([^:\"\!]*)\.php\?([^#\"<>]*)(#[^\"<>]*)?\"/', '\1!~!~!~'.DOL_URL_ROOT.'/public/website/index.php?website='.$website->ref.'&pageref=\2&\3\4"', $content, -1, $nbrep);
|
||||
// Replace relative link without .php like /xxx#aaa or /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\3', $content, -1, $nbrep);
|
||||
@ -291,8 +296,10 @@ function dolWebsiteOutput($content, $contenttype = 'html', $containerid = '')
|
||||
$content = str_replace('src="!~!~!~/viewimage.php', 'src="!~!~!~'.DOL_URL_ROOT.'/viewimage.php', $content);
|
||||
$content = str_replace('href="!~!~!~/document.php', 'href="!~!~!~'.DOL_URL_ROOT.'/document.php', $content);
|
||||
|
||||
// Remove the protection tag !~!~!~
|
||||
$content = str_replace('!~!~!~', '', $content);
|
||||
// Remove the protection tag !~!~!~, but only if this is the parent page and not an include
|
||||
if (empty($includehtmlcontentopened)) {
|
||||
$content = str_replace('!~!~!~', '', $content);
|
||||
}
|
||||
}
|
||||
else // REPLACEMENT OF LINKS When page called from virtual host
|
||||
{
|
||||
@ -511,6 +518,9 @@ function includeContainer($containerref)
|
||||
print 'ERROR: RECURSIVE CONTENT LEVEL. Depth of recursive call is more than the limit of '.$MAXLEVEL.".\n";
|
||||
return;
|
||||
}
|
||||
|
||||
//dol_syslog("Include container ".$containerref.' includehtmlcontentopened='.$includehtmlcontentopened);
|
||||
|
||||
// file_get_contents is not possible. We must execute code with include
|
||||
//$content = file_get_contents($fullpathfile);
|
||||
//print preg_replace(array('/^.*<body[^>]*>/ims','/<\/body>.*$/ims'), array('', ''), $content);*/
|
||||
@ -520,7 +530,7 @@ function includeContainer($containerref)
|
||||
$tmpoutput = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
print "\n".'<!-- include '.$websitekey.'/'.$containerref.' level = '.$includehtmlcontentopened.' -->'."\n";
|
||||
print "\n".'<!-- include '.$websitekey.'/'.$containerref.(is_object($websitepage) ? ' parent id='.$websitepage->id : '').' level = '.$includehtmlcontentopened.' -->'."\n";
|
||||
print preg_replace(array('/^.*<body[^>]*>/ims', '/<\/body>.*$/ims'), array('', ''), $tmpoutput);
|
||||
|
||||
if (!$res)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user