setCSSClass('date');
}
public function parseInput($input, $parent) {
if(trim($input) == "")
return NULL;
elseif(preg_match('$([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2})$', $input, $match)) {
return new Date($input);
}
else
throw new LogicException('date format is invalid');
return $input;
}
public function generate($parent) {
$id = $this->getID();
$name = $this->getName();
$css = $this->getCSSClass();
$system = System::getInstance();
$size = $this->getParam('size', 0);
$maxsize = $this->getParam('maxsize', 40);
$value = $this->getValue();
$js_import = array();
$js_submit = '';
$html = ' 0)
$html .= 'size="' . $size . '" ';
if($maxsize > 0)
$html .= 'maxlength="' . $maxsize . '" ';
if($value !== false) {
if($value instanceof DateTime || $value instanceof MFDate) {
$value->setTimezone($system->getActiveTimezone());
$value = $value->format('Y-m-d');
}
$html .= 'value="' . self::escapeString((string) $value) . '" ';
}
if($this->isRequired()) {
$html .= ' onblur="validate(\'' . self::escapeString($id) . '\',\'^.+$\',\'' . $css . '\',\'' . $css . '_error\',true);" ';
$js_import[] = 'jscript/form/validate.js';
$js_submit .= '';
}
$html .= '/>';
$js_import[] = JQUERY_JS_LIB;
$js_import[] = JQUERY_UI_BASE_URL . 'minified/jquery.ui.core.min.js';
$js_import[] = JQUERY_UI_BASE_URL . 'minified/jquery.ui.widget.min.js';
$js_import[] = JQUERY_UI_BASE_URL . 'minified/jquery.ui.datepicker.min.js';
// date form fallback code
$js_end = '
var i = document.createElement("input"); i.setAttribute("type", "date");
if (i.type == "text") { $(function() { $( "#' . self::escapeString($id) . '" ).datepicker({ dateFormat: \'yy-mm-dd\' }); }); }
';
if($this->getParam('null')) {
$html .= ' $html,'js_import' => $js_import,'js_submit' => $js_submit,
'js_end' => $js_end);
}
}