function authcache_admin_blocks in Authenticated User Page Caching (Authcache) 6
Same name and namespace in other branches
- 7 authcache.admin.inc \authcache_admin_blocks()
Authcache Ajax Blocks
1 string reference to 'authcache_admin_blocks'
- authcache_menu in ./
authcache.module - Implements hook_menu().
File
- ./
authcache.admin.inc, line 367 - Admin forms and pages.
Code
function authcache_admin_blocks() {
drupal_set_title(t('Authcache Ajax Blocks'));
if (!variable_get('block_cache', FALSE)) {
drupal_set_message(t('Drupal core block cache is currently disabled. It is recommened you <a href="@performance_link">enable it</a>.', array(
'@performance_link' => url('admin/settings/performance'),
)), 'warning');
}
$form['#suffix'] = '';
$form['#prefix'] = '<p>' . t('!blocks may be configured to load during the Authcache Ajax phase. This is useful for dynamic or user-centric content.', array(
'!blocks' => l(t('Blocks'), 'admin/build/block'),
)) . '</p><p>' . t('There is a performance disadvantage, however, as uncached blocks require a full Drupal bootstrap by loading all Drupal files and modules, increasing server load. To improve performance, blocks may be cached server-side (<a href="@performance_link">@is_enabled</a>) and locally on the user\'s browser by using "Minimum cache lifetime" on the block configuration page. This option also prevents jumpiness when navigating across pages.', array(
'@performance_link' => url('admin/settings/performance'),
'@is_enabled' => variable_get('block_cache', FALSE) ? t('currently enabled') : t('currently disabled'),
)) . '</p>';
$blocks = array();
$q = db_query("SELECT module,delta,region,title FROM {blocks} ORDER BY region, weight, module");
while ($r = db_fetch_object($q)) {
$blocks["{$r->module}-{$r->delta}"] = $r;
}
$header = array(
t('Region'),
t('Block'),
t('Cache Lifetime'),
);
$rows = array();
if ($authcache_block = variable_get('authcache_block', array())) {
foreach ($authcache_block as $block_id => $lifetime) {
if (isset($blocks[$block_id])) {
$block = $blocks[$block_id];
if (!$block->title) {
$info = module_invoke($block->module, 'block', 'list');
if (isset($info[$block->delta])) {
$block->title = $info[$block->delta]['info'];
}
}
if (!$block->region) {
$block->region = '<em>' . t('disabled') . '</em>';
}
$rows[] = array(
$block->region,
l($block->title, "admin/build/block/configure/{$block->module}/{$block->delta}", array(
'query' => array(
'destination' => 'admin/settings/performance/authcache/blocks',
),
)),
$lifetime . ' ' . t('seconds'),
);
}
}
$form['#suffix'] = theme('table', $header, $rows);
}
$form['#suffix'] .= '<em>' . t('To add an Authcache Ajax block, visit the !blocks page and click "configure" next to the block.', array(
'!blocks' => l(t('Blocks'), 'admin/build/block'),
)) . '</em>';
return $form;
}