|
|
|
@ -229,7 +229,7 @@ function handle_stylesheets() |
|
|
|
|
$form = new FormValidator( |
|
|
|
|
'stylesheet_upload', |
|
|
|
|
'post', |
|
|
|
|
'settings.php?category=Stylesheets#tabs-2' |
|
|
|
|
'settings.php?category=Stylesheets#tabs-3' |
|
|
|
|
); |
|
|
|
|
$form->addElement('text', 'name_stylesheet', get_lang('NameStylesheet'), array('size' => '40', 'maxlength' => '40')); |
|
|
|
|
$form->addRule('name_stylesheet', get_lang('ThisFieldIsRequired'), 'required'); |
|
|
|
@ -362,6 +362,67 @@ function handle_stylesheets() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$logoForm = new FormValidator( |
|
|
|
|
'logo_upload', |
|
|
|
|
'post', |
|
|
|
|
'settings.php?category=Stylesheets#tabs-2' |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
$logoForm->addHtml(Display::return_message(sprintf(get_lang('TheLogoMustBeSizeXAndFormatY'), '250 x 70', 'PNG'), 'info')); |
|
|
|
|
|
|
|
|
|
$dir = api_get_path(SYS_PUBLIC_PATH).'css/themes/' . $selected . '/images/'; |
|
|
|
|
$url = api_get_path(WEB_CSS_PATH).'themes/' . $selected . '/images/'; |
|
|
|
|
$logoFileName = 'header-logo.png'; |
|
|
|
|
$newLogoFileName = 'header-logo-custom.png'; |
|
|
|
|
|
|
|
|
|
if (is_file($dir.$newLogoFileName)) { |
|
|
|
|
$logoForm->addLabel(get_lang('CurrentLogo'), '<img id="header-logo-custom" src="'. $url . $newLogoFileName .'?'. time() . '">'); |
|
|
|
|
} else { |
|
|
|
|
$logoForm->addLabel(get_lang('CurrentLogo'), '<img id="header-logo-custom" src="'. $url . $logoFileName .'?'. time() . '">'); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$logoForm->addFile('new_logo', get_lang('UpdateLogo')); |
|
|
|
|
$allowedFileTypes = ['png']; |
|
|
|
|
|
|
|
|
|
if (isset($_POST['logo_reset'])) { |
|
|
|
|
if (is_file($dir.$newLogoFileName)) { |
|
|
|
|
unlink($dir.$newLogoFileName); |
|
|
|
|
Display::display_normal_message(get_lang('ResetToTheOriginalLogo')); |
|
|
|
|
echo '<script>' |
|
|
|
|
. '$("#header-logo").attr("src","'.$url.$logoFileName.'");' |
|
|
|
|
. '</script>'; |
|
|
|
|
} |
|
|
|
|
} elseif (isset($_POST['logo_upload'])) { |
|
|
|
|
|
|
|
|
|
$logoForm->addRule('new_logo', get_lang('InvalidExtension').' ('.implode(',', $allowedFileTypes).')', 'filetype', $allowedFileTypes); |
|
|
|
|
$logoForm->addRule('new_logo', get_lang('ThisFieldIsRequired'), 'required'); |
|
|
|
|
|
|
|
|
|
if ($logoForm->validate()) { |
|
|
|
|
|
|
|
|
|
$imageInfo = getimagesize($_FILES['new_logo']['tmp_name']); |
|
|
|
|
$width = $imageInfo[0]; |
|
|
|
|
$height = $imageInfo[1]; |
|
|
|
|
if ($width <= 250 && $height <= 70 ) { |
|
|
|
|
if (is_file($dir.$newLogoFileName)) { |
|
|
|
|
unlink($dir.$newLogoFileName); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$status = move_uploaded_file($_FILES['new_logo']['tmp_name'], $dir.$newLogoFileName); |
|
|
|
|
|
|
|
|
|
if ($status) { |
|
|
|
|
Display::display_normal_message(get_lang('NewLogoUpdated')); |
|
|
|
|
echo '<script>' |
|
|
|
|
. '$("#header-logo").attr("src","'.$url.$newLogoFileName.'");' |
|
|
|
|
. '</script>'; |
|
|
|
|
} else { |
|
|
|
|
Display::display_error_message('Error - '.get_lang('UplNoFileUploaded')); |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
Display::display_error_message('Error - '.get_lang('InvalidImageDimensions')); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if ($is_style_changeable) { |
|
|
|
|
$group = [ |
|
|
|
@ -371,6 +432,13 @@ function handle_stylesheets() |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
$form_change->addGroup($group); |
|
|
|
|
|
|
|
|
|
$logoGroup = [ |
|
|
|
|
$logoForm->addButtonUpload(get_lang('Upload'), 'logo_upload', true), |
|
|
|
|
$logoForm->addButtonCancel(get_lang('Reset'), 'logo_reset', true) |
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
$logoForm->addGroup($logoGroup); |
|
|
|
|
|
|
|
|
|
if ($show_upload_form) { |
|
|
|
|
echo '<script> |
|
|
|
@ -379,12 +447,23 @@ function handle_stylesheets() |
|
|
|
|
}); |
|
|
|
|
</script>'; |
|
|
|
|
echo Display::tabs( |
|
|
|
|
array(get_lang('Update'), get_lang('UploadNewStylesheet')), |
|
|
|
|
array($form_change->return_form(), $form->return_form()) |
|
|
|
|
array(get_lang('Update'),get_lang('UpdateLogo'), get_lang('UploadNewStylesheet')), |
|
|
|
|
array($form_change->return_form(), $logoForm->return_form(), $form->return_form()) |
|
|
|
|
); |
|
|
|
|
} else { |
|
|
|
|
$form_change->display(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//Little hack to update the logo image in update form when submiting |
|
|
|
|
if (isset($_POST['logo_reset'])) { |
|
|
|
|
echo '<script>' |
|
|
|
|
. '$("#header-logo-custom").attr("src","'.$url.$logoFileName.'");' |
|
|
|
|
. '</script>'; |
|
|
|
|
} elseif (isset($_POST['logo_upload']) && is_file($dir.$newLogoFileName)) { |
|
|
|
|
echo '<script>' |
|
|
|
|
. '$("#header-logo-custom").attr("src","'.$url.$newLogoFileName.'");' |
|
|
|
|
. '</script>'; |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
$form_change->freeze(); |
|
|
|
|
} |
|
|
|
|