Skip to content

Commit

Permalink
Debug website module
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Dec 17, 2017
1 parent 5cd0039 commit 8d671b2
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 7 deletions.
2 changes: 1 addition & 1 deletion htdocs/core/lib/website.lib.php
Expand Up @@ -39,7 +39,7 @@ function dolWebsiteReplacementOfLinks($website, $content, $removephppart=0)
if ($removephppart) $replacewith='';
$content = preg_replace('/value="<\?php((?!\?>).)*\?>\n*/ims', 'value="'.$replacewith.'"', $content);

$replacewith='<span style="background: #ddd; border: 1px solid #ccc; border-radius: 4px;">...php...</span>';
$replacewith='<span class="phptag">...php...</span>';
if ($removephppart) $replacewith='';
$content = preg_replace('/<\?php((?!\?>).)*\?>\n*/ims', $replacewith, $content);

Expand Down
4 changes: 4 additions & 0 deletions htdocs/theme/eldy/style.css.php
Expand Up @@ -3468,6 +3468,10 @@
/* Module website */
/* ============================================================================== */

.phptag {
background: #ddd; border: 1px solid #ccc; border-radius: 4px;
}

.nobordertransp {
border: 0px;
background-color: transparent;
Expand Down
4 changes: 4 additions & 0 deletions htdocs/theme/md/style.css.php
Expand Up @@ -3533,6 +3533,10 @@
/* Module website */
/* ============================================================================== */

.phptag {
background: #ddd; border: 1px solid #ccc; border-radius: 4px;
}

.nobordertransp {
border: 0px;
background-color: transparent;
Expand Down
44 changes: 38 additions & 6 deletions htdocs/website/index.php
Expand Up @@ -110,6 +110,15 @@
if (($pageid > 0 || $pageref) && $action != 'addcontainer')
{
$res = $objectpage->fetch($pageid, ($object->id > 0 ? $object->id : null), $pageref);
// Check if pageid is inside the new website, if not we reset param pageid
if ($object->id > 0 && ($objectpage->fk_website != $object->id))
{
$res = $objectpage->fetch(0, $object->id, '');;
if ($res == 0) // Page was not found, we reset it
{
$objectpage=new WebsitePage($db);
}
}
$pageid = $objectpage->id;
}

Expand Down Expand Up @@ -1202,6 +1211,7 @@
'/includes/ace/ext-statusbar.js',
'/includes/ace/ext-language_tools.js',
//'/includes/ace/ext-chromevox.js'
//'/includes/jquery/plugins/jqueryscoped/jquery.scoped.js',
);
$arrayofcss = array();

Expand Down Expand Up @@ -2016,11 +2026,30 @@

// 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, 1);
$out.= '/* Include HTML header from the inline block */'."\n";
$out.= $objectpage->htmlheader."\n";
$out.='<style scoped>'."\n"; // "scoped" means "apply to parent element only". No more supported by browsers, snif !
$tmpout='';
$tmpout.= '/* Include website CSS file */'."\n";
$tmpout.= dolWebsiteReplacementOfLinks($object, $csscontent, 1);
$tmpout.= '/* Include style from the HTML header of page */'."\n";
// Clean the html header of page to get only <style> content
$tmp = preg_split('(<style[^>]*>|</style>)', $objectpage->htmlheader);
$tmpstyleinheader ='';
$i=0;
foreach($tmp as $valtmp)
{
$i++;
if ($i % 2 == 0) $tmpstyleinheader.=$valtmp."\n";
}
//$tmpstyleinheader.='</style>';
//$pos=strpos($tmpstyleinheader, '<style');
//if ($pos) $tmpstyleinheader = substr($tmpstyleinheader, $pos);
//$tmpstyleinheader = preg_replace('/^.*(<style[^>]*>)+/ims','aaa', $tmpstyleinheader);
//$tmpstyleinheader = preg_replace('/(</style>).*$/ims','$1', $tmpstyleinheader);
//$tmpstyleinheader = preg_replace('/</style>.*<style[^>]*>/ims','', $tmpstyleinheader);
$tmpout.= $tmpstyleinheader."\n";
// Clean style that may affect global style of Dolibarr
$tmpout=preg_replace('/}[\s\n]*body\s*{[^}]+}/ims','}',$tmpout);
$out.=$tmpout;
$out.='</style>'."\n";

// Do not enable the contenteditable when page was grabbed, ckeditor is removing span and adding borders,
Expand All @@ -2032,10 +2061,13 @@

$out.='</div>';

$out.='</div>';
$out.='</div> <!-- End div id=websitecontentundertopmenu -->';

$out.= "\n".'<!-- End page content '.$filetpl.' -->'."\n\n";

// For jqueryscoped (does not work as expected)
//$out.="<script>$.scoped();</script>";

print $out;

/*file_put_contents($filetpl, $out);
Expand Down

0 comments on commit 8d671b2

Please sign in to comment.