From e8481d38c7d8cce0c3f8675d306382412bf3e445 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 12 May 2022 00:52:28 +0200 Subject: [PATCH] Fix missing index.php file on "regenerate all files" button --- htdocs/website/class/website.class.php | 13 +++++++++---- htdocs/website/index.php | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/htdocs/website/class/website.class.php b/htdocs/website/class/website.class.php index 80a48048151..a353ea64e83 100644 --- a/htdocs/website/class/website.class.php +++ b/htdocs/website/class/website.class.php @@ -1287,7 +1287,7 @@ class Website extends CommonObject } /** - * Rebuild all files of a containers of a website. Rebuild also the wrapper.php file. TODO Add other files too. + * Rebuild all files of all the pages/containers of a website. Rebuild also the index and wrapper.php file. * Note: Files are already regenerated during importWebSite so this function is useless when importing a website. * * @return int <0 if KO, >=0 if OK @@ -1339,7 +1339,7 @@ class Website extends CommonObject $aliasesarray[] = $objectpagestatic->pageurl; } - // Regenerate all aliases pages (pages with a natural name) + // Regenerate also all aliases pages (pages with a natural name) by calling dolSavePageAlias() if (is_array($aliasesarray)) { foreach ($aliasesarray as $aliasshortcuttocreate) { if (trim($aliasshortcuttocreate)) { @@ -1357,10 +1357,15 @@ class Website extends CommonObject } if (!$error) { - // Save wrapper.php + // Save index.php and wrapper.php $pathofwebsite = $conf->website->dir_output.'/'.$object->ref; + $fileindex = $pathofwebsite.'/index.php'; + $filetpl = ''; + if ($object->fk_default_home) { + $filetpl = $pathofwebsite.'/page'.$object->fk_default_home.'.tpl.php'; + } $filewrapper = $pathofwebsite.'/wrapper.php'; - dolSaveIndexPage($pathofwebsite, '', '', $filewrapper); + dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper); } if ($error) { diff --git a/htdocs/website/index.php b/htdocs/website/index.php index 8ac4d612264..705ac92d709 100644 --- a/htdocs/website/index.php +++ b/htdocs/website/index.php @@ -2181,7 +2181,7 @@ if ($action == 'regeneratesite' && $usercanedit) { $pathtomediasinwebsite = $pathofwebsite.'/medias'; if (!is_link(dol_osencode($pathtomediasinwebsite))) { dol_syslog("Create symlink for ".$pathtomedias." into name ".$pathtomediasinwebsite); - dol_mkdir(dirname($pathtomediasinwebsite)); // To be sure dir for website exists + dol_mkdir(dirname($pathtomediasinwebsite)); // To be sure that the directory for website exists $result = symlink($pathtomedias, $pathtomediasinwebsite); if (!$result) { setEventMessages($langs->trans("ErrorFieldToCreateSymLinkToMedias", $pathtomediasinwebsite, $pathtomedias), null, 'errors');