function dynamic_cache_test_page in Dynamic Cache 6
Same name and namespace in other branches
- 7 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 51 - 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>';
}
switch ($GLOBALS['conf']['cache_original']) {
case CACHE_AGGRESSIVE:
$output .= '<p style="background:#f88;">' . t('Cache is set to CACHE_AGGRESSIVE (Dynamic Cache will not work).') . '</p>';
break;
case CACHE_DISABLED:
$output .= '<p style="background:#f88;">' . t('Cache is set to CACHE_DISABLED (Dynamic Cache has no effect).') . '</p>';
break;
case CACHE_NORMAL:
$output .= '<p style="background:#8f8;">' . t('Cache is set to CACHE_NORMAL.') . '</p>';
$anon_cache++;
break;
}
$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;
}