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() {
|
|
|
|
Requirements::javascript("jsparty/calendar/calendar.js");
|
|
|
|
Requirements::javascript("jsparty/calendar/lang/calendar-en.js");
|
|
|
|
Requirements::javascript("jsparty/calendar/calendar-setup.js");
|
|
|
|
Requirements::css("sapphire/css/CalendarDateField.css");
|
|
|
|
Requirements::css("jsparty/calendar/calendar-win2k-1.css");
|
|
|
|
|
|
|
|
$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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|