2007-07-19 12:40:28 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* This field creates a date field that shows a calendar on pop-up
|
2008-01-09 05:18:36 +01:00
|
|
|
* @package forms
|
|
|
|
* @subpackage fields-datetime
|
2007-07-19 12:40:28 +02:00
|
|
|
*/
|
|
|
|
class CalendarDateField extends DateField {
|
|
|
|
protected $futureOnly;
|
|
|
|
|
2007-11-02 04:20:05 +01:00
|
|
|
static function HTMLField( $id, $name, $val ) {
|
|
|
|
return <<<HTML
|
|
|
|
<input type="text" id="$id" name="$name" value="$val" />
|
|
|
|
<img src="sapphire/images/calendar-icon.gif" id="$id-icon" />
|
|
|
|
<div class="calendarpopup" id="$id-calendar"></div>
|
|
|
|
HTML;
|
|
|
|
}
|
|
|
|
|
2007-07-19 12:40:28 +02:00
|
|
|
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 . "/calendar/calendar.js");
|
|
|
|
Requirements::javascript(THIRDPARTY_DIR . "/calendar/lang/calendar-en.js");
|
|
|
|
Requirements::javascript(THIRDPARTY_DIR . "/calendar/calendar-setup.js");
|
|
|
|
Requirements::css(SAPPHIRE_DIR . "/css/CalendarDateField.css");
|
|
|
|
Requirements::css(THIRDPARTY_DIR . "/calendar/calendar-win2k-1.css");
|
2007-07-19 12:40:28 +02:00
|
|
|
|
|
|
|
$field = parent::Field();
|
2008-04-06 06:08:45 +02:00
|
|
|
|
2007-07-19 12:40:28 +02:00
|
|
|
$id = $this->id();
|
|
|
|
$val = $this->attrValue();
|
|
|
|
|
|
|
|
$futureClass = $this->futureOnly ? ' futureonly' : '';
|
|
|
|
|
2007-11-02 04:20:05 +01:00
|
|
|
$innerHTML = self::HTMLField( $id, $this->name, $val );
|
|
|
|
|
2007-07-19 12:40:28 +02:00
|
|
|
return <<<HTML
|
|
|
|
<div class="calendardate$futureClass">
|
2007-11-02 04:20:05 +01:00
|
|
|
$innerHTML
|
2007-07-19 12:40:28 +02:00
|
|
|
</div>
|
|
|
|
HTML;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sets the field so that only future dates can be set on them
|
|
|
|
*/
|
|
|
|
function futureDateOnly() {
|
|
|
|
$this->futureOnly = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|