From 29b0c1e5a369a8bcdd5ebbe2c8769c41c4aba51f Mon Sep 17 00:00:00 2001 From: Pig Fang Date: Thu, 4 Apr 2019 11:40:18 +0800 Subject: [PATCH] Extract some helper functions to view --- app/helpers.php | 51 ------------------- resources/views/admin/master.blade.php | 17 ++----- resources/views/auth/master.blade.php | 2 +- .../views/common/custom-copyright.blade.php | 8 +++ resources/views/common/favicon.blade.php | 6 +++ resources/views/common/user-menu.blade.php | 4 +- resources/views/common/user-panel.blade.php | 18 +++++++ resources/views/index.blade.php | 4 +- resources/views/skinlib/master.blade.php | 4 +- resources/views/user/master.blade.php | 17 ++----- 10 files changed, 45 insertions(+), 86 deletions(-) create mode 100644 resources/views/common/custom-copyright.blade.php create mode 100644 resources/views/common/favicon.blade.php create mode 100644 resources/views/common/user-panel.blade.php diff --git a/app/helpers.php b/app/helpers.php index 95878c09..c6111b47 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -16,15 +16,6 @@ if (! function_exists('get_base_url')) { } } -if (! function_exists('avatar')) { - function avatar(User $user, $size) - { - $fname = base64_encode($user->email).'.png?tid='.$user->avatar; - - return url("avatar/$size/$fname"); - } -} - if (! function_exists('webpack_assets')) { function webpack_assets($relativeUri) { @@ -107,20 +98,6 @@ if (! function_exists('bs_header_extra')) { } } -if (! function_exists('bs_favicon')) { - function bs_favicon() - { - // Fallback to default favicon - $url = Str::startsWith($url = (option('favicon_url') ?: config('options.favicon_url')), 'http') ? $url : url($url); - - return <<< ICONS - - - -ICONS; - } -} - if (! function_exists('bs_menu')) { function bs_menu($type) { @@ -224,34 +201,6 @@ if (! function_exists('bs_copyright')) { } } -if (! function_exists('bs_custom_copyright')) { - function bs_custom_copyright() - { - return get_string_replaced(option_localized('copyright_text'), [ - '{site_name}' => option_localized('site_name'), - '{site_url}' => option('site_url'), - ]); - } -} - -if (! function_exists('bs_role')) { - function bs_role(User $user = null) - { - $user = $user ?: auth()->user(); - - $roles = [ - User::NORMAL => 'normal', - User::BANNED => 'banned', - User::ADMIN => 'admin', - User::SUPER_ADMIN => 'super-admin', - ]; - - $role = Arr::get($roles, $user->permission); - - return trans("admin.users.status.$role"); - } -} - if (! function_exists('option')) { /** * Get / set the specified option value. diff --git a/resources/views/admin/master.blade.php b/resources/views/admin/master.blade.php index b81c4773..aa4ff3c8 100644 --- a/resources/views/admin/master.blade.php +++ b/resources/views/admin/master.blade.php @@ -4,7 +4,7 @@ @yield('title') - {{ option_localized('site_name') }} - {!! bs_favicon() !!} + @include('common.favicon') @@ -54,18 +54,7 @@