ystem_sql($data, array(
'Com_select' => t('The number of SELECT-statements.'),
'Com_insert' => t('The number of INSERT-statements.'),
'Com_update' => t('The number of UPDATE-statements.'),
'Com_delete' => t('The number of DELETE-statements.'),
'Com_lock_tables' => t('The number of table locks.'),
'Com_unlock_tables' => t('The number of table unlocks.')
));
$output .= '
'. t('Query performance') .'
';
$output .= _system_sql($data, array(
'Select_full_join' => t('The number of joins without an index; should be zero.'),
'Select_range_check' => t('The number of joins without keys that check for key usage after each row; should be zero.'),
'Sort_scan' => t('The number of sorts done without using an index; should be zero.'),
'Table_locks_immediate' => t('The number of times a lock could be acquired immediately.'),
'Table_locks_waited' => t('The number of times the server had to wait for a lock.')
));
$output .= ''. t('Query cache information') .'
';
$output .= ''. t('The MySQL query cache can improve performance of your site by storing the result of queries. Then, if an identical query is received later, the MySQL server retrieves the result from the query cache rather than parsing and executing the statement again.') .'
';
$output .= _system_sql($data, array(
'Qcache_queries_in_cache' => t('The number of queries in the query cache.'),
'Qcache_hits' => t('The number of times MySQL found previous results in the cache.'),
'Qcache_inserts' => t('The number of times MySQL added a query to the cache (misses).'),
'Qcache_lowmem_prunes' => t('The number of times MySQL had to remove queries from the cache because it ran out of memory. Ideally should be zero.')
));
return $output;
}
/**
* Default page callback for batches.
*/
function system_batch_page() {
require_once './includes/batch.inc';
$output = _batch_page();
if ($output === FALSE) {
drupal_access_denied();
}
elseif (isset($output)) {
// Force a page without blocks or messages to
// display a list of collected messages later.
print theme('page', $output, FALSE, FALSE);
}
}
/**
* This function formats an administrative block for display.
*
* @param $block
* An array containing information about the block. It should
* include a 'title', a 'description' and a formatted 'content'.
* @ingroup themeable
*/
function theme_admin_block($block) {
// Don't display the block if it has no content to display.
if (empty($block['content'])) {
return '';
}
$output = <<< EOT
$block[title]
$block[description]
$block[content]
EOT;
return $output;
}
/**
* This function formats the content of an administrative block.
*
* @param $content
* An array containing information about the block. It should
* include a 'title', a 'description' and a formatted 'content'.
* @ingroup themeable
*/
function theme_admin_block_content($content) {
if (!$content) {
return '';
}
if (system_admin_compact_mode()) {
$output = '';
}
else {
$output = '';
foreach ($content as $item) {
$output .= '- '. l($item['title'], $item['href'], $item['localized_options']) .'
';
$output .= '- '. $item['description'] .'
';
}
$output .= '
';
}
return $output;
}
/**
* This function formats an administrative page for viewing.
*
* @param $blocks
* An array of blocks to display. Each array should include a
* 'title', a 'description', a formatted 'content' and a
* 'position' which will control which container it will be
* in. This is usually 'left' or 'right'.
* @ingroup themeable
*/
function theme_#disabled'] = TRUE;
}
}
// Table with filters
$all = filter_list_all();
$enabled = filter_list_format($format->format);
$form['filters'] = array('#type' => 'fieldset',
'#title' => t('Filters'),
'#description' => t('Choose the filters that will be used in this filter format.'),
'#tree' => TRUE,
);
foreach ($all as $id => $filter) {
$form['filters'][$id] = array('#type' => 'checkbox',
'#title' => $filter->name,
'#default_value' => isset($enabled[$id]),
'#description' => module_invoke($filter->module, 'filter', 'description', $filter->delta),
);
}
if (!empty($format->format)) {
$form['format'] = array('#type' => 'hidden', '#value' => $format->format);
// Composition tips (guidelines)
$tips = _filter_tips($format->format, FALSE);
$extra = ''. l(t('More information about formatting options'), 'filter/tips') .'
';
$tiplist = theme('filter_tips', $tips, FALSE, $extra);
if (!$tiplist) {
$tiplist = ''. t('No guidelines available.') .'
';
}
$group = ''. t('These are the guidelines that users will see for posting in this input format. They are automatically generated from the filter settings.') .'
';
$group .= $tiplist;
$form['tips'] = array('#value' => ''. t('Formatting guidelines') .'
'. $group);
}
$form['submit'] = array('#type' => 'submit', '#value' => t('Save configuration'));
return $form;
}
/**
* Validate filter format form submissions.
*/
function filter_admin_format_form_validate($form, &$form_state) {
if (!isset($form_state['values']['format'])) {
$name = trim($form_state['values']['name']);
$result = db_fetch_object(db_query("SELECT format FROM {filter_formats} WHERE name='%s'", $name));
if ($result) {
form_set_error('name', t('Filter format names need to be unique. A format named %name already exists.', array('%name' => $name)));
}
}
}
/**
* Process filter format form submissions.
*/
function filter_admin_format_form_submit($form, &$form_state) {
$format = isset($form_state['values']['format']) ? $form_state['values']['format'] : NULL;
$current = filter_list_format($format);
$name = trim($form_state['values']['name']);
$cache = TRUE;
// Add a new filter format.
if (!$format) {
$new = TRUE;
db_query("INSERT INTO {filter_formats} (name) VALUES ('%s')", $name);
$format = db_result(db_query("SELECT MAX(format) AS format FROM {filter_formats}"));
drupal_set_message(t('Added input format %format.', array('%format' => $name)));
}
else {
drupal_set_message(t('The input format settings have been updated.'));
}
db_query("DELETE FROM {filters} WHERE format = %d", $format);
foreach ($form_state['values']['filters'] as $id => $checked) {
if ($checked) {
list($module, $delta) = explode('/', $id);
// Add new filters to the bottom.
$weight = isset($current[$id]->weight) ? $current[$id]->weight : 10;
db_query("INSERT INTO {filters} (format, module, delta, weight) VALUES (%d, '%s', %d, %d)", $format, $module, $delta, $weight);
// Check if there are any 'no cache' filters.
$cache &= !module_invoke($module, 'filter', 'no cache', $delta);
}
}
// We store the roles as a string for ease of use.
// We should always set all roles to TRUE when saving a default role.
// We use leading and trailing comma's to allow easy substring matching.
$roles = array();
if (isset($form_state['values']['roles'])) {
foreach ($form_state['values']['roles'] as $id => $checked) {
if ($checked) {
$roles[] = $id;
}
}
}
if (!empty($form_state['values']['default_format'])) {
$roles = ','. implode(',', array_keys(user_roles())) .',';
}
else {
$roles = ','. implode(',', $roles) .',';
}
db_query("UPDATE {filter_formats} SET cache = %d, name='%s', roles = '%s' WHERE format = %d", $cache, $name, $roles, $format);
cache_clear_all($format .':', 'cache_filter', TRUE);
// If a new filter was added, return to the main list of filters. Otherwise, stay on edit filter page to show new changes.
$return = 'admin/settings/filters';
if (!empty($new)) {
$return .= '/'. $format;
}
$form_state['redirect'] = $return;
return;
}
/**
* Menu callback; confirm deletion of a format.
*
* @ingroup forms
* @see filter_admin_delete_submit()
*/
function filter_admin_delete() {
$format = arg(4);
$format = db_fetch_object(db_query('SELECT * FROM {filter_formats} WHERE format = %d', $format));
if ($format) {
if ($format->format != variable_get('filter_default_format', 1)) {
$form['format'] = array('#type' => 'hidden', '#value' => $format->format);
$form['name'] = array('#type' => 'hidden', '#value' => $format->name);
return confirm_form($form, t('Are you sure you want to delete the input format %format?', array('%format' => $format->name)), 'admin/settings/filters', t('If you have any content left in this input format, it will be switched to the default input format. This action cannot be undone.'), t('Delete'), t('Cancel'));
}
else {
drupal_set_message(t('The default format cannot be deleted.'));
drupal_goto('admin/settings/filters');
}
}
else {
drupal_not_found();
}
}
/**
* Process filter delete form submission.
*/
function filter_admin_delete_submit($form, &$form_state) {
db_query("DELETE FROM {filter_formats} WHERE format = %d", $form_state['values']['format']);
db_query("DELETE FROM {filters} WHERE format = %d", $form_state['values']['format']);
$default = variable_get('filter_default_format', 1);
// Replace existing instances of the deleted format with the default format.
db_query("UPDATE {node_revisions} SET format = %d WHERE format = %d", $default, $form_state['values']['format']);
db_query("UPDATE {comments} SET format = %d WHERE format = %d", $default, $form_state['values']['format']);
db_query("UPDATE {boxes} SET format = %d WHERE format = %d", $default, $form_state['values']['format']);
cache_clear_all($form_state['values']['format'] .':', 'cache_filter', TRUE);
drupal_set_message(t('Deleted input format %format.', array('%format' => $form_state['values']['name'])));
$form_state['redirect'] = 'admin/settings/filters';
return;
}
/**
* Menu callback; display settings defined by a format's filters.
*/
function filter_admin_configure_page($format) {
drupal_set_title(t("Configure %format", array('%format' => $format->name)));
return drupal_get_form('filter_admin_configure', $format);
}
/**
* Build a form to change the settings for a format's filters.
*
* @ingroup forms
*/
function filter_admin_configure(&$form_state, $format) {
$list = filter_list_format($format->format);
$form = array();
foreach ($list as $filter) {
$form_module = module_invoke($filter->module, 'filter', 'settings', $filter->delta, $format->format);
if (isset($form_module) && is_array($form_module)) {
$form = array_merge($form, $form_module);
}
}
if (!empty($form)) {
$form = system_settings_form($form);
}
else {
$form['error'] = array('#value' => t('No settings are available.'));
}
$form['format'] = array('#type' => 'hidden', '#value' => $format->format);
$form['#submit'][] = 'filter_admin_configure_submit';
return $form;
}
/**
* Clear the filter's cache when configuration settings are saved.
*/
function filter_admin_configure_submit($form, &$form_state) {
cache_clear_all($form_state['values']['format'] .':', 'cache_filter', TRUE);
}
/**
* Menu callback; display form for ordering filters for a format.
*/
function filter_admin_order_page($format) {
drupal_set_title(t("Rearrange %format", array('%format' => $format->name)));
return drupal_get_form('filter_admin_order', $format);
}
/**
* Build the form for ordering filters for a format.
*
* @ingroup forms
* @see theme_filter_admin_order()
* @see filter_admin_order_submit()
*/
function filter_admin_order(&$form_state, $format = NULL) {
// Get list (with forced refresh).
$filters = filter_list_format($format->format);
$form['weights'] = array('#tree' => TRUE);
foreach ($filtersput;
}
/**
* Theme the theme select form.
* @param $form
* An associative array containing the structure of the form.
* @ingroup themeable
*/
function theme_system_theme_select_form($form) {
foreach (element_children($form) as $key) {
$row = array();
if (isset($form[$key]['description']) && is_array($form[$key]['description'])) {
$row[] = drupal_render($form[$key]['screenshot']);
$row[] = drupal_render($form[$key]['description']);
$row[] = drupal_render($form['theme'][$key]);
}
$rows[] = $row;
}
$header = array(t('Screenshot'), t('Name'), t('Selected'));
$output = theme('table', $header, $rows);
return $output;
}
/**
* Theme function for the system themes form.
*
* @param $form
* An associative array containing the structure of the form.
* @ingroup themeable
*/
function theme_system_themes_form($form) {
foreach (element_children($form) as $key) {
// Only look for themes
if (!isset($form[$key]['info'])) {
continue;
}
// Fetch info
$info = $form[$key]['info']['#value'];
// Localize theme description.
$description = t($info['description']);
// Make sure it is compatible and render the checkbox if so.
if (isset($form['status']['#incompatible_themes_core'][$key])) {
unset($form['status'][$key]);
$status = theme('image', 'misc/watchdog-error.png', t('incompatible'), t('Incompatible with this version of Drupal core'));
$description .= ''. t('This version is incompatible with the !core_version version of Drupal core.', array('!core_version' => VERSION)) .'
';
}
elseif (isset($form['status']['#incompatible_themes_php'][$key]))