mirror of
https://github.com/e107inc/e107.git
synced 2025-08-06 06:38:00 +02:00
Issue #4372 Contact page code cleanup and 'layout' template added.
This commit is contained in:
111
contact.php
111
contact.php
@@ -25,34 +25,58 @@ class contact_front
|
||||
{
|
||||
$active = varset($pref['contact_visibility'], e_UC_PUBLIC);
|
||||
$contactInfo = trim(SITECONTACTINFO);
|
||||
$pref = e107::getPref();
|
||||
|
||||
if(!check_class($active) && empty($contactInfo) && empty($pref['contact_info']))
|
||||
{
|
||||
e107::redirect();
|
||||
}
|
||||
|
||||
if(isset($_POST['send-contactus']))
|
||||
{
|
||||
$this->processFormSubmit($sql);
|
||||
}
|
||||
|
||||
$form = '';
|
||||
$info = '';
|
||||
|
||||
if(deftrue('SITECONTACTINFO') || !empty($pref['contact_info']))
|
||||
{
|
||||
$info = $this->renderContactInfo();
|
||||
}
|
||||
if(check_class($active) && isset($pref['sitecontacts']) && $pref['sitecontacts'] != e_UC_NOBODY)
|
||||
{
|
||||
$form = $this->renderContactForm();
|
||||
}
|
||||
elseif($active == e_UC_MEMBER && ($pref['sitecontacts'] != e_UC_NOBODY))
|
||||
{
|
||||
$this->renderSignupRequired();
|
||||
}
|
||||
|
||||
if(!$LAYOUT = e107::getCoreTemplate('contact', 'layout'))
|
||||
{
|
||||
$LAYOUT = '{---CONTACT-INFO---} {---CONTACT-FORM---} ';
|
||||
}
|
||||
|
||||
echo str_replace(
|
||||
['{---CONTACT-FORM---}', '{---CONTACT-INFO---}'],
|
||||
[$form, $info],
|
||||
$LAYOUT
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $sql
|
||||
* @return array
|
||||
*/
|
||||
private function processFormSubmit()
|
||||
{
|
||||
$sql = e107::getDb();
|
||||
$sec_img = e107::getSecureImg();
|
||||
$tp = e107::getParser();
|
||||
$ns = e107::getRender();
|
||||
$pref = e107::getPref();
|
||||
|
||||
$CONTACT_FORM = varset($GLOBALS['CONTACT_FORM']);
|
||||
|
||||
if (empty($CONTACT_FORM))
|
||||
{
|
||||
/* if (file_exists(THEME."contact_template.php"))
|
||||
{
|
||||
require_once(THEME."contact_template.php");
|
||||
}
|
||||
else*/
|
||||
{
|
||||
$CONTACT_FORM = e107::getCoreTemplate('contact','form'); // require_once(e_THEME."templates/contact_template.php");
|
||||
}
|
||||
}
|
||||
|
||||
if(isset($_POST['send-contactus']))
|
||||
{
|
||||
$error = "";
|
||||
$ignore = false;
|
||||
|
||||
@@ -89,7 +113,7 @@ class contact_front
|
||||
$email_copy = !empty($_POST['email_copy']) ? 1 : 0;
|
||||
|
||||
// Check Image-Code
|
||||
if (isset($_POST['rand_num']) && !$sec_img->verify_code($_POST['rand_num'], $_POST['code_verify']))
|
||||
if(isset($_POST['rand_num']) && ($sec_img->invalidCode($_POST['rand_num'], $_POST['code_verify'])))
|
||||
{
|
||||
$error .= LANCONTACT_15 . "\\n";
|
||||
}
|
||||
@@ -112,7 +136,6 @@ class contact_front
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Check email address on remote server (if enabled). XXX Problematic!
|
||||
/*
|
||||
if ($pref['signup_remote_emailcheck'] && $error == '')
|
||||
@@ -146,7 +169,7 @@ class contact_front
|
||||
$body .= "<br /><br />
|
||||
<table class='table'>
|
||||
<tr>
|
||||
<td>IP:</td><td>".e107::getIPHandler()->getIP(TRUE)."</td></tr>";
|
||||
<td>IP:</td><td>" . e107::getIPHandler()->getIP(true) . "</td></tr>";
|
||||
|
||||
if(USER)
|
||||
{
|
||||
@@ -231,8 +254,7 @@ class contact_front
|
||||
);
|
||||
|
||||
|
||||
|
||||
$message = e107::getEmail()->sendEmail($send_to, $send_to_name, $eml, false) ? LANCONTACT_09 : LANCONTACT_10;
|
||||
$message = e107::getEmail()->sendEmail($send_to, $send_to_name, $eml) ? LANCONTACT_09 : LANCONTACT_10;
|
||||
|
||||
// $message = (sendemail($send_to,"[".SITENAME."] ".$subject, $body,$send_to_name,$sender,$sender_name)) ? LANCONTACT_09 : LANCONTACT_10;
|
||||
|
||||
@@ -244,54 +266,69 @@ class contact_front
|
||||
|
||||
|
||||
$ns->tablerender('', "<div class='alert alert-success'>" . $message . "</div>");
|
||||
require_once(FOOTERF);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
message_handler("P_ALERT", $error);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string html
|
||||
*/
|
||||
private function renderContactInfo()
|
||||
{
|
||||
|
||||
$contact_shortcodes = e107::getScBatch('contact');
|
||||
|
||||
if(deftrue('SITECONTACTINFO') || !empty($pref['contact_info']))
|
||||
{
|
||||
if(!isset($CONTACT_INFO))
|
||||
$CONTACT_INFO = varset($GLOBALS['CONTACT_INFO']);
|
||||
|
||||
if(empty($CONTACT_INFO))
|
||||
{
|
||||
$CONTACT_INFO = e107::getCoreTemplate('contact', 'info');
|
||||
}
|
||||
|
||||
|
||||
$contact_shortcodes->wrapper('contact/info');
|
||||
$text = $tp->parseTemplate($CONTACT_INFO, true, $contact_shortcodes);
|
||||
$ns->tablerender(LANCONTACT_01, $text,"contact-info");
|
||||
$text = e107::getParser()->parseTemplate($CONTACT_INFO, true, $contact_shortcodes);
|
||||
return e107::getRender()->tablerender(LANCONTACT_01, $text, "contact-info", true);
|
||||
|
||||
}
|
||||
|
||||
|
||||
if(check_class($active) && isset($pref['sitecontacts']) && $pref['sitecontacts'] != e_UC_NOBODY)
|
||||
private function renderContactForm()
|
||||
{
|
||||
|
||||
// Wrapper support
|
||||
$CONTACT_FORM = varset($GLOBALS['CONTACT_FORM']);
|
||||
|
||||
if(empty($CONTACT_FORM))
|
||||
{
|
||||
$CONTACT_FORM = e107::getCoreTemplate('contact', 'form'); // require_once(e_THEME."templates/contact_template.php");
|
||||
}
|
||||
|
||||
$contact_shortcodes = e107::getScBatch('contact');
|
||||
$contact_shortcodes->wrapper('contact/form');
|
||||
|
||||
$text = $tp->parseTemplate($CONTACT_FORM, true, $contact_shortcodes);
|
||||
$text = e107::getParser()->parseTemplate($CONTACT_FORM, true, $contact_shortcodes);
|
||||
|
||||
if(trim($text) != "")
|
||||
if(trim($text) !== '')
|
||||
{
|
||||
$ns->tablerender(LANCONTACT_02, $text, "contact-form");
|
||||
return e107::getRender()->tablerender(LANCONTACT_02, $text, "contact-form", true);
|
||||
}
|
||||
}
|
||||
elseif($active == e_UC_MEMBER && ($pref['sitecontacts'] != e_UC_NOBODY))
|
||||
|
||||
|
||||
private function renderSignupRequired()
|
||||
{
|
||||
|
||||
$srch = array("[", "]");
|
||||
$repl = array("<a class='alert-link' href='" . e_SIGNUP . "'>", "</a>");
|
||||
$message = LANCONTACT_16; // "You must be [registered] and signed-in to use this form.";
|
||||
|
||||
$ns->tablerender(LANCONTACT_02, "<div class='alert alert-info'>".str_replace($srch, $repl, $message)."</div>", "contact");
|
||||
}
|
||||
e107::getRender()->tablerender(LANCONTACT_02, "<div class='alert alert-info'>" . str_replace($srch, $repl, $message) . "</div>", "contact");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@@ -130,6 +130,14 @@ $CONTACT_TEMPLATE['form'] = "
|
||||
|
||||
</form>";
|
||||
|
||||
|
||||
// Set the layout and order of the info and form.
|
||||
$CONTACT_TEMPLATE['layout'] = '{---CONTACT-INFO---}
|
||||
{---CONTACT-FORM---}
|
||||
';
|
||||
|
||||
|
||||
|
||||
// Customize the email subject
|
||||
// Variables: CONTACT_SUBJECT and CONTACT_PERSON as well as any custom fields set in the form. )
|
||||
$CONTACT_TEMPLATE['email']['subject'] = "{CONTACT_SUBJECT}";
|
||||
@@ -137,3 +145,4 @@ $CONTACT_TEMPLATE['email']['subject'] = "{CONTACT_SUBJECT}";
|
||||
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user