function ajaxblocks_preprocess_block in Ajax Blocks 7
Same name and namespace in other branches
- 6 ajaxblocks.module \ajaxblocks_preprocess_block()
Implements hook_preprocess_block().
File
- ./
ajaxblocks.module, line 338 - Loads dynamic blocks on cached page for anonymous users by performing AJAX request.
Code
function ajaxblocks_preprocess_block(&$variables) {
if (ajaxblocks_in_ajax_handler()) {
return;
}
$id = $variables['block']->module . '-' . $variables['block']->delta;
$settings = array();
if (!ajaxblocks_is_ajax($id, $settings)) {
return;
}
$current_user_rids = array_keys($GLOBALS['user']->roles);
if (ajaxblocks_page_cacheable()) {
if (count(array_intersect($current_user_rids, $settings['cached_roles'])) == 0) {
return;
}
}
else {
if (count(array_intersect($current_user_rids, $settings['uncached_roles'])) == 0) {
return;
}
}
ajaxblocks_page_ajax_list($id, $settings);
$noscript = '';
if ($settings['include_noscript']) {
$noscript = '<script type="text/javascript"></script><noscript>' . $variables['content'] . '</noscript>';
}
$wrapper_class = "ajaxblocks-wrapper";
if ($settings['loader_picture']) {
$wrapper_class = "ajaxblocks-wrapper-" . intval($settings['loader_picture']);
}
$variables['content'] = '<div id="block-' . $id . '-ajax-content" class="' . $wrapper_class . '">' . $noscript . '</div>';
}