function pagestyle_form in Page Style 7
Same name and namespace in other branches
- 5 includes/pagestyle.block.inc \pagestyle_form()
- 6 includes/pagestyle.block.inc \pagestyle_form()
Implement hook_form().
Generate the select form for the block.
See also
pagestyle_block()
1 string reference to 'pagestyle_form'
- pagestyle_block_view in ./
pagestyle.module - Implement hook_block_view().
File
- includes/
pagestyle.block.inc, line 269 - Block, page and theme functions.
Code
function pagestyle_form() {
$pagestyle_cookie_expires = pagestyle_cookie_expires($mode = 'php');
$pagestyle_cookie_domain = variable_get('pagestyle_cookie_domain', base_path());
$pagestyle_block_title = pagestyle_block_title($title = 'title');
$pagestyle_normal = variable_get('pagestyle_normal', 'standard');
$pagestyle_javascript = variable_get('pagestyle_javascript', 1);
$pagestyle = pagestyle_get_current($value = 'int');
$options = pagestyle_block_form_options();
$pagestyle_text = array(
'black_white' => t('Black') . '/' . t('White'),
'white_black' => t('White') . '/' . t('Black'),
'yellow_blue' => t('Yellow') . '/' . t('Blue'),
'standard' => t('Standard'),
);
$pagestyle_message = variable_get('pagestyle_message', 1);
$pagestyle_post = array();
$pagestyle_cookie = array();
// allowed values
$pagestyle_allowed = pagestyle_allowed_values();
// check the type and the content
if (isset($_COOKIE['pagestyle']) && isset($_POST['pagestyle_select'])) {
if (in_array(check_plain($_POST['pagestyle_select']), $pagestyle_allowed)) {
$pagestyle_post['pagestyle'] = (string) filter_xss($_POST['pagestyle_select']);
}
// set session/cookie
setcookie("pagestyle", $pagestyle_post['pagestyle'], time() + $pagestyle_cookie_expires, $pagestyle_cookie_domain, "");
if ($pagestyle_javascript == 0 || $pagestyle_javascript == 1) {
$_SESSION['pagestyle'] = $pagestyle_post['pagestyle'];
}
if ($pagestyle_message == 1) {
drupal_set_message(t('The page style have been saved as %pagestyle_post.', array(
'%pagestyle_post' => $pagestyle_text[$pagestyle_post['pagestyle']],
)));
}
pagestyle_clear_cache();
}
elseif (!isset($_COOKIE['pagestyle']) && isset($_POST['pagestyle_select']) && $pagestyle_message == 1) {
drupal_set_message(t('The page style have not been saved, because your browser do not accept cookies.'), 'error');
}
$subtitle = NULL;
if (variable_get('pagestyle_display_subtitle', 0) == 1) {
$subtitle = $pagestyle_block_title;
}
$form = array();
$form['pagestyle_select'] = array(
'#type' => 'select',
'#title' => check_plain($subtitle),
'#name' => 'pagestyle_select',
'#options' => $options,
'#default_value' => variable_get('pagestyle_select', $pagestyle),
'#weight' => 0,
);
$form['#attributes']['class'][] = 'pagestyle';
$form['pagestyle_submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
'#weight' => 1,
);
$form['#skip_duplicate_check'] = TRUE;
return $form;
}