function pagestyle_block in Page Style 5
Same name and namespace in other branches
- 6 pagestyle.module \pagestyle_block()
Implement hook_block().
File
- ./
pagestyle.module, line 75 - Display a style changer on the page and in the browser menue for a better web accessibility.
Code
function pagestyle_block($op = 'list', $delta = 0) {
$pagestyle_cookie_expires = pagestyle_cookie_expires($mode = 'php');
$pagestyle_cookie_domain = variable_get('pagestyle_cookie_domain', base_path());
$block_title = pagestyle_block_title($title = 'title');
$pagestyle_current_text = variable_get('pagestyle_display_current_pagestyle', 'display');
$pagestyle_normal = variable_get('pagestyle_normal', 'standard');
$pagestyle_increment = variable_get('pagestyle_increment', 10);
if (!isset($_SESSION['pagestyle'])) {
$_SESSION['pagestyle'] = $pagestyle_normal;
}
if (!isset($_COOKIE['pagestyle'])) {
setcookie("pagestyle", $pagestyle_normal, time() + $pagestyle_cookie_expires, $pagestyle_cookie_domain, "");
}
if ($op == "list") {
$block[0]["info"] = $block_title;
return $block;
}
elseif ($op == 'view') {
if (user_access('access pagestyle content')) {
$pagestyle_block_type = variable_get('pagestyle_block_type', 'text');
switch ($pagestyle_block_type) {
case 'text':
$block_content = theme('pagestyle_text');
break;
case 'image':
$block_content = theme('pagestyle_image');
break;
case 'select':
$block_content = drupal_get_form('pagestyle_form');
break;
default:
$block_content = theme('pagestyle_text');
}
$block['subject'] = $block_title;
$block['content'] = $block_content;
return $block;
}
}
}