--- typo3conf/ext/th_mailformplus/ext_tables.php.orig	2007-03-15 12:05:10.663325256 +0100
+++ typo3conf/ext/th_mailformplus/ext_tables.php	2007-03-15 12:24:21.999295584 +0100
@@ -3,6 +3,9 @@
 
 t3lib_extMgm::allowTableOnStandardPages("tx_thmailformplus_main");
 
+$TCA['tt_content']['types']['list']['subtypes_addlist'][$_EXTKEY.'_pi1']=  'pi_flexform';
+t3lib_extMgm::addPiFlexFormValue($_EXTKEY.'_pi1', 'FILE:EXT:'.$_EXTKEY.'/flexform_ds.xml');
+
 
 t3lib_extMgm::addToInsertRecords("tx_thmailformplus_main");
 
@@ -36,4 +39,4 @@
 
 # if (TYPO3_MODE=="BE")	
 #    $TBE_MODULES_EXT["xMOD_db_new_content_el"]["addElClasses"]["tx_thmailformplus_pi1_wizicon"] = t3lib_extMgm::extPath($_EXTKEY)."pi1/class.tx_thmailformplus_pi1_wizicon.php";
-?>
\ Kein Zeilenumbruch am Dateiende.
+?>
--- /dev/null	2005-04-05 16:46:42.000000000 +0200
+++ typo3conf/ext/th_mailformplus/flexform_ds.xml	2007-03-15 14:47:24.212980088 +0100
@@ -0,0 +1,136 @@
+<T3DataStructure>
+	<meta>
+	<langDisable>1</langDisable>
+	<!--  <langChildren>1</langChildren>!-->
+		</meta>
+<sheets>
+	<sDEFAULT>
+	<ROOT>
+		<TCEforms>
+			<sheetTitle>LLL:EXT:th_mailformplus/locallang_tca.php:th_mailformplus.pi_flexform.sheet_general</sheetTitle>
+		</TCEforms>
+		<type>array</type>
+		<el>
+			<template_file>
+				<TCEforms>
+					<label>LLL:EXT:th_mailformplus/locallang_tca.php:th_mailformplus.pi_flexform.template_file</label>
+					<config>
+						<type>group</type>
+						<internal_type>file</internal_type>
+						<allowed>tmpl,html,htm</allowed>
+						<max_size>100</max_size>
+						<uploadfolder>uploads/tx_thmailformplus/</uploadfolder>
+						<maxitems>1</maxitems>
+						<size>1</size>
+						<selectedListStyle>Width:180px</selectedListStyle>
+					</config>
+				</TCEforms>
+			</template_file>
+		</el>
+	</ROOT>
+	</sDEFAULT>
+
+	<s_form>
+		<ROOT>
+			<TCEforms>
+				<sheetTitle>LLL:EXT:th_mailformplus/locallang_tca.php:th_mailformplus.pi_flexform.sheet_emailSettings</sheetTitle>
+			</TCEforms>
+			<type>array</type>
+			<el>
+				<email_to>
+					<TCEforms>
+					<label>LLL:EXT:th_mailformplus/locallang_tca.php:th_mailformplus.pi_flexform.emailRecipient</label>
+					<config>
+						<type>input</type>
+						<eval>text</eval>
+						<size>50</size>
+					</config>
+					</TCEforms>
+				</email_to>
+
+				<email_subject>
+					<TCEforms>
+					<label>LLL:EXT:th_mailformplus/locallang_tca.php:th_mailformplus.pi_flexform.emailSubject</label>
+					<config>
+						<type>input</type>
+						<eval>text</eval>
+						<size>50</size>
+					</config>
+					</TCEforms>
+				</email_subject>
+
+				<email_sender>
+					<TCEforms>
+						<label>LLL:EXT:th_mailformplus/locallang_tca.php:th_mailformplus.pi_flexform.emailFrom</label>
+						<config>
+							<type>input</type>
+							<eval>text</eval>
+							<size>50</size>
+						</config>
+					</TCEforms>
+				</email_sender>
+
+				<email_redirect>
+					<TCEforms>
+						<label>LLL:EXT:th_mailformplus/locallang_tca.php:th_mailformplus.pi_flexform.redirectPage</label>
+						<config>
+							<type>group</type>
+							<internal_type>db</internal_type>
+							<allowed>pages</allowed>
+							<size>1</size>
+							<maxitems>1</maxitems>
+							<minitems>0</minitems>
+							<show_thumbs>1</show_thumbs>
+						</config>
+					</TCEforms>
+				</email_redirect>
+
+				<email_requiredfields>
+					<TCEforms>
+						<label>LLL:EXT:th_mailformplus/locallang_tca.php:th_mailformplus.pi_flexform.mandatoryFields</label>
+						<config>
+							<type>input</type>
+							<eval>text</eval>
+							<size>500</size>
+						</config>
+					</TCEforms>
+				</email_requiredfields>
+
+				<email_replyto>
+					<TCEforms>
+						<label>LLL:EXT:th_mailformplus/locallang_tca.php:th_mailformplus.pi_flexform.replyTo</label>
+						<config>
+							<type>input</type>
+							<eval>text</eval>
+							<size>50</size>
+						</config>
+					</TCEforms>
+				</email_replyto>
+
+				<email_sendtouser>
+					<TCEforms>
+						<label>LLL:EXT:th_mailformplus/locallang_tca.php:th_mailformplus.pi_flexform.emailConfirm</label>
+						<config>
+							<type>input</type>
+							<eval>text</eval>
+							<size>50</size>
+						</config>
+					</TCEforms>
+				</email_sendtouser>
+
+				<email_subject_user>
+					<TCEforms>
+						<label>LLL:EXT:th_mailformplus/locallang_tca.php:th_mailformplus.pi_flexform.emailConfirmSubject</label>
+						<config>
+							<type>input</type>
+							<eval>text</eval>
+							<size>50</size>
+						</config>
+					</TCEforms>
+				</email_subject_user>
+
+			</el>
+		</ROOT>
+	</s_form>
+</sheets>
+</T3DataStructure>
--- /dev/null	2005-04-05 16:46:42.000000000 +0200
+++ typo3conf/ext/th_mailformplus/locallang_tca.xml	2007-03-15 13:53:20.126626552 +0100
@@ -0,0 +1,113 @@
+<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
+<T3locallang>
+	<meta type="array">
+		<description>language labels for th_mailformplus BE forms</description>
+		<type>database</type>
+		<csh_table></csh_table>
+		<fileId>EXT:th_mailformplus/locallang_tca.xml</fileId>
+		<labelContext type="array">
+			<label index="th_mailformplus.pi_flexform.sheet_general"></label>
+			<label index="th_mailformplus.pi_flexform.sheet_emailSettings"></label>
+			<label index="th_mailformplus.pi_flexform.template_file"></label>
+		</labelContext>
+	</meta>
+	<data type="array">
+		<languageKey index="default" type="array">
+			<label index="th_mailformplus.pi_flexform.sheet_general">General Settings</label>
+			<label index="th_mailformplus.pi_flexform.sheet_emailSettings">E-Mail Settings</label>
+			<label index="th_mailformplus.pi_flexform.template_file">Template File</label>
+			<label index="th_mailformplus.pi_flexform.emailRecipient">Recipient</label>
+			<label index="th_mailformplus.pi_flexform.emailSubject">Subject</label>
+			<label index="th_mailformplus.pi_flexform.emailFrom">Mail From</label>
+			<label index="th_mailformplus.pi_flexform.redirectPage">Redirect Page</label>
+			<label index="th_mailformplus.pi_flexform.mandatoryFields">Mandatory field (enter name of formular field seperated by ",")</label>
+			<label index="th_mailformplus.pi_flexform.replyTo">use the value of this submitted form-field as reply-to (optional, name of input field)</label>
+			<label index="th_mailformplus.pi_flexform.emailConfirm">optional: Send a confirmation email to user (enter input-field name)</label>
+			<label index="th_mailformplus.pi_flexform.emailConfirmSubject">Subject of the mail to the user:</label>
+		</languageKey>
+		<languageKey index="dk" type="array">
+		</languageKey>
+		<languageKey index="de" type="array">
+		</languageKey>
+		<languageKey index="no" type="array">
+		</languageKey>
+		<languageKey index="it" type="array">
+		</languageKey>
+		<languageKey index="fr" type="array">
+		</languageKey>
+		<languageKey index="es" type="array">
+		</languageKey>
+		<languageKey index="nl" type="array">
+		</languageKey>
+		<languageKey index="cz" type="array">
+		</languageKey>
+		<languageKey index="pl" type="array">
+		</languageKey>
+		<languageKey index="si" type="array">
+		</languageKey>
+		<languageKey index="fi" type="array">
+		</languageKey>
+		<languageKey index="tr" type="array">
+		</languageKey>
+		<languageKey index="se" type="array">
+		</languageKey>
+		<languageKey index="pt" type="array">
+		</languageKey>
+		<languageKey index="ru" type="array">
+		</languageKey>
+		<languageKey index="ro" type="array">
+		</languageKey>
+		<languageKey index="ch" type="array">
+		</languageKey>
+		<languageKey index="sk" type="array">
+		</languageKey>
+		<languageKey index="lt" type="array">
+		</languageKey>
+		<languageKey index="is" type="array">
+		</languageKey>
+		<languageKey index="hr" type="array">
+		</languageKey>
+		<languageKey index="hu" type="array">
+		</languageKey>
+		<languageKey index="gl" type="array">
+		</languageKey>
+		<languageKey index="th" type="array">
+		</languageKey>
+		<languageKey index="gr" type="array">
+		</languageKey>
+		<languageKey index="hk" type="array">
+		</languageKey>
+		<languageKey index="eu" type="array">
+		</languageKey>
+		<languageKey index="bg" type="array">
+		</languageKey>
+		<languageKey index="br" type="array">
+		</languageKey>
+		<languageKey index="et" type="array">
+		</languageKey>
+		<languageKey index="ar" type="array">
+		</languageKey>
+		<languageKey index="he" type="array">
+		</languageKey>
+		<languageKey index="ua" type="array">
+		</languageKey>
+		<languageKey index="lv" type="array">
+		</languageKey>
+		<languageKey index="jp" type="array">
+		</languageKey>
+		<languageKey index="vn" type="array">
+		</languageKey>
+		<languageKey index="ca" type="array">
+		</languageKey>
+		<languageKey index="ba" type="array">
+		</languageKey>
+		<languageKey index="kr" type="array">
+		</languageKey>
+		<languageKey index="eo" type="array">
+		</languageKey>
+		<languageKey index="my" type="array">
+		</languageKey>
+		<languageKey index="hi" type="array">
+		</languageKey>
+	</data>
+</T3locallang>
--- typo3conf/ext/th_mailformplus/example_form/mailformplus_demo.html.orig	2007-03-15 14:58:27.466150280 +0100
+++ typo3conf/ext/th_mailformplus/example_form/mailformplus_demo.html	2007-03-15 14:58:30.961618888 +0100
@@ -133,7 +133,7 @@
 <form name="Formular" method="post" action="index.php" enctype="multipart/form-data">
 <input type="hidden" name="id" value="###PID###">
 <input type="hidden" name="submitted" value="1">
-<input type="hidden" name="L" value="0">
+<input type="hidden" name="L" value="###value_language_id###">
 <input type="hidden" name="type" value="###value_type###">
 ###ERROR###
 <table border="0" cellspacing="2" cellpadding="0">
--- typo3conf/ext/th_mailformplus/pi1/class.tx_thmailformplus_pi1.php.orig	2007-03-15 12:05:26.595903136 +0100
+++ typo3conf/ext/th_mailformplus/pi1/class.tx_thmailformplus_pi1.php	2007-03-15 15:06:45.043735720 +0100
@@ -48,6 +48,9 @@
 		$this->get_post = array_merge(t3lib_div::_GET(), t3lib_div::_POST());
 		$this->debug = $this->conf['saveDB.']['debug'];
 
+		$this->pi_setPiVarDefaults();
+		$this->pi_initPIflexForm();
+
 		$this->loadDefaultValues();
 
 		switch((string)$conf["CMD"])	{
@@ -63,7 +66,7 @@
 			    $mailformplus_id = $this->cObj->data['pages'];
 				# default: display the form from the page where the plugin is inserted
 			    if (!$mailformplus_id) $mailformplus_id = $this->cObj->data['pid'];
-			    
+
                                 // Initializing the query parameters:
 			    $query = "SELECT tx_thmailformplus_main.* FROM tx_thmailformplus_main WHERE pid IN (".$mailformplus_id.") LIMIT 0,1";
 			    $res = $GLOBALS['TYPO3_DB']->sql(TYPO3_db, $query); 
@@ -77,14 +80,31 @@
 			    t3lib_div::loadTCA('tx_thmailformplus_main');
 			    $config = $GLOBALS['TCA']['tx_thmailformplus_main'];
 				# old version: copy of template file in upload folder
-			    if ($config[columns][email_htmltemplate][config][uploadfolder]) $template_folder = $config[columns][email_htmltemplate][config][uploadfolder].'/';
-			    else $template_folder = '';
-	
-			    $this->templateCode_orig = t3lib_div::getURL($template_folder.$this->getFieldContent("email_htmltemplate"));
+			    if ($config[columns][email_htmltemplate][config][uploadfolder])
+				{
+				  $template_folder = $config[columns][email_htmltemplate][config][uploadfolder].'/';
+				}
+			    else 
+				{
+				  $template_folder = '';
+				}
+
+				/* get the template */
+				$templateFile = $this->getFieldContent("email_htmltemplate");
+				/* content_field */
+				$templateFile = ($this->getFieldContent("email_htmltemplate")) ? $this->getFieldContent("email_htmltemplate") : $templateFile;
+				
+				/* TS entry */
+#				$templateFile = ($this->conf["email_htmltemplate"] != '') ? $this->conf["email_htmltemplate"] : $templateFile;
+				/* FlexForm entry */
+				$templateFile = ( $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'template_file', 'sDEFAULT') ) ? $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'template_file', 'sDEFAULT') : $templateFile;
+
+
+			    $this->templateCode_orig = t3lib_div::getURL($template_folder.$templateFile);
 				# compatibility reasons: look for copy of template in uploads directory
 			    if (!$this->templateCode_orig) {
-				$template_folder = "uploads/tx_thmailformplus/";
-				$this->templateCode_orig = t3lib_div::getURL($template_folder.$this->getFieldContent("email_htmltemplate"));
+					$template_folder = "uploads/tx_thmailformplus/";
+					$this->templateCode_orig = t3lib_div::getURL($template_folder.$templateFile);
 			    }
 			    
 			    ##############################
@@ -585,7 +605,6 @@
 	    $email_to = $this->getFieldContent("email_to");
 	    $email_replyto = $this->getFieldContent("email_replyto");
 
-
 		# since 18.10.2005: prevent mail injection (reported by Joerg Schoppet - thx!)
 	    if (eregi("\r",$email_sender) || eregi("\n",$email_sender)) {
 		$email_sender = '';
@@ -1003,6 +1022,8 @@
 	    $globalMarkerArray["###EMAIL_TO###"] = $this->getFieldContent("email_to");
 	    $globalMarkerArray["###EMAIL_REQUIREDFIELDS###"] = $this->getFieldContent("email_requiredfields");
 	    // $globalMarkerArray['###PID###'] = $this->get_post['id'];
+	    $globalMarkerArray['###value_language_id###'] = $GLOBALS['TSFE']->sys_language_uid;
+
 	    $globalMarkerArray['###PID###'] = $GLOBALS["TSFE"]->id;
 	    $globalMarkerArray['###ERROR###'] = $this->error;
 
@@ -1781,6 +1802,7 @@
 	    $globalMarkerArray["###EMAIL_REQUIREDFIELDS###"] = $this->getFieldContent("email_requiredfields");
 	    // // bugfixed - thx to Sebastian F.:: $globalMarkerArray['###PID###'] = $this->get_post['id'];
 	    $globalMarkerArray['###PID###'] = $GLOBALS["TSFE"]->id;
+	    $globalMarkerArray['###value_language_id###'] = $GLOBALS['TSFE']->sys_language_uid;
 	    $globalMarkerArray['###ERROR###'] = $this->error;
 	    
 	    $this->templateCode = $this->cObj->substituteMarkerArray($this->templateCode, $globalMarkerArray);
@@ -1813,6 +1835,10 @@
 				if ($this->conf['default.'][$fN.'.']) {
 				    return $this->cObj->TEXT($this->conf['default.'][$fN.'.']);
 				} else {
+					if ($this->pi_getFFvalue($this->cObj->data['pi_flexform'], $fN, 's_form') )
+					{
+					  return $this->pi_getFFvalue($this->cObj->data['pi_flexform'], $fN, 's_form');
+					}
 				    return $this->conf['default.'][$fN];
 				}
 
@@ -1828,4 +1854,4 @@
 	include_once($TYPO3_CONF_VARS[TYPO3_MODE]["XCLASS"]["ext/th_mailformplus/pi1/class.tx_thmailformplus_pi1.php"]);
 }
 
-?>
\ Kein Zeilenumbruch am Dateiende.
+?>
