diff --git a/htdocs/core/lib/website2.lib.php b/htdocs/core/lib/website2.lib.php index 4de604e1752..e06c08b8a7c 100644 --- a/htdocs/core/lib/website2.lib.php +++ b/htdocs/core/lib/website2.lib.php @@ -22,7 +22,6 @@ */ - /** * Save content of a page on disk * @@ -543,11 +542,13 @@ function showWebsiteTemplates(Website $website) global $conf, $langs, $form, $user; $dirthemes = array('/doctemplates/websites'); - if (!empty($conf->modules_parts['websitetemplates'])) { // Using this feature slow down application + /* + if (!empty($conf->modules_parts['websitetemplates'])) { foreach ($conf->modules_parts['websitetemplates'] as $reldir) { $dirthemes = array_merge($dirthemes, (array) ($reldir.'doctemplates/websites')); } } + */ $dirthemes = array_unique($dirthemes); // Now dir_themes=array('/themes') or dir_themes=array('/theme','/mymodule/theme') diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 2a81062d00e..64fc3022684 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -2284,6 +2284,28 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it continue; // Discard empty arrays } + // If module brings website templates, we must generate the zip like we do whenenabling the website module + if ($key == 'websitetemplates' && $value == 1) { + $srcroot = dol_buildpath('/'.strtolower($this->name).'/doctemplates/websites'); + + // Copy templates in dir format (recommended) into zip file + $docs = dol_dir_list($srcroot, 'directories', 0, 'website_.*$'); + foreach ($docs as $cursorfile) { + $src = $srcroot.'/'.$cursorfile['name']; + $dest = DOL_DATA_ROOT.'/doctemplates/websites/'.$cursorfile['name']; + + // Compress it + global $errormsg; + $errormsg = ''; + $result = dol_compress_dir($src, $dest.'.zip', 'zip'); + if ($result < 0) { + $error++; + $this->error = ($errormsg ? $errormsg : $langs->trans('ErrorFailToCreateZip', $dest)); + $this->errors[] = ($errormsg ? $errormsg : $langs->trans('ErrorFailToCreateZip', $dest)); + } + } + } + $entity = $conf->entity; // Reset the current entity $newvalue = $value; diff --git a/htdocs/core/modules/modWebsite.class.php b/htdocs/core/modules/modWebsite.class.php index a1a573553b3..f75acbf713b 100644 --- a/htdocs/core/modules/modWebsite.class.php +++ b/htdocs/core/modules/modWebsite.class.php @@ -215,9 +215,8 @@ class modWebsite extends DolibarrModules } } - // Copy templates in dir format (recommended) + // Copy templates in dir format (recommended) into zip file $docs = dol_dir_list($srcroot, 'directories', 0, 'website_.*$'); - foreach ($docs as $cursorfile) { $src = $srcroot.'/'.$cursorfile['name']; $dest = $destroot.'/'.$cursorfile['name'];