<?php 
/**
 * @package    Contact Form
 * @author     Arrowthemes https://arrowthemes.com
 * @copyright  Copyright (C) 2016 Arrowthemes. All rights reserved.
 * @license    http://www.gnu.org/licenses/gpl.html GNU/GPL
 */

defined ('_JEXEC') or die;

//Import plugin captcha
if($params->get("captcha") == 1) {
  JPluginHelper::importPlugin( 'captcha' );
  $dispatcher = JEventDispatcher::getInstance();
  $dispatcher->trigger('onInit','tm_contact_recaptcha');
}

//if error get value
if ( isset( $status ) && $status["check"] === false ) {
  $field1 = " value='" . $input->getString("field1", null) . "'";
  $field2 = " value='" . $input->getString("field2", null) . "'"; 
  $field3 = " value='" . $input->getString("field3", null) . "'";
  $field4 = " value='" . $input->getString("field4", null) . "'";
  $field5 = " value='" . $input->getString("field5", null) . "'";
  $message = htmlspecialchars($input->get("message",  "", "RAW"), ENT_QUOTES);
} else {
  $field1 = "";
  $field2 = "";
  $field3 = "";
  $field4 = "";
  $field5 = "";
  $message = "";
}

?>

<?php // load layout
  require JModuleHelper::getLayoutPath("mod_contact_form", "default_" . $params->get("layout"));   
?>

<?php
  //display messages for email send / email error
  if ( isset($status) && $status["check"] === true) {
	JFactory::getApplication()->enqueueMessage( $status["info"] );
	
  } elseif ( isset( $status ) && $status["check"] === false ) {
	JFactory::getApplication()->enqueueMessage( $status["info"], "error" );
  }

 //Check if captcha plugin enabled
  $captcha_enabled = JPluginHelper::isEnabled("captcha");
  if( $params->get("captcha") == 1 && $captcha_enabled === false ) {
	  JFactory::getApplication()->enqueueMessage( JText::_("JLIB_CAPTCHA_ERROR_PLUGIN_NOT_FOUND"), "error" );
  }
  
?> 