Better handling of the custom theme settings.
This commit is contained in:
@@ -0,0 +1,39 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Cachet.
|
||||||
|
*
|
||||||
|
* (c) James Brooks <james@cachethq.io>
|
||||||
|
* (c) Joseph Cohen <joseph.cohen@dinkbit.com>
|
||||||
|
* (c) Graham Campbell <graham@mineuk.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace CachetHQ\Cachet\Composers;
|
||||||
|
|
||||||
|
use CachetHQ\Cachet\Facades\Setting;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
|
||||||
|
class ThemeComposer
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Bind data to the view.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\View\View $view
|
||||||
|
*/
|
||||||
|
public function compose(View $view)
|
||||||
|
{
|
||||||
|
$view->with('themeBackgroundColor', Setting::get('style_background_color') ?: null);
|
||||||
|
$view->with('themeTextColor', Setting::get('style_text_color') ?: null);
|
||||||
|
|
||||||
|
$viewData = $view->getData();
|
||||||
|
$themeView = array_only($viewData, preg_grep('/^theme/', array_keys($viewData)));
|
||||||
|
$hasThemeSettings = array_filter($themeView, function ($data) {
|
||||||
|
return $data != null;
|
||||||
|
});
|
||||||
|
|
||||||
|
$view->with('themeSetup', !empty($hasThemeSettings));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -32,6 +32,7 @@ class ViewComposerServiceProvider extends ServiceProvider
|
|||||||
{
|
{
|
||||||
$this->app->view->composer('*', 'CachetHQ\Cachet\Composers\LoggedUserComposer');
|
$this->app->view->composer('*', 'CachetHQ\Cachet\Composers\LoggedUserComposer');
|
||||||
$this->app->view->composer('index', 'CachetHQ\Cachet\Composers\IndexComposer');
|
$this->app->view->composer('index', 'CachetHQ\Cachet\Composers\IndexComposer');
|
||||||
|
$this->app->view->composer('index', 'CachetHQ\Cachet\Composers\ThemeComposer');
|
||||||
$this->app->view->composer('dashboard.*', 'CachetHQ\Cachet\Composers\DashboardComposer');
|
$this->app->view->composer('dashboard.*', 'CachetHQ\Cachet\Composers\DashboardComposer');
|
||||||
$this->app->view->composer([
|
$this->app->view->composer([
|
||||||
'setup',
|
'setup',
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
|
@if($themeSetup)
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
body.status-page {
|
body.status-page {
|
||||||
@if($styleBackgroundColor = Setting::get('style_background_color'))
|
@if($themeBackgroundColor)
|
||||||
background-color: {{ $styleBackgroundColor }};
|
background-color: {{ $themeBackgroundColor }};
|
||||||
@endif
|
@endif
|
||||||
@if($styleTextColor = Setting::get('style_text_color'))
|
@if($themeTextColor)
|
||||||
color: {{ $styleTextColor }};
|
color: {{ $themeTextColor }};
|
||||||
@endif
|
@endif
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@endif
|
||||||
|
|||||||
Reference in New Issue
Block a user