File: D:/HostingSpaces/PvdBoogaard/indoorski.nl/backup/oude-site/cms/api/form/class.field.datetime.php
<?php
/**
* This file contains the iwp_field_datetime class.
*
* Notes:
* - This field requires a value to be set which is similar to: date space time (e.g. 31/12/2009 11:35 A - or whatever formats are recognised by datepicker/timepicker client side stuff)
* - The value will be split internally between two sub fields
* - The HTML output will contain two fields, one named {fieldname}_date and one named {fieldname}_time which use the iwp_field_date and iwp_field_time field classes respectively
* - The result of validating this field will return a string containing both date and time concatenated back into the original format used by ->Value() (stated above)
* - In some cases the time or date may be absent if the client-side code has disabled the form elements (e.g. the calendar module will disable the time field if 'all day' is checked)
*
* @version $Id$
* @author Gwilym <gwilym.evans@interspire.com>
*
* @package IWP
* @subpackage IWP_FormFields
*/
/**
* DateTime Field Class
* This class is used by the api form class to generate a field with a date picker and a time picker.
*
* @package IWP
* @subpackage IWP_FormFields
*/
class iwp_field_datetime extends iwp_field {
/**
* This is the form field type of the field
*
* @var string
*/
public $type = 'datetime';
protected $showLabel = false;
/**
* This is an array of required javascript files needed by this field
*
* @var array
*/
public $RequiredJs = array('../javascript/date.js', array('../javascript/jquery.bgiframe.js', 'IE'), '../javascript/jquery.datePicker.js');
/**
* __construct
* The constructor which calls the parent constructor that sets up the field name if it is passed in during the initialization
*
* @var string
*/
public function __construct($name=null){
parent::__construct($name);
}
/**
* GetFieldOutput
* Returns the HTML for this field. It generates the relevant parts, assigns them to template variables and returns a parse template file.
*
* @return string Returns the field HTML
*/
public function GetFieldOutput ($setOnly=false) {
// we can reuse the individual date and time fields
$parts = explode(' ', $this->FieldValue, 2);
$dateField = new iwp_field_date($this->FieldName .'_date');
$dateField->Value($parts[0]);
$timeField = new iwp_field_time($this->FieldName .'_time');
if (isset($parts[1])) {
$timeField->Value($parts[1]);
} else {
$timeField->Value('');
}
$dateField->GetFieldOutput();
$inputField = $this->template->Get('inputField') .' ';
$timeField->GetFieldOutput();
$inputField .= $this->template->Get('inputField');
parent::GetFieldOutput();
$this->template->Assign('inputField', $inputField);
$this->template->Assign('FieldName', $this->FieldName);
if(!$setOnly){
return $this->template->ParseTemplate('form.field', true);
}
return '';
}
/**
* Validate
* This is the function that data for this field is passed to to ensure it was submitted properly.
*
* @return string|boolean If the data is not valid, it will return false, if it is valid it will return a value
*/
public function Validate($arrData){
// @todo this doesn't appear to be used - when set to always return false, forms with dates validate ok
return $arrData[$this->FieldName .'_date'] . ' ' . $arrData[$this->FieldName .'_time'];
}
}