diff --git a/htdocs/core/lib/website2.lib.php b/htdocs/core/lib/website2.lib.php
index 58a0c6a64dd..6f532e078b3 100644
--- a/htdocs/core/lib/website2.lib.php
+++ b/htdocs/core/lib/website2.lib.php
@@ -533,6 +533,27 @@ function dolSaveReadme($file, $content)
return $result;
}
+/**
+ * Save content of a page on disk
+ *
+ * @param string $file Full path of filename to generate
+ * @param string $content Content of file
+ * @return boolean True if OK
+ */
+function dolSaveLicense($file, $content)
+{
+ global $conf, $pathofwebsite;
+
+ dol_syslog("Save LICENSE file into ".$file);
+
+ dol_mkdir($pathofwebsite);
+ $result = file_put_contents($file, $content);
+ if (!empty($conf->global->MAIN_UMASK)) {
+ @chmod($file, octdec($conf->global->MAIN_UMASK));
+ }
+
+ return $result;
+}
/**
* Show list of themes. Show all thumbs of themes/skins
diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang
index 3d5a57e91d3..379eadef08f 100644
--- a/htdocs/langs/en_US/website.lang
+++ b/htdocs/langs/en_US/website.lang
@@ -16,9 +16,9 @@ WEBSITE_HTML_HEADER=Addition at bottom of HTML Header (common to all pages)
WEBSITE_ROBOT=Robot file (robots.txt)
WEBSITE_HTACCESS=Website .htaccess file
WEBSITE_MANIFEST_JSON=Website manifest.json file
-WEBSITE_README=README.md file
WEBSITE_KEYWORDSDesc=Use a comma to separate values
-EnterHereLicenseInformation=Enter here meta data or license information to fille a README.md file. if you distribute your website as a template, the file will be included into the temptate package.
+EnterHereReadmeInformation=Enter here a description of the website. If you distribute your website as a template, the file will be included into the temptate package.
+EnterHereLicenseInformation=Enter here the LICENSE of the code of the website. If you distribute your website as a template, the file will be included into the temptate package.
HtmlHeaderPage=HTML header (specific to this page only)
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.
EditTheWebSiteForACommonHeader=Note: If you want to define a personalized header for all pages, edit the header on the site level instead of on the page/container.
diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php
index 811c0e9c7cc..b18daba1031 100644
--- a/htdocs/website/class/website.class.php
+++ b/htdocs/website/class/website.class.php
@@ -979,6 +979,9 @@ class Website extends CommonObject
dol_syslog("Copy pages from ".$srcdir." into ".$destdir);
dolCopyDir($srcdir, $destdir, 0, 1, $arrayreplacementinfilename, 2, array('old', 'back'));
+ // Copy file README.md from containers to root
+ dol_copy($conf->website->dir_temp.'/'.$website->ref.'/containers/README.md', $conf->website->dir_temp.'/'.$website->ref.'/README.md');
+
// Copy files into medias/image
$srcdir = DOL_DATA_ROOT.'/medias/image/'.$website->ref;
$destdir = $conf->website->dir_temp.'/'.$website->ref.'/medias/image/websitekey';
diff --git a/htdocs/website/index.php b/htdocs/website/index.php
index f92642556d0..ac92d6166e7 100644
--- a/htdocs/website/index.php
+++ b/htdocs/website/index.php
@@ -243,6 +243,7 @@ $fileindex = $pathofwebsite.'/index.php';
$filewrapper = $pathofwebsite.'/wrapper.php';
$filemanifestjson = $pathofwebsite.'/manifest.json.php';
$filereadme = $pathofwebsite.'/README.md';
+$filelicense = $pathofwebsite.'/LICENSE';
$filemaster = $pathofwebsite.'/master.inc.php';
// Define $urlwithroot
@@ -1191,6 +1192,11 @@ if ($action == 'addcontainer' && $usercanedit) {
$result = dolSaveReadme($filereadme, $readmecontent);
}
+ if (!dol_is_file($filelicense)) {
+ $licensecontent = "MIT License";
+ $result = dolSaveLicense($filelicense, $licensecontent);
+ }
+
$action = 'preview';
}
}
@@ -1669,6 +1675,43 @@ if ($action == 'updatecss' && $usercanedit) {
$error++;
}
+ $dataposted = trim(GETPOST('WEBSITE_LICENSE', 'restricthtml'));
+ $dataposted = str_replace('=', '\n";*/
+
+ $licensecontent .= $dataposted."\n";
+
+ /*$readmecontent.= '"."\n";*/
+
+ $result = dolSaveLicense($filelicense, $licensecontent);
+ if (!$result) {
+ $error++;
+ setEventMessages('Failed to write file '.$filelicense, null, 'errors');
+ }
+ } else {
+ $error++;
+ }
// Save wrapper.php
$result = dolSaveIndexPage($pathofwebsite, '', '', $filewrapper, $object);
@@ -3365,6 +3408,17 @@ if ($action == 'editcss') {
//$readmecontent.="";
}
+ if (!GETPOSTISSET('WEBSITE_LICENSE')) {
+ $licensecontent = @file_get_contents($filelicense);
+ // Clean the readme file to remove php code and get only html part
+ $licensecontent = preg_replace('/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims', '', $licensecontent);
+ } else {
+ $licensecontent = GETPOST('WEBSITE_LICENSE', 'none');
+ }
+ if (!trim($licensecontent)) {
+ //$readmecontent.="";
+ }
+
print dol_get_fiche_head();
print ''."\n";
@@ -3507,8 +3561,8 @@ if ($action == 'editcss') {
// README.md
print '