Added favicon management to back-end customisation (#4045)
Credit to @Farrow. Also accessible with `brand.faviconPath` configuration item.
This commit is contained in:
parent
920eb15af5
commit
1caaac9704
|
|
@ -427,6 +427,8 @@ return [
|
||||||
'brand' => 'Brand',
|
'brand' => 'Brand',
|
||||||
'logo' => 'Logo',
|
'logo' => 'Logo',
|
||||||
'logo_description' => 'Upload a custom logo to use in the back-end.',
|
'logo_description' => 'Upload a custom logo to use in the back-end.',
|
||||||
|
'favicon' => 'Favicon',
|
||||||
|
'favicon_description' => 'Upload a custom favicon to use in the back-end',
|
||||||
'app_name' => 'App Name',
|
'app_name' => 'App Name',
|
||||||
'app_name_description' => 'This name is shown in the title area of the back-end.',
|
'app_name_description' => 'This name is shown in the title area of the back-end.',
|
||||||
'app_tagline' => 'App Tagline',
|
'app_tagline' => 'App Tagline',
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
<meta name="backend-timezone" content="<?= e(Backend\Models\Preference::get('timezone')) ?>">
|
<meta name="backend-timezone" content="<?= e(Backend\Models\Preference::get('timezone')) ?>">
|
||||||
<meta name="backend-locale" content="<?= e(Backend\Models\Preference::get('locale')) ?>">
|
<meta name="backend-locale" content="<?= e(Backend\Models\Preference::get('locale')) ?>">
|
||||||
<meta name="csrf-token" content="<?= csrf_token() ?>">
|
<meta name="csrf-token" content="<?= csrf_token() ?>">
|
||||||
<link rel="icon" type="image/png" href="<?= Backend::skinAsset('assets/images/favicon.png') ?>">
|
<link rel="icon" type="image/png" href="<?= e(Backend\Models\BrandSetting::getFavicon()) ?>">
|
||||||
<title data-title-template="<?= empty($this->pageTitleTemplate) ? '%s' : e($this->pageTitleTemplate) ?> | <?= e(Backend\Models\BrandSetting::get('app_name')) ?>">
|
<title data-title-template="<?= empty($this->pageTitleTemplate) ? '%s' : e($this->pageTitleTemplate) ?> | <?= e(Backend\Models\BrandSetting::get('app_name')) ?>">
|
||||||
<?= e(trans($this->pageTitle)) ?> | <?= e(Backend\Models\BrandSetting::get('app_name')) ?>
|
<?= e(trans($this->pageTitle)) ?> | <?= e(Backend\Models\BrandSetting::get('app_name')) ?>
|
||||||
</title>
|
</title>
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||||
<meta name="backend-base-path" content="<?= Backend::baseUrl() ?>">
|
<meta name="backend-base-path" content="<?= Backend::baseUrl() ?>">
|
||||||
<meta name="csrf-token" content="<?= csrf_token() ?>">
|
<meta name="csrf-token" content="<?= csrf_token() ?>">
|
||||||
<link rel="icon" type="image/png" href="<?= Backend::skinAsset('assets/images/favicon.png') ?>">
|
<link rel="icon" type="image/png" href="<?= e(Backend\Models\BrandSetting::getFavicon()) ?>">
|
||||||
<title><?= e(trans('backend::lang.auth.title')) ?></title>
|
<title><?= e(trans('backend::lang.auth.title')) ?></title>
|
||||||
<link href="<?= Url::asset('modules/system/assets/ui/storm.css') ?>" rel="stylesheet">
|
<link href="<?= Url::asset('modules/system/assets/ui/storm.css') ?>" rel="stylesheet">
|
||||||
<link href="<?= Url::to('modules/backend/assets/css/october.css') ?>" rel="stylesheet">
|
<link href="<?= Url::to('modules/backend/assets/css/october.css') ?>" rel="stylesheet">
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
<?php namespace Backend\Models;
|
<?php namespace Backend\Models;
|
||||||
|
|
||||||
use App;
|
use App;
|
||||||
|
use Backend;
|
||||||
use Url;
|
use Url;
|
||||||
use File;
|
use File;
|
||||||
use Lang;
|
use Lang;
|
||||||
|
|
@ -39,6 +40,7 @@ class BrandSetting extends Model
|
||||||
public $settingsFields = 'fields.yaml';
|
public $settingsFields = 'fields.yaml';
|
||||||
|
|
||||||
public $attachOne = [
|
public $attachOne = [
|
||||||
|
'favicon' => \System\Models\File::class,
|
||||||
'logo' => \System\Models\File::class
|
'logo' => \System\Models\File::class
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
@ -85,6 +87,17 @@ class BrandSetting extends Model
|
||||||
Cache::forget(self::instance()->cacheKey);
|
Cache::forget(self::instance()->cacheKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getFavicon()
|
||||||
|
{
|
||||||
|
$settings = self::instance();
|
||||||
|
|
||||||
|
if ($settings->favicon) {
|
||||||
|
return $settings->favicon->getPath();
|
||||||
|
}
|
||||||
|
|
||||||
|
return self::getDefaultFavicon() ?: null;
|
||||||
|
}
|
||||||
|
|
||||||
public static function getLogo()
|
public static function getLogo()
|
||||||
{
|
{
|
||||||
$settings = self::instance();
|
$settings = self::instance();
|
||||||
|
|
@ -147,6 +160,17 @@ class BrandSetting extends Model
|
||||||
return !!Config::get('brand');
|
return !!Config::get('brand');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function getDefaultFavicon()
|
||||||
|
{
|
||||||
|
$faviconPath = File::symbolizePath(Config::get('brand.faviconPath'));
|
||||||
|
|
||||||
|
if ($faviconPath && File::exists($faviconPath)) {
|
||||||
|
return Url::asset(File::localToPublic($faviconPath));
|
||||||
|
}
|
||||||
|
|
||||||
|
return Backend::skinAsset('assets/images/favicon.png');
|
||||||
|
}
|
||||||
|
|
||||||
public static function getDefaultLogo()
|
public static function getDefaultLogo()
|
||||||
{
|
{
|
||||||
$logoPath = File::symbolizePath(Config::get('brand.logoPath'));
|
$logoPath = File::symbolizePath(Config::get('brand.logoPath'));
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,16 @@ tabs:
|
||||||
tab: backend::lang.branding.brand
|
tab: backend::lang.branding.brand
|
||||||
span: left
|
span: left
|
||||||
|
|
||||||
|
favicon:
|
||||||
|
label: backend::lang.branding.favicon
|
||||||
|
type: fileupload
|
||||||
|
commentAbove: backend::lang.branding.favicon_description
|
||||||
|
mode: image
|
||||||
|
imageHeight: 32
|
||||||
|
tab: backend::lang.branding.brand
|
||||||
|
span: right
|
||||||
|
fileTypes: jpg,jpeg,bmp,png,webp,gif,svg,ico
|
||||||
|
|
||||||
primary_color:
|
primary_color:
|
||||||
label: backend::lang.branding.primary_color
|
label: backend::lang.branding.primary_color
|
||||||
type: colorpicker
|
type: colorpicker
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue