FIX Avoid to add new line in css file at each save

This commit is contained in:
Laurent Destailleur 2019-08-14 16:28:41 +02:00
parent 6df36866e1
commit 10a3e773ce
2 changed files with 44 additions and 94 deletions

View File

@ -214,13 +214,7 @@ function dolSaveHtmlHeader($filehtmlheader, $htmlheadercontent)
if (! empty($conf->global->MAIN_UMASK)) if (! empty($conf->global->MAIN_UMASK))
@chmod($filehtmlheader, octdec($conf->global->MAIN_UMASK)); @chmod($filehtmlheader, octdec($conf->global->MAIN_UMASK));
if (! $result) return $result;
{
setEventMessages('Failed to write file '.$filehtmlheader, null, 'errors');
return false;
}
return true;
} }
/** /**
@ -241,13 +235,7 @@ function dolSaveCssFile($filecss, $csscontent)
if (! empty($conf->global->MAIN_UMASK)) if (! empty($conf->global->MAIN_UMASK))
@chmod($filecss, octdec($conf->global->MAIN_UMASK)); @chmod($filecss, octdec($conf->global->MAIN_UMASK));
if (! $result) return $result;
{
setEventMessages('Failed to write file '.$filecss, null, 'errors');
return false;
}
return true;
} }
/** /**
@ -268,13 +256,7 @@ function dolSaveJsFile($filejs, $jscontent)
if (! empty($conf->global->MAIN_UMASK)) if (! empty($conf->global->MAIN_UMASK))
@chmod($filejs, octdec($conf->global->MAIN_UMASK)); @chmod($filejs, octdec($conf->global->MAIN_UMASK));
if (! $result) return $result;
{
setEventMessages('Failed to write file '.$filejs, null, 'errors');
return false;
}
return true;
} }
/** /**
@ -295,13 +277,7 @@ function dolSaveRobotFile($filerobot, $robotcontent)
if (! empty($conf->global->MAIN_UMASK)) if (! empty($conf->global->MAIN_UMASK))
@chmod($filerobot, octdec($conf->global->MAIN_UMASK)); @chmod($filerobot, octdec($conf->global->MAIN_UMASK));
if (! $result) return $result;
{
setEventMessages('Failed to write file '.$filerobot, null, 'errors');
return false;
}
return true;
} }
/** /**
@ -322,13 +298,7 @@ function dolSaveHtaccessFile($filehtaccess, $htaccess)
if (! empty($conf->global->MAIN_UMASK)) if (! empty($conf->global->MAIN_UMASK))
@chmod($filehtaccess, octdec($conf->global->MAIN_UMASK)); @chmod($filehtaccess, octdec($conf->global->MAIN_UMASK));
if (! $result) return $result;
{
setEventMessages('Failed to write file '.$filehtaccess, null, 'errors');
return false;
}
return true;
} }
/** /**
@ -349,13 +319,7 @@ function dolSaveManifestJson($file, $content)
if (! empty($conf->global->MAIN_UMASK)) if (! empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK)); @chmod($file, octdec($conf->global->MAIN_UMASK));
if (! $result) return $result;
{
setEventMessages('Failed to write file '.$file, null, 'errors');
return false;
}
return true;
} }

View File

@ -772,7 +772,10 @@ if ($action == 'addcontainer')
// Save page alias // Save page alias
$result=dolSavePageAlias($filealias, $object, $objectpage); $result=dolSavePageAlias($filealias, $object, $objectpage);
if (! $result) setEventMessages('Failed to write file '.$filealias, null, 'errors'); if (! $result)
{
setEventMessages('Failed to write file '.$filealias, null, 'errors');
}
// Save page of content // Save page of content
$result=dolSavePageContent($filetpl, $object, $objectpage); $result=dolSavePageContent($filetpl, $object, $objectpage);
@ -990,7 +993,11 @@ if ($action == 'updatecss')
// Now generate the master.inc.php page // Now generate the master.inc.php page
$result = dolSaveMasterFile($filemaster); $result = dolSaveMasterFile($filemaster);
if (! $result) setEventMessages('Failed to write file '.$filemaster, null, 'errors'); if (! $result)
{
$error++;
setEventMessages('Failed to write file '.$filemaster, null, 'errors');
}
// Html header file // Html header file
@ -1014,7 +1021,12 @@ if ($action == 'updatecss')
$htmlheadercontent = trim($htmlheadercontent)."\n"; $htmlheadercontent = trim($htmlheadercontent)."\n";
dolSaveHtmlHeader($filehtmlheader, $htmlheadercontent); $result = dolSaveHtmlHeader($filehtmlheader, $htmlheadercontent);
if (! $result)
{
$error++;
setEventMessages('Failed to write file '.$filehtmlheader, null, 'errors');
}
// Css file // Css file
@ -1032,19 +1044,15 @@ if ($action == 'updatecss')
$csscontent.= "}\n"; $csscontent.= "}\n";
$csscontent.= "// END PHP ?>\n"; $csscontent.= "// END PHP ?>\n";
$csscontent.= GETPOST('WEBSITE_CSS_INLINE', 'none'); $csscontent.= trim(GETPOST('WEBSITE_CSS_INLINE', 'none'))."\n";
$csscontent.= "\n".'<?php // BEGIN PHP'."\n"; $csscontent.= '<?php // BEGIN PHP'."\n";
$csscontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "css");'."\n"; $csscontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "css");'."\n";
$csscontent.= "// END PHP ?>"."\n"; $csscontent.= "// END PHP ?>"."\n";
dol_syslog("Save css content into ".$filecss); dol_syslog("Save css content into ".$filecss);
dol_mkdir($pathofwebsite); $result = dolSaveCssFile($filecss, $csscontent);
$result = file_put_contents($filecss, $csscontent);
if (! empty($conf->global->MAIN_UMASK))
@chmod($filecss, octdec($conf->global->MAIN_UMASK));
if (! $result) if (! $result)
{ {
$error++; $error++;
@ -1065,19 +1073,13 @@ if ($action == 'updatecss')
$jscontent.= "header('Content-type: application/javascript');\n"; $jscontent.= "header('Content-type: application/javascript');\n";
$jscontent.= "// END PHP ?>\n"; $jscontent.= "// END PHP ?>\n";
$jscontent.= GETPOST('WEBSITE_JS_INLINE', 'none'); $jscontent.= trim(GETPOST('WEBSITE_JS_INLINE', 'none'))."\n";
$jscontent.= "\n".'<?php // BEGIN PHP'."\n"; $jscontent.= '<?php // BEGIN PHP'."\n";
$jscontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "js");'."\n"; $jscontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "js");'."\n";
$jscontent.= "// END PHP ?>"."\n"; $jscontent.= "// END PHP ?>"."\n";
dol_syslog("Save js content into ".$filejs); $result = dolSaveJsFile($filejs, $jscontent);
dol_mkdir($pathofwebsite);
$result = file_put_contents($filejs, $jscontent);
if (! empty($conf->global->MAIN_UMASK))
@chmod($filejs, octdec($conf->global->MAIN_UMASK));
if (! $result) if (! $result)
{ {
$error++; $error++;
@ -1098,19 +1100,13 @@ if ($action == 'updatecss')
$robotcontent.= "header('Content-type: text/css');\n"; $robotcontent.= "header('Content-type: text/css');\n";
$robotcontent.= "// END PHP ?>\n";*/ $robotcontent.= "// END PHP ?>\n";*/
$robotcontent.= GETPOST('WEBSITE_ROBOT', 'none'); $robotcontent.= trim(GETPOST('WEBSITE_ROBOT', 'none'))."\n";
/*$robotcontent.= "\n".'<?php // BEGIN PHP'."\n"; /*$robotcontent.= "\n".'<?php // BEGIN PHP'."\n";
$robotcontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "robot");'."\n"; $robotcontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "robot");'."\n";
$robotcontent.= "// END PHP ?>"."\n";*/ $robotcontent.= "// END PHP ?>"."\n";*/
dol_syslog("Save file robot into ".$filerobot); $result = dolSaveRobotFile($filerobot, $robotcontent);
dol_mkdir($pathofwebsite);
$result = file_put_contents($filerobot, $robotcontent);
if (! empty($conf->global->MAIN_UMASK))
@chmod($filerobot, octdec($conf->global->MAIN_UMASK));
if (! $result) if (! $result)
{ {
$error++; $error++;
@ -1120,20 +1116,15 @@ if ($action == 'updatecss')
// Htaccess file // Htaccess file
$htaccesscontent =''; $htaccesscontent ='';
$htaccesscontent.= GETPOST('WEBSITE_HTACCESS', 'none'); $htaccesscontent.= trim(GETPOST('WEBSITE_HTACCESS', 'none'))."\n";
dol_syslog("Save file htaccess into ".$filehtaccess); $result = dolSaveHtaccessFile($filehtaccess, $htaccesscontent);
if (! $result)
{
$error++;
setEventMessages('Failed to write file '.$filehtaccess, null, 'errors');
}
dol_mkdir($pathofwebsite);
$result = file_put_contents($filehtaccess, $htaccesscontent);
if (! empty($conf->global->MAIN_UMASK))
@chmod($filehtaccess, octdec($conf->global->MAIN_UMASK));
if (! $result)
{
$error++;
setEventMessages('Failed to write file '.$filehtaccess, null, 'errors');
}
// manifest.json file // manifest.json file
$manifestjsoncontent =''; $manifestjsoncontent ='';
@ -1148,24 +1139,19 @@ if ($action == 'updatecss')
$manifestjsoncontent.= "header('Content-type: application/manifest+json');\n"; $manifestjsoncontent.= "header('Content-type: application/manifest+json');\n";
$manifestjsoncontent.= "// END PHP ?>\n"; $manifestjsoncontent.= "// END PHP ?>\n";
$manifestjsoncontent.= GETPOST('WEBSITE_MANIFEST_JSON', 'none'); $manifestjsoncontent.= trim(GETPOST('WEBSITE_MANIFEST_JSON', 'none'))."\n";
$manifestjsoncontent.= "\n".'<?php // BEGIN PHP'."\n"; $manifestjsoncontent.= '<?php // BEGIN PHP'."\n";
$manifestjsoncontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "manifest");'."\n"; $manifestjsoncontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "manifest");'."\n";
$manifestjsoncontent.= "// END PHP ?>"."\n"; $manifestjsoncontent.= "// END PHP ?>"."\n";
dol_syslog("Save file manifest.json.php into ".$manifestjsoncontent); $result = dolSaveManifestJson($filemanifestjson, $manifestjsoncontent);
if (! $result)
{
$error++;
setEventMessages('Failed to write file '.$filemanifestjson, null, 'errors');
}
dol_mkdir($pathofwebsite);
$result = file_put_contents($filemanifestjson, $manifestjsoncontent);
if (! empty($conf->global->MAIN_UMASK))
@chmod($filemanifestjson, octdec($conf->global->MAIN_UMASK));
if ($result === false)
{
$error++;
setEventMessages('Failed to write file '.$filemanifestjson, null, 'errors');
}
// Message if no error // Message if no error
if (! $error) if (! $error)