diff --git a/htdocs/core/js/lib_head.js.php b/htdocs/core/js/lib_head.js.php
index cf8557de961..d177e7d99c1 100644
--- a/htdocs/core/js/lib_head.js.php
+++ b/htdocs/core/js/lib_head.js.php
@@ -856,7 +856,8 @@ function newpopup(url, title) {
}
/**
- * Function show document preview. Use the "dialog" function.
+ * Function show document preview. It uses the "dialog" function.
+ * The a tag around the img must have the src='', class='documentpreview', mime='image/xxx', target='_blank' from getAdvancedPreviewUrl().
*
* @param string file Url
* @param string type Mime file type ("image/jpeg", "application/pdf", "text/html")
diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php
index bc1e08353cb..456580124d8 100644
--- a/htdocs/core/lib/website.lib.php
+++ b/htdocs/core/lib/website.lib.php
@@ -30,14 +30,16 @@
* @param string $content Content to replace
* @param int $removephppart 0=Replace PHP sections with a PHP badge. 1=Remove completely PHP sections.
* @param string $contenttype Content type
+ * @param int $containerid Contenair id
* @return boolean True if OK
* @see dolWebsiteOutput() for function used to replace content in a web server context
*/
-function dolWebsiteReplacementOfLinks($website, $content, $removephppart = 0, $contenttype = 'html')
+function dolWebsiteReplacementOfLinks($website, $content, $removephppart = 0, $contenttype = 'html', $containerid = '')
{
$nbrep = 0;
- dol_syslog('dolWebsiteReplacementOfLinks start (contenttype='.$contenttype." USEDOLIBARRSERVER=".(defined('USEDOLIBARRSERVER')?'1':'')." USEDOLIBARREDITOR=".(defined('USEDOLIBARREDITOR')?'1':'').')', LOG_DEBUG);
+ dol_syslog('dolWebsiteReplacementOfLinks start (contenttype='.$contenttype." containerid=".$containerid." USEDOLIBARREDITOR=".(defined('USEDOLIBARREDITOR')?'1':'')." USEDOLIBARRSERVER=".(defined('USEDOLIBARRSERVER')?'1':'').')', LOG_DEBUG);
+ //if ($contenttype == 'html') { print $content;exit; }
// Replace php code. Note $content may come from database and does not contains body tags.
$replacewith='...php...';
@@ -72,8 +74,9 @@ function dolWebsiteReplacementOfLinks($website, $content, $removephppart = 0, $c
// Replace relative link / with dolibarr URL
$content = preg_replace('/(href=")\/\"/', '\1'.DOL_URL_ROOT.'/website/index.php?website='.$website->ref.'&pageid='.$website->fk_default_home.'"', $content, -1, $nbrep);
- // Replace relative link /xxx.php with dolibarr URL
- $content = preg_replace('/(href=")\/?([^:\"]*)(\.php\")/', '\1'.DOL_URL_ROOT.'/website/index.php?website='.$website->ref.'&pageref=\2"', $content, -1, $nbrep);
+ // Replace relative link /xxx.php#aaa or /xxx.php with dolibarr URL (we discard param ?...)
+ // TODO To support replacement of /xxx.php?bbb=ccc we must be able to replace only if link is not already DOL_URL_ROOT.'/website/index.php
+ $content = preg_replace('/(href=")\/?([^:\"]*)\.php(\?[^\"<>#]*)?(#[^\"<>]*)?\"/', '\1'.DOL_URL_ROOT.'/website/index.php?website='.$website->ref.'&pageref=\2\4"', $content, -1, $nbrep);
// Fix relative link into medias with correct URL after the DOL_URL_ROOT: ../url("medias/
$content = preg_replace('/url\((["\']?)medias\//', 'url(\1'.DOL_URL_ROOT.'/viewimage.php?modulepart=medias&file=', $content, -1, $nbrep);
@@ -97,6 +100,7 @@ function dolWebsiteReplacementOfLinks($website, $content, $removephppart = 0, $c
$content=preg_replace('/(url\(")(\/?viewimage\.php\?[^\"]*modulepart=[^\"]*)(\")/', '\1'.DOL_URL_ROOT.'\2\3', $content, -1, $nbrep);
dol_syslog('dolWebsiteReplacementOfLinks end', LOG_DEBUG);
+ //if ($contenttype == 'html') { print $content;exit; }
return $content;
}
@@ -196,7 +200,7 @@ function dolWebsiteOutput($content, $contenttype = 'html', $containerid = '')
global $db, $langs, $conf, $user;
global $dolibarr_main_url_root, $dolibarr_main_data_root;
- dol_syslog("dolWebsiteOutput start (contenttype=".$contenttype." containerid=".$containerid." USEDOLIBARRSERVER=".(defined('USEDOLIBARRSERVER')?'1':'')." USEDOLIBARREDITOR=".(defined('USEDOLIBARREDITOR')?'1':'').')');
+ dol_syslog("dolWebsiteOutput start (contenttype=".$contenttype." containerid=".$containerid." USEDOLIBARREDITOR=".(defined('USEDOLIBARREDITOR')?'1':'')." USEDOLIBARRSERVER=".(defined('USEDOLIBARRSERVER')?'1':'').')');
// Define $urlwithroot
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT, '/').'$/i', '', trim($dolibarr_main_url_root));
diff --git a/htdocs/core/lib/website2.lib.php b/htdocs/core/lib/website2.lib.php
index f45df83700a..cf6082f3bd8 100644
--- a/htdocs/core/lib/website2.lib.php
+++ b/htdocs/core/lib/website2.lib.php
@@ -322,10 +322,30 @@ 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;
+}
/**
- * Show list of themes. Show all thumbs of themes
+ * Show list of themes. Show all thumbs of themes/skins
*
* @param Website $website Object website to load the tempalte into
* @return void
@@ -397,11 +417,25 @@ function showWebsiteTemplates(Website $website)
print '
';
- $file=$dirtheme."/".$subdirwithoutzip.".jpg";
+ $file = $dirtheme."/".$subdirwithoutzip.".jpg";
$url=DOL_URL_ROOT.'/viewimage.php?modulepart=doctemplateswebsite&file='.$subdirwithoutzip.".jpg";
if (! file_exists($file)) $url=DOL_URL_ROOT.'/public/theme/common/nophoto.png';
- print '

';
+
+ $originalfile = basename($file);
+ $entity = $conf->entity;
+ $modulepart = 'doctemplateswebsite';
+ $cache = '';
+ $title = $file;
+
+ $ret='';
+ $urladvanced=getAdvancedPreviewUrl($modulepart, $originalfile, 1, '&entity='.$entity);
+ if (! empty($urladvanced)) $ret.='
';
+ else $ret.='';
+ print $ret;
+ print '
';
+ print '';
+
print '
';
print $subdir.' ('.dol_print_size(dol_filesize($dirtheme."/".$subdir), 1, 1).')';
print '
ref.'&templateuserfile='.$subdir.'" class="button">'.$langs->trans("Load").'';
diff --git a/htdocs/core/modules/modWebsite.class.php b/htdocs/core/modules/modWebsite.class.php
index 24a929c82a0..cf4623fdb3b 100644
--- a/htdocs/core/modules/modWebsite.class.php
+++ b/htdocs/core/modules/modWebsite.class.php
@@ -158,7 +158,7 @@ class modWebsite extends DolibarrModules
// Remove permissions and default values
$this->remove($options);
- // Copy flags and octicons directoru
+ // Copy flags and octicons directory
$dirarray=array('common/flags', 'common/octicons');
foreach($dirarray as $dir)
{
@@ -179,6 +179,26 @@ class modWebsite extends DolibarrModules
}
}
+ // Website templates
+ $srcroot=DOL_DOCUMENT_ROOT.'/install/doctemplates/websites';
+ $destroot=DOL_DATA_ROOT.'/doctemplates/websites';
+
+ dol_mkdir($destroot);
+
+ $docs=dol_dir_list($srcroot, 'files', 0, 'website_.*(\.zip|\.jpg)$');
+ foreach($docs as $cursorfile)
+ {
+ $src=$srcroot.'/'.$cursorfile['name'];
+ $dest=$destroot.'/'.$cursorfile['name'];
+
+ $result=dol_copy($src, $dest, 0, 0);
+ if ($result < 0)
+ {
+ $langs->load("errors");
+ $this->error=$langs->trans('ErrorFailToCopyFile', $src, $dest);
+ }
+ }
+
$sql = array();
return $this->_init($sql, $options);
diff --git a/htdocs/install/doctemplates/websites/website-template-corporate.jpg b/htdocs/install/doctemplates/websites/website_template-corporate.jpg
similarity index 100%
rename from htdocs/install/doctemplates/websites/website-template-corporate.jpg
rename to htdocs/install/doctemplates/websites/website_template-corporate.jpg
diff --git a/htdocs/install/doctemplates/websites/website_template-corporate.zip b/htdocs/install/doctemplates/websites/website_template-corporate.zip
index 6ee933a0c7b..e86e11df288 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.jpg b/htdocs/install/doctemplates/websites/website_template-stellar.jpg
new file mode 100644
index 00000000000..66867384b58
Binary files /dev/null and b/htdocs/install/doctemplates/websites/website_template-stellar.jpg differ
diff --git a/htdocs/install/doctemplates/websites/website_template-stellar.zip b/htdocs/install/doctemplates/websites/website_template-stellar.zip
new file mode 100644
index 00000000000..728b9f37b35
Binary files /dev/null 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 f01494fcdac..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.
@@ -106,4 +108,6 @@ DeleteAlsoJs=Delete also all javascript files specific to this website?
DeleteAlsoMedias=Delete also all medias files specific to this website?
MyWebsitePages=My website pages
SearchReplaceInto=Search | Replace into
-ReplaceString=New string
\ No newline at end of file
+ReplaceString=New string
+CSSContentTooltipHelp=Enter here CSS content. To avoid any conflict with the CSS of the application, be sure to prepend all declaration with the .bodywebsite class. For example:
#mycssselector, input.myclass:hover { ... }
must be
.bodywebsite #mycssselector, .bodywebsite input.myclass:hover { ... }
Note: If you have a large file without this prefix, you can use 'lessc' to convert it to append the .bodywebsite prefix everywhere.
+LinkAndScriptsHereAreNotLoadedInEditor=Warning: This content is output only when site is accessed from a server. It is not used in Edit mode so if you need to load javascript files also in edit mode, just add your tag 'script src=...' into the page.
\ No newline at end of file
diff --git a/htdocs/theme/eldy/global.inc.php b/htdocs/theme/eldy/global.inc.php
index d0a0c5958ef..b05968356ce 100644
--- a/htdocs/theme/eldy/global.inc.php
+++ b/htdocs/theme/eldy/global.inc.php
@@ -3020,11 +3020,15 @@ table.noborder.paymenttable {
height: 22px;
}
-/* Disable shadows */
+/* Disable-Enable shadows */
.noshadow {
-webkit-box-shadow: 0px 0px 0px #DDD !important;
box-shadow: 0px 0px 0px #DDD !important;
}
+.shadow {
+ -webkit-box-shadow: 2px 2px 5px #CCC !important;
+ box-shadow: 2px 2px 5px #CCC !important;
+}
div.tabBar .noborder {
-webkit-box-shadow: 0px 0px 0px #DDD !important;
diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php
index 4218552c9aa..31b10401c8c 100644
--- a/htdocs/website/class/website.class.php
+++ b/htdocs/website/class/website.class.php
@@ -931,6 +931,10 @@ class Website extends CommonObject
$stringtoexport = str_replace('file=logos%2Fthumbs%2F'.$mysoc->logo_small, "file=logos%2Fthumbs%2F__LOGO_SMALL_KEY__", $stringtoexport);
$stringtoexport = str_replace('file=logos%2Fthumbs%2F'.$mysoc->logo_mini, "file=logos%2Fthumbs%2F__LOGO_MINI_KEY__", $stringtoexport);
$stringtoexport = str_replace('file=logos%2Fthumbs%2F'.$mysoc->logo, "file=logos%2Fthumbs%2F__LOGO_KEY__", $stringtoexport);
+
+ // When we have a link src="image/websiteref/file.png" into html content
+ $stringtoexport = str_replace('="image/'.$website->ref.'/', '="image/__WEBSITE_KEY__/', $stringtoexport);
+
$line.= "'".$this->db->escape($stringtoexport)."'"; // Replace \r \n to have record on 1 line
$line.= ");";
$line.= "\n";
diff --git a/htdocs/website/index.php b/htdocs/website/index.php
index 6b73907ad70..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";
@@ -2557,7 +2605,8 @@ if ($action == 'editcss')
// CSS file
print '
| ';
- print $langs->trans('WEBSITE_CSS_INLINE');
+ $htmlhelp=$langs->trans("CSSContentTooltipHelp");
+ print $form->textwithpicto($langs->trans('WEBSITE_CSS_INLINE'), $htmlhelp, 1, 'help', '', 0, 2, 'csstooltip');
print ' | ';
$doleditor=new DolEditor('WEBSITE_CSS_INLINE', $csscontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', '');
@@ -2577,9 +2626,12 @@ if ($action == 'editcss')
// Common HTML header
print ' |
';
+ print $langs->trans('WEBSITE_HTML_HEADER');
$htmlhelp=$langs->trans("Example").' : ';
$htmlhelp.=dol_htmlentitiesbr($htmlheadercontentdefault);
- print $form->textwithpicto($langs->trans('WEBSITE_HTML_HEADER'), $htmlhelp, 1, 'help', '', 0, 2, 'htmlheadertooltip');
+ $textwithhelp = $form->textwithpicto('', $htmlhelp, 1, 'help', '', 0, 2, 'htmlheadertooltip');
+ $htmlhelp2=$langs->trans("LinkAndScriptsHereAreNotLoadedInEditor").' ';
+ print $form->textwithpicto($textwithhelp, $htmlhelp2, 1, 'warning', '', 0, 2, 'htmlheadertooltip2');
print ' | ';
$doleditor=new DolEditor('WEBSITE_HTML_HEADER', $htmlheadercontent, '', '220', 'ace', 'In', true, false, 'ace', 0, '100%', '');
@@ -2619,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();
@@ -3281,7 +3344,7 @@ if ($action == 'preview' || $action == 'createfromclone' || $action == 'createpa
{
// Keep the contenteditable="true" when mode Edit Inline is on
}
- $out.=dolWebsiteReplacementOfLinks($object, $newcontent)."\n";
+ $out.=dolWebsiteReplacementOfLinks($object, $newcontent, 0, 'html', $objectpage->id)."\n";
//$out.=$newcontent;
$out.='
';