-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmmeu.module
69 lines (56 loc) · 1.99 KB
/
mmeu.module
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
<?php
/**
* @file
* Module file for mmeu module.
* backdrop port
*/
/**
* Implements hook_form_FORM_ID_alter() for system_site_maintenance_mode().
*/
function mmeu_form_system_site_maintenance_mode_alter(&$form, &$form_state) {
$form['mmeu_urls'] = array(
'#type' => 'textarea',
'#title' => t('Exclude Urls'),
'#description' => t("Enter pages to be shown to visitors in maintenance mode. Enter one page per line as Backdrop paths. The * character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.",
array(
'%blog' => 'blog',
'%blog-wildcard' => 'blog/*',
'%front' => '<front>',
)
),
//'#default_value' => variable_get('mmeu_urls', ''),
// change for backdrop
'#default_value' => config_get('mmeu.settings', 'mmeu_urls'),
);
// add submit handler for backdrop
$form['#submit'][1] = 'mmeu_form_system_site_maintenance_mode_alter_newsubmit';
}
function mmeu_form_system_site_maintenance_mode_alter_newsubmit($form, &$form_state) {
// change for backdrop
$excludeurl = $form_state['values']['mmeu_urls'];
config_set('mmeu.settings', 'mmeu_urls', $excludeurl);
backdrop_set_message("Config values: $excludeurl saved.");
}
/**
* Implements hook_menu_site_status_alter().
*/
function mmeu_menu_site_status_alter(&$menu_site_status, $path) {
//$mmeu_urls = variable_get('mmeu_urls', '');
// change for backdrop
$mmeu_urls = config_get('mmeu.settings', 'mmeu_urls');
if ($menu_site_status == MENU_SITE_OFFLINE && trim($mmeu_urls) != ''
&& (backdrop_match_path(backdrop_get_path_alias($path), $mmeu_urls)
|| backdrop_match_path($path, $mmeu_urls))) {
$menu_site_status = MENU_SITE_ONLINE;
}
}
/**
* Implements hook_config_info() for backdrop.
*/
function mmeu_config_info() {
$prefixes['mmeu.settings'] = array(
'label' => t('MMEU Settings'),
'group' => t('Configuration'),
);
return $prefixes;
}