function pagestyle_form in Page Style 5
Same name and namespace in other branches
- 6 includes/pagestyle.block.inc \pagestyle_form()
- 7 includes/pagestyle.block.inc \pagestyle_form()
Implement hook_form().
Generate the select form for the block.
See also
1 string reference to 'pagestyle_form'
- pagestyle_block in ./
pagestyle.module - Implement hook_block().
File
- includes/
pagestyle.block.inc, line 254 - 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 = 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($_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, "");
$_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' => $subtitle,
'#name' => 'pagestyle_select',
'#options' => $options,
'#default_value' => variable_get('pagestyle_select', $pagestyle),
'#weight' => 0,
'#attributes' => array(
'class' => 'pagestyle',
),
);
$form['pagestyle_submit'] = array(
'#type' => 'submit',
'#value' => t('Save'),
'#weight' => 1,
);
$form['#skip_duplicate_check'] = TRUE;
return $form;
}