Skip to content

Instantly share code, notes, and snippets.

@ProxiBlue
Created January 27, 2018 09:10
Show Gist options
  • Save ProxiBlue/bff88b184c9c0e44997ff6ae05468b01 to your computer and use it in GitHub Desktop.
Save ProxiBlue/bff88b184c9c0e44997ff6ae05468b01 to your computer and use it in GitHub Desktop.
ReCaptcha Email to a friend template with changes
<?php
/**
* Magento
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE_AFL.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@magentocommerce.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade Magento to newer
* versions in the future. If you wish to customize Magento for your
* needs please refer to http://www.magentocommerce.com for more information.
*
* @category design
* @package base_default
* @copyright Copyright (c) 2014 Magento Inc. (http://www.magentocommerce.com)
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
*/
/* @var $this Mage_Sendfriend_Block_Send */
/**
* Send to friend form
*
* @see Mage_Sendfriend_Block_Send
*/
?>
<script type="text/javascript">
//<![CDATA[
<?php if($recipients = $this->getFormData()->getData('recipients')): ?>
i=<?php echo count($recipients['name']) - 1; ?>;
var recipCount = <?php echo count($recipients['name']); ?>;
<?php else: ?>
i=0;
var recipCount = 1;
<?php endif; ?>
var maxRecip = <?php echo $this->getMaxRecipients() ?>;
function remove_recipient(i){
$('recipients_name'+i).up(2).remove();
recipCount--;
if(recipCount<maxRecip && maxRecip != 0) {
$('add_recipient_button').show();
$('max_recipient_message').hide();
}
return false;
}
function add_recipient(){
ul = $('recipients_options');
var li_mail = Element.extend(document.createElement("LI"));
li_mail.addClassName('fields additional-row');
li_mail.innerHTML = '<p><a href="delete_email" title="<?php echo $this->jsQuoteEscape($this->__('Remove Email')) ?>" onclick="remove_recipient('+i+'); return false" class="btn-remove"><?php echo $this->jsQuoteEscape($this->__('Remove Email')) ?>"<\/a><\/p>'
li_mail.innerHTML += '<div class="field"><label for="recipients_name'+i+'" class="required"><em>*<\/em><?php echo $this->jsQuoteEscape($this->__('Name:')) ?><\/label><div class="input-box"><input name="recipients[name][]" type="text" class="input-text required-entry" id="recipients_name'+i+'" /><\/div>';
li_mail.innerHTML += '<div class="field"><label for="recipients_email'+i+'" class="required"><em>*<\/em><?php echo $this->jsQuoteEscape($this->__('Email Address:')) ?><\/label><div class="input-box"><input name="recipients[email][]" value="" title="<?php echo $this->jsQuoteEscape($this->__('Email Address')) ?>" id="recipients_email'+i+'" type="text" class="input-text required-entry validate-email" /><\/div><\/div>';
i++;
recipCount++;
if(recipCount>=maxRecip && maxRecip != 0) {
$('add_recipient_button').hide();
$('max_recipient_message').show();
}
ul.appendChild(li_mail);
}
//]]>
</script>
<div class="send-friend">
<?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
<div class="page-title">
<h1><?php echo $this->__('Email to a Friend') ?></h1>
</div>
<form action="<?php echo $this->getSendUrl() ?>" method="post" id="product_sendtofriend_form">
<div class="fieldset">
<?php echo $this->getBlockHtml('formkey')?>
<h2 class="legend"><?php echo $this->__('Sender:') ?></h2>
<ul class="form-list" id="sender_options">
<li class="fields">
<div class="field">
<label for="sender_name" class="required"><em>*</em><?php echo $this->__('Name:') ?></label>
<div class="input-box">
<input name="sender[name]" value="<?php echo $this->escapeHtml($this->getUserName()) ?>" title="<?php echo $this->__('Name') ?>" id="sender_name" type="text" class="input-text required-entry" />
</div>
</div>
<div class="field">
<label for="sender_email" class="required"><em>*</em><?php echo $this->__('Email:') ?></label>
<div class="input-box">
<input name="sender[email]" value="<?php echo $this->escapeHtml($this->getEmail()) ?>" title="<?php echo $this->__('Email Address') ?>" id="sender_email" type="text" class="input-text required-entry validate-email" />
</div>
</div>
</li>
<li class="wide">
<label for="sender_message" class="required"><em>*</em><?php echo $this->__('Message:') ?></label>
<div class="input-box">
<textarea name="sender[message]" class="input-text required-entry" id="sender_message" cols="3" rows="3"><?php echo $this->escapeHtml($this->getMessage())?></textarea>
</div>
</li>
<?php echo $this->getChildHtml('recaptcha'); ?>
</ul>
</div>
<div class="fieldset">
<h2 class="legend"><?php echo $this->__('Recipient:') ?></h2>
<ul class="form-list" id="recipients_options">
<?php if($recipients = $this->getFormData()->getData('recipients')): ?>
<?php for($x = 0; $x < count($recipients['name']); $x++): ?>
<li class="fields <?php if($x > 0): ?>additional-row<?php endif;?>">
<?php if($x > 0): ?>
<p><a href="delete_email" title="<?php echo $this->jsQuoteEscape($this->__('Remove Email')) ?>" onclick="remove_recipient('<?php echo $x; ?>'); return false" class="btn-remove"><?php echo $this->jsQuoteEscape($this->__('Remove Email')) ?>"</a></p>
<?php endif;?>
<div class="field">
<label for="recipients_name" class="required"><em>*</em><?php echo $this->__('Name:') ?></label>
<div class="input-box">
<input name="recipients[name][]" type="text" class="input-text required-entry" id="recipients_name<?php echo $x; ?>" value="<?php echo $recipients['name'][$x]; ?>"/>
</div>
</div>
<div class="field">
<label for="recipients_email" class="required"><em>*</em><?php echo $this->__('Email Address:') ?></label>
<div class="input-box">
<input value="<?php echo $recipients['email'][$x]; ?>" name="recipients[email][]" title="<?php echo $this->__('Email Address') ?>" id="recipients_email<?php echo $x; ?>" type="text" class="input-text required-entry validate-email" />
</div>
</div>
</li>
<?php endfor; ?>
<?php else: ?>
<li class="fields">
<div class="field">
<label for="recipients_name" class="required"><em>*</em><?php echo $this->__('Name:') ?></label>
<div class="input-box">
<input name="recipients[name][]" type="text" class="input-text required-entry" id="recipients_name" />
</div>
</div>
<div class="field">
<label for="recipients_email" class="required"><em>*</em><?php echo $this->__('Email Address:') ?></label>
<div class="input-box">
<input name="recipients[email][]" value="" title="<?php echo $this->__('Email Address') ?>" id="recipients_email" type="text" class="input-text required-entry validate-email" />
</div>
</div>
</li>
<?php endif; ?>
</ul>
</div>
<div class="buttons-set">
<p class="back-link"><a href="#" onclick="history.back(); return false;"><small>&laquo; </small><?php echo $this->__('Back') ?></a></p>
<button type="submit" class="button<?php if (!$this->canSend()):?> disabled<?php endif ?>"<?php if (!$this->canSend()):?> disabled="disabled"<?php endif ?>><span><span><?php echo $this->__('Send Email') ?></span></span></button>
<div id="max_recipient_message" style="display:none;">
<?php if ($this->getMaxRecipients()): ?>
<p class="limit"><?php echo $this->__('Maximum %d email addresses allowed.', $this->getMaxRecipients()) ?></p>
<?php endif; ?>
</div>
<?php if (1 < $this->getMaxRecipients()): ?>
<p id="add_recipient_button">
<button type="button" onclick="add_recipient();" class="button"><span><span><?php echo $this->__('Add Recipient') ?></span></span></button>
</p>
<?php endif; ?>
</div>
</form>
<script type="text/javascript">
//<![CDATA[
var productSendtofriendForm = new VarienForm('product_sendtofriend_form');
productSendtofriendForm.submit = function() {
if(this.validator.validate()) {
this.form.submit();
}
}.bind(productSendtofriendForm);
//]]>
</script>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment