-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
executable file
·110 lines (94 loc) · 4.26 KB
/
Copy pathindex.php
File metadata and controls
executable file
·110 lines (94 loc) · 4.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?php
/*
* Canvas Theme addon for Bear CMS
* https://github.com/bearcms/canvas-theme-addon
* Copyright (c) Amplilabs Ltd.
* Free to use under the MIT license.
*/
use BearFramework\App;
$app = App::get();
$app->bearCMS->themes
->register('bearcms/canvas', function (\BearCMS\Themes\Theme $theme) use ($app): void {
$context = $app->contexts->get(__DIR__);
$app->localization
->addDictionary('en', function () use ($context) {
return include $context->dir . '/locales/en.php';
})
->addDictionary('bg', function () use ($context) {
return include $context->dir . '/locales/bg.php';
});
$context->assets
->addDir('assets');
$theme->version = '1.0';
$theme->get = function (\BearCMS\Themes\Theme\Customizations $customizations, array $cntx) use ($app, $context) {
$templateFilename = $context->dir . '/components/template.php';
$template = (static function ($__filename) {
ob_start();
include $__filename;
return ob_get_clean();
})($templateFilename);
if ($app->bearCMS->hasEventListeners('internalBearCMSCanvasThemeGet')) {
$eventDetails = new stdClass();
$eventDetails->template = $template;
$app->bearCMS->dispatchEvent('internalBearCMSCanvasThemeGet', $eventDetails);
$template = $eventDetails->template;
}
return $template;
};
$theme->manifest = function () use ($app, $context, $theme) {
$manifest = $theme->makeManifest();
$manifest->name = __('bearcms.themes.canvas.name');
$manifest->description = __('bearcms.themes.canvas.description');
$manifest->author = [
'name' => 'BearCMS Team',
'url' => 'https://bearcms.com/addons/',
'email' => 'addons@bearcms.com',
];
$manifest->media = [
[
'filename' => $context->dir . '/assets/1.jpg',
'width' => 1680,
'height' => 1260,
]
];
if ($app->bearCMS->hasEventListeners('internalBearCMSCanvasThemeManifest')) {
$eventDetails = new stdClass();
$eventDetails->manifest = $manifest;
$app->bearCMS->dispatchEvent('internalBearCMSCanvasThemeManifest', $eventDetails);
$manifest = $eventDetails->manifest;
}
return $manifest;
};
$theme->options = function () use ($app, $context, $theme, &$updateValues) {
$options = $theme->makeOptions(); // used inside
$options
->addElementsGroup('elements', '.template-content');
$options
->addPagesGroup([
"cssOptions" => ["*/hoverState", "*/activeState", "*/focusState", "*/screenSizeState"]
]);
$windowGroup = $options->addGroup(__("bearcms.themes.canvas.options.Window"));
$windowGroup
->addOption("body", "css", "", [
"cssTypes" => ["cssPadding", "cssBorder", "cssBackground"],
"cssOptions" => ["*/hoverState", "*/screenSizeState", "*/pageTypeState", "*/tagsState"],
"cssOutput" => [
["selector", ".template-body"]
],
"defaultValue" => "{\"background-color\":\"#ffffff\"}"
]);
if ($app->bearCMS->hasEventListeners('internalBearCMSCanvasThemeOptions')) {
$eventDetails = new stdClass();
$eventDetails->options = $options;
$app->bearCMS->dispatchEvent('internalBearCMSCanvasThemeOptions', $eventDetails);
$options = $eventDetails->options;
}
return $options;
};
if ($app->bearCMS->hasEventListeners('internalBearCMSCanvasThemeRegister')) {
$eventDetails = new stdClass();
$eventDetails->theme = $theme;
$app->bearCMS->dispatchEvent('internalBearCMSCanvasThemeRegister', $eventDetails);
$theme = $eventDetails->theme;
}
});