-
Notifications
You must be signed in to change notification settings - Fork 2
/
the_curtain.module
executable file
·192 lines (178 loc) · 6.74 KB
/
the_curtain.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
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
<?php
/**
* @file
* .module file for 'the_curtain' module
*/
/**
* Implements hook_menu()
*/
function the_curtain_menu() {
$menu['admin/config/development/the_curtain'] = array(
'title' => 'The Curtain',
'description' => 'Pay no attention to that man behind the curtain.',
'page callback' => '_the_curtain_admin_page',
'access arguments' => array('access administration pages'),
'file' => 'the_curtain.admin.inc',
'type' => MENU_NORMAL_ITEM,
'weight' => $weight = 0,
);
$menu['admin/config/development/the_curtain/unveil'] = array(
'title' => 'Unveilings',
'description' => 'Show behind-the-scenes data from Drupal.',
'page callback' => 'drupal_get_form',
'page arguments' => array('_the_curtain_admin_unveilings_form'),
// this has its own permission since it changes the display on regular pages.
'access arguments' => array('the curtain unveil'),
'file' => 'the_curtain.admin.inc',
'type' => MENU_LOCAL_TASK,
'weight' => $weight++,
);
$menu['admin/config/development/the_curtain/fields'] = array(
'title' => 'Fields',
'description' => 'Information about fields on the site',
'page callback' => '_the_curtain_admin_fields',
'access arguments' => array('access administration pages'),
// this has its own permission since it changes the display on regular pages.
'file' => 'the_curtain.admin.inc',
'type' => MENU_LOCAL_TASK,
'weight' => $weight++,
);
$menu['admin/config/development/the_curtain/tables'] = array(
'title' => 'Tables',
'description' => 'Show data from arbitrary tables',
'page callback' => 'drupal_get_form',
'page arguments' => array('_the_curtain_admin_tables_form'),
// this has its own permission since it changes the display on regular pages.
'access arguments' => array('the curtain unveil'),
'file' => 'the_curtain.admin.inc',
'type' => MENU_LOCAL_TASK,
'weight' => $weight++,
);
$menu['admin/config/development/the_curtain/tables/%'] = array(
'title' => 'Table',
'description' => '',
'page callback' => '_the_curtain_admin_table',
'page arguments' => array(5),
// this has its own permission since it displays database values
'access arguments' => array('the curtain unveil'),
'file' => 'the_curtain.admin.inc',
'type' => MENU_CALLBACK,
'weight' => $weight++,
);
$menu['admin/config/development/the_curtain/hooks'] = array(
'title' => 'Hooks',
'description' => 'Show hooks that modules implement',
'page callback' => '_the_curtain_admin_hooks',
// this has its own permission since it changes the display on regular pages.
'access arguments' => array('access administration pages'),
'file' => 'the_curtain.admin.inc',
'type' => MENU_LOCAL_TASK,
'weight' => $weight++,
);
$menu['admin/config/development/the_curtain/watchdog_stats'] = array(
'title' => 'Watchdog Stats',
'description' => 'Show the most common entries in the Watchdog log',
'page callback' => '_the_curtain_watchdog_stats',
// this has its own permission since it changes the display on regular pages.
'access arguments' => array('access administration pages'),
'file' => 'the_curtain.admin.inc',
'type' => MENU_LOCAL_TASK,
'weight' => $weight++,
);
// create an array of similar menu items
if ( module_exists('url_alias') ) {
$revealings['aliases'] = array(
'title'=> t('Aliases'),
'description' => t('Display the URL Aliases table'),
);
}
$revealings['menu_router'] = array(
'title'=> t('Menu Router'),
'description' => t('Display the Menu Router table'),
);
$revealings['system'] = array(
'title' => t('System Table'),
'description' => t('Display the System table (installed and available modules and themes).'),
);
$revealings['variable'] = array(
'title' => t('Variable Table'),
'description' => t('Display the Variable table (Core and Module key/value pairs)'),
);
foreach ( $revealings as $key => $revealing ) {
$menu['admin/config/development/the_curtain/' . $key] = array(
'title' => $revealing['title'],
'description' => $revealing['description'],
'page callback' => '_the_curtain_admin_display_table',
'page arguments' => array($key),
'access arguments' => array('access administration pages'),
'file' => 'the_curtain.admin.inc',
'type' => MENU_LOCAL_TASK,
'weight' => $weight++,
);
}
return $menu;
}
/**
* Implements hook_permission
*/
function the_curtain_permission() {
return array(
'the curtain unveil' => array(
'title'=> t('Unveil the inner workings of Drupal'),
'description' => t('Show things such as SQL strings, form data, etc. on pages.'),
),
'the curtain edit' => array(
'title'=> t('Edit Variable Values'),
'description' => t('Edit the values of variables in the variables table'),
),
);
}
/**
* Implements hook_query_alter()
* Displays the all available queries to the UI
* Or EFQs tagged to be displayed.
*/
function the_curtain_query_alter(SelectQueryInterface $query) {
if ( get_class($query) != 'EntityFieldQuery' &&
( variable_get('the_curtain_show_sql')
|| ( variable_get('the_curtain_show_efq') && $query->hasTag('the_curtain') )
)
) {
drupal_set_message(t('Module \'@module\' is kpr\'ing queries.', array('@module'=>'The Curtain')), 'status', FALSE);
module_load_include('inc', 'the_curtain', 'the_curtain.utils');
drupal_set_message(the_curtain_query_to_sql($query));
}
}
/**
* Implements hook_form_alter()
* Displays form and form state data if directed.
*/
function the_curtain_form_alter($form, &$form_state, $form_id) {
if ( variable_get('the_curtain_show_form_id') ) {
drupal_set_message(t('Module \'@module\' is kpr\'ing form ids.', array('@module'=>'The Curtain')), 'status', FALSE);
drupal_set_message(t('Form ID is \'@id\'.', array('@id'=>$form_id)));
}
if ( variable_get('the_curtain_show_forms') ) {
drupal_set_message(t('Module \'@module\' is kpr\'ing form arrays.', array('@module'=>'The Curtain')), 'status', FALSE);
kpr($form);
}
if ( variable_get('the_curtain_show_form_states') ) {
drupal_set_message(t('Module \'@module\' is kpr\'ing form state arrays.', array('@module'=>'The Curtain')), 'status', FALSE);
kpr($form_state);
}
}
/**
* Implements hook_entity_field_query
* alters Entity Field Queries to tag them,
* so that their quieries are displayed,
* if so directed
* burma shave
*/
function the_curtain_entity_query_alter($query) {
if ( variable_get('the_curtain_show_efq') ) {
drupal_set_message(t('Module \'@module\' is kpr\'ing Entity Field Queries.', array('@module'=>'The Curtain')), 'status', FALSE);
$query->addTag(__FUNCTION__);
}
}
function the_curtain_form_system_modules_alter($form, &$form_state) {
}