Skip to content

Commit

Permalink
[com_contact] - moved the captchaEnabled var from default to view (#1…
Browse files Browse the repository at this point in the history
…1964)

* [com_contact] - moved the captchaEnabled var out of the default.php file to the view.html.php file

moved the captchaEnabled var out of the default.php file to the view.html.php file.

* moved captchaEnabled to the view

moved captchaEnabled to the view

* missed var  declarationi/initialization

missed var   $captchaSet  declarationi/initialization
  • Loading branch information
alikon authored and wilsonge committed Sep 18, 2016
1 parent 6836352 commit d88cb23
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
14 changes: 1 addition & 13 deletions components/com_contact/views/contact/tmpl/default_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,11 @@
JHtml::_('behavior.keepalive');
JHtml::_('behavior.formvalidator');

$captchaEnabled = false;

$captchaSet = $this->params->get('captcha', JFactory::getApplication()->get('captcha', '0'));

foreach (JPluginHelper::getPlugin('captcha') as $plugin)
{
if ($captchaSet === $plugin->name)
{
$captchaEnabled = true;
break;
}
}
?>
<div class="contact-form">
<form id="contact-form" action="<?php echo JRoute::_('index.php'); ?>" method="post" class="form-validate form-horizontal well">
<?php foreach ($this->form->getFieldsets() as $fieldset): ?>
<?php if ($fieldset->name === 'captcha' && !$captchaEnabled) : ?>
<?php if ($fieldset->name === 'captcha' && !$this->captchaEnabled) : ?>
<?php continue; ?>
<?php endif; ?>
<?php $fields = $this->form->getFieldset($fieldset->name); ?>
Expand Down
21 changes: 20 additions & 1 deletion components/com_contact/views/contact/view.html.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,14 @@ class ContactViewContact extends JViewLegacy
*/
protected $return_page;

/**
* Should we show a captcha form for the submission of the contact request?
*
* @var bool
* @since __DEPLOY_VERSION__
*/
protected $captchaEnabled = false;

/**
* Execute and display a template script.
*
Expand Down Expand Up @@ -288,8 +296,19 @@ public function display($tpl = null)

$model = $this->getModel();
$model->hit();
$this->_prepareDocument();

$captchaSet = $params->get('captcha', JFactory::getApplication()->get('captcha', '0'));

foreach (JPluginHelper::getPlugin('captcha') as $plugin)
{
if ($captchaSet === $plugin->name)
{
$this->captchaEnabled = true;
break;
}
}

$this->_prepareDocument();
return parent::display($tpl);
}

Expand Down

0 comments on commit d88cb23

Please sign in to comment.