function styleswitcher_block in Style Switcher 6
Same name and namespace in other branches
- 6.2 styleswitcher.module \styleswitcher_block()
Implementation of hook_block().
File
- ./
styleswitcher.module, line 11 - Framework for themes to easily add stylesheet switching functionality.
Code
function styleswitcher_block($op = 'list', $delta = 0, $edit = array()) {
if ($op == 'list') {
$blocks[0] = array(
'info' => t('Style Switcher'),
'cache' => BLOCK_NO_CACHE,
);
return $blocks;
}
else {
if ($op == 'view') {
switch ($delta) {
case 0:
global $theme_info;
if (!empty($theme_info->info['styleswitcher'])) {
$links = array();
foreach ($theme_info->info['styleswitcher']['css'] as $title => $file) {
$links[] = '<a href="#" class="style-switcher" rel="' . $title . '">' . $title . '</a>';
_styleswitcher_add_css($file, $title);
}
drupal_add_js(drupal_get_path('module', 'styleswitcher') . '/styleswitcher.js');
drupal_add_js(drupal_get_path('module', 'styleswitcher') . '/jquery.cookie.js');
drupal_add_js('Drupal.styleSwitcher.defaultStyle();', 'inline', 'styleswitcher');
$default = $theme_info->info['styleswitcher']['default'];
drupal_add_js(array(
'styleSwitcher' => array(
'defaultStyle' => $default,
),
), 'setting');
$block['content'] = theme('item_list', $links);
}
break;
}
return $block;
}
}
}