diff --git a/htdocs/core/lib/website2.lib.php b/htdocs/core/lib/website2.lib.php index f45df83700a..e622b79bd2c 100644 --- a/htdocs/core/lib/website2.lib.php +++ b/htdocs/core/lib/website2.lib.php @@ -322,6 +322,26 @@ function dolSaveManifestJson($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 dolSaveReadme($file, $content) +{ + global $conf, $pathofwebsite; + + dol_syslog("Save README.md 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; +} /** diff --git a/htdocs/install/doctemplates/websites/website_template-corporate.zip b/htdocs/install/doctemplates/websites/website_template-corporate.zip index 6ee933a0c7b..620f2d379c4 100644 Binary files a/htdocs/install/doctemplates/websites/website_template-corporate.zip and b/htdocs/install/doctemplates/websites/website_template-corporate.zip differ diff --git a/htdocs/install/doctemplates/websites/website_template-stellar.zip b/htdocs/install/doctemplates/websites/website_template-stellar.zip index b7fdfc1bd37..0ef1302528f 100644 Binary files a/htdocs/install/doctemplates/websites/website_template-stellar.zip and b/htdocs/install/doctemplates/websites/website_template-stellar.zip differ diff --git a/htdocs/langs/en_US/website.lang b/htdocs/langs/en_US/website.lang index ec8bc0c2232..7ecb94e3fec 100644 --- a/htdocs/langs/en_US/website.lang +++ b/htdocs/langs/en_US/website.lang @@ -15,6 +15,8 @@ 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 +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. 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/index.php b/htdocs/website/index.php index 8797020a717..d16e8661390 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -184,6 +184,7 @@ $filetpl=$pathofwebsite.'/page'.$pageid.'.tpl.php'; $fileindex=$pathofwebsite.'/index.php'; $filewrapper=$pathofwebsite.'/wrapper.php'; $filemanifestjson=$pathofwebsite.'/manifest.json.php'; +$filereadme=$pathofwebsite.'/README.md'; // Define $urlwithroot $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root)); @@ -855,6 +856,11 @@ if ($action == 'addcontainer') $result=dolSaveManifestJson($filemanifestjson, $manifestjsoncontent); } + if (! dol_is_file($filereadme)) + { + $readmecontent = "Website generated by Dolibarr ERP CRM"; + $result=dolSaveReadme($filereadme, $readmecontent); + } $action = 'preview'; } @@ -1153,6 +1159,33 @@ if ($action == 'updatecss') } + // README.md file + $readmecontent =''; + + /*$readmecontent.= "\n";*/ + + $readmecontent.= trim(GETPOST('WEBSITE_README', 'none'))."\n"; + + /*$readmecontent.= '"."\n";*/ + + $result = dolSaveReadme($filereadme, $readmecontent); + if (! $result) + { + $error++; + setEventMessages('Failed to write file '.$filereadme, null, 'errors'); + } + + // Message if no error if (! $error) { @@ -2529,6 +2562,21 @@ if ($action == 'editcss') //$manifestjsoncontent.=""; } + if (GETPOST('editcss', 'alpha') || GETPOST('refreshpage', 'alpha')) + { + $readmecontent = @file_get_contents($filereadme); + // Clean the readme file to remove php code and get only html part + $readmecontent = preg_replace('/<\?php \/\/ BEGIN PHP[^\?]*END PHP \?>\n*/ims', '', $readmecontent); + } + else + { + $readmecontent = GETPOST('WEBSITE_README'); + } + if (! trim($readmecontent)) + { + //$readmecontent.=""; + } + dol_fiche_head(); print ''."\n"; @@ -2623,6 +2671,17 @@ if ($action == 'editcss') print ''; + // README.md + print ''; + $htmlhelp=$langs->trans("EnterHereLicenseInformation"); + print $form->textwithpicto($langs->trans('WEBSITE_README'), $htmlhelp, 1, 'help', '', 0, 2, 'readmetooltip'); + print ''; + + $doleditor=new DolEditor('WEBSITE_README', $readmecontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', ''); + print $doleditor->Create(1, '', true, $langs->trans("File").' README.md', 'text'); + + print ''; + print ''; dol_fiche_end();