diff options
author | Steven Wittens <steven@10.no-reply.drupal.org> | 2005-03-03 20:51:27 +0000 |
---|---|---|
committer | Steven Wittens <steven@10.no-reply.drupal.org> | 2005-03-03 20:51:27 +0000 |
commit | 198ec98f756673da8c899bb0236a91808ed010ec (patch) | |
tree | e4527ed4574134a16683a9c6c665480e81f86e8e /includes | |
parent | 96211c616e6a71e208134272cb5266bac5edd31f (diff) | |
download | brdo-198ec98f756673da8c899bb0236a91808ed010ec.tar.gz brdo-198ec98f756673da8c899bb0236a91808ed010ec.tar.bz2 |
#18329: Unify confirmation messages (and make them themable)
Diffstat (limited to 'includes')
-rw-r--r-- | includes/theme.inc | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/includes/theme.inc b/includes/theme.inc index c2698aef4..775ed941a 100644 --- a/includes/theme.inc +++ b/includes/theme.inc @@ -849,6 +849,57 @@ function theme_blocks($region) { } return $output; } + +/** + * Output a confirmation form + * + * This function outputs a complete form for confirming an action. A link is + * offered to go back to the item that is being changed in case the user changes + * his/her mind. + * + * You should use $_POST['edit'][$name] (where $name is usually 'confirm') to + * check if the confirmation was succesful. + * + * @param $question + * The question to ask the user (e.g. "Are you sure you want to delete the + * block <em>foo</em>?"). + * @param $path + * The page to go to if the user denies the action. + * @param $description + * Additional text to display (defaults to "This action cannot be undone."). + * @param $yes + * A caption for the button which confirms the action (e.g. "Delete", + * "Replace", ...). + * @param $no + * A caption for the link which denies the action (e.g. "Cancel"). + * @param $extra + * Additional HTML to inject into the form, for example form_hidden()s. + * @param $name + * The internal name used to refer to the confirmation item. + * @return + * A themed HTML string representing the form. + */ +function theme_confirm($question, $path, $description = NULL, $yes = NULL, $no = NULL, $extra = NULL, $name = 'confirm') { + drupal_set_title($question); + + if (is_null($description)) { + $description = t('This action cannot be undone.'); + } + + $output .= '<p>'. $description ."</p>\n"; + if (!is_null($extra)) { + $output .= $extra; + } + $output .= '<div class="container-inline">'; + $output .= form_submit($yes ? $yes : t('Confirm')); + $output .= l($no ? $no : t('Cancel'), $path); + $output .= "</div>\n"; + + $output .= form_hidden($name, 1); + return form($output, 'post', NULL, array('class' => 'confirmation')); +} + + /** * @} End of "defgroup themeable". */ |