forked from mkalkbrenner/themekey
-
Notifications
You must be signed in to change notification settings - Fork 0
/
themekey_debug.module
75 lines (64 loc) · 2.21 KB
/
themekey_debug.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
<?php
/**
* @file
* Provides a debug mode for module ThemeKey.
* @see themekey.module
*
* @author Markus Kalkbrenner | Cocomore AG
* @see http://drupal.org/user/124705
*/
/**
* Iterates over all ThemeKey Properties and prints
* out their current values.
*/
function themekey_debug_properties() {
global $user;
if (1 == $user->uid || variable_get('themekey_debug_non_admin_users', FALSE)) {
module_load_include('inc', 'themekey', 'themekey_base');
$properties = variable_get('themekey_properties', array());
$message = t('These are the current values of all available ThemeKey Properties. By clicking the value you can start creating a corresponding Theme Switching Rule.') . '<ul>';
$parameters = themekey_get_global_parameters();
foreach ($properties as $property) {
if (!isset($parameters[$property])) {
themekey_property_value($parameters, $property);
}
$value = '';
if (is_null($parameters[$property])) {
if ('drupal:path' == $property) {
$value = '<em>no debug information</em>';
}
else {
$value = '<em>empty</em>';
}
}
else {
$values = is_array($parameters[$property]) ? $parameters[$property] : array($parameters[$property]);
$links = array();
foreach ($values as $single_value) {
$links[] = l($single_value, 'admin/settings/themekey', array('fragment' => 'themekey_new_rule', 'query' => array('property' => $property, 'value' => $single_value)));
}
$value = implode('<br />', $links);
}
$message .= '<li>' . $property . '<br />' . $value . '</li><br />';
}
$message .= '</ul>';
themekey_set_debug_message($message, array(), FALSE);
}
}
/**
* Implements hook_menu().
*/
function themekey_debug_menu() {
$items = array();
$items['admin/settings/themekey/settings/debug'] = array(
'title' => 'Debug',
'access callback' => 'user_access',
'access arguments' => array('administer themekey settings'),
'file' => 'themekey_debug_admin.inc',
'page callback' => 'drupal_get_form',
'page arguments' => array('themekey_debug_settings_form'),
'type' => MENU_LOCAL_TASK,
'weight' => 10
);
return $items;
}