-
Notifications
You must be signed in to change notification settings - Fork 8
/
lbdev.module
83 lines (68 loc) · 2.44 KB
/
lbdev.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
include_once('lbdev.features.inc');
/**
* Implementation of hook_enable().
*/
function lbdev_enable() {
// Weight needs to be high in order to strongarm variables.
db_query("UPDATE {system} SET weight = 100 WHERE name = 'lbdev' AND type = 'module'");
// Enable recommended modules if they are available. We save the modules we
// enabled to a variable so we can disable them when this feature is disabled.
if (function_exists('features_get_features') && ($feature = features_get_features('lbdev', TRUE)) && !empty($feature->info['recommends'])) {
$all_modules = array_keys(module_rebuild_cache());
// Filter out any non-existent modules.
$modules = array_intersect($feature->info['recommends'], $all_modules);
// Find out if any modules are already enabled.
$enabled = array_filter($modules, 'module_exists');
// We only want disabled modules.
if ($modules = array_diff($modules, $enabled)) {
features_install_modules($modules);
variable_set('lbdev_enabled_modules', $modules);
// Let somebody know what we just did.
$singular = 'The @modules module was enabled.';
$plural = 'The following modules were enabled: @modules';
$message = format_plural(count($modules), $singular, $plural, array('@modules' => implode(', ', $modules)));
drupal_set_message($message);
}
}
drupal_flush_all_caches();
}
/**
* Implementation of hook_disable().
*/
function lbdev_disable() {
if ($modules = variable_get('lbdev_enabled_modules', array())) {
module_disable($modules);
// Let somebody know what we just did.
$singular = 'The @modules module was disabled.';
$plural = 'The following modules were disabled: @modules';
$message = format_plural(count($modules), $singular, $plural, array('@modules' => implode(', ', $modules)));
drupal_set_message($message);
// Delete the old variable.
variable_del('lbdev_enabled_modules');
}
}
/**
* Implementation of hook_menu().
*/
function lbdev_menu() {
$items = array();
$items['typography'] = array(
'title' => 'Typography Test Page',
'description' => 'Configure settings',
'page callback' => 'theme',
'page arguments' => array('typography_test_page'),
'access callback' => TRUE,
);
return $items;
}
/**
* Implementation of hook_theme().
*/
function lbdev_theme() {
$items = array();
$items['typography_test_page'] = array(
'template' => 'typography-test-page',
);
return $items;
}