mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
03c5caea72
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.4@93611 467b73ca-7a2a-4603-9d3b-597d59a354a9
36 lines
1.3 KiB
PHP
Executable File
36 lines
1.3 KiB
PHP
Executable File
<?php
|
|
/**
|
|
* Action that uses an image instead of a button
|
|
* @package forms
|
|
* @subpackage actions
|
|
*/
|
|
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) {
|
|
$this->image = $image;
|
|
$this->hoverImage = $hoverImage;
|
|
$this->className = $className;
|
|
parent::__construct($action, $title, $form);
|
|
}
|
|
function Field() {
|
|
Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/prototype/prototype.js');
|
|
Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/behaviour/behaviour.js');
|
|
Requirements::javascript(SAPPHIRE_DIR . '/javascript/ImageFormAction.js');
|
|
|
|
$classClause = '';
|
|
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}\" />";
|
|
}
|
|
}
|
|
|
|
?>
|