Guest User

Untitled

a guest
Sep 23rd, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4. * Action that takes the user back to a given link rather than submitting
  5. * the form.
  6. *
  7. * @package cancelformaction
  8. */
  9. class CancelFormAction extends FormAction {
  10.  
  11. /**
  12. * @var string
  13. */
  14. private $link;
  15.  
  16. function __construct($link = "", $title = "", $form = null, $extraData = null, $extraClass = '') {
  17. if(!$title) $title = _t('CancelFormAction.CANCEL', 'Cancel');
  18.  
  19. $this->setLink($link);
  20.  
  21. parent::__construct('CancelFormAction', $title, $form, $extraData, $extraClass);
  22. }
  23.  
  24. function setLink($link) {
  25. $this->link = $link;
  26. }
  27.  
  28. function getLink() {
  29. return $this->link;
  30. }
  31.  
  32. function Field() {
  33. $attributes = array(
  34. 'class' => 'action cancel ' . ($this->extraClass() ? $this->extraClass() : ''),
  35. 'id' => $this->id(),
  36. 'name' => $this->action,
  37. 'tabindex' => $this->getTabIndex(),
  38. 'href' => $this->getLink()
  39. );
  40.  
  41. if($this->isReadonly()) {
  42. $attributes['disabled'] = 'disabled';
  43. $attributes['class'] = $attributes['class'] . ' disabled';
  44. }
  45.  
  46. return $this->createTag(
  47. 'a',
  48. $attributes,
  49. $this->buttonContent ? $this->buttonContent : $this->Title()
  50. );
  51. }
  52. }
Add Comment
Please, Sign In to add comment