function closeblock_ajax_settings in Close Block 6
Same name and namespace in other branches
- 7 includes/closeblock.api.inc \closeblock_ajax_settings()
Write block settings to Drupal.settings.closeblock
2 calls to closeblock_ajax_settings()
- closeblock_blocks_process in includes/
closeblock.api.inc - Get blocks settings.
- closeblock_block_view_alter in ./
closeblock.module - Implements hook_block_view_alter().
File
- includes/
closeblock.api.inc, line 67
Code
function closeblock_ajax_settings($block) {
if (user_access('closeblock') && !empty($block->content)) {
global $closeblock_blocks, $closeblock_theme_settings;
$settings = variable_get('closeblock_settings', array());
$params = (array) $block;
$block_id = theme('closeblock_block_id', $params);
if (empty($settings[$block_id]['closeblock_active'])) {
return;
}
if (!empty($settings[$block_id]['closeblock_custom'])) {
$theme_settings = array_merge($closeblock_theme_settings, $settings[$block_id], array());
}
$closed = !empty($closeblock_blocks[$block_id]) && !empty($theme_settings['closeblock_save']);
if (!empty($theme_settings['closeblock_count']) && $theme_settings['closeblock_count'] > 1) {
if (empty($closeblock_blocks[$block_id]['count']) || $closeblock_blocks[$block_id]['count'] < $theme_settings['closeblock_count']) {
if (empty($theme_settings['closeblock_frequency'])) {
$closed = 0;
}
else {
$current_time = time();
$time = strtotime($theme_settings['closeblock_frequency']) - $current_time;
if (empty($closeblock_blocks[$block_id]['timestamp']) || $closeblock_blocks[$block_id]['timestamp'] + $time < $current_time) {
$closed = 0;
}
}
}
}
$types = array(
1 => '',
2 => 'slideUp',
3 => 'fadeOut',
);
drupal_add_js(array(
'closeblock' => array(
$block_id => array(
'closed' => $closed,
'speed' => $theme_settings['closeblock_speed'],
'save' => $theme_settings['closeblock_save'],
'type' => $types[$theme_settings['closeblock_type']],
'module' => $params['module'],
'delta' => $params['delta'],
),
),
), 'setting');
$path = drupal_get_path('module', 'closeblock');
drupal_add_js($path . '/theme/js/closeblock.js');
drupal_add_css($path . '/theme/css/closeblock.css');
}
}