diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang
index c065dc7ca53..4352c480fc0 100644
--- a/htdocs/langs/en_US/website.lang
+++ b/htdocs/langs/en_US/website.lang
@@ -7,7 +7,8 @@ WEBSITE_PAGENAME=Page name/alias
WEBSITE_HTML_HEADER=HTML Header (common to all pages)
HtmlHeaderPage=HTML specific header for ppage
WEBSITE_CSS_URL=URL of external CSS file
-WEBSITE_CSS_INLINE=CSS content
+WEBSITE_CSS_INLINE=CSS file content (common to all pages)
+WEBSITE_JS_INLINE=Javascript file content (common to all pages)
WEBSITE_ROBOT=Robot file (robots.txt)
WEBSITE_HTACCESS=Web site .htaccess file
PageNameAliasHelp=Name or alias of the page.
This alias is also used to forge a SEO URL when website is ran from a Virtual host of a Web server (like Apacke, Nginx, ...). Use the button "%s" to edit this alias.
diff --git a/htdocs/websites/index.php b/htdocs/websites/index.php
index 18941f20823..523e7b7e561 100644
--- a/htdocs/websites/index.php
+++ b/htdocs/websites/index.php
@@ -141,6 +141,7 @@ global $dolibarr_main_data_root;
$pathofwebsite=$dolibarr_main_data_root.'/websites/'.$website;
$filehtmlheader=$pathofwebsite.'/htmlheader.html';
$filecss=$pathofwebsite.'/styles.css.php';
+$filejs=$pathofwebsite.'/javascript.js.php';
$filerobot=$pathofwebsite.'/robots.txt';
$filehtaccess=$pathofwebsite.'/.htaccess';
$filetpl=$pathofwebsite.'/page'.$pageid.'.tpl.php';
@@ -497,10 +498,16 @@ if ($action == 'add')
if (! dol_is_file($filecss))
{
- $csscontent = "/* CSS content (all pages) */\nbody.bodywebsite { margin: 0; }'";
+ $csscontent = "/* CSS content (all pages) */\nbody.bodywebsite { margin: 0; }";
$result=dolSaveCssFile($filecss, $csscontent);
}
+ if (! dol_is_file($filejs))
+ {
+ $jscontent = "/* JS content (all pages) */\n";
+ $result=dolSaveJsFile($filejs, $jscontent);
+ }
+
if (! dol_is_file($filerobot))
{
$robotcontent = "# Robot file. Generated with Dolibarr\nUser-agent: *\nAllow: /public/\nDisallow: /administrator/";
@@ -621,7 +628,39 @@ if ($action == 'updatecss')
}
- // Css file
+ // Js file
+ $jscontent ='';
+
+ $jscontent.= "\n";
+
+ $jscontent.= GETPOST('WEBSITE_JS_INLINE', 'none');
+
+ $jscontent.= "\n".'"."\n";
+
+ dol_syslog("Save js content into ".$filejs);
+
+ dol_mkdir($pathofwebsite);
+ $result = file_put_contents($filejs, $jscontent);
+ if (! empty($conf->global->MAIN_UMASK))
+ @chmod($filejs, octdec($conf->global->MAIN_UMASK));
+
+ if (! $result)
+ {
+ $error++;
+ setEventMessages('Failed to write file '.$filejs, null, 'errors');
+ }
+
+
+ // Robot file
$robotcontent ='';
/*$robotcontent.= "\n*/ims', '', $jscontent);
+ $jscontent.= GETPOST('WEBSITE_JS_INLINE');
+ if (! trim($jscontent)) $jscontent='/* JS content (all pages) */'."\n";
+
$htmlheader = @file_get_contents($filehtmlheader);
// Clean the php htmlheader file to remove php code and get only html part
$htmlheader = preg_replace('/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims', '', $htmlheader);
@@ -1473,6 +1518,16 @@ if ($action == 'editcss')
print '';
+ // JS file
+ print '