Update templates

This commit is contained in:
Laurent Destailleur 2019-08-15 00:55:47 +02:00
parent dfe2c3de74
commit f81463af0c
5 changed files with 81 additions and 0 deletions

View File

@ -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;
}
/**

View File

@ -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.<br>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 "<strong>%s</strong>" 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.

View File

@ -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.= "<?php // BEGIN PHP\n";
$readmecontent.= '$websitekey=basename(__DIR__);'."\n";
$readmecontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once __DIR__.'/master.inc.php'; } // Load env if not already loaded"."\n"; // For the css, we need to set path of master using the dirname of css file.
$readmecontent.= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
$readmecontent.= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
$readmecontent.= "ob_start();\n";
$readmecontent.= "header('Cache-Control: max-age=3600, public, must-revalidate');\n";
$readmecontent.= "header('Content-type: application/manifest+json');\n";
$readmecontent.= "// END PHP ?>\n";*/
$readmecontent.= trim(GETPOST('WEBSITE_README', 'none'))."\n";
/*$readmecontent.= '<?php // BEGIN PHP'."\n";
$readmecontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "manifest");'."\n";
$readmecontent.= "// END PHP ?>"."\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 '<!-- Edit CSS -->'."\n";
@ -2623,6 +2671,17 @@ if ($action == 'editcss')
print '</td></tr>';
// README.md
print '<tr><td class="tdtop">';
$htmlhelp=$langs->trans("EnterHereLicenseInformation");
print $form->textwithpicto($langs->trans('WEBSITE_README'), $htmlhelp, 1, 'help', '', 0, 2, 'readmetooltip');
print '</td><td>';
$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 '</td></tr>';
print '</table>';
dol_fiche_end();