forked from FriendsOfREDAXO/theme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboot.php
104 lines (94 loc) · 3.35 KB
/
boot.php
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
<?php
/**
* Theme
*
* @var rex_addon $this
*/
// Load theme languages
rex_i18n::addDirectory(theme_path::lang());
// Autoload theme lib
rex_autoload::addDirectory(theme_path::lib());
// Include files
if (is_dir(theme_path::inc())) {
foreach (glob(theme_path::inc('*.php')) as $file) {
include_once ($file);
}
}
// Fallbacks
else {
if (file_exists(theme_path::lib('functions.php'))) {
include_once (theme_path::lib('functions.php'));
}
if (file_exists(theme_path::lib('Functions.php'))) {
include_once (theme_path::lib('Functions.php'));
}
}
// Include backend assets
if (rex::isBackend() && $this->getConfig('include_be_files')) {
rex_extension::register('PACKAGES_INCLUDED', 'theme_add_backend_assets', rex_extension::LATE);
}
// Configure developer
if (rex_addon::get('developer')->isAvailable()) {
// Add JS to deactivate developers synchronize checkboxes
rex_extension::register('PAGE_HEADER', 'theme_deactivate_developer_checkboxes', rex_extension::LATE, [
'addon' => $this,
]);
// Register own theme paths
rex_extension::register('DEVELOPER_MANAGER_START', array('theme_manager', 'start'), rex_extension::NORMAL, [
'theme_folder' => $this->getProperty('theme_folder'),
'synchronize_actions' => $this->getConfig('synchronize_actions'),
'synchronize_modules' => $this->getConfig('synchronize_modules'),
'synchronize_templates' => $this->getConfig('synchronize_templates'),
]);
}
/**
* Add JS to deactivate developers synchronize checkboxes
* EP: PAGE_HEADER
*
* @param rex_extension_point $ep
* @return mixed|string
*/
function theme_deactivate_developer_checkboxes(rex_extension_point $ep)
{
/** @var rex_addon $addon */
$addon = $ep->getParam('addon');
$subject = $ep->getSubject();
$subject .= '
<!-- theme -->
<script type="text/javascript">
jQuery("document").ready(function() {
if (jQuery("body").attr("id") == "rex-page-developer-settings") {
var $templates = jQuery("#rex-developer-templates");
var $modules = jQuery("#rex-developer-modules");
var $actions = jQuery("#rex-developer-actions");
if ('.($addon->getConfig('synchronize_templates') ? '1' : '0').') {
$templates.prop("disabled", "disabled").parent().append(" ['.$addon->i18n('set_by_theme').']");
}
if ('.($addon->getConfig('synchronize_modules') ? '1' : '0').') {
$modules.prop("disabled", "disabled").parent().append(" ['.$addon->i18n('set_by_theme').']");
}
if ('.($addon->getConfig('synchronize_actions') ? '1' : '0').') {
$actions.prop("disabled", "disabled").parent().append(" ['.$addon->i18n('set_by_theme').']");
}
}
});
</script>
<!-- end theme -->
';
return $subject;
}
/**
* Add backend assets
* EP: PACKAGES_INCLUDED
*
* @param rex_extension_point $ep
*/
function theme_add_backend_assets(rex_extension_point $ep)
{
if (file_exists(theme_path::assets('backend/backend.css'))) {
rex_view::addCssFile(theme_url::assets('backend/backend.css'));
}
if (file_exists(theme_path::assets('backend/backend.js'))) {
rex_view::addJsFile(theme_url::assets('backend/backend.js'));
}
}