This page contains deprecated components, that are not contained in release 1.11. Thus, this page now is under development until this message is removed. If you have, any question, please create a new thread in our support forum.
Please refer to the German language copy&paste wiki tutorial to see how the contact form can be included into your web page.
/config/tools/form/taglib/{CONTEXT}/{ENVIRONMENT}_formconfig.ini/config/tools/form/taglib/sites/demosite/DEFAULT_formconfig.iniPlease fill the field in e-mail address!Please provide a valid e-mail address!<form:validate
button="send"
field="email"
type="EMail"
msginputreq="Contact.EMail.InputRequired"
msginputwrg="Contact.EMail.InputWrong"
/>[de]
Contact.EMail.InputRequired = "Bitte geben Sie eine E-Mail-Adresse sein!"
Contact.EMail.InputWrong = "Bitte geben Sie eine gültige E-Mail-Adresse sein!"
[en]
Contact.EMail.InputRequired = "Please fill the field sender name!"
Contact.EMail.InputWrong = "Please provide a valid email address!"/config/modules/kontakt4/{CONTEXT}/{ENVIRONMENT}_language.ini;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Deutsche Texte ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[de]
; Header
header.title = "Kontakt"
; Hinweise zum Formular
formhint.text = "Wenn Sie mit mir in Kontakt treten möchten, dann benutzen Sie einfach dieses Formular. Geben Sie Ihre Nachricht ein und schon kann es los gehen. Ich werden mich dann umgehend mit Ihnen in Verbindung setzten. Bitte füllen Sie das Formular vollständig aus!"
; Formular
form.person = "Person / Gruppe: "
form.name = "Ihr Name:"
form.email = "Ihre E-Mail-Adresse:"
form.subject = "Ihr Betreff:"
form.comment = "Ihre Nachricht:"
form.button = "Senden"
form.captcha = "Bestätigungscode:"
; confirmation text
message.text = "Vielen Danke für Ihre Anfrage. Ich werde mich umgehend mit Ihnen in Verbindung setzen!"
; validation messages
form.name.error = "Bitte füllen Sie das Feld Absender-Name!"
form.email.error = "Bitte geben Sie eine gültige E-Mail-Adresse sein!"
form.subject.error = "Bitte füllen Sie das Feld Betreff!"
form.text.error = "Bitte füllen Sie das Feld Text!"
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Englisch texts ;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[en]
; header
header.title = "Contact"
; hints on the form
formhint.text = "If you want to contact me, please use the form provided below. Then I will immediately get in contact with you. Please fill all required fields!"
; form labels
form.person = "Person / group: "
form.name = "Your name:"
form.email = "Your email address:"
form.subject = "Your subject:"
form.comment = "Your message:"
form.button = "Send"
form.captcha = "Security code:"
; confirmation text
message.text = "Many thanks for your message. We will get in contact with you immediately!"
; validation messages
form.name.error = "Please provide a sender name!"
form.email.error = "Please provide a valid email address!"
form.subject.error = "Please fill the subject field!"
form.text.error = "The message may not be empty!"// Load language dependent configuration
$Config = &$this->__getConfiguration('modules::kontakt4','language');
// Get a reference on the desired form control
$Button = &$Form->getFormElementByName('KontaktSenden');
// Set the value attribute of the control using the $this->__Language member
$Button->setAttribute('value',$Config->getValue($this->__Language,'form.button'));/modules/
kontakt4/
biz/
data/
pres/
documentcontroller/
templates/<core:addtaglib namespace="tools::html::taglib" prefix="html" class="getstring" />
<font style="..."><html:getstring namespace="modules::kontakt4" config="language" entry="header.title" /></font>
<br />
<br />
<core:importdesign namespace="modules::kontakt4::pres::templates" template="[pagepart=formular]" /><@controller
namespace="modules::kontakt4::pres::documentcontroller"
file="kontakt_v4_controller"
class="kontakt_v4_controller"
@>
<core:addtaglib namespace="tools::form::taglib" prefix="html" class="form" />
<core:addtaglib namespace="tools::html::taglib" prefix="html" class="getstring" />
<html:getstring namespace="modules::kontakt4" config="language" entry="formhint.text" />
<br />
<div style="text-align: left; padding-left: 80px; font-size: 12px;">
<html:placeholder name="Inhalt" />
</div>
<html:form name="Kontakt" method="post">
<form:valgroup name="FormValGroup">
<br />
<div style="width: 400px; border: 1px solid red; padding: 5px;">
<img src="<valgroup:placeholder name="WarnImage" />" />
<font style=".."><valgroup:placeholder name="WarnText" />:</font>
<br />
<valgroup:validate
type="text" field="AbsenderName" button="KontaktSenden"
msginputreq="Contact.Sender.InputRequired" />
<valgroup:validate
type="text" field="AbsenderAdresse" button="KontaktSenden"
msginputreq="Contact.EMail.InputRequired" msginputwrg="Contact.EMail.InputWrong"
validator="EMail" />
<valgroup:validate type="text" field="Betreff" button="KontaktSenden"
msginputreq="Contact.Subject.InputRequired" />
<valgroup:validate type="text" field="Text" button="KontaktSenden"
msginputreq="Contact.Text.InputRequired" />
</div>
<br />
</form:valgroup>
<br />
<span style="margin-right:
<form:getstring namespace="modules::kontakt4" config="language" entry="form.person.margin" />px;">
<form:getstring namespace="modules::kontakt4" config="language" entry="form.person" />
</span><form:select name="Empfaenger" class="eingabe_feld" />
<br />
<br />
<span style="margin-right:
<form:getstring namespace="modules::kontakt4" config="language" entry="form.name.margin" />px;">
<form:getstring namespace="modules::kontakt4" config="language" entry="form.name" /></span>
<form:text name="AbsenderName" class="eingabe_feld" style="width: 280px;" validate="true"
button="KontaktSenden" />
<br />
<br />
<span style="margin-right: <form:getstring namespace="modules::kontakt4" config="language"
entry="form.email.margin" />px;">
<form:getstring namespace="modules::kontakt4" config="language" entry="form.email" />
</span><form:text name="AbsenderAdresse" class="eingabe_feld" style="width: 280px;"
validate="true" validator="EMail" button="KontaktSenden" />
<br />
<br />
<span style="margin-right:
<form:getstring namespace="modules::kontakt4" config="language" entry="form.subject.margin" />px;">
<form:getstring namespace="modules::kontakt4" config="language" entry="form.subject" />
</span><form:text name="Betreff" class="eingabe_feld" style="width: 280px;" validate="true"
button="KontaktSenden" />
<br />
<br />
<form:getstring namespace="modules::kontakt4" config="language" entry="form.comment" />
<br />
<form:area name="Text" class="eingabe_feld" style="..." validate="true" button="KontaktSenden" />
<br />
<br />
<form:getstring namespace="modules::kontakt4" config="language" entry="form.captcha" />
<br />
<br />
<form:addtaglib namespace="modules::captcha::pres::taglib" prefix="form" class="captcha" />
<form:captcha text_class="eingabe_feld" validate="true" button="KontaktSenden"/>
<br />
<br />
<form:button name="KontaktSenden" class="eingabe_feld" />
</html:form><br />
<core:addtaglib namespace="tools::html::taglib" prefix="html" class="getstring" />
<html:getstring namespace="modules::kontakt4" config="language" entry="message.text" />
<br />
<br />import('tools::request','RequestHandler');
import('modules::kontakt4::biz','contactManager');
class kontakt_v4_controller extends base_controller {
var $_LOCALS;
function kontakt_v4_controller(){
$this->_LOCALS = RequestHandler::getValues(array('Empfaenger',
'AbsenderName',
'AbsenderAdresse',
'Betreff',
'Text'
)
);
}
function transformContent(){
// get form object
$Form = &$this->__getForm('Kontakt');
if($Form->get('isValid') && $Form->get('isSent')){
// what is going to be sent?
//
// - contact id
// - name
// - email
// - subject
// - text
$oFD = new oFormData();
$oFD->set('RecipientID',$this->_LOCALS['Empfaenger']);
$oFD->set('SenderName',$this->_LOCALS['AbsenderName']);
$oFD->set('SenderEMail',$this->_LOCALS['AbsenderAdresse']);
$oFD->set('Subject',$this->_LOCALS['Betreff']);
$oFD->set('Text',$this->_LOCALS['Text']);
// submit form
$cM = &$this->__getServiceObject('modules::kontakt4::biz','contactManager');
$cM->sendContactForm($oFD);
}
else{
$this->setPlaceHolder('Inhalt',$this->__buildForm());
}
}
function __buildForm(){
// get the form object
$Form__Kontakt = &$this->__getForm('Kontakt');
// set action attribute
$Form__Kontakt->setAttribute('action',$_SERVER['REQUEST_URI']);
// sign and format button
$Config = &$this->__getConfiguration('modules::kontakt4','language');
$Button = &$Form__Kontakt->getFormElementByName('KontaktSenden');
$Button->setAttribute('value',$Config->getValue($this->__Language,'form.button'));
$Button->setAttribute('style',$Config->getValue($this->__Language,'form.button.style'));
// insert image link for validator group
$Config = &$this->__getConfiguration('tools::form::taglib','formconfig');
$ValGroup = &$Form__Kontakt->getFormElementByName('FormValGroup');
$ValGroup->setPlaceHolder('WarnImage',$Config->getValue($this->__Language,'Contact.Warning.Image'));
$ValGroup->setPlaceHolder('WarnText',$Config->getValue($this->__Language,'Contact.Warning.Text'));
// get select field
$Recipients = & $Form__Kontakt->getFormElementByName('Empfaenger');
// load recipient list
$cM = &$this->__getServiceObject('modules::kontakt4::biz','contactManager');
$RecipientList = $cM->loadRecipients();
for($i = 0; $i < count($RecipientList); $i++){
$Recipients->addOption($RecipientList[$i]->get('Name'),$RecipientList[$i]->get('oID'));
}
// transform form
return $Form__Kontakt->transformForm();
}
}/config/tools/form/taglib/{CONTEXT}/{ENVIRONMENT}_formconfig.iniContact.Warning.Image$Config = &$this->__getConfiguration('tools::form::taglib','formconfig');
$ValGroup = &$Form__Kontakt->getFormElementByName('FormValGroup');
$ValGroup->setPlaceHolder('WarnImage',$Config->getValue($this->__Language,'Contact.Warning.Image'));
$ValGroup->setPlaceHolder('WarnText',$Config->getValue($this->__Language,'Contact.Warning.Text'));import('modules::kontakt4::biz','oFormData');
import('modules::kontakt4::biz','oRecipient');
import('modules::kontakt4::data','contactMapper');
import('tools::mail','mailSender');
import('tools::link','LinkHandler');
class contactManager extends APFObject {
function sendContactForm($oFD){
// get contactMapper
$cM = &$this->__getServiceObject('modules::kontakt4::data','contactMapper');
// get mail sender
$MAIL = &$this->__getAndInitServiceObject('tools::mail','mailSender','Kontaktformular');
// fill recipient
$Recipient = $cM->loadRecipientPerId($oFD->get('RecipientID'));
$MAIL->setRecipient($Recipient->get('Adresse'),$Recipient->get('Name'));
// add text
$Text = 'Dear sir or madame,';
$Text .= "\n\n";
$Text .= $oFD->get('SenderName').' (E-Mail: '.$oFD->get('SenderEMail')
.') has sent the following notice via the contact form:';
$Text .= "\n\n\n";
$Text .= $oFD->get('Text');
$MAIL->setContent($Text);
// add subject
$MAIL->setSubject($oFD->get('Subject'));
// send mail
$MAIL->sendMail();
// setup new mail
$MAIL->clearRecipients();
$MAIL->clearCCRecipients();
$MAIL->clearContent();
// set recipient
$MAIL->setRecipient($oFD->get('SenderEMail'),$oFD->get('SenderName'));
// add text
$Text = 'Dear sir or madame,';
$Text .= "\n\n";
$Text .= 'your request was forwared to "'.$Recipient->get('Name').'"
. We will send you an answer as soon as possible!';
$Text .= "\n\n";
$Text .= 'Your message:';
$Text .= "\n";
$Text .= $oFD->get('Text');
$MAIL->setContent($Text);
// add subject
$MAIL->setSubject($oFD->get('Subject'));
// send mail
$MAIL->sendMail();
// redirect to thanks page
$Link = LinkHandler::generateLink($_SERVER['REQUEST_URI'],array('pagepart' => 'meldung'));
$URLRewriting = Registry::retrieve('apf::core','URLRewriting');
if($URLRewriting != true){
$Link = str_replace('&','&',$Link);
// end if
}
header('Location: '.$Link);
}
function loadRecipients(){
$cM = & $this->__getServiceObject('modules::kontakt4::data','contactMapper');
return $cM->loadRecipients();
}
}import('modules::kontakt4::biz','oFormData');
import('modules::kontakt4::biz','oRecipient');
class contactMapper extends APFObject {
function loadRecipients(){
// read config
$Config = $this->__getConfiguration('modules::kontakt4','empfaenger');
// read relevant section
$Sections = $Config->getConfiguration();
// initialize return array
$Recipients = array();
// parse config and generate recipients
foreach($Config->getConfiguration() as $Key => $Values){
$Count = count($Recipients);
$Recipients[$Count] = new oRecipient();
// id
preg_match("/Kontakt ([0-9]+)/i",$Key,$Matches);
$Recipients[$Count]->set('oID',$Matches[1]);
// name
$Recipients[$Count]->set('Name',$Values['EmpfaengerName']);
// email
$Recipients[$Count]->set('Adresse',$Values['EmpfaengerAdresse']);
}
// return recipient list
return $Recipients;
}
function loadRecipientPerId($Id){
$Rec = $this->loadRecipients();
if(!is_array($Rec)){
return array();
}
else{
for($i = 0; $i < count($Rec); $i++){
if($Rec[$i]->get('oID') == $Id){
return $Rec[$i];
}
}
}
}
}[Kontakt ([0-9]+)]
EmpfaengerName = "([A-Za-z0-9,.-_ ]+)"
EmpfaengerAdresse = "([A-Za-z0-9.-_@]+)"