Bug #14921 » bug_1369_2.patch
TYPO3core_testing/t3lib/jsfunc.validateform.js 2005-11-11 16:52:07.000000000 +0100 | ||
---|---|---|
function validateForm(theFormname,theFieldlist,goodMess,badMess,emailMess) {
|
||
if (document[theFormname] && theFieldlist) {
|
||
var formname = document[theFormname];
|
||
if (!formname) {
|
||
formname = document.getElementById(theFormname);
|
||
}
|
||
if (formname && theFieldlist) {
|
||
var index=1;
|
||
var theField = split(theFieldlist, ",", index);
|
||
var msg="";
|
||
... | ... | |
index++;
|
||
theLabel = unescape(split(theFieldlist, ",", index));
|
||
theField = unescape(theField);
|
||
if (document[theFormname][theField]) {
|
||
var fObj = document[theFormname][theField];
|
||
if (formname[theField]) {
|
||
var fObj = formname[theField];
|
||
var type=fObj.type;
|
||
if (!fObj.type) {
|
||
type="radio";
|
TYPO3core_testing/typo3/sysext/cms/tslib/class.tslib_content.php 2005-11-11 17:47:54.000000000 +0100 | ||
---|---|---|
$fieldname_hashArray = Array();
|
||
$cc = 0;
|
||
// Formname;
|
||
$formname = $GLOBALS['TSFE']->uniqueHash();
|
||
if (ctype_digit($formname{0})) { // form name must start with a letter
|
||
$formname = 'a'.$formname;
|
||
$xhtmlStrict = t3lib_div::inList('xhtml_strict,xhtml_11,xhtml_2',$GLOBALS['TSFE']->config['config']['doctype']);
|
||
// Formname
|
||
if ($conf['formName']) {
|
||
$formname = $this->cleanFormName($conf['formName']);
|
||
} else {
|
||
$formname = $GLOBALS['TSFE']->uniqueHash();
|
||
$formname = 'a'.$formname; // form name has to start with a letter to reach XHTML compliance
|
||
}
|
||
if (isset($conf['fieldPrefix'])) {
|
||
if ($conf['fieldPrefix']) {
|
||
$prefix = $this->cleanFormName($conf['fieldPrefix']);
|
||
} else {
|
||
$prefix = '';
|
||
}
|
||
} else {
|
||
$prefix = $formname;
|
||
}
|
||
foreach($dataArr as $val) {
|
||
... | ... | |
$typeParts = explode('=',$fParts[0]);
|
||
$confData['type'] = trim(strtolower(end($typeParts)));
|
||
if (count($typeParts)==1) {
|
||
$confData['fieldname'] = substr(ereg_replace('[^a-zA-Z0-9_]','',str_replace(' ','_',trim($parts[0]))),0,30);
|
||
$confData['fieldname'] = $this->cleanFormName($parts[0]);
|
||
if (strtolower(ereg_replace('[^[:alnum:]]','',$confData['fieldname']))=='email') {$confData['fieldname']='email';}
|
||
// Duplicate fieldnames resolved
|
||
if (isset($fieldname_hashArray[md5($confData['fieldname'])])) {
|
||
... | ... | |
if (strcmp('',$addParams)) $addParams=' '.$addParams;
|
||
} else $addParams='';
|
||
if ($conf['dontMd5FieldNames']) {
|
||
$fName = $confData['fieldname'];
|
||
} else {
|
||
$fName = md5($confData['fieldname']);
|
||
}
|
||
// Accessibility: Set id = fieldname attribute:
|
||
if ($conf['accessibility']) {
|
||
$elementIdAttribute = ' id="'.$formname.'_'.md5($confData['fieldname']).'"';
|
||
if ($conf['accessibility'] || $xhtmlStrict) {
|
||
$elementIdAttribute = ' id="'.$prefix.$fName.'"';
|
||
} else {
|
||
$elementIdAttribute = '';
|
||
}
|
||
... | ... | |
break;
|
||
case 'radio':
|
||
$option='';
|
||
if ($conf['accessibility']) {
|
||
$option.='<fieldset'.$elementIdAttribute.'><legend>'.$confData['label'].'</legend>';
|
||
}
|
||
$valueParts = explode(',',$parts[2]);
|
||
$items=array(); // Where the items will be
|
||
$default='';
|
||
... | ... | |
$default = $this->getFieldDefaultValue($conf['noValueInsert'], $confData['fieldname'], $default);
|
||
// Create the select-box:
|
||
for($a=0;$a<count($items);$a++) {
|
||
$option.= '<input type="radio" name="'.$confData['fieldname'].'"'.$elementIdAttribute.' value="'.$items[$a][1].'"'.(!strcmp($items[$a][1],$default)?' checked="checked"':'').''.$addParams.' />';
|
||
$option.= $this->stdWrap(trim($items[$a][0]), $conf['radioWrap.']);
|
||
$radioId = $prefix.$fName.$this->cleanFormName($items[$a][0]);
|
||
if ($conf['accessibility']) {
|
||
$radioLabelIdAttribute = ' id="'.$radioId.'"';
|
||
} else {
|
||
$radioLabelIdAttribute = '';
|
||
}
|
||
$option.= '<input type="radio" name="'.$confData['fieldname'].'"'.$radioLabelIdAttribute.' value="'.$items[$a][1].'"'.(!strcmp($items[$a][1],$default)?' checked="checked"':'').''.$addParams.' />';
|
||
if ($conf['accessibility']) {
|
||
$option.= '<label for="'.$radioId.'">' . $this->stdWrap(trim($items[$a][0]), $conf['radioWrap.']) . '</label>';
|
||
} else {
|
||
$option.= $this->stdWrap(trim($items[$a][0]), $conf['radioWrap.']);
|
||
}
|
||
$option.= '<br />';
|
||
}
|
||
if ($conf['accessibility']) {
|
||
$option.='</fieldset>';
|
||
}
|
||
$fieldCode = $option;
|
||
break;
|
||
case 'hidden':
|
||
... | ... | |
// Field:
|
||
$fieldLabel = $confData['label'];
|
||
if ($conf['accessibility']) {
|
||
$fieldLabel = '<label for="'.$formname.'_'.md5($confData['fieldname']).'">'.$fieldLabel.'</label>';
|
||
if ($conf['accessibility'] && $confData['type'] != 'label') {
|
||
$fieldLabel = '<label for="'.$prefix.$fName.'">'.$fieldLabel.'</label>';
|
||
}
|
||
// Getting template code:
|
||
... | ... | |
$content = Array(
|
||
'<form'.
|
||
' action="'.htmlspecialchars($action).'"'.
|
||
' name="'.$formname.'"'.
|
||
' id="'.$formname.'"'.
|
||
' enctype="'.$GLOBALS['TYPO3_CONF_VARS']['SYS']['form_enctype'].'"'.
|
||
' method="'.($conf['method']?$conf['method']:'post').'"'.
|
||
($theTarget ? ' target="'.$theTarget.'"' : '').
|
||
... | ... | |
return $altParam;
|
||
}
|
||
/**
|
||
* removes forbidden characters and spaces from name/id attributes in the form tag and formfields
|
||
*
|
||
* @param string Input string
|
||
* @return string the cleaned string
|
||
* @see FORM()
|
||
*/
|
||
function cleanFormName($name) {
|
||
// turn data[x][y] into data:x:y:
|
||
$name = ereg_replace('\[|\]\[?',':',trim($name));
|
||
// remove illegal chars like _
|
||
return substr(preg_replace('#[^:a-zA-Z0-9]#','',trim($name)),0,30);
|
||
}
|
||