Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 21st, 2012  |  syntax: None  |  size: 1.10 KB  |  hits: 16  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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. }