Close #17113 : Can upload a favicon in website module
This commit is contained in:
parent
a3fb8d3e14
commit
49b3970700
@ -141,3 +141,6 @@ GenerateSitemaps=Generate website sitemap file
|
|||||||
ConfirmGenerateSitemaps=If you confirm, you will erase the existing sitemap file...
|
ConfirmGenerateSitemaps=If you confirm, you will erase the existing sitemap file...
|
||||||
ConfirmSitemapsCreation=Confirm sitemap generation
|
ConfirmSitemapsCreation=Confirm sitemap generation
|
||||||
SitemapGenerated=Sitemap Generated
|
SitemapGenerated=Sitemap Generated
|
||||||
|
ImportFavicon=Favicon
|
||||||
|
ErrorFaviconType=Favicon must be png
|
||||||
|
ErrorFaviconSize=Favicon must be of size 32x32
|
||||||
@ -34,6 +34,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/website.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/website2.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/website2.lib.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/images.lib.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formwebsite.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formwebsite.class.php';
|
||||||
@ -1313,6 +1314,37 @@ if ($action == 'updatecss' && $usercanedit) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!$error) {
|
||||||
|
if (($_FILES['addedfile']["name"] != '')) {
|
||||||
|
$uploadfolder = $conf->website->dir_output.'/'.$websitekey;
|
||||||
|
if ($_FILES['addedfile']['type'] != 'image/png') {
|
||||||
|
$error++;
|
||||||
|
setEventMessages($langs->trans('ErrorFaviconType'), array(), 'errors');
|
||||||
|
}
|
||||||
|
$filetoread = realpath(dol_osencode($_FILES['addedfile']['tmp_name']));
|
||||||
|
$filesize = getimagesize($filetoread);
|
||||||
|
if ($filesize[0] != 32 || $filesize[1] != 32) {
|
||||||
|
$error++;
|
||||||
|
setEventMessages($langs->trans('ErrorFaviconSize'), array(), 'errors');
|
||||||
|
}
|
||||||
|
if (!$error) {
|
||||||
|
dol_add_file_process($uploadfolder, 1, 0, 'addedfile', 'favicon.png');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($error) {
|
||||||
|
if (!GETPOSTISSET('updateandstay')) { // If we click on "Save And Stay", we don not make the redirect
|
||||||
|
$action = 'preview';
|
||||||
|
if ($backtopage) {
|
||||||
|
$backtopage = preg_replace('/searchstring=[^&]*/', '', $backtopage); // Clean backtopage url
|
||||||
|
header("Location: ".$backtopage);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$action = 'editcss';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!$error) {
|
if (!$error) {
|
||||||
// Save master.inc.php file
|
// Save master.inc.php file
|
||||||
dol_syslog("Save master file ".$filemaster);
|
dol_syslog("Save master file ".$filemaster);
|
||||||
@ -3118,6 +3150,13 @@ if ($action == 'editcss') {
|
|||||||
print '</td>';
|
print '</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
|
// Favicon
|
||||||
|
print '<tr><td>';
|
||||||
|
print $langs->trans('ImportFavicon');
|
||||||
|
print '</td><td>';
|
||||||
|
print '<input type="file" class="flat minwidth300" name="addedfile" id="addedfile"/>';
|
||||||
|
print '</tr></td>';
|
||||||
|
|
||||||
// CSS file
|
// CSS file
|
||||||
print '<tr><td class="tdtop">';
|
print '<tr><td class="tdtop">';
|
||||||
$htmlhelp = $langs->trans("CSSContentTooltipHelp");
|
$htmlhelp = $langs->trans("CSSContentTooltipHelp");
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user