Fix missing index.php file on "regenerate all files" button

This commit is contained in:
Laurent Destailleur 2022-05-12 00:52:28 +02:00
parent 7b21e0b6ff
commit e8481d38c7
2 changed files with 10 additions and 5 deletions

View File

@ -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) {

View File

@ -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');