function dynamic_cache_test_page in Dynamic Cache 7
Same name and namespace in other branches
- 6 dynamic_cache_test.module \dynamic_cache_test_page()
Menu callback for dynamic_cache/test.
1 string reference to 'dynamic_cache_test_page'
- dynamic_cache_test_menu in ./
dynamic_cache_test.module - Implements hook_menu().
File
- ./
dynamic_cache_test.module, line 60 - Dynamic Cache Test module.
Code
function dynamic_cache_test_page() {
$output = '';
// Print info about Anonymous status, cache status, and test cookie.
global $user, $conf;
// Track conditions necessary for normal anonymous caching to be active.
$anon_cache = 0;
if (array_key_exists(DRUPAL_ANONYMOUS_RID, $user->roles)) {
$output .= '<p style="background:#8f8;">' . t('Current user is ANONYMOUS.') . '</p>';
$anon_cache++;
}
elseif (array_key_exists(DRUPAL_AUTHENTICATED_RID, $user->roles)) {
$output .= '<p style="background:#f88;">' . t('Current user is AUTHENTICATED (Dynamic Cache only affects Anonymous users).') . '</p>';
}
if (empty($GLOBALS['cache_original'])) {
$output .= '<p style="background:#f88;">' . t('Cache is DISABLED (Dynamic Cache has no effect).') . '</p>';
}
else {
$output .= '<p style="background:#8f8;">' . t('Cache is ENABLED.') . '</p>';
$anon_cache++;
}
if (drupal_get_bootstrap_phase() == DRUPAL_BOOTSTRAP_FULL) {
$output .= '<p style="background:#8f8;">' . t('Bootstrap phase') . ': ' . DRUPAL_BOOTSTRAP_FULL . ' {DRUPAL_BOOTSTRAP_FULL}</p>';
}
else {
$output .= '<p style="background:#f88;">' . t('Bootstrap phase') . ': ' . drupal_get_bootstrap_phase() . ' (' . t('Should be') . ' ' . DRUPAL_BOOTSTRAP_FULL . ' {DRUPAL_BOOTSTRAP_FULL})</p>';
}
if ($GLOBALS['dynamic_cache_test_boot_count'] == 1) {
$output .= '<p style="background:#8f8;">hook_boot() ' . t('count') . ': 1</p>';
}
else {
$output .= '<p style="background:#f88;">hook_boot() ' . t('count') . ': ' . $GLOBALS['dynamic_cache_test_boot_count'] . ' (' . t('Should be') . ' 1)</p>';
}
$generation_type = $anon_cache >= 2 && !dynamic_cache_test_is_dynamic() ? t('CACHED') : t('DYNAMIC');
$output .= '<p>' . t('This page was generated at') . ':</p><h2>' . date('H:i:s') . ' (' . $generation_type . ')</h2><p>(' . date('D M d Y') . ').</p>';
$output .= '<h3>' . t('Options') . '</h3>';
$output .= '<ul><li>' . l(t('Set Cookie'), 'dynamic_cache_test/set_cookie') . ' ' . t('(this cookie will activate Dynamic Cache, allowing anonymous users to see a dynamic page).') . '</li>';
$output .= '<li>' . l(t('Clear Cookie'), 'dynamic_cache_test/clear_cookie') . ' ' . t('(clears the cookie, returning anonymous users to seeing the cached page).') . '</li></ul>';
$output .= '<p>' . t('Cookie') . ': ' . (empty($_COOKIE['dynamic_cache_test']) ? '0' : '1') . '</p>';
return $output;
}