Debug website module

This commit is contained in:
Laurent Destailleur 2017-12-10 20:34:35 +01:00
parent 748aee9a54
commit 7d553f58f5
2 changed files with 11 additions and 6 deletions

View File

@ -29,14 +29,19 @@
*
* @param Website $website Web site object
* @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
*/
function dolWebsiteReplacementOfLinks($website, $content)
function dolWebsiteReplacementOfLinks($website, $content, $removephppart=0)
{
// Replace php code. Note $content may come from database and does not contains body tags.
$replacewith='...php...';
if ($removephppart) $replacewith='';
$content = preg_replace('/value="<\?php((?!\?>).)*\?>\n*/ims', 'value="'.$replacewith.'"', $content);
$content = preg_replace('/value="<\?php((?!\?>).)*\?>\n*/ims', 'value="...php..."', $content);
$content = preg_replace('/<\?php((?!\?>).)*\?>\n*/ims', '<span style="background: #ddd; border: 1px solid #ccc; border-radius: 4px;">...php...</span>', $content);
$replacewith='<span style="background: #ddd; border: 1px solid #ccc; border-radius: 4px;">...php...</span>';
if ($removephppart) $replacewith='';
$content = preg_replace('/<\?php((?!\?>).)*\?>\n*/ims', $replacewith, $content);
// Replace relative link / with dolibarr URL
$content = preg_replace('/(href=")\/\"/', '\1'.DOL_URL_ROOT.'/website/index.php?website='.$website->ref.'&pageid='.$website->fk_default_home.'"', $content, -1, $nbrep);

View File

@ -2007,9 +2007,9 @@ if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpa
// REPLACEMENT OF LINKS When page called by website editor
$out.='<style scoped>'."\n"; // "scoped" means "apply to parent element only". Not yet supported by browsers
$out.= '<!-- Include website CSS file -->'."\n";
$out.=dolWebsiteReplacementOfLinks($object, $csscontent);
$out.= '<!-- Include HTML header from page inline block -->'."\n";
$out.= '/* Include website CSS file */'."\n";
$out.=dolWebsiteReplacementOfLinks($object, $csscontent, 1);
$out.= '/* Include HTML header from the inline block */'."\n";
$out.= $objectpage->htmlheader."\n";
$out.='</style>'."\n";