Commit 99ce96e5 authored by Dries's avatar Dries

- Patch #459980 by Xano: rework admin/settings/performance.

parent da2639d6
......@@ -6,6 +6,30 @@
* Admin page callbacks for the block module.
*/
/**
* Implement hook_form_FORM_ID_alter().
*/
function block_form_system_performance_settings_alter(&$form, &$form_state) {
$disabled = count(module_implements('node_grants'));
$form['caching']['block_cache'] = array(
'#type' => 'checkbox',
'#title' => t('Cache blocks'),
'#default_value' => variable_get('block_cache', FALSE),
'#disabled' => $disabled,
'#description' => $disabled ? t('Block caching is inactive because you have enabled modules defining content access restrictions.') : NULL,
'#weight' => -1,
);
// Check if the "Who's online" block is enabled.
$online_block_enabled = db_query_range("SELECT 1 FROM {block} b WHERE module = 'user' AND delta = 'online' AND status = 1", array(), 0, 1)->fetchField();
// If the "Who's online" block is enabled, append some descriptive text to
// the end of the form description.
if ($online_block_enabled) {
$form['page_cache']['cache']['#description'] .= '<p>' . t('When caching is enabled, anonymous user sessions are only saved to the database when needed, so the "Who\'s online" block does not display the number of anonymous users.') . '</p>';
}
}
/**
* Menu callback for admin/structure/block.
*/
......
......@@ -461,39 +461,6 @@ function block_user_validate(&$edit, &$account, $category = NULL) {
return $edit;
}
/**
* Implement hook_form_FORM_ID_alter().
*/
function block_form_system_performance_settings_alter(&$form, &$form_state) {
// Add the block cache fieldset on the performance settings page.
$form['block_cache'] = array(
'#type' => 'fieldset',
'#title' => t('Block cache'),
'#description' => t('Enabling the block cache can offer a performance increase for all users by preventing blocks from being reconstructed on each page load. If the page cache is also enabled, performance increases from enabling the block cache will mainly benefit authenticated users.'),
'#weight' => 0,
);
$form['block_cache']['block_cache'] = array(
'#type' => 'radios',
'#title' => t('Block cache'),
'#default_value' => variable_get('block_cache', CACHE_DISABLED),
'#options' => array(CACHE_DISABLED => t('Disabled'), CACHE_NORMAL => t('Enabled (recommended)')),
'#disabled' => count(module_implements('node_grants')),
'#description' => t('Note that block caching is inactive when modules defining content access restrictions are enabled.'),
);
// Check if the "Who's online" block is enabled.
$online_block_enabled = db_query_range("SELECT 1 FROM {block} b WHERE module = 'user' AND delta = 'online' AND status = 1", array(), 0, 1)->fetchField();
// If the "Who's online" block is enabled, append some descriptive text to
// the end of the form description.
if ($online_block_enabled) {
$form['page_cache']['cache']['#description'] .= '<p>' . t('When caching is enabled, anonymous user sessions are only saved to the database when needed, so the "Who\'s online" block does not display the number of anonymous users.') . '</p>';
}
}
/**
* Implement hook_form_FORM_ID_alter().
*/
......
This diff is collapsed.
......@@ -148,5 +148,26 @@ Drupal.behaviors.poweredByPreview = {
};
/**
* Show/hide settings for page caching depending on whether page caching is
* enabled or not.
*/
Drupal.behaviors.pageCache = {
attach: function (context, settings) {
$('#edit-cache-0', context).change(function () {
$('#page-compression-wrapper').hide();
$('#cache-error').hide();
});
$('#edit-cache-1', context).change(function () {
$('#page-compression-wrapper').show();
$('#cache-error').hide();
});
$('#edit-cache-2', context).change(function () {
$('#page-compression-wrapper').show();
$('#cache-error').show();
});
},
};
})(jQuery);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment