Scrutinizer Auto-Fixes

This commit consists of patches automatically generated for this project on https://scrutinizer-ci.com
This commit is contained in:
Scrutinizer Auto-Fixer
2019-11-13 18:35:02 +00:00
parent 545c2207b2
commit 8a527631a0
108 changed files with 11097 additions and 11098 deletions

View File

@@ -38,11 +38,11 @@ function dolSaveMasterFile($filemaster)
dol_delete_file($filemaster);
$mastercontent = '<?php'."\n";
$mastercontent.= '// File generated to link to the master file - DO NOT MODIFY - It is just an include'."\n";
$mastercontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) require_once '".DOL_DOCUMENT_ROOT."/master.inc.php';\n";
$mastercontent.= '?>'."\n";
$mastercontent .= '// File generated to link to the master file - DO NOT MODIFY - It is just an include'."\n";
$mastercontent .= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) require_once '".DOL_DOCUMENT_ROOT."/master.inc.php';\n";
$mastercontent .= '?>'."\n";
$result = file_put_contents($filemaster, $mastercontent);
if (! empty($conf->global->MAIN_UMASK))
if (!empty($conf->global->MAIN_UMASK))
@chmod($filemaster, octdec($conf->global->MAIN_UMASK));
return $result;
@@ -64,17 +64,17 @@ function dolSavePageAlias($filealias, $object, $objectpage)
dol_syslog("dolSavePageAlias We regenerate the alias page filealias=".$filealias);
$aliascontent = '<?php'."\n";
$aliascontent.= "// File generated to wrap the alias page - DO NOT MODIFY - It is just a wrapper to real page\n";
$aliascontent.= 'global $dolibarr_main_data_root;'."\n";
$aliascontent.= 'if (empty($dolibarr_main_data_root)) require \'./page'.$objectpage->id.'.tpl.php\'; ';
$aliascontent.= 'else require $dolibarr_main_data_root.\'/website/\'.$website->ref.\'/page'.$objectpage->id.'.tpl.php\';'."\n";
$aliascontent.= '?>'."\n";
$aliascontent .= "// File generated to wrap the alias page - DO NOT MODIFY - It is just a wrapper to real page\n";
$aliascontent .= 'global $dolibarr_main_data_root;'."\n";
$aliascontent .= 'if (empty($dolibarr_main_data_root)) require \'./page'.$objectpage->id.'.tpl.php\'; ';
$aliascontent .= 'else require $dolibarr_main_data_root.\'/website/\'.$website->ref.\'/page'.$objectpage->id.'.tpl.php\';'."\n";
$aliascontent .= '?>'."\n";
$result = file_put_contents($filealias, $aliascontent);
if (! empty($conf->global->MAIN_UMASK)) {
if (!empty($conf->global->MAIN_UMASK)) {
@chmod($filealias, octdec($conf->global->MAIN_UMASK));
}
return ($result?true:false);
return ($result ?true:false);
}
@@ -96,54 +96,54 @@ function dolSavePageContent($filetpl, $object, $objectpage)
dol_delete_file($filetpl);
$shortlangcode = '';
if ($objectpage->lang) $shortlangcode=preg_replace('/[_-].*$/', '', $objectpage->lang); // en_US or en-US -> en
if ($objectpage->lang) $shortlangcode = preg_replace('/[_-].*$/', '', $objectpage->lang); // en_US or en-US -> en
$tplcontent ='';
$tplcontent.= "<?php // BEGIN PHP\n";
$tplcontent.= '$websitekey=basename(__DIR__); if (empty($websitepagefile)) $websitepagefile=__FILE__;'."\n";
$tplcontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once './master.inc.php'; } // Not already loaded"."\n";
$tplcontent.= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
$tplcontent.= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
$tplcontent.= "ob_start();\n";
$tplcontent.= "// END PHP ?>\n";
if (! empty($conf->global->WEBSITE_FORCE_DOCTYPE_HTML5))
$tplcontent = '';
$tplcontent .= "<?php // BEGIN PHP\n";
$tplcontent .= '$websitekey=basename(__DIR__); if (empty($websitepagefile)) $websitepagefile=__FILE__;'."\n";
$tplcontent .= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once './master.inc.php'; } // Not already loaded"."\n";
$tplcontent .= "require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
$tplcontent .= "require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
$tplcontent .= "ob_start();\n";
$tplcontent .= "// END PHP ?>\n";
if (!empty($conf->global->WEBSITE_FORCE_DOCTYPE_HTML5))
{
$tplcontent.= "<!DOCTYPE html>\n";
$tplcontent .= "<!DOCTYPE html>\n";
}
$tplcontent.= '<html'.($shortlangcode ? ' lang="'.$shortlangcode.'"':'').'>'."\n";
$tplcontent.= '<head>'."\n";
$tplcontent.= '<title>'.dol_string_nohtmltag($objectpage->title, 0, 'UTF-8').'</title>'."\n";
$tplcontent.= '<meta charset="utf-8">'."\n";
$tplcontent.= '<meta http-equiv="content-type" content="text/html; charset=utf-8" />'."\n";
$tplcontent.= '<meta name="robots" content="index, follow" />'."\n";
$tplcontent.= '<meta name="viewport" content="width=device-width, initial-scale=1.0">'."\n";
$tplcontent.= '<meta name="keywords" content="'.dol_string_nohtmltag($objectpage->keywords).'" />'."\n";
$tplcontent.= '<meta name="title" content="'.dol_string_nohtmltag($objectpage->title, 0, 'UTF-8').'" />'."\n";
$tplcontent.= '<meta name="description" content="'.dol_string_nohtmltag($objectpage->description, 0, 'UTF-8').'" />'."\n";
$tplcontent.= '<meta name="generator" content="'.DOL_APPLICATION_TITLE.' '.DOL_VERSION.' (https://www.dolibarr.org)" />'."\n";
$tplcontent.= '<meta name="dolibarr:pageid" content="'.dol_string_nohtmltag($objectpage->id).'" />'."\n";
$tplcontent.= '<link href="/'.(($objectpage->id == $object->fk_default_home) ? '' : ($objectpage->pageurl.'.php')).'" rel="canonical" />'."\n";
$tplcontent.= '<!-- Include link to CSS file -->'."\n";
$tplcontent.= '<link rel="stylesheet" href="styles.css.php?website=<?php echo $websitekey; ?>" 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/".$websitekey."/htmlheader.html")); ?>'."\n";
$tplcontent.= '<!-- Include HTML header from page header block -->'."\n";
$tplcontent.= preg_replace('/<\/?html>/ims', '', $objectpage->htmlheader)."\n";
$tplcontent.= '</head>'."\n";
$tplcontent .= '<html'.($shortlangcode ? ' lang="'.$shortlangcode.'"' : '').'>'."\n";
$tplcontent .= '<head>'."\n";
$tplcontent .= '<title>'.dol_string_nohtmltag($objectpage->title, 0, 'UTF-8').'</title>'."\n";
$tplcontent .= '<meta charset="utf-8">'."\n";
$tplcontent .= '<meta http-equiv="content-type" content="text/html; charset=utf-8" />'."\n";
$tplcontent .= '<meta name="robots" content="index, follow" />'."\n";
$tplcontent .= '<meta name="viewport" content="width=device-width, initial-scale=1.0">'."\n";
$tplcontent .= '<meta name="keywords" content="'.dol_string_nohtmltag($objectpage->keywords).'" />'."\n";
$tplcontent .= '<meta name="title" content="'.dol_string_nohtmltag($objectpage->title, 0, 'UTF-8').'" />'."\n";
$tplcontent .= '<meta name="description" content="'.dol_string_nohtmltag($objectpage->description, 0, 'UTF-8').'" />'."\n";
$tplcontent .= '<meta name="generator" content="'.DOL_APPLICATION_TITLE.' '.DOL_VERSION.' (https://www.dolibarr.org)" />'."\n";
$tplcontent .= '<meta name="dolibarr:pageid" content="'.dol_string_nohtmltag($objectpage->id).'" />'."\n";
$tplcontent .= '<link href="/'.(($objectpage->id == $object->fk_default_home) ? '' : ($objectpage->pageurl.'.php')).'" rel="canonical" />'."\n";
$tplcontent .= '<!-- Include link to CSS file -->'."\n";
$tplcontent .= '<link rel="stylesheet" href="styles.css.php?website=<?php echo $websitekey; ?>" 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/".$websitekey."/htmlheader.html")); ?>'."\n";
$tplcontent .= '<!-- Include HTML header from page header block -->'."\n";
$tplcontent .= preg_replace('/<\/?html>/ims', '', $objectpage->htmlheader)."\n";
$tplcontent .= '</head>'."\n";
$tplcontent.= '<!-- File generated by Dolibarr website module editor -->'."\n";
$tplcontent.= '<body id="bodywebsite" class="bodywebsite bodywebpage-'.$objectpage->ref.'">'."\n";
$tplcontent.= $objectpage->content."\n";
$tplcontent.= '</body>'."\n";
$tplcontent.= '</html>'."\n";
$tplcontent .= '<!-- File generated by Dolibarr website module editor -->'."\n";
$tplcontent .= '<body id="bodywebsite" class="bodywebsite bodywebpage-'.$objectpage->ref.'">'."\n";
$tplcontent .= $objectpage->content."\n";
$tplcontent .= '</body>'."\n";
$tplcontent .= '</html>'."\n";
$tplcontent.= '<?php // BEGIN PHP'."\n";
$tplcontent.= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "html", '.$objectpage->id.');'."\n";
$tplcontent.= "// END PHP ?>"."\n";
$tplcontent .= '<?php // BEGIN PHP'."\n";
$tplcontent .= '$tmp = ob_get_contents(); ob_end_clean(); dolWebsiteOutput($tmp, "html", '.$objectpage->id.');'."\n";
$tplcontent .= "// END PHP ?>"."\n";
//var_dump($filetpl);exit;
$result = file_put_contents($filetpl, $tplcontent);
if (! empty($conf->global->MAIN_UMASK))
if (!empty($conf->global->MAIN_UMASK))
@chmod($filetpl, octdec($conf->global->MAIN_UMASK));
return $result;
@@ -163,33 +163,33 @@ function dolSaveIndexPage($pathofwebsite, $fileindex, $filetpl, $filewrapper)
{
global $conf;
$result1=false;
$result2=false;
$result1 = false;
$result2 = false;
dol_mkdir($pathofwebsite);
dol_delete_file($fileindex);
$indexcontent = '<?php'."\n";
$indexcontent.= "// BEGIN PHP File generated to provide an index.php as Home Page or alias redirector - DO NOT MODIFY - It is just a generated wrapper.\n";
$indexcontent.= '$websitekey=basename(__DIR__); if (empty($websitepagefile)) $websitepagefile=__FILE__;'."\n";
$indexcontent.= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once './master.inc.php'; } // Load master if not already loaded\n";
$indexcontent.= 'if (! empty($_GET[\'pageref\']) || ! empty($_GET[\'pagealiasalt\']) || ! empty($_GET[\'pageid\'])) {'."\n";
$indexcontent.= " require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
$indexcontent.= " require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
$indexcontent.= ' redirectToContainer($_GET[\'pageref\'], $_GET[\'pagealiasalt\'], $_GET[\'pageid\']);'."\n";
$indexcontent.= "}\n";
$indexcontent.= "include_once './".basename($filetpl)."'\n";
$indexcontent.= '// END PHP ?>'."\n";
$indexcontent .= "// BEGIN PHP File generated to provide an index.php as Home Page or alias redirector - DO NOT MODIFY - It is just a generated wrapper.\n";
$indexcontent .= '$websitekey=basename(__DIR__); if (empty($websitepagefile)) $websitepagefile=__FILE__;'."\n";
$indexcontent .= "if (! defined('USEDOLIBARRSERVER') && ! defined('USEDOLIBARREDITOR')) { require_once './master.inc.php'; } // Load master if not already loaded\n";
$indexcontent .= 'if (! empty($_GET[\'pageref\']) || ! empty($_GET[\'pagealiasalt\']) || ! empty($_GET[\'pageid\'])) {'."\n";
$indexcontent .= " require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';\n";
$indexcontent .= " require_once DOL_DOCUMENT_ROOT.'/core/website.inc.php';\n";
$indexcontent .= ' redirectToContainer($_GET[\'pageref\'], $_GET[\'pagealiasalt\'], $_GET[\'pageid\']);'."\n";
$indexcontent .= "}\n";
$indexcontent .= "include_once './".basename($filetpl)."'\n";
$indexcontent .= '// END PHP ?>'."\n";
$result1 = file_put_contents($fileindex, $indexcontent);
if (! empty($conf->global->MAIN_UMASK))
if (!empty($conf->global->MAIN_UMASK))
@chmod($fileindex, octdec($conf->global->MAIN_UMASK));
dol_delete_file($filewrapper);
$wrappercontent=file_get_contents(DOL_DOCUMENT_ROOT.'/website/samples/wrapper.html');
$wrappercontent = file_get_contents(DOL_DOCUMENT_ROOT.'/website/samples/wrapper.html');
$result2 = file_put_contents($filewrapper, $wrappercontent);
if (! empty($conf->global->MAIN_UMASK))
if (!empty($conf->global->MAIN_UMASK))
@chmod($filewrapper, octdec($conf->global->MAIN_UMASK));
return ($result1 && $result2);
@@ -211,7 +211,7 @@ function dolSaveHtmlHeader($filehtmlheader, $htmlheadercontent)
dol_mkdir($pathofwebsite);
$result = file_put_contents($filehtmlheader, $htmlheadercontent);
if (! empty($conf->global->MAIN_UMASK))
if (!empty($conf->global->MAIN_UMASK))
@chmod($filehtmlheader, octdec($conf->global->MAIN_UMASK));
return $result;
@@ -232,7 +232,7 @@ function dolSaveCssFile($filecss, $csscontent)
dol_mkdir($pathofwebsite);
$result = file_put_contents($filecss, $csscontent);
if (! empty($conf->global->MAIN_UMASK))
if (!empty($conf->global->MAIN_UMASK))
@chmod($filecss, octdec($conf->global->MAIN_UMASK));
return $result;
@@ -253,7 +253,7 @@ function dolSaveJsFile($filejs, $jscontent)
dol_mkdir($pathofwebsite);
$result = file_put_contents($filejs, $jscontent);
if (! empty($conf->global->MAIN_UMASK))
if (!empty($conf->global->MAIN_UMASK))
@chmod($filejs, octdec($conf->global->MAIN_UMASK));
return $result;
@@ -274,7 +274,7 @@ function dolSaveRobotFile($filerobot, $robotcontent)
dol_mkdir($pathofwebsite);
$result = file_put_contents($filerobot, $robotcontent);
if (! empty($conf->global->MAIN_UMASK))
if (!empty($conf->global->MAIN_UMASK))
@chmod($filerobot, octdec($conf->global->MAIN_UMASK));
return $result;
@@ -295,7 +295,7 @@ function dolSaveHtaccessFile($filehtaccess, $htaccess)
dol_mkdir($pathofwebsite);
$result = file_put_contents($filehtaccess, $htaccess);
if (! empty($conf->global->MAIN_UMASK))
if (!empty($conf->global->MAIN_UMASK))
@chmod($filehtaccess, octdec($conf->global->MAIN_UMASK));
return $result;
@@ -316,7 +316,7 @@ function dolSaveManifestJson($file, $content)
dol_mkdir($pathofwebsite);
$result = file_put_contents($file, $content);
if (! empty($conf->global->MAIN_UMASK))
if (!empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));
return $result;
@@ -337,7 +337,7 @@ function dolSaveReadme($file, $content)
dol_mkdir($pathofwebsite);
$result = file_put_contents($file, $content);
if (! empty($conf->global->MAIN_UMASK))
if (!empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));
return $result;
@@ -352,29 +352,29 @@ function dolSaveReadme($file, $content)
*/
function showWebsiteTemplates(Website $website)
{
global $conf,$langs,$db,$form;
global $conf, $langs, $db, $form;
global $bc;
$dirthemes=array('/doctemplates/websites');
if (! empty($conf->modules_parts['websitetemplates'])) // Using this feature slow down application
$dirthemes = array('/doctemplates/websites');
if (!empty($conf->modules_parts['websitetemplates'])) // Using this feature slow down application
{
foreach($conf->modules_parts['websitetemplates'] as $reldir)
foreach ($conf->modules_parts['websitetemplates'] as $reldir)
{
$dirthemes=array_merge($dirthemes, (array) ($reldir.'doctemplates/websites'));
$dirthemes = array_merge($dirthemes, (array) ($reldir.'doctemplates/websites'));
}
}
$dirthemes=array_unique($dirthemes);
$dirthemes = array_unique($dirthemes);
// Now dir_themes=array('/themes') or dir_themes=array('/theme','/mymodule/theme')
$colspan=2;
$colspan = 2;
$thumbsbyrow=6;
$thumbsbyrow = 6;
print '<table class="noborder centpercent">';
// Title
print '<tr class="liste_titre"><th class="titlefield"></th>';
print '<th class="right">';
$url='https://www.dolistore.com/43-web-site-templates';
$url = 'https://www.dolistore.com/43-web-site-templates';
print '<a href="'.$url.'" target="_blank">';
print $langs->trans('DownloadMoreSkins');
print '</a>';
@@ -383,7 +383,7 @@ function showWebsiteTemplates(Website $website)
print '<tr>';
print '<td>'.$langs->trans("ThemeDir").'</td>';
print '<td>';
foreach($dirthemes as $dirtheme)
foreach ($dirthemes as $dirtheme)
{
echo '"'.$dirtheme.'" ';
}
@@ -394,17 +394,17 @@ function showWebsiteTemplates(Website $website)
print '<table class="nobordernopadding" width="100%"><tr><td><div class="center">';
$i=0;
foreach($dirthemes as $dir)
$i = 0;
foreach ($dirthemes as $dir)
{
//print $dirroot.$dir;exit;
$dirtheme=DOL_DATA_ROOT.$dir; // This include loop on $conf->file->dol_document_root
$dirtheme = DOL_DATA_ROOT.$dir; // This include loop on $conf->file->dol_document_root
if (is_dir($dirtheme))
{
$handle=opendir($dirtheme);
$handle = opendir($dirtheme);
if (is_resource($handle))
{
while (($subdir = readdir($handle))!==false)
while (($subdir = readdir($handle)) !== false)
{
if (is_file($dirtheme."/".$subdir) && substr($subdir, 0, 1) <> '.'
&& substr($subdir, 0, 3) <> 'CVS' && preg_match('/\.zip$/i', $subdir))
@@ -418,9 +418,9 @@ function showWebsiteTemplates(Website $website)
print '<div class="inline-block" style="margin-top: 10px; margin-bottom: 10px; margin-right: 20px; margin-left: 20px;">';
$file = $dirtheme."/".$subdirwithoutzip.".jpg";
$url=DOL_URL_ROOT.'/viewimage.php?modulepart=doctemplateswebsite&file='.$subdirwithoutzip.".jpg";
$url = DOL_URL_ROOT.'/viewimage.php?modulepart=doctemplateswebsite&file='.$subdirwithoutzip.".jpg";
if (! file_exists($file)) $url=DOL_URL_ROOT.'/public/theme/common/nophoto.png';
if (!file_exists($file)) $url = DOL_URL_ROOT.'/public/theme/common/nophoto.png';
$originalfile = basename($file);
$entity = $conf->entity;
@@ -428,10 +428,10 @@ function showWebsiteTemplates(Website $website)
$cache = '';
$title = $file;
$ret='';
$urladvanced=getAdvancedPreviewUrl($modulepart, $originalfile, 1, '&entity='.$entity);
if (! empty($urladvanced)) $ret.='<a class="'.$urladvanced['css'].'" target="'.$urladvanced['target'].'" mime="'.$urladvanced['mime'].'" href="'.$urladvanced['url'].'">';
else $ret.='<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$entity.'&file='.urlencode($originalfile).'&cache='.$cache.'">';
$ret = '';
$urladvanced = getAdvancedPreviewUrl($modulepart, $originalfile, 1, '&entity='.$entity);
if (!empty($urladvanced)) $ret .= '<a class="'.$urladvanced['css'].'" target="'.$urladvanced['target'].'" mime="'.$urladvanced['mime'].'" href="'.$urladvanced['url'].'">';
else $ret .= '<a href="'.DOL_URL_ROOT.'/viewimage.php?modulepart='.$modulepart.'&entity='.$entity.'&file='.urlencode($originalfile).'&cache='.$cache.'">';
print $ret;
print '<img class="img-skinthumb shadow" src="'.$url.'" border="0" alt="'.$title.'" title="'.$title.'" style="margin-bottom: 5px;">';
print '</a>';