function apdqc_admin_system_performance_settings_form in Asynchronous Prefetch Database Query Cache 7
Add various apdqc settings to the system_performance_settings form.
1 call to apdqc_admin_system_performance_settings_form()
- apdqc_form_system_performance_settings_alter in ./
apdqc.module - Implements hook_form_FORM_ID_alter().
File
- ./
apdqc.admin.inc, line 39 - Admin page callbacks for the apdqc module.
Code
function apdqc_admin_system_performance_settings_form(&$form, $form_state) {
apdqc_admin_set_message_if_needed();
// Add in additional times.
$form['caching']['cache_lifetime']['#options'] += apdqc_admin_additional_times();
ksort($form['caching']['cache_lifetime']['#options']);
$form['caching']['page_cache_maximum_age']['#options'] += apdqc_admin_additional_times();
ksort($form['caching']['page_cache_maximum_age']['#options']);
// Give more detail about cache_lifetime.
$form['caching']['cache_lifetime']['#description'] .= ' ' . t("When set to <none>, the entire block and page cache is cleared every time any content is saved.");
// Recommend the expire module.
if (!module_exists('expire')) {
$form['caching']['cache_lifetime']['#description'] .= '<p> ' . t('If using something other than <none> the <a href="@expire">Cache Expiration</a> module is highly recommended.', array(
'@expire' => 'https://www.drupal.org/project/expire',
)) . '</p>';
}
else {
// Get config page for expire module.
$items = expire_menu();
$link = '';
foreach ($items as $url => $item) {
if (in_array('expire_admin_settings_form', $item['page arguments'])) {
$link = $url;
break;
}
}
if (empty($link)) {
foreach ($items as $url => $item) {
if (strpos($url, 'admin') && strpos($url, 'expire')) {
$link = $url;
break;
}
}
}
// Inform user they need to configure expire.
$form['caching']['cache_lifetime']['#description'] .= '<p> ' . t('Be sure to <a href="@expire-admin">configure the expire module</a> correctly.', array(
'@expire-admin' => url($link),
)) . '</p>';
}
// Give more detail about page_cache_maximum_age.
$form['caching']['page_cache_maximum_age']['#description'] .= ' ' . t('This not only affects reverse proxy caches like Varnish, but also how long browsers should keep cached versions of your pages. If your site changes often keep this value low.');
$apdqc_form = apdqc_admin_get_settings();
// Expose the cache_garbage_collection_frequency variable.
$form['caching']['cache_garbage_collection_frequency'] = $apdqc_form['cache_garbage_collection_frequency'];
// Allow for module level prefetching to be disabled.
$form['caching']['apdqc_prefetch'] = $apdqc_form['apdqc_prefetch'];
// Re-order cache fields.
$form['caching']['cache_lifetime']['#weight'] = 10;
$form['caching']['cache_garbage_collection_frequency']['#weight'] = 11;
$form['caching']['page_cache_maximum_age']['#weight'] = 12;
$form['caching']['apdqc_prefetch']['#weight'] = 2;
}