2007-07-19 10:40:28 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Action button with confirmation text.
|
|
|
|
* These button are useful for things like delete buttons.
|
2008-10-27 22:50:24 +00:00
|
|
|
*
|
|
|
|
* @deprecated 2.3 Instead of using ConfirmedFormAction, just
|
|
|
|
* apply a simple javascript event handler to your standard
|
|
|
|
* FormAction form fields.
|
|
|
|
*
|
2008-01-09 04:18:36 +00:00
|
|
|
* @package forms
|
|
|
|
* @subpackage actions
|
2007-07-19 10:40:28 +00:00
|
|
|
*/
|
|
|
|
class ConfirmedFormAction extends FormAction {
|
|
|
|
protected $confirmation;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Create a new action button.
|
|
|
|
* @param action The method to call when the button is clicked
|
|
|
|
* @param title The label on the button
|
2008-10-14 23:07:05 +00:00
|
|
|
* @param confirmation The message to display in the confirmation box
|
2007-07-19 10:40:28 +00:00
|
|
|
* @param form The parent form, auto-set when the field is placed inside a form
|
|
|
|
*/
|
2008-10-14 23:07:05 +00:00
|
|
|
function __construct($action, $title = "", $confirmation = null, $form = null) {
|
|
|
|
if($confirmation) {
|
|
|
|
$this->confirmation = $confirmation;
|
|
|
|
} else {
|
|
|
|
$this->confirmation = _t('ConfirmedFormAction.CONFIRMATION', "Are you sure?", PR_MEDIUM, 'Confirmation popup before executing the form action');
|
|
|
|
}
|
|
|
|
|
2007-07-19 10:40:28 +00:00
|
|
|
parent::__construct($action, $title, $form);
|
|
|
|
}
|
2008-09-16 23:14:31 +00:00
|
|
|
|
2007-07-19 10:40:28 +00:00
|
|
|
function Field() {
|
2008-04-06 04:08:45 +00:00
|
|
|
$attributes = array(
|
|
|
|
'type' => 'submit',
|
2008-10-21 20:58:11 +00:00
|
|
|
'class' => ($this->extraClass() ? $this->extraClass() : ''),
|
2008-04-06 04:08:45 +00:00
|
|
|
'id' => $this->id(),
|
2008-04-09 11:21:22 +00:00
|
|
|
'name' => $this->Name(),
|
2008-04-06 04:08:45 +00:00
|
|
|
'value' => $this->attrTitle(),
|
2008-09-16 23:14:31 +00:00
|
|
|
'tabindex' => $this->getTabIndex(),
|
2008-04-06 04:08:45 +00:00
|
|
|
'onclick' => "return confirm('$this->confirmation');"
|
|
|
|
);
|
|
|
|
|
|
|
|
return $this->createTag('input', $attributes);
|
2007-07-19 10:40:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
?>
|