2007-07-19 12:40:28 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Action that uses an image instead of a button
|
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) {
|
|
|
|
$this->image = $image;
|
|
|
|
$this->hoverImage = $hoverImage;
|
|
|
|
$this->className = $className;
|
|
|
|
parent::__construct($action, $title, $form);
|
|
|
|
}
|
|
|
|
function Field() {
|
ENHANCEMENT Introduced constants for system paths like /sapphire in preparation for a more flexible directory reorganisation. Instead of hardcoding your path, please use the following constants: BASE_PATH, BASE_URL, SAPPHIRE_DIR, SAPPHIRE_PATH, CMS_DIR, CMS_PATH, THIRDPARTY_DIR, THIRDPARTY_PATH, ASSETS_DIR, ASSETS_PATH, THEMES_DIR, THEMES_PATH
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@63154 467b73ca-7a2a-4603-9d3b-597d59a354a9
2008-09-27 18:02:38 +02:00
|
|
|
Requirements::javascript(THIRDPARTY_DIR . '/prototype.js');
|
|
|
|
Requirements::javascript(THIRDPARTY_DIR . '/behaviour.js');
|
|
|
|
Requirements::javascript(SAPPHIRE_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}\" />";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-02-02 00:49:53 +01:00
|
|
|
?>
|