mailform_v2-40beta1.diff

Administrator Admin, 2005-12-30 12:28

Download (14.4 KB)

View differences:

typo3/sysext/cms/tslib/class.tslib_content.php 30 Dec 2005 11:22:20 -0000
1663 1663
				}
1664 1664
				$typeParts = explode('=',$fParts[0]);
1665 1665
				$confData['type'] = trim(strtolower(end($typeParts)));
1666
				$confData['typeUpper'] = strtoupper($confData['type']);
1666 1667
				if (count($typeParts)==1)	{
1667 1668
					$confData['fieldname'] = $this->cleanFormName($parts[0]);
1668 1669
					if (strtolower(ereg_replace('[^[:alnum:]]','',$confData['fieldname']))=='email')	{$confData['fieldname']='email';}
......
1691 1692
					// Additional parameters
1692 1693
				if (trim($confData['type']))	{
1693 1694
					$addParams=trim($conf['params']);
1694
					if (is_array($conf['params.']) && isset($conf['params.'][$confData['type']]))	{
1695
					if ($conf[$confData['typeUpper'].'.']['addParams'])	{
1696
						$addParams = trim($conf[$confData['typeUpper'].'.']['addParams']);
1697
					} elseif (is_array($conf['params.']) && isset($conf['params.'][$confData['type']]))	{
1698
							// Backwards compatibility
1695 1699
						$addParams=trim($conf['params.'][$confData['type']]);
1696 1700
					}
1697 1701
					if (strcmp('',$addParams))	$addParams=' '.$addParams;
......
1702 1706
				} else {
1703 1707
					$fName = md5($confData['fieldname']);
1704 1708
				}
1709
				$id = $prefix.$fName;
1705 1710

  
1706
					// Accessibility: Set id = fieldname attribute:
1707
				if ($conf['accessibility'] || $xhtmlStrict)	{
1708
					$elementIdAttribute = ' id="'.$prefix.$fName.'"';
1709
				} else {
1710
					$elementIdAttribute = '';
1711
				}
1711
				$addParams = str_replace('###ID###',$id,$addParams);
1712 1712

  
1713 1713
					// Create form field based on configuration/type:
1714 1714
				switch($confData['type'])	{
......
1726 1726
							$wrap = $wrap ? ' wrap="'.$wrap.'"' : ' wrap="virtual"';
1727 1727
						}
1728 1728
						$default = $this->getFieldDefaultValue($conf['noValueInsert'], $confData['fieldname'], str_replace('\n',chr(10),trim($parts[2])));
1729
						$fieldCode=sprintf('<textarea name="%s"'.$elementIdAttribute.' cols="%s" rows="%s"%s'.$addParams.'>%s</textarea>',
1729
						$fieldCode=sprintf('<textarea name="%s" cols="%s" rows="%s"%s'.$addParams.'>%s</textarea>',
1730 1730
							$confData['fieldname'], $cols, $rows, $wrap, t3lib_div::formatForTextarea($default));
1731 1731
					break;
1732 1732
					case 'input':
......
1744 1744
						$max=trim($fParts[2]) ? ' maxlength="'.t3lib_div::intInRange($fParts[2],1,1000).'"' : "";
1745 1745
						$theType = $confData['type']=='input' ? 'text' : 'password';
1746 1746

  
1747
						$fieldCode=sprintf('<input type="'.$theType.'" name="%s"'.$elementIdAttribute.' size="%s"%s value="%s"'.$addParams.' />',
1747
						$fieldCode=sprintf('<input type="'.$theType.'" name="%s" size="%s"%s value="%s"'.$addParams.' />',
1748 1748
							$confData['fieldname'], $size, $max, htmlspecialchars($default));
1749 1749

  
1750 1750
					break;
1751 1751
					case 'file':
1752 1752
						$size=trim($fParts[1]) ? t3lib_div::intInRange($fParts[1],1,60) : 20;
1753
						$fieldCode=sprintf('<input type="file" name="%s"'.$elementIdAttribute.' size="%s"'.$addParams.' />',
1753
						$fieldCode=sprintf('<input type="file" name="%s" size="%s"'.$addParams.' />',
1754 1754
							$confData['fieldname'], $size);
1755 1755
					break;
1756 1756
					case 'check':
1757 1757
							// alternative default value:
1758 1758
						$default = $this->getFieldDefaultValue($conf['noValueInsert'], $confData['fieldname'], trim($parts[2]));
1759 1759
						$checked = $default ? ' checked="checked"' : '';
1760
						$fieldCode=sprintf('<input type="checkbox" value="%s" name="%s"'.$elementIdAttribute.'%s'.$addParams.' />',
1760
						$fieldCode=sprintf('<input type="checkbox" value="%s" name="%s"%s'.$addParams.' />',
1761 1761
							1, $confData['fieldname'], $checked);
1762 1762
					break;
1763 1763
					case 'select':
......
1795 1795
						}
1796 1796

  
1797 1797
						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.
1798
						$fieldCode=sprintf('<select name="%s"'.$elementIdAttribute.' size="%s"%s'.$addParams.'>%s</select>',
1798
						$fieldCode=sprintf('<select name="%s" size="%s"%s'.$addParams.'>%s</select>',
1799 1799
							$confData['fieldname'], $size, $multiple, $option); //RTF
1800 1800
					break;
1801 1801
					case 'radio':
1802 1802
						$option='';
1803
						if ($conf['accessibility'])	{
1804
							$option.='<fieldset'.$elementIdAttribute.'><legend>'.$confData['label'].'</legend>';
1805
						}
1806 1803
						$valueParts = explode(',',$parts[2]);
1807 1804
						$items=array();		// Where the items will be
1808 1805
						$default='';
......
1822 1819
						$default = $this->getFieldDefaultValue($conf['noValueInsert'], $confData['fieldname'], $default);
1823 1820
							// Create the select-box:
1824 1821
						for($a=0;$a<count($items);$a++)	{
1825
							$radioId = $prefix.$fName.$this->cleanFormName($items[$a][0]);
1826
							if ($conf['accessibility'])	{
1827
								$radioLabelIdAttribute = ' id="'.$radioId.'"';
1828
							} else {
1829
								$radioLabelIdAttribute = '';
1822
							$radioId = $id.$this->cleanFormName($items[$a][0]);
1823
							$itemAddParams = $conf['RADIO.']['item.']['addParams'];
1824
							$itemAddParams = str_replace('###RADIO_ID###',$radioId,$itemAddParams);
1825
							$radio = '<input type="radio" name="'.$confData['fieldname'].'" value="'.$items[$a][1].'"'.(!strcmp($items[$a][1],$default)?' checked="checked"':'').''.$itemAddParams.' />';
1826
							if (is_array($conf['RADIO.']['item.']['labelWrap.']))	{
1827
								$radioLabel = $this->stdWrap(trim($items[$a][0]), $conf['RADIO.']['item.']['labelWrap.']);
1828
							} elseif (is_array($conf['radioWrap.']))	{
1829
									// Backwards compatibility
1830
								$radioLabel = $this->stdWrap(trim($items[$a][0]), $conf['radioWrap.']);
1830 1831
							}
1831
							$option .= '<input type="radio" name="'.$confData['fieldname'].'"'.$radioLabelIdAttribute.' value="'.$items[$a][1].'"'.(!strcmp($items[$a][1],$default)?' checked="checked"':'').''.$addParams.' />';
1832
							if ($conf['accessibility'])	{
1833
								$option .= '<label for="'.$radioId.'">' . $this->stdWrap(trim($items[$a][0]), $conf['radioWrap.']) . '</label>';
1832
							$radioLabel = str_replace('###RADIO_ID###',$radioId,$radioLabel);
1833
							if ($conf['RADIO.']['item.']['layout'])	{
1834
								$itemLayout = $conf['RADIO.']['item.']['layout'];
1835
								$itemLayout = str_replace('###RADIO###',$radio,$itemLayout);
1836
								$itemLayout = str_replace('###RADIO_LABEL###',$radioLabel,$itemLayout);
1834 1837
							} else {
1835
								$option .= $this->stdWrap(trim($items[$a][0]), $conf['radioWrap.']);
1838
									// Backwards compatibility
1839
								$itemLayout = $radio.$radioLabel.'<br />';
1836 1840
							}
1837
 							$option .= '<br />';
1841
							$option .= $itemLayout;
1838 1842
 						}
1839
						if ($conf['accessibility'])	{
1840
							$option.='</fieldset>';
1841
						}
1842 1843
						$fieldCode = $option;
1843 1844
					break;
1844 1845
					case 'hidden':
......
1849 1850
						if (strlen($value) && t3lib_div::inList('recipient_copy,recipient',$confData['fieldname']))	{
1850 1851
							$value = $GLOBALS['TSFE']->codeString($value);
1851 1852
						}
1852
						$hiddenfields.=sprintf('<input type="hidden" name="%s"'.$elementIdAttribute.' value="%s" />',
1853
						$hiddenfields.=sprintf('<input type="hidden" name="%s" value="%s"'.$addParams.'/>',
1853 1854
							$confData['fieldname'], htmlspecialchars($value));
1854 1855
					break;
1855 1856
					case 'property':
......
1868 1869
						if($image)	{
1869 1870
							$fieldCode = str_replace('<img','<input type="image"'.$addParams.' name="'.$confData['fieldname'].'"' ,$image);
1870 1871
						} else	{
1871
							$fieldCode=sprintf('<input type="submit" name="%s"'.$elementIdAttribute.' value="%s"'.$addParams.' />',
1872
							$fieldCode=sprintf('<input type="submit" name="%s" value="%s"'.$addParams.' />',
1872 1873
								$confData['fieldname'], t3lib_div::deHSCentities(htmlspecialchars($value)));
1873 1874
						}
1874 1875
					break;
1875 1876
					case 'reset':
1876 1877
						$value=trim($parts[2]);
1877
						$fieldCode=sprintf('<input type="reset" name="%s"'.$elementIdAttribute.' value="%s"'.$addParams.' />',
1878
						$fieldCode=sprintf('<input type="reset" name="%s" value="%s"'.$addParams.' />',
1878 1879
							$confData['fieldname'], t3lib_div::deHSCentities(htmlspecialchars($value)));
1879 1880
					break;
1880 1881
					case 'label':
......
1882 1883
					break;
1883 1884
					default:
1884 1885
						$confData['type'] = 'comment';
1886
						$confData['typeUpper'] = 'COMMENT';
1885 1887
						$fieldCode = trim($parts[2]).'&nbsp;';
1886 1888
					break;
1887 1889
				}
......
1918 1920
						break;
1919 1921
					}
1920 1922

  
1921
						// Field:
1923

  
1924
						// Getting template markers:
1925
						// ###FIELD###
1926
					$rawFieldCode = $fieldCode;
1927
					if (is_array($conf[$confData['typeUpper'].'.']['fieldWrap.']))	{
1928
						$fieldCode = $this->stdWrap($fieldCode, $conf[$confData['typeUpper'].'.']['fieldWrap.']);
1929
					} else	{
1930
						$fieldCode = $this->stdWrap($fieldCode, $conf['fieldWrap.']);
1931
					}
1932
						// ###LABEL###
1922 1933
					$fieldLabel = $confData['label'];
1923
					if ($conf['accessibility'] && $confData['type']!='radio' && $confData['type'] != 'label')	{
1924
						$fieldLabel = '<label for="'.$prefix.$fName.'">'.$fieldLabel.'</label>';
1934
					if (is_array($conf[$confData['typeUpper'].'.']['labelWrap.']))	{
1935
						$labelCode = $this->stdWrap($fieldLabel, $conf[$confData['typeUpper'].'.']['labelWrap.']);
1936
					} else	{
1937
						$labelCode = $this->stdWrap($fieldLabel, $conf['labelWrap.']);
1925 1938
					}
1939
					$labelCode = str_replace('###ID###',$id,$labelCode);
1926 1940

  
1927
						// Getting template code:
1928
					$fieldCode = $this->stdWrap($fieldCode, $conf['fieldWrap.']);
1929
					$labelCode = $this->stdWrap($fieldLabel, $conf['labelWrap.']);
1941
						// ###COMMENT### (alternative label wrapping)
1930 1942
					$commentCode = $this->stdWrap($confData['label'], $conf['commentWrap.']); // RTF
1943

  
1944
						// Getting template code
1931 1945
					$result = $conf['layout'];
1946
					if (isset($conf[$confData['typeUpper'].'.']['layout']))	{
1947
						$result = $conf[$confData['typeUpper'].'.']['layout'];
1948
					}
1932 1949
					if ($conf['REQ'] && $confData['required'])	{
1933
						if (is_array($conf['REQ.']['fieldWrap.']))
1934
							$fieldCode = $this->stdWrap($fieldCode, $conf['REQ.']['fieldWrap.']);
1935
						if (is_array($conf['REQ.']['labelWrap.']))
1950
						if (is_array($conf[$confData['typeUpper'].'.']['REQ.']['fieldWrap.']))
1951
							$fieldCode = $this->stdWrap($rawFieldCode, $conf[$confData['typeUpper'].'.']['REQ.']['fieldWrap.']);
1952
						elseif (is_array($conf['REQ.']['fieldWrap.']))
1953
							$fieldCode = $this->stdWrap($rawFieldCode, $conf['REQ.']['fieldWrap.']);
1954

  
1955
						if (is_array($conf[$confData['typeUpper'].'.']['REQ.']['labelWrap.']))
1956
							$labelCode = $this->stdWrap($fieldLabel, $conf[$confData['typeUpper'].'.']['REQ.']['labelWrap.']);
1957
						elseif (is_array($conf['REQ.']['labelWrap.']))
1936 1958
							$labelCode = $this->stdWrap($fieldLabel, $conf['REQ.']['labelWrap.']);
1937
						if ($conf['REQ.']['layout'])	{
1959

  
1960
						if (is_array($conf[$confData['typeUpper'].'.']['REQ.']['layout']))
1961
							$result = $conf[$confData['typeUpper'].'.']['REQ.']['layout'];
1962
						elseif (is_array($conf['REQ.']['layout']))
1938 1963
							$result = $conf['REQ.']['layout'];
1939
						}
1940
					}
1941
					if ($confData['type']=='comment' && $conf['COMMENT.']['layout'])	{
1942
						$result = $conf['COMMENT.']['layout'];
1943
					}
1944
					if ($confData['type']=='check' && $conf['CHECK.']['layout'])	{
1945
						$result = $conf['CHECK.']['layout'];
1946
					}
1947
					if ($confData['type']=='radio' && $conf['RADIO.']['layout'])	{
1948
						$result = $conf['RADIO.']['layout'];
1949
					}
1950
					if ($confData['type']=='label' && $conf['LABEL.']['layout']) {
1951
						$result = $conf['LABEL.']['layout'];
1952 1964
					}
1953 1965
					$result = str_replace('###FIELD###',$fieldCode,$result);
1954 1966
					$result = str_replace('###LABEL###',$labelCode,$result);
1967
					$result = str_replace('###ID###',$id,$result);
1955 1968
					$result = str_replace('###COMMENT###',$commentCode,$result); //RTF
1956 1969
					$content.= $result;
1957 1970
				}
typo3/sysext/css_styled_content/static/setup.txt 30 Dec 2005 11:22:20 -0000
1120 1120

  
1121 1121
# change mailform to accesssible mode
1122 1122
tt_content.mailform.20 {
1123
  accessibility = 1
1124
  noWrapAttr=1
1123
  noWrapAttr = 1
1125 1124
  formName = mailform
1126 1125
  dontMd5FieldNames = 1
1127
  REQ = 1
1128 1126
  layout = <div class="csc-mailform-field">###LABEL### ###FIELD###</div>
1129
  COMMENT.layout = <div class="csc-mailform-label">###LABEL###</div>
1130
  RADIO.layout = <div class="csc-mailform-field">###LABEL### <fieldset class="csc-mailform-radio" id="testform_radio">###FIELD###</fieldset></div>
1131
  LABEL.layout = <div class="csc-mailform-field">###LABEL### <span class="csc-mailform-label">###FIELD###</span></div>
1132
  labelWrap.wrap = |
1127
  labelWrap.wrap = <label for="###ID###" class="csc-mailform-label"> | </label>
1133 1128
  commentWrap.wrap = |
1134
  radioWrap.wrap = |
1135
  REQ.labelWrap.wrap = |
1129
  REQ = 1
1130
  REQ.labelWrap.wrap = <label for="###ID###" class="csc-mailform-label-req"> | </label>
1131
  COMMENT {
1132
    layout = <div class="csc-mailform-label">###LABEL###</div>
1133
    labelWrap.wrap = |
1134
  }
1135
  RADIO {
1136
    layout = <div class="csc-mailform-field">###LABEL### <fieldset class="csc-mailform-radio" id="###ID###"><legend>###COMMENT###</legend>###FIELD###</fieldset></div>
1137
    item {
1138
      layout = ###RADIO######RADIO_LABEL###<br />
1139
      addParams = id="###RADIO_ID###" class="csc-mailform-radio"
1140
      labelWrap.wrap = <label for="###RADIO_ID###"> | </label>
1141
    }
1142
  }
1143
  LABEL {
1144
    layout = <div class="csc-mailform-field"><span class="csc-mailform-label">###LABEL###</span></div>
1145
    labelWrap.wrap = |
1146
  }
1147
  CHECK {
1148
    addParams = id="###ID###" class="csc-mailform-check"
1149
  }
1150
  INPUT {
1151
    addParams = id="###ID###" class="csc-mailform-input"
1152
  }
1153
  HIDDEN {
1154
    addParams = id="###ID###"
1155
  }
1156
  PASSWORD {
1157
    addParams = id="###ID###" class="csc-mailform-password"
1158
  }
1159
  FILE {
1160
    addParams = id="###ID###" class="csc-mailform-file"
1161
  }
1162
  TEXTAREA {
1163
    addParams = id="###ID###" class="csc-mailform-textarea"
1164
  }
1165
  SELECT {
1166
    addParams = id="###ID###" class="csc-mailform-select"
1167
  }
1168
  SUBMIT {
1169
    addParams = id="###ID###" class="csc-mailform-submit"
1170
  }
1171
  RESET {
1172
    addParams = id="###ID###" class="csc-mailform-reset"
1173
  }
1136 1174
  stdWrap.wrap = <fieldset class="csc-mailform"> | </fieldset>
1137
  params.radio = class="csc-mailform-radio"
1138
  params.check = class="csc-mailform-check"
1139
  params.submit = class="csc-mailform-submit"
1140 1175
}
1141 1176

  
1142 1177
# accessible menu