File: D:/HostingSpaces/PvdBoogaard/indoorski.nl/backup/oude-site/cms/api/form/class.field.date.php
<?php
/**
* This file contains the iwp_field_date class
*
* @version $Id$
*
*
* @package IWP
* @subpackage IWP_FormFields
*/
/**
* Date Field Class
* This class is used by the api form class to generate a field with a date picker.
*
* @package IWP
* @subpackage IWP_FormFields
*/
class iwp_field_date extends iwp_field {
/**
* This is the form field type of the field
*
* @var string
*/
public $type = 'date';
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){
$inputField = $this->Prepend.'<input type="text" class="Field100 date-pick-'. iwp_htmlspecialchars($this->FieldName) .'" id="'. iwp_htmlspecialchars($this->FieldName) .'" name="'. iwp_htmlspecialchars($this->FieldName) .'" value="'. iwp_htmlspecialchars($this->FieldValue) .'"';
$inputField .= $this->GetAttributes();
$inputField .= ' />'.$this->Append;
$inputField .= '<script type="text/javascript">
$(document).ready(function() {
if($(\'.date-pick-'.$this->FieldName.'\').exists()){';
$american = iwp_settings::IsAmericanDateFormat(iwp_getShortDateFormat());
if ($american) {
$inputField .= "Date.format = 'mm/dd/yyyy';\n";
}
if(iwp_validation::IsBlank($this->FieldValue)){
$inputField .= '$(\'.date-pick-'.$this->FieldName.'\').datePicker({clickInput:true, startDate:\'01/01/1971\', verticalOffset: $(\'#'. $this->FieldName .'\').outerHeight()}).val(new Date().asString()).trigger(\'change\');';
}else{
$inputField .= '$(\'.date-pick-'.$this->FieldName.'\').datePicker({clickInput:true, startDate:\'01/01/1971\', verticalOffset: $(\'#'. $this->FieldName .'\').outerHeight()}).trigger(\'change\');';
}
$inputField .= ' }
});
</script>';
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];
}
}