1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-02 04:40:44 +02:00

Issue #4372 - Enhancement: Contact page info. Requires database update.

This commit is contained in:
Cameron
2021-02-15 10:58:49 -08:00
parent 523fae8582
commit c94b1867a3
7 changed files with 450 additions and 300 deletions

View File

@@ -10,46 +10,43 @@
*
*/
require_once("class2.php");
//define('e_HANDLER', "e107_handlers/");
// security image may be disabled by removing the appropriate shortcodes from the template.
require_once(__DIR__."/class2.php");
class contact_front
{
function __construct()
{
$this->init();
}
function init()
{
$active = varset($pref['contact_visibility'], e_UC_PUBLIC);
$contactInfo = trim(SITECONTACTINFO);
if(!check_class($active) && empty($contactInfo))
if(!check_class($active) && empty($contactInfo) && empty($pref['contact_info']))
{
e107::getRedirect()->go(e_HTTP."index.php");
e107::redirect();
}
require_once(e_HANDLER."secure_img_handler.php");
$sec_img = new secure_image;
e107::lan('core','contact');
if(!defined('PAGE_NAME'))
{
define('PAGE_NAME', LANCONTACT_00); // FIX ME
}
e107::canonical('contact');
require_once(HEADERF);
$sec_img = e107::getSecureImg();
$tp = e107::getParser();
$ns = e107::getRender();
$pref = e107::getPref();
if (!vartrue($CONTACT_FORM))
$CONTACT_FORM = $GLOBALS['CONTACT_FORM'];
if (empty($CONTACT_FORM))
{
if (file_exists(THEME."contact_template.php"))
/* if (file_exists(THEME."contact_template.php"))
{
require_once(THEME."contact_template.php");
}
else
else*/
{
// Redirect Page if no contact-form or contact-info is available.
if(($pref['sitecontacts']== e_UC_NOBODY) && trim(SITECONTACTINFO) == "")
{
e107::getRedirect()->redirect(e_BASE."index.php");
exit;
}
$CONTACT_FORM = e107::getCoreTemplate('contact','form'); // require_once(e_THEME."templates/contact_template.php");
}
}
@@ -257,21 +254,23 @@ if(isset($_POST['send-contactus']))
}
if(SITECONTACTINFO)
if(deftrue('SITECONTACTINFO') || !empty($pref['contact_info']))
{
if(!isset($CONTACT_INFO))
{
$CONTACT_INFO = e107::getCoreTemplate('contact','info');
}
$text = $tp->parseTemplate($CONTACT_INFO, true, vartrue($contact_shortcodes));
$contact_shortcodes = e107::getScBatch('contact');
$contact_shortcodes->wrapper('contact/info');
$text = $tp->parseTemplate($CONTACT_INFO, true, $contact_shortcodes);
$ns->tablerender(LANCONTACT_01, $text,"contact-info");
}
if(check_class($active) && isset($pref['sitecontacts']) && $pref['sitecontacts'] != e_UC_NOBODY)
{
$contact_shortcodes = e107::getScBatch('contact');
// Wrapper support
$contact_shortcodes->wrapper('contact/form');
@@ -290,8 +289,17 @@ elseif($active == e_UC_MEMBER && ($pref['sitecontacts'] != e_UC_NOBODY))
$ns->tablerender(LANCONTACT_02, "<div class='alert alert-info'>".str_replace($srch, $repl, $message)."</div>", "contact");
}
}
}
e107::lan('core','contact');
e107::title(LANCONTACT_00);
e107::canonical('contact');
require_once(HEADERF);
new contact_front;
require_once(FOOTERF);

View File

@@ -38,9 +38,8 @@ e107::coreLan('mailout', true);
require_once (e_ADMIN."auth.php");
$e_userclass = e107::getUserClass();
require_once (e_HANDLER."user_extended_class.php");
require_once(e_HANDLER.'mailout_admin_class.php'); // Admin tasks handler
$ue = new e107_user_extended();
$ue = e107::getUserExt();
$core_pref = e107::getConfig();
if(!$core_pref->get('timezone'))
@@ -321,7 +320,7 @@ $text = "
<form method='post' action='".e_SELF."' autocomplete='off'>
<input type='hidden' name='e-token' value='".defset('e_TOKEN')."' />
<fieldset id='core-prefs-main'>
<legend>".PRFLAN_1."</legend>
<h4 class='caption'>".PRFLAN_53.SEP.PRFLAN_1."</h4>
<table class='table adminform'>
<colgroup>
<col class='col-label' />
@@ -423,7 +422,7 @@ $text .= "
// Email and Contact Information --------------
$text .= "<fieldset class='e-hideme' id='core-prefs-email'>
<legend>".PRFLAN_13."</legend>
<h4 class='caption'>".PRFLAN_53.SEP.PRFLAN_13."</h4>
<table class='table adminform'>
<colgroup>
<col class='col-label' />
@@ -492,8 +491,53 @@ $text .= "<fieldset class='e-hideme' id='core-prefs-email'>
<tr>
<td><label for='sitecontactinfo'>".PRFLAN_162."</label>".$frm->help(PRFLAN_163)."</td>
<td>
".$frm->textarea('sitecontactinfo', $pref['sitecontactinfo'], 6, 59, array('size'=>'xxlarge'))."
<td>";
if(!empty($pref['sitecontactinfo']))
{
$text .= $frm->textarea('sitecontactinfo', $pref['sitecontactinfo'], 6, 59, array('size'=>'xxlarge'));
}
else
{
$text .= "<table class='table table-bordered table-striped' style='margin:0; max-width:690px'>
<colgroup>
<col style='width:150px' />
<col />
</colgroup>
<tr>";
$text .= "<td>Company</td>
<td>".$frm->text('contact_info[company]', varset($pref['contact_info']['company']), 200, ['size'=>'block-level', 'placeholder'=>'My Company'])."</td>
</tr>";
$text .= "<td>Address</td>
<td>".$frm->textarea('contact_info[address]', varset($pref['contact_info']['address']), 2, 80, ['size'=>'block-level', 'placeholder'=>'123 address st. city, state, zip/postal, country'])."</td>
</tr>";
$contactFields = [
'phone1' => ['label'=>'Phone', 'placeholder'=>'+1-555-555-5555'],
'phone2' => ['label'=>'Phone', 'placeholder'=>'+1-444-444-4444'],
'phone3' => ['label'=>'Phone', 'placeholder'=>'+1-333-333-3333'],
'fax' => ['label'=>'Fax', 'placeholder'=>'+1-555-555-5555'],
'email1' => ['label'=>LAN_EMAIL, 'placeholder'=>'info@mycompany.com'],
'email2' => ['label'=>LAN_EMAIL, 'placeholder'=>'sales@mycompany.com']
];
foreach($contactFields as $type => $var)
{
$text .= "<td>".$var['label']."</td>
<td>".$frm->text('contact_info['.$type.']', varset($pref['contact_info'][$type]), 200, ['size'=>'block-level', 'placeholder'=>varset($var['placeholder'])])."</td>
</tr>
";
}
$text .= "</table>";
}
$text .= "
</td>
</tr>
<tr>
@@ -544,7 +588,7 @@ $text .= "<fieldset class='e-hideme' id='core-prefs-email'>
// GDPR Settings -----------------------------
$text .= "
<fieldset class='e-hideme' id='core-prefs-gdpr'>
<legend>".PRFLAN_277."</legend>
<h4 class='caption'>".PRFLAN_53.SEP.PRFLAN_277."</h4>
<table class='table adminform'>
<colgroup>
<col class='col-label' />
@@ -580,7 +624,7 @@ $text .= "
$text .= "
<fieldset class='e-hideme' id='core-prefs-display'>
<legend>".PRFLAN_13."</legend>
<h4 class='caption'>".PRFLAN_53.SEP.PRFLAN_13."</h4>
<table class='table adminform'>
<colgroup>
<col class='col-label' />
@@ -630,7 +674,7 @@ $text .= "
*/
$text .= "
<fieldset class='e-hideme' id='core-prefs-admindisp'>
<legend>".PRFLAN_77."</legend>
<h4 class='caption'>".PRFLAN_53.SEP.PRFLAN_77."</h4>
<table class='table adminform'>
<colgroup>
<col class='col-label' />
@@ -703,7 +747,7 @@ $date4 = $tp->toDate(time(),"input");
$text .= "
<fieldset class='e-hideme' id='core-prefs-date'>
<legend>".PRFLAN_21."</legend>
<h4 class='caption'>".PRFLAN_53.SEP.PRFLAN_21."</h4>
<table class='table adminform'>
<colgroup>
<col class='col-label' />
@@ -817,7 +861,7 @@ $elements = array(1=> PRFLAN_259, 2=> PRFLAN_260, 0=>LAN_DISABLED);
$text .= "
<fieldset class='e-hideme' id='core-prefs-registration'>
<legend>".PRFLAN_28."</legend>
<h4 class='caption'>".PRFLAN_53.SEP.PRFLAN_28."</h4>
<table class='table adminform'>
<colgroup>
<col class='col-label' />
@@ -962,7 +1006,7 @@ $prefOptionPassword = (isset($pref['signup_option_password'])) ? $pref['signup_o
$text .= "
<fieldset class='e-hideme' id='core-prefs-signup'>
<legend>".PRFLAN_19."</legend>
<h4 class='caption'>".PRFLAN_53.SEP.PRFLAN_19."</h4>
<table class='table adminform'>
<colgroup>
<col class='col-label' />
@@ -1166,7 +1210,7 @@ if ($savePrefs) $core_pref->setPref($pref)->save(false, true);
$text .= "
<fieldset class='e-hideme' id='core-prefs-textpost'>
<legend>".PRFLAN_101."</legend>
<h4 class='caption'>".PRFLAN_53.SEP.PRFLAN_286."</h4>
<table class='table adminform'>
<colgroup>
<col class='col-label' />
@@ -1332,7 +1376,7 @@ $hasGD = extension_loaded("gd");
$text .= "
<fieldset class='e-hideme' id='core-prefs-security'>
<legend>".PRFLAN_47."</legend>
<h4 class='caption'>".PRFLAN_53.SEP.PRFLAN_47."</h4>
<table class='table adminform'>
<colgroup>
<col class='col-label' />
@@ -1575,7 +1619,7 @@ $text .= "
$text .= "
<fieldset class='e-hideme' id='core-prefs-comments'>
<legend>".PRFLAN_87."</legend>
<h4 class='caption'>".PRFLAN_53.SEP.PRFLAN_87."</h4>
<table class='table adminform'>
<colgroup>
<col class='col-label' />
@@ -1646,7 +1690,7 @@ $text .= "
</tbody>
</table>
<legend>".PRFLAN_209."</legend>
<h4 class='caption'>".PRFLAN_209."</h4>
<table class='table adminform'>
<colgroup>
<col class='col-label' />
@@ -1679,7 +1723,7 @@ $text .= "
$text .= "
<fieldset class='e-hideme' id='core-prefs-uploads'>
<legend>".PRFLAN_238."</legend>";
<h4 class='caption'>".PRFLAN_53.SEP.PRFLAN_238."</h4>";
$upload_max_filesize = ini_get('upload_max_filesize');
@@ -1764,7 +1808,8 @@ $text .= "
</fieldset>";
$text .= "<fieldset class='e-hideme' id='core-prefs-javascript'>";
$text .= "<fieldset class='e-hideme' id='core-prefs-javascript'>
<h4 class='caption'>".PRFLAN_53.SEP.PRFLAN_257 . "</h4>";
if(E107_DEBUG_LEVEL > 0)
{
@@ -1772,7 +1817,7 @@ if(E107_DEBUG_LEVEL > 0)
// Javascript Control
$text .= "
<legend>" . PRFLAN_242 . "</legend>
<h4>".PRFLAN_242 . "</h4>
<table class='table adminform'>
<colgroup>
<col class='col-label' />
@@ -1972,7 +2017,7 @@ $text .= "</fieldset>";
$text .= "
<fieldset class='e-hideme' id='core-prefs-advanced'>
<legend>".PRFLAN_149."</legend>
<h4 class='caption'>".PRFLAN_53.SEP.PRFLAN_149."</h4>
<table class='table adminform'>
<colgroup>
<col class='col-label' />
@@ -2043,8 +2088,8 @@ $text .= "
</form>
</div>
";
$ns->tablerender(PRFLAN_53, $mes->render().$text);
//PRFLAN_53
$ns->tablerender(null, $mes->render().$text);
require_once(e_ADMIN."footer.php");
@@ -2107,7 +2152,7 @@ function prefs_adminmenu()
$var['core-prefs-admindisp']['text'] = PRFLAN_77;
$var['core-prefs-admindisp']['image_src'] = 'fa-dashboard.glyph';
$var['core-prefs-textpost']['text'] = PRFLAN_101;
$var['core-prefs-textpost']['text'] = PRFLAN_286;
$var['core-prefs-textpost']['image_src'] = 'fa-filter.glyph';
$var['core-prefs-security']['text'] = PRFLAN_47;

View File

@@ -103,6 +103,71 @@ class contact_shortcodes extends e_shortcode
return "<input type='text' id='contactName' title='".LANCONTACT_17."' name='author_name' required='required' size='30' ".$placeholder." class='".$class."' value=\"".$value."\" />";
}
function sc_contact_map($parm=null)
{
$pref = e107::getPref('contact_info');
if(empty($pref['address']))
{
return null;
}
$address = trim($pref['address']);
$zoom = varset($parm['zoom'], 'street');
$zoomOpts = [
'street' => 17,
'district' => 14,
'city' => 12,
];
$zoom = (int) varset($zoomOpts[$zoom],$zoom);
// &z='.$zoom.'
return '<iframe class="sc-contact-map" src="https://maps.google.com/maps?q='.$address.'&output=embed&z='.$zoom.'"></iframe>';
}
function sc_contact_info($parm=null)
{
$ipref = e107::getPref('contact_info');
$type = varset($parm['type']);
if(empty($type) || empty($ipref[$type]))
{
return null;
}
$tp = e107::getParser();
$ret = '';
switch($type)
{
case "company":
$ret = $tp->toHTML($ipref[$type], true, 'TITLE');
break;
case 'email1':
case 'email2':
case 'phone1':
case 'phone2':
case 'phone3':
case 'fax':
$ret = $tp->obfuscate($ipref[$type]);
break;
default:
$ret = $tp->toHTML($ipref[$type], true, 'BODY');
// code to be executed if n is different from all labels;
}
return $ret;
}
/* example {CONTACT_EMAIL} */

View File

@@ -12,11 +12,40 @@
if (!defined('e107_INIT')) { exit; }
$CONTACT_WRAPPER['info']['CONTACT_INFO'] = "<div>{---}</div>";
$CONTACT_WRAPPER['info']['CONTACT_INFO: type=company'] = "<h4>{---}</h4>";
$CONTACT_WRAPPER['info']['CONTACT_INFO: type=address'] = "<address>{GLYPH=fa-map-marker} {---}</address>";
$CONTACT_WRAPPER['info']['CONTACT_INFO: type=email1'] = "<div>{GLYPH=fa-envelope} {---}</div>";
$CONTACT_WRAPPER['info']['CONTACT_INFO: type=email2'] = "<div>{GLYPH=fa-envelope} {---}</div>";
$CONTACT_WRAPPER['info']['CONTACT_INFO: type=phone1'] = "<div>{GLYPH=fas-phone-alt} {---}</div>";
$CONTACT_WRAPPER['info']['CONTACT_INFO: type=phone2'] = "<div>{GLYPH=fas-phone-alt} {---}</div>";
$CONTACT_WRAPPER['info']['CONTACT_INFO: type=phone3'] = "<div>{GLYPH=fas-phone-alt} {---}</div>";
$CONTACT_WRAPPER['info']['CONTACT_INFO: type=fax'] = "<div>{GLYPH=fa-fax} {---}</div>";
$CONTACT_TEMPLATE['info'] = "
<div id='contactInfo' >
<address>{SITECONTACTINFO}</address>
<!-- Backward Compat. Contact Info -->
{SITECONTACTINFO}
<!-- New Contact Info -->
{CONTACT_INFO: type=company}
<div class='row'>
<div class ='col-md-6 col-lg-4 h=100'>
{CONTACT_INFO: type=address}
<div class='form-group'>
{CONTACT_INFO: type=phone1}
{CONTACT_INFO: type=phone2}
{CONTACT_INFO: type=phone3}
{CONTACT_INFO: type=fax}
</div>
{CONTACT_INFO: type=email1}
{CONTACT_INFO: type=email2}
</div>
<div class ='col-md-6 col-lg-8 h=100'>
{CONTACT_MAP: zoom=city}
</div>
</div>
</div>
";

View File

@@ -33,6 +33,8 @@
<core name="comments_moderate">247</core>
<core name="comments_sort">desc</core>
<core name="compress_output">0</core>
<core name="contact_info"><![CDATA[array (
)]]></core>
<core name="contact_emailcopy">0</core>
<core name="contact_visibility">0</core>
<core name="contact_filter"></core>

View File

@@ -61,7 +61,7 @@ define("PRFLAN_59", "ticking will restrict all areas apart from the front page a
define("PRFLAN_60", "Use SSL only");
define("PRFLAN_61", "Redirect all traffic through SSL (https)");
define("PRFLAN_76", "Display CAPTCHA on signup page.");
define("PRFLAN_77", "Admin Display Options ");
define("PRFLAN_77", "Admin Display");
define("PRFLAN_78", "Leave blank to disable");
// define("PRFLAN_80", "Click here to view");
define("PRFLAN_81", "Display CAPTCHA on login page.");
@@ -99,7 +99,7 @@ define("PRFLAN_95", "Display plugins info:");
define("PRFLAN_96", "Will display info on all admin pages for each plugin supporting this type of feature");
define("PRFLAN_97", "Unique 'Plugins info' menu:");
define("PRFLAN_98", "If disabled, each plugin will display its own info in an individual menu. If enabled all info will be displayed in one menu.");
define("PRFLAN_101", "Text Rendering");
// define("PRFLAN_101", "Text Rendering");
define("PRFLAN_102", "Replace clickable URLs");
define("PRFLAN_103", "If ticked, and 'Make Clickable' (above) is also ticked, posted URLs or Email addresses are displayed as a hyperlink using text from the textboxes below. This keeps very long URLs/Emails from breaking layout.");
define("PRFLAN_104", "URL replacement text");
@@ -307,4 +307,4 @@ define("PRFLAN_282", "Session Save Method");
define("PRFLAN_283", "Display navigation-bar labels");
define("PRFLAN_284", "Collapse navigation side-bar by default");
define("PRFLAN_285", "Display field help tips");
define("PRFLAN_286", "Content Filters");

View File

@@ -382,6 +382,7 @@ cursor: pointer;
#uiAlert .alert { z-index:10000; box-shadow:1px 4px 5px rgba(0,0,0,0.4) }
#uiAlert.notifications { top: 48%; left: 0; width: 100%; }
#contactInfo iframe.sc-contact-map { width:100%; min-height:195px }
#login-template { max-width: 330px; margin-right: auto; margin-left: auto; }