2007-07-19 12:40:28 +02:00
< ? php
/**
2011-12-22 14:40:51 +01:00
* Action that uses an image instead of a button .
*
* @ deprecated 3.0 Use FormAction with setAttribute ( 'src' , 'myimage.png' ) and custom JavaScript to achieve hover effect
2008-01-09 05:18:36 +01:00
* @ package forms
* @ subpackage actions
2007-07-19 12:40:28 +02:00
*/
class ImageFormAction extends FormAction {
protected $image , $hoverImage , $className ;
/**
* Create a new action button .
* @ param action The method to call when the button is clicked
* @ param title The label on the button
* @ param image The default image to display
* @ param hoverImage The image to display on hover
* @ param form The parent form , auto - set when the field is placed inside a form
*/
function __construct ( $action , $title = " " , $image = " " , $hoverImage = null , $className = null , $form = null ) {
2012-07-13 11:37:35 +02:00
Deprecation :: notice ( '3.0' , " Use FormAction with setAttribute('src', 'myimage.png') and custom JavaScript to achieve hover effect " , Deprecation :: SCOPE_CLASS );
2011-12-22 14:40:51 +01:00
2007-07-19 12:40:28 +02:00
$this -> image = $image ;
$this -> hoverImage = $hoverImage ;
$this -> className = $className ;
parent :: __construct ( $action , $title , $form );
}
2011-12-21 17:35:42 +01:00
2012-04-11 07:33:36 +02:00
function Field ( $properties = array ()) {
2009-12-16 06:38:28 +01:00
Requirements :: javascript ( THIRDPARTY_DIR . '/jquery/jquery.js' );
2012-03-24 04:38:57 +01:00
Requirements :: javascript ( FRAMEWORK_DIR . '/javascript/ImageFormAction.js' );
2007-07-19 12:40:28 +02:00
2007-12-13 22:47:39 +01:00
$classClause = '' ;
2007-07-19 12:40:28 +02:00
if ( $this -> className ) $classClause = $this -> className . ' ' ;
if ( $this -> hoverImage ) $classClause .= 'rollover ' ;
return " <input class= \" { $classClause } action \" id= \" " . $this -> id () . " \" type= \" image \" name= \" { $this -> name } \" src= \" { $this -> image } \" title= \" { $this -> title } \" alt= \" { $this -> title } \" /> " ;
}
2012-03-24 04:38:57 +01:00
}