From 8507860b15056f74053854b60ea59d289a856ea8 Mon Sep 17 00:00:00 2001 From: printempw Date: Thu, 15 Sep 2016 11:04:08 +0800 Subject: [PATCH] add helper function for header and footer --- app/helpers.php | 49 ++++++++++++++++++++++++++++++ resources/views/admin/master.tpl | 14 ++------- resources/views/auth/master.tpl | 20 ++---------- resources/views/index.tpl | 12 ++------ resources/views/skinlib/master.tpl | 14 ++------- resources/views/user/master.tpl | 20 ++---------- 6 files changed, 60 insertions(+), 69 deletions(-) diff --git a/app/helpers.php b/app/helpers.php index fb383a22..6cf2b939 100644 --- a/app/helpers.php +++ b/app/helpers.php @@ -81,3 +81,52 @@ if (! function_exists('json')) { } } } + +if (! function_exists('bs_footer')) { + + function bs_footer($page_identification = "") + { + $scripts = [ + assets('js/app.min.js'), + assets('lang/'.session('locale', config('app.locale')).'/locale.js'), + assets('js/general.js') + ]; + + if ($page_identification !== "") { + $scripts[] = assets("js/$page_identification.js"); + } + + foreach ($scripts as $script) { + echo ""; + } + + if (Session::has('msg')): ?> + + '.Option::get("custom_js").''; + } +} + +if (! function_exists('bs_header')) { + + function bs_header($page_identification = "") + { + $styles = [ + assets('css/app.min.css'), + assets('vendor/skins/'.Option::get('color_scheme').'.min.css') + ]; + + if ($page_identification !== "") { + $styles[] = assets("css/$page_identification.css"); + } + + foreach ($styles as $style) { + echo ""; + } + + echo ''; + } +} diff --git a/resources/views/admin/master.tpl b/resources/views/admin/master.tpl index 6b7f6adc..aeba4fa4 100644 --- a/resources/views/admin/master.tpl +++ b/resources/views/admin/master.tpl @@ -8,15 +8,9 @@ - - - - - + {!! bs_header('admin') !!} @yield('style') - - @@ -138,9 +132,7 @@ - - - + {!! bs_footer('admin') !!} @if (Option::get('check_update') == '1') diff --git a/resources/views/auth/master.tpl b/resources/views/auth/master.tpl index 6afbb180..90515856 100644 --- a/resources/views/auth/master.tpl +++ b/resources/views/auth/master.tpl @@ -7,13 +7,7 @@ - - - - - - - + {!! bs_header('auth') !!} @@ -21,16 +15,8 @@ @yield('content') - + {!! bs_footer('auth') !!} - - - @if (Session::has('msg')) - - @endif - - + @yield('script') diff --git a/resources/views/index.tpl b/resources/views/index.tpl index 076416e8..39beeff8 100644 --- a/resources/views/index.tpl +++ b/resources/views/index.tpl @@ -8,18 +8,12 @@ - - - - - + {!! bs_header('index') !!} @@ -122,8 +116,6 @@ - - - + {!! bs_footer() !!} diff --git a/resources/views/skinlib/master.tpl b/resources/views/skinlib/master.tpl index 377dbfc1..fccf59d5 100644 --- a/resources/views/skinlib/master.tpl +++ b/resources/views/skinlib/master.tpl @@ -8,15 +8,9 @@ - - - - - + {!! bs_header('skinlib') !!} @yield('style') - - @@ -151,12 +145,8 @@ - - - + {!! bs_footer('skinlib') !!} @yield('script') - - diff --git a/resources/views/user/master.tpl b/resources/views/user/master.tpl index b2de4b76..75e69ed5 100644 --- a/resources/views/user/master.tpl +++ b/resources/views/user/master.tpl @@ -8,15 +8,9 @@ - - - - - + {!! bs_header('user') !!} @yield('style') - - @@ -139,18 +133,8 @@ - - - + {!! bs_footer('user') !!} @yield('script') - - @if (Session::has('msg')) - - @endif - -