Fix files generated

This commit is contained in:
Laurent Destailleur 2018-09-10 23:20:31 +02:00
parent d2c6c7ddff
commit b0be1ddadb
3 changed files with 11 additions and 16 deletions

View File

@ -542,9 +542,7 @@ function dolSaveMasterFile($filemaster)
if (! empty($conf->global->MAIN_UMASK))
@chmod($filemaster, octdec($conf->global->MAIN_UMASK));
if (! $result) setEventMessages('Failed to write file '.$filemaster, null, 'errors');
return ($result?true:false);
return $result;
}
/**
@ -618,7 +616,7 @@ function dolSavePageContent($filetpl, $object, $objectpage)
$tplcontent.= '<!-- Include link to CSS file -->'."\n";
$tplcontent.= '<link rel="stylesheet" href="styles.css.php?websiteid='.$object->id.'" type="text/css" />'."\n";
$tplcontent.= '<!-- Include HTML header from common file -->'."\n";
$tplcontent.= '<?php print preg_replace(\'/<\/?html>/ims\', \'\', file_get_contents(DOL_DATA_ROOT."/website/'.$object->ref.'/htmlheader.html")); ?>'."\n";
$tplcontent.= '<?php print preg_replace(\'/<\/?html>/ims\', \'\', file_get_contents(DOL_DATA_ROOT."/website/".$websitekey."/htmlheader.html")); ?>'."\n";
$tplcontent.= '<!-- Include HTML header from page header block -->'."\n";
$tplcontent.= preg_replace('/<\/?html>/ims', '', $objectpage->htmlheader)."\n";
$tplcontent.= '</head>'."\n";

View File

@ -974,6 +974,11 @@ class Website extends CommonObject
// Now generate the master.inc.php page
$filemaster=$conf->website->dir_output.'/'.$object->ref.'/master.inc.php';
dolSaveMasterFile($filemaster);
if (! $result)
{
$this->errors[]='Failed to write file '.$filemaster;
$error++;
}
dolCopyDir($conf->website->dir_temp.'/'.$object->ref.'/medias/image/websitekey', $conf->website->dir_output.'/'.$object->ref.'/medias/image/'.$object->ref, 0, 1); // Medias can be shared, do not overwrite if exists
dolCopyDir($conf->website->dir_temp.'/'.$object->ref.'/medias/js/websitekey', $conf->website->dir_output.'/'.$object->ref.'/medias/js/'.$object->ref, 0, 1); // Medias can be shared, do not overwrite if exists
@ -999,7 +1004,7 @@ class Website extends CommonObject
$runsql = run_sql($sqlfile, 1, '', 0, '', 'none', 0, 1);
if ($runsql <= 0)
{
$this->errors[]='Failed to load sql file '.$sqlfile.'.';
$this->errors[]='Failed to load sql file '.$sqlfile;
$error++;
}

View File

@ -1134,7 +1134,8 @@ if ($action == 'updatemeta')
// Now generate the master.inc.php page
dolSaveMasterFile($filemaster);
$result = dolSaveMasterFile($filemaster);
if (! $result) setEventMessages('Failed to write file '.$filemaster, null, 'errors');
// Now delete the alias.php page
if (! empty($fileoldalias))
@ -1321,16 +1322,7 @@ if (($action == 'updatesource' || $action == 'updatecontent' || $action == 'conf
// Now generate the master.inc.php page
dol_syslog("We regenerate the master file");
dol_delete_file($filemaster);
$mastercontent = '<?php'."\n";
$mastercontent.= '// File generated to link to the master file'."\n";
$mastercontent.= "if (! defined('USEDOLIBARRSERVER')) require_once '".DOL_DOCUMENT_ROOT."/master.inc.php';\n";
$mastercontent.= '?>'."\n";
$result = file_put_contents($filemaster, $mastercontent);
if (! empty($conf->global->MAIN_UMASK))
@chmod($filemaster, octdec($conf->global->MAIN_UMASK));
$result = dolSaveMasterFile($filemaster);
if (! $result) setEventMessages('Failed to write file '.$filemaster, null, 'errors');