1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Thinktomorrow\Chief\App\Providers; |
4
|
|
|
|
5
|
|
|
use Illuminate\Support\Facades\Blade; |
6
|
|
|
use Illuminate\Support\Facades\View; |
7
|
|
|
use Illuminate\Support\ServiceProvider; |
8
|
|
|
use Thinktomorrow\Chief\Site\Urls\UrlHelper; |
9
|
|
|
|
10
|
|
|
class ViewServiceProvider extends ServiceProvider |
11
|
|
|
{ |
12
|
|
|
public function boot(): void |
13
|
|
|
{ |
14
|
|
|
$this->loadViewsFrom(__DIR__.'/../../resources/views', 'chief'); |
15
|
|
|
|
16
|
|
|
$this->app['view']->addNamespace('chief-fragments', __DIR__.'/../../src/Fragments/resources'); |
17
|
|
|
|
18
|
|
|
View::composer([ |
19
|
|
|
'chief::manager._transitions.modals.archive-modal', |
20
|
|
|
], function ($view) { |
21
|
|
|
$viewData = $view->getData(); |
22
|
|
|
|
23
|
|
|
$ignoredModel = (isset($viewData['model'])) |
24
|
|
|
? $viewData['model'] |
25
|
|
|
: null; |
26
|
|
|
|
27
|
|
|
$onlineModels = UrlHelper::allOnlineModels(false, $ignoredModel); |
28
|
|
|
$view->with('targetModels', $onlineModels); |
29
|
|
|
}); |
30
|
|
|
|
31
|
|
|
Blade::componentNamespace('Thinktomorrow\\Chief\\App\\View\\Components', 'chief'); |
32
|
|
|
Blade::component('chief::manager.windows.status.window', 'chief::window.status'); |
33
|
|
|
Blade::component('chief::manager.windows.links.window', 'chief::window.links'); |
34
|
|
|
|
35
|
|
|
// Chief components |
36
|
|
|
Blade::component('chief::components.title', 'chief-title'); |
37
|
|
|
Blade::component('chief::components.content', 'chief-content'); |
38
|
|
|
Blade::component('chief::components.sidebar', 'chief-sidebar'); |
39
|
|
|
Blade::component('chief::components.inline-notification', 'chief-inline-notification'); |
40
|
|
|
Blade::component('chief::components.icon-label', 'chief-icon-label'); |
41
|
|
|
Blade::component('chief::components.icon-button', 'chief-icon-button'); |
42
|
|
|
Blade::component('chief::components.hierarchy', 'chief-hierarchy'); |
43
|
|
|
Blade::component('chief::components.nav-item', 'chief::nav.item'); |
44
|
|
|
|
45
|
|
|
// Wireframe components |
46
|
|
|
Blade::component('chief::wireframes.wireframe', 'wireframe'); |
47
|
|
|
Blade::component('chief::wireframes.container', 'wireframe-container'); |
48
|
|
|
Blade::component('chief::wireframes.row', 'wireframe-row'); |
49
|
|
|
Blade::component('chief::wireframes.column', 'wireframe-column'); |
50
|
|
|
Blade::component('chief::wireframes.title', 'wireframe-title'); |
51
|
|
|
Blade::component('chief::wireframes.text', 'wireframe-text'); |
52
|
|
|
Blade::component('chief::wireframes.image', 'wireframe-image'); |
53
|
|
|
Blade::component('chief::wireframes.video', 'wireframe-video'); |
54
|
|
|
Blade::component('chief::wireframes.rect', 'wireframe-rect'); |
55
|
|
|
|
56
|
|
|
// Chief directives |
57
|
|
|
|
58
|
|
|
Blade::directive('adminRoute', function ($expression) { |
59
|
|
|
return "<?php echo \$manager->route({$expression}); ?>"; |
60
|
|
|
}); |
61
|
|
|
|
62
|
|
|
Blade::directive('adminCan', function ($expression) { |
63
|
|
|
return "<?php if (\$manager->can({$expression})) { ?>"; |
64
|
|
|
}); |
65
|
|
|
|
66
|
|
|
Blade::directive('elseAdminCan', function () { |
67
|
|
|
return '<?php } else { ?>'; |
68
|
|
|
}); |
69
|
|
|
|
70
|
|
|
Blade::directive('endAdminCan', function () { |
71
|
|
|
return '<?php } ?>'; |
72
|
|
|
}); |
73
|
|
|
|
74
|
|
|
// TODO(ben): better solution for this ugly mess |
75
|
|
|
// Hello Tijs. We meet again |
76
|
|
|
$isCollapsedOnPageLoad = |
77
|
|
|
isset($_COOKIE['is-navigation-collapsed']) |
78
|
|
|
? filter_var($_COOKIE['is-navigation-collapsed'], FILTER_VALIDATE_BOOLEAN) |
79
|
|
|
: false; |
80
|
|
|
view()->share('isCollapsedOnPageLoad', $isCollapsedOnPageLoad); |
81
|
|
|
} |
82
|
|
|
|
83
|
|
|
public function register() |
84
|
|
|
{ |
85
|
|
|
} |
86
|
|
|
} |
87
|
|
|
|