$links));
}
/**
* Page callback: Clears all caches, then redirects to the previous page.
*/
function devel_cache_clear() {
if (!isset($_GET['token']) || !drupal_valid_token($_GET['token'], 'devel-cache-clear')) {
return MENU_ACCESS_DENIED;
}
drupal_flush_all_caches();
drupal_set_message('Cache cleared.');
drupal_goto();
}
/**
* Page callback: Called by the AJAX link in query log.
*/
function devel_querylog_explain($request_id, $qid) {
if (!is_numeric($request_id)) {
return MENU_ACCESS_DENIED;
}
$path = "temporary://devel_querylog/$request_id.txt";
$path = file_stream_wrapper_uri_normalize($path);
$output = t('No explain log found.');
if (file_exists($path)) {
$queries = json_decode(file_get_contents($path));
if ($queries !== FALSE && isset($queries[$qid])) {
$header = $rows = array();
$query = $queries[$qid];
$result = db_query('EXPLAIN ' . $query->query, (array)$query->args)->fetchAllAssoc('table');
$i = 1;
foreach ($result as $row) {
$row = (array)$row;
if ($i == 1) {
$header = array_keys($row);
}
$rows[] = array_values($row);
$i++;
}
$output = theme('table', array('header' => $header, 'rows' => $rows));
}
}
// Print and return nothing thus avoiding page wrapper.
print $output;
$GLOBALS['devel_shutdown'] = FALSE;
}
/**
* Page callback: Called by the AJAX link in query log.
*/
function devel_querylog_arguments($request_id, $qid) {
if (!is_numeric($request_id)) {
return MENU_ACCESS_DENIED;
}
$path = "temporary://devel_querylog/$request_id.txt";
$path = file_stream_wrapper_uri_normalize($path);
$output = t('No arguments log found.');
if (file_exists($path)) {
$queries = json_decode(file_get_contents($path));
if ($queries !== FALSE && isset($queries[$qid])) {
$query = $queries[$qid];
$conn = Database::getConnection();
$quoted = array();
foreach ((array)$query->args as $key => $val) {
$quoted[$key] = $conn->quote($val);
}
$output = strtr($query->query, $quoted);
}
}
// Print and return nothing thus avoiding page wrapper.
print $output;
$GLOBALS['devel_shutdown'] = FALSE;
}
/**
* Page callback: Clears the database, resetting the menu to factory defaults.
*/
function devel_menu_rebuild() {
menu_rebuild();
drupal_set_message(t('The menu router has been rebuilt.'));
drupal_goto();
}
/**
* Form constructor for reinstalling any module from a dropdown.
*
* @see devel_reinstall_submit()
*
* @ingroup forms
*/
function devel_reinstall($form, &$form_state) {
$output = '';
$modules = module_list();
sort($modules);
$options = drupal_map_assoc($modules);
$form['list'] = array(
'#type' => 'checkboxes',
'#options' => $options,
'#description' => t('Uninstall and then install the selected modules. hook_uninstall()
and hook_install()
will be executed and the schema version number will be set to the most recent update number. You may have to manually clear out any existing tables first if the module doesn\'t implement hook_uninstall()
.'),
);
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array(
'#value' => t('Reinstall'),
'#type' => 'submit',
);
return $form;
}
/**
* Form submission callback for devel_reinstall().
*/
function devel_reinstall_submit($form, &$form_state) {
// require_once './includes/install.inc';
$modules = array_filter($form_state['values']['list']);
module_disable($modules, FALSE);
drupal_uninstall_modules($modules, FALSE);
module_enable($modules, FALSE);
drupal_set_message(t('Uninstalled and installed: %names.', array('%names' => implode(', ', $modules))));
}
/**
* Page callback: Rebuilds the theme registry.
*/
function devel_theme_registry() {
drupal_theme_initialize();
$hooks = theme_get_registry();
ksort($hooks);
return kprint_r($hooks, TRUE);
}
/**
* Page callback: Returns information from hook_entity_info().
*
* @param string $entity_type
* (optional) Limit results to the specified entity type. The default is to
* return information about all entity types. The $entity_type argument is not
* currently used in the UI.
*
* @return
* The results from kprint_r().
*/
function devel_entity_info_page($entity_type = NULL) {
$info = entity_get_info($entity_type);
ksort($info);
return kprint_r($info, TRUE);
}
/**
* Page callback: Returns information about fields.
*/
function devel_field_info_page() {
$info = field_info_fields();
$output = kprint_r($info, TRUE, t('Fields'));
$info = field_info_instances();
$output .= kprint_r($info, TRUE, t('Instances'));
$info = field_info_bundles();
$output .= kprint_r($info, TRUE, t('Bundles'));
$info = field_info_field_types();
$output .= kprint_r($info, TRUE, t('Field types'));
$info = field_info_formatter_types();
$output .= kprint_r($info, TRUE, t('Formatter types'));
$info = field_info_storage_types();
$output .= kprint_r($info, TRUE, t('Storage types'));
$info = field_info_widget_types();
$output .= kprint_r($info, TRUE, t('Widget types'));
return $output;
}
/**
* Form constructor for displaying and editing variables.
*
* @see devel_variable_form_submit()
*
* @ingroup forms.
*/
function devel_variable_form() {
$header = array(
'name' => array('data' => t('Name'), 'field' => 'name', 'sort' => 'asc'),
'value' => array('data' => t('Value'), 'field' => 'value'),
'length' => array('data' => t('Length'), 'field' => 'length'),
'edit' => array('data' => t('Operations')),
);
// @todo: We could get variables out of $conf but that would include
// hard-coded ones too. Ideally I would highlight overridden/hard-coded
// variables.
$query = db_select('variable', 'v')->extend('TableSort');
$query->fields('v', array('name', 'value'));
switch (db_driver()) {
case 'mssql':
$query->addExpression("LEN(v.value)", 'length');
break;
default:
$query->addExpression("LENGTH(v.value)", 'length');
break;
}
$result = $query
->orderByHeader($header)
->execute();
foreach ($result as $row) {
// $variables[$row->name] = '';
$options[$row->name]['name'] = check_plain($row->name);
if (merits_krumo($row->value)) {
$value = krumo_ob(variable_get($row->name, NULL));
}
else {
if (drupal_strlen($row->value) > 70) {
$value = check_plain(drupal_substr($row->value, 0, 65)) .'...';
}
else {
$value = check_plain($row->value);
}
}
$options[$row->name]['value'] = $value;
$options[$row->name]['length'] = $row->length;
$options[$row->name]['edit'] = l(t('Edit'), "devel/variable/edit/$row->name");
}
$form['variables'] = array(
'#type' => 'tableselect',
'#header' => $header,
'#options' => $options,
'#empty' => t('No variables.'),
);
$form['actions'] = array('#type' => 'actions');
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t('Delete'),
);
$form['#after_build'][] = 'devel_variable_form_after_build';
// krumo($form);
return $form;
}
/**
* Form submission handler for devel_variable_form().
*/
function devel_variable_form_submit($form, &$form_state) {
$deletes = array_filter($form_state['values']['variables']);
array_walk($deletes, 'variable_del');
if (count($deletes)) {
drupal_set_message(format_plural(count($deletes), 'One variable deleted.', '@count variables deleted.'));
}
}
/**
* After build callback for devel_variable_form().
*
* Wrap each variable name in a