Feature #15324 » mailform-40beta1.diff
typo3/sysext/cms/tslib/class.tslib_content.php 28 Dec 2005 23:25:16 -0000 | ||
---|---|---|
}
|
||
$typeParts = explode('=',$fParts[0]);
|
||
$confData['type'] = trim(strtolower(end($typeParts)));
|
||
$confData['typeUpper'] = strtoupper($confData['type']);
|
||
if (count($typeParts)==1) {
|
||
$confData['fieldname'] = $this->cleanFormName($parts[0]);
|
||
if (strtolower(ereg_replace('[^[:alnum:]]','',$confData['fieldname']))=='email') {$confData['fieldname']='email';}
|
||
... | ... | |
// Additional parameters
|
||
if (trim($confData['type'])) {
|
||
$addParams=trim($conf['params']);
|
||
if (is_array($conf['params.']) && isset($conf['params.'][$confData['type']])) {
|
||
if ($conf[$confData['typeUpper'].'.']['addParams']) {
|
||
$addParams = trim($conf[$confData['typeUpper'].'.']['addParams']);
|
||
} else if (is_array($conf['params.']) && isset($conf['params.'][$confData['type']])) {
|
||
// Backwards compatibility
|
||
$addParams=trim($conf['params.'][$confData['type']]);
|
||
}
|
||
if (strcmp('',$addParams)) $addParams=' '.$addParams;
|
||
... | ... | |
} else {
|
||
$fName = md5($confData['fieldname']);
|
||
}
|
||
$id = $prefix.$fName;
|
||
// Accessibility: Set id = fieldname attribute:
|
||
if ($conf['accessibility'] || $xhtmlStrict) {
|
||
$elementIdAttribute = ' id="'.$prefix.$fName.'"';
|
||
} else {
|
||
$elementIdAttribute = '';
|
||
}
|
||
$addParams = str_replace('###ID###',$id,$addParams);
|
||
// Create form field based on configuration/type:
|
||
switch($confData['type']) {
|
||
... | ... | |
$wrap = $wrap ? ' wrap="'.$wrap.'"' : ' wrap="virtual"';
|
||
}
|
||
$default = $this->getFieldDefaultValue($conf['noValueInsert'], $confData['fieldname'], str_replace('\n',chr(10),trim($parts[2])));
|
||
$fieldCode=sprintf('<textarea name="%s"'.$elementIdAttribute.' cols="%s" rows="%s"%s'.$addParams.'>%s</textarea>',
|
||
$fieldCode=sprintf('<textarea name="%s" cols="%s" rows="%s"%s'.$addParams.'>%s</textarea>',
|
||
$confData['fieldname'], $cols, $rows, $wrap, t3lib_div::formatForTextarea($default));
|
||
break;
|
||
case 'input':
|
||
... | ... | |
$max=trim($fParts[2]) ? ' maxlength="'.t3lib_div::intInRange($fParts[2],1,1000).'"' : "";
|
||
$theType = $confData['type']=='input' ? 'text' : 'password';
|
||
$fieldCode=sprintf('<input type="'.$theType.'" name="%s"'.$elementIdAttribute.' size="%s"%s value="%s"'.$addParams.' />',
|
||
$fieldCode=sprintf('<input type="'.$theType.'" name="%s" size="%s"%s value="%s"'.$addParams.' />',
|
||
$confData['fieldname'], $size, $max, htmlspecialchars($default));
|
||
break;
|
||
case 'file':
|
||
$size=trim($fParts[1]) ? t3lib_div::intInRange($fParts[1],1,60) : 20;
|
||
$fieldCode=sprintf('<input type="file" name="%s"'.$elementIdAttribute.' size="%s"'.$addParams.' />',
|
||
$fieldCode=sprintf('<input type="file" name="%s" size="%s"'.$addParams.' />',
|
||
$confData['fieldname'], $size);
|
||
break;
|
||
case 'check':
|
||
// alternative default value:
|
||
$default = $this->getFieldDefaultValue($conf['noValueInsert'], $confData['fieldname'], trim($parts[2]));
|
||
$checked = $default ? ' checked="checked"' : '';
|
||
$fieldCode=sprintf('<input type="checkbox" value="%s" name="%s"'.$elementIdAttribute.'%s'.$addParams.' />',
|
||
$fieldCode=sprintf('<input type="checkbox" value="%s" name="%s"%s'.$addParams.' />',
|
||
1, $confData['fieldname'], $checked);
|
||
break;
|
||
case 'select':
|
||
... | ... | |
}
|
||
if ($multiple) $confData['fieldname'].='[]'; // The fieldname must be prepended '[]' if multiple select. And the reason why it's prepended is, because the required-field list later must also have [] prepended.
|
||
$fieldCode=sprintf('<select name="%s"'.$elementIdAttribute.' size="%s"%s'.$addParams.'>%s</select>',
|
||
$fieldCode=sprintf('<select name="%s" size="%s"%s'.$addParams.'>%s</select>',
|
||
$confData['fieldname'], $size, $multiple, $option); //RTF
|
||
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++) {
|
||
$radioId = $prefix.$fName.$this->cleanFormName($items[$a][0]);
|
||
if ($conf['accessibility']) {
|
||
$radioLabelIdAttribute = ' id="'.$radioId.'"';
|
||
} else {
|
||
$radioLabelIdAttribute = '';
|
||
$radioId = $id.$this->cleanFormName($items[$a][0]);
|
||
$itemAddParams = $conf['RADIO.']['item.']['addParams'];
|
||
$itemAddParams = str_replace('###RADIO_ID###',$radioId,$itemAddParams);
|
||
$radio = '<input type="radio" name="'.$confData['fieldname'].'" value="'.$items[$a][1].'"'.(!strcmp($items[$a][1],$default)?' checked="checked"':'').''.$itemAddParams.' />';
|
||
if (is_array($conf['RADIO.']['item.']['labelWrap.'])) {
|
||
$radioLabel = $this->stdWrap(trim($items[$a][0]), $conf['RADIO.']['item.']['labelWrap.']);
|
||
} else if (is_array($conf['radioWrap.'])) {
|
||
// Backwards compatibility
|
||
$radioLabel = $this->stdWrap(trim($items[$a][0]), $conf['radioWrap.']);
|
||
}
|
||
$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>';
|
||
$radioLabel = str_replace('###RADIO_ID###',$radioId,$radioLabel);
|
||
if ($conf['RADIO.']['item.']['layout']) {
|
||
$itemLayout = $conf['RADIO.']['item.']['layout'];
|
||
$itemLayout = str_replace('###RADIO###',$radio,$itemLayout);
|
||
$itemLayout = str_replace('###RADIO_LABEL###',$radioLabel,$itemLayout);
|
||
} else {
|
||
$option .= $this->stdWrap(trim($items[$a][0]), $conf['radioWrap.']);
|
||
// Backwards compatibility
|
||
$itemLayout = $radio.$radioLabel.'<br />';
|
||
}
|
||
$option .= '<br />';
|
||
$option .= $itemLayout;
|
||
}
|
||
if ($conf['accessibility']) {
|
||
$option.='</fieldset>';
|
||
}
|
||
$fieldCode = $option;
|
||
break;
|
||
case 'hidden':
|
||
... | ... | |
if (strlen($value) && t3lib_div::inList('recipient_copy,recipient',$confData['fieldname'])) {
|
||
$value = $GLOBALS['TSFE']->codeString($value);
|
||
}
|
||
$hiddenfields.=sprintf('<input type="hidden" name="%s"'.$elementIdAttribute.' value="%s" />',
|
||
$hiddenfields.=sprintf('<input type="hidden" name="%s" value="%s"'.$addParams.'/>',
|
||
$confData['fieldname'], htmlspecialchars($value));
|
||
break;
|
||
case 'property':
|
||
... | ... | |
if($image) {
|
||
$fieldCode = str_replace('<img','<input type="image"'.$addParams.' name="'.$confData['fieldname'].'"' ,$image);
|
||
} else {
|
||
$fieldCode=sprintf('<input type="submit" name="%s"'.$elementIdAttribute.' value="%s"'.$addParams.' />',
|
||
$fieldCode=sprintf('<input type="submit" name="%s" value="%s"'.$addParams.' />',
|
||
$confData['fieldname'], t3lib_div::deHSCentities(htmlspecialchars($value)));
|
||
}
|
||
break;
|
||
case 'reset':
|
||
$value=trim($parts[2]);
|
||
$fieldCode=sprintf('<input type="reset" name="%s"'.$elementIdAttribute.' value="%s"'.$addParams.' />',
|
||
$fieldCode=sprintf('<input type="reset" name="%s" value="%s"'.$addParams.' />',
|
||
$confData['fieldname'], t3lib_div::deHSCentities(htmlspecialchars($value)));
|
||
break;
|
||
case 'label':
|
||
... | ... | |
// Field:
|
||
$fieldLabel = $confData['label'];
|
||
if ($conf['accessibility'] && $confData['type']!='radio' && $confData['type'] != 'label') {
|
||
$fieldLabel = '<label for="'.$prefix.$fName.'">'.$fieldLabel.'</label>';
|
||
}
|
||
// Getting template code:
|
||
$fieldCode = $this->stdWrap($fieldCode, $conf['fieldWrap.']);
|
||
$labelCode = $this->stdWrap($fieldLabel, $conf['labelWrap.']);
|
||
if (is_array($conf[$confData['typeUpper'].'.']['labelWrap.'])) {
|
||
$labelCode = $this->stdWrap($fieldLabel, $conf[$confData['typeUpper'].'.']['labelWrap.']);
|
||
} else {
|
||
$labelCode = $this->stdWrap($fieldLabel, $conf['labelWrap.']);
|
||
}
|
||
$labelCode = str_replace('###ID###',$id,$labelCode);
|
||
$commentCode = $this->stdWrap($confData['label'], $conf['commentWrap.']); // RTF
|
||
$result = $conf['layout'];
|
||
if (isset($conf[$confData['typeUpper'].'.']['layout'])) {
|
||
$result = $conf[$confData['typeUpper'].'.']['layout'];
|
||
}
|
||
if ($conf['REQ'] && $confData['required']) {
|
||
if (is_array($conf['REQ.']['fieldWrap.']))
|
||
if (is_array($conf[$confData['typeUpper'].'.']['REQ.']['fieldWrap.']))
|
||
$fieldCode = $this->stdWrap($fieldCode, $conf[$confData['typeUpper'].'.']['REQ.']['fieldWrap.']);
|
||
else if (is_array($conf['REQ.']['fieldWrap.']))
|
||
$fieldCode = $this->stdWrap($fieldCode, $conf['REQ.']['fieldWrap.']);
|
||
if (is_array($conf['REQ.']['labelWrap.']))
|
||
if (is_array($conf[$confData['typeUpper'].'.']['REQ.']['labelWrap.']))
|
||
$labelCode = $this->stdWrap($fieldLabel, $conf[$confData['typeUpper'].'.']['REQ.']['labelWrap.']);
|
||
else if (is_array($conf['REQ.']['labelWrap.']))
|
||
$labelCode = $this->stdWrap($fieldLabel, $conf['REQ.']['labelWrap.']);
|
||
if ($conf['REQ.']['layout']) {
|
||
if (is_array($conf[$confData['typeUpper'].'.']['REQ.']['layout']))
|
||
$result = $conf[$confData['typeUpper'].'.']['REQ.']['layout'];
|
||
else if (is_array($conf['REQ.']['layout']))
|
||
$result = $conf['REQ.']['layout'];
|
||
}
|
||
}
|
||
if ($confData['type']=='comment' && $conf['COMMENT.']['layout']) {
|
||
$result = $conf['COMMENT.']['layout'];
|
||
}
|
||
if ($confData['type']=='check' && $conf['CHECK.']['layout']) {
|
||
$result = $conf['CHECK.']['layout'];
|
||
}
|
||
if ($confData['type']=='radio' && $conf['RADIO.']['layout']) {
|
||
$result = $conf['RADIO.']['layout'];
|
||
}
|
||
if ($confData['type']=='label' && $conf['LABEL.']['layout']) {
|
||
$result = $conf['LABEL.']['layout'];
|
||
}
|
||
$result = str_replace('###FIELD###',$fieldCode,$result);
|
||
$result = str_replace('###LABEL###',$labelCode,$result);
|
||
$result = str_replace('###RAWLABEL###',$confData['label'],$result);
|
||
$result = str_replace('###ID###',$id,$result);
|
||
$result = str_replace('###COMMENT###',$commentCode,$result); //RTF
|
||
$content.= $result;
|
||
}
|
typo3/sysext/css_styled_content/static/setup.txt 28 Dec 2005 23:25:16 -0000 | ||
---|---|---|
# change mailform to accesssible mode
|
||
tt_content.mailform.20 {
|
||
accessibility = 1
|
||
noWrapAttr=1
|
||
noWrapAttr = 1
|
||
formName = mailform
|
||
dontMd5FieldNames = 1
|
||
REQ = 1
|
||
layout = <div class="csc-mailform-field">###LABEL### ###FIELD###</div>
|
||
COMMENT.layout = <div class="csc-mailform-label">###LABEL###</div>
|
||
RADIO.layout = <div class="csc-mailform-field">###LABEL### <fieldset class="csc-mailform-radio" id="testform_radio">###FIELD###</fieldset></div>
|
||
LABEL.layout = <div class="csc-mailform-field">###LABEL### <span class="csc-mailform-label">###FIELD###</span></div>
|
||
labelWrap.wrap = |
|
||
commentWrap.wrap = |
|
||
radioWrap.wrap = |
|
||
REQ.labelWrap.wrap = |
|
||
labelWrap.wrap = <label for="###ID###" class="csc-mailform-label"> | </label>
|
||
REQ = 1
|
||
REQ.labelWrap.wrap = <label for="###ID###" class="csc-mailform-label-req"> | </label>
|
||
COMMENT {
|
||
layout = <div class="csc-mailform-label">###LABEL###</div>
|
||
}
|
||
RADIO {
|
||
layout = <div class="csc-mailform-field">###LABEL### <fieldset class="csc-mailform-radio" id="###ID###"><legend>###RAWLABEL###</legend>###FIELD###</fieldset></div>
|
||
item {
|
||
layout = ###RADIO######RADIO_LABEL###<br />
|
||
addParams = id="###RADIO_ID###" class="csc-mailform-radio"
|
||
labelWrap.wrap = <label for="###RADIO_ID###"> | </label>
|
||
}
|
||
}
|
||
LABEL {
|
||
layout = <div class="csc-mailform-field">###LABEL### <span class="csc-mailform-label">###FIELD###</span></div>
|
||
labelWrap.wrap = |
|
||
}
|
||
CHECK {
|
||
addParams = id="###ID###" class="csc-mailform-check"
|
||
}
|
||
INPUT {
|
||
addParams = id="###ID###" class="csc-mailform-input"
|
||
}
|
||
HIDDEN {
|
||
addParams = id="###ID###"
|
||
}
|
||
PASSWORD {
|
||
addParams = id="###ID###" class="csc-mailform-password"
|
||
}
|
||
FILE {
|
||
addParams = id="###ID###" class="csc-mailform-file"
|
||
}
|
||
TEXTAREA {
|
||
addParams = id="###ID###" class="csc-mailform-textarea"
|
||
}
|
||
SELECT {
|
||
addParams = id="###ID###" class="csc-mailform-select"
|
||
}
|
||
SUBMIT {
|
||
addParams = id="###ID###" class="csc-mailform-submit"
|
||
}
|
||
RESET {
|
||
addParams = id="###ID###" class="csc-mailform-reset"
|
||
}
|
||
stdWrap.wrap = <fieldset class="csc-mailform"> | </fieldset>
|
||
params.radio = class="csc-mailform-radio"
|
||
params.check = class="csc-mailform-check"
|
||
params.submit = class="csc-mailform-submit"
|
||
}
|
||
# accessible menu
|