Source for file ContactForm.class.php
Documentation is available at ContactForm.class.php
* For including this file you have to define the constant "CLASSPATH".
* Because every include in the framework depends on the CLASSPATH definition.
* The CLASSPATH means the relative path to the folder that contains the
echo "<h3>You have to define the constant CLASSPATH!</h3>\n";
echo "Example: define( 'CLASSPATH', '../path/to/classes/' );\n";
* Including the basic class to define html forms.
require_once( CLASSPATH. "forms/HTMLForm.class.php" );
* Including a set of regular expressions defined in contants.
require_once( CLASSPATH. "RegExpConstants.inc.php" );
* Including a set of regular expressions defined in contants.
require_once( CLASSPATH. "communication/EMail.class.php" );
* A class to generate contact forms. After submit there will be generate a
* plaintext email to a recipient.
* You also can use this class for an object of an e-mail, with all its
* If you add an e-mail address as target, you should know that you can do it in
* two different ways. You can only declare a plain e-mail address such as
* "nobody@nowhere.no" or you can additionally declare some Information such as
* name of the receiver. In this case you have to enclose the e-mail address
* in brackets like "<>". The full example is
* "\"Firstname Surname\" <nobody@nowhere.no>".
* @author Daniel Plücken <daniel@debakel.net>
* @license http://www.gnu.org/copyleft/lesser.html
* GNU Lesser General Public License
* @copyright Copyright (C) 2003 Daniel Plücken <daniel@debakel.net>
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General
* Public License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307 USA
* Reference to the email-object which should be send.
* @author Daniel Plücken <daniel@debakel.net>
* @param string $onSubmitOrder
* @param string $targetFile
$this->HTMLForm( $name, $onSubmitOrder, $targetFile, $method );
* Returns the stored email.
* @author Daniel Plücken <daniel@debakel.net>
{ return $this->email_obj->getTargetEmail(); }
* Stores the email where the message should be send.
* @author Daniel Plücken <daniel@debakel.net>
{ $this->email_obj->setTargetEmail( $string ); }
* Adds an email to the array of emails where the message should be send in
* @author Daniel Plücken <daniel@debakel.net>
{ $this->email_obj->addTargetEmailCopy( $string ); }
* Stores the emails where the message should be send in copy.
* @author Daniel Plücken <daniel@debakel.net>
{ $this->email_obj->setTargetEmailCopyArray( $array ); }
* Adds an email to the array of emails where the message should be send in
* @author Daniel Plücken <daniel@debakel.net>
{ $this->email_obj->addTargetEmailBlindCopy( $string ); }
* Stores the emails where the message should be send in blind copy.
* @author Daniel Plücken <daniel@debakel.net>
{ $this->email_obj->setTargetEmailBlindCopyArray( $array ); }
* Sends the email with values of the form to the addressee stored in
* @author Daniel Plücken <daniel@debakel.net>
* @param string $sender_email
function send( $sender_email, $subject, $content = "" )
{ return $this->email_obj->send( $sender_email, $subject, $content ); }
* Generates the sourcecode to build this object and returns it.
* @author Daniel Plücken <daniel@debakel.net>
if( !empty( $this->layoutTable ) )
$out = $this->layoutTable->getPHPSource(). "\n\n";
$out .= $this->formItems[$i]->getPHPSource(). "\n\n";
$out .= "\x24formname = \"". $this->getName(). "\";\n";
$out .= !empty( $this->getSubmitOrder() )
? "\x24onSubmitOrder = \"".$this->getSubmitOrder()."\";\n"
$out .= !empty( $this->getTargetFile() )
? "\x24targetFile = \"".$this->getTargetFile()."\";\n"
$out .= !empty( $this->getMethod() )
? "\x24method = \"".$this->getMethod()."\";\n"
$out .= "\x24form = new ContactForm(\n"
* Returns a generated string based on the Attributes of this HTML-Object.
* @author Daniel Plücken <daniel@debakel.net>
* @param HTMLTable $obj_ref A reference of a table by dint of the form
* should be formatted. The form items will be
* placed in the table where the string "[item]"
* @param boolean $php_code Is this parameter true, the form will be
* returned as the source-php-code of this
case "resetsubmitbutton":
$tmp = $this->formItems[$i]->getNameOfSubmitButton();
$tmpItNa[] = $this->formItems[$i]->getName();
$out .= "if( !empty( \x24_". strtoupper( $param[2] )
$out .= " \x24mailbody = \"\";\n";
$out .= " \x24date = date( \"d.m.Y\", mktime( 0, 0, 0, "
. "date( \"m\" ), date( \"d\" ), date( \"Y\" ) ) );\n";
$out .= " \x24ip = getenv( \"REMOTE_ADDR\" );\n";
$out .= " \x24host = gethostbyaddr( \x24ip );\n\n";
$out .= " \x24mailbody .= \"IP: \".\x24host.\" "
. "Datum:\".\x24date.\"\\n\";\n\n";
for( $i = 0; $i < count( $tmpItNa ); $i++ )
$out .= " if( !empty( \x24_". strtoupper( $param[2] )
. "['". $tmpItNa[$i]. "'] ) )\n";
::firstToUpper( $tmpItNa[$i] ). ": \""
. "['". $tmpItNa[$i]. "'].\"\\n\";\n";
$out .= "\n \x24receiver = \"". $this->targetEmail. "\";\n";
$out .= " \x24subject = \"". $this->subject. "\";\n\n";
$out .= " \x24res = mail( \x24receiver, "
$out .= " if( \x24res )\n";
$out .= " { # eMail erfolgreich versendet\n";
$out .= " Vielen Dank für Ihre Mitteilung.<br>\n";
$out .= " Wir werden uns umgehend bei Ihnen melden.\n";
$out .= " } # ENDE eMail erfolgreich versendet\n";
$out .= " { # falls eMail nicht versendet werden konnte\n";
$out .= " Leider ist ein übertragungsfehler beim "
. "versenden Ihrer Mitteilung aufgetreten.<br>\n";
$out .= " Bitte versuchen Sie es erneut.<br><br>\n";
$out .= " <a href=\"javascript:document.history.back();\">"
$out .= " } # ENDE falls eMail nicht versendet werden konnte\n";
$out .= parent::get( $param[0], $param[1], $param[2] );
} // End of class ContactForm
|