From 8501ec106746fc5656cd06fd9421b7a311da9da8 Mon Sep 17 00:00:00 2001 From: aFolletete Date: Mon, 14 Nov 2011 16:18:58 +0000 Subject: [PATCH] // revert send to friend module --- modules/sendtoafriend/sendtoafriend.css | 143 ++++++++++++++++-------- modules/sendtoafriend/sendtoafriend.php | 119 +++++--------------- modules/sendtoafriend/sendtoafriend.tpl | 65 ++++++----- 3 files changed, 161 insertions(+), 166 deletions(-) diff --git a/modules/sendtoafriend/sendtoafriend.css b/modules/sendtoafriend/sendtoafriend.css index ac69a4767..13bad9571 100644 --- a/modules/sendtoafriend/sendtoafriend.css +++ b/modules/sendtoafriend/sendtoafriend.css @@ -1,46 +1,99 @@ -/* ************************************************************************************************ - PAGE SEND TO FRIEND -************************************************************************************************ */ -#sendfriendpage form.std fieldset { - margin:0 0 20px 0; - padding: 10px 15px; - background: none repeat scroll 0 0 #eee -} - -#sendfriendpage .product {} -#sendfriendpage .product .img_link {float:left} -#sendfriendpage .product .img_link img { - margin:0 10px 0 0; - border:1px solid #ccc; -} -#sendfriendpage .product .product_desc { - float:left; - width:200px; - font-weight:bold; - font-size:12px; - color:#000; -} - -#sendfriendpage #send_friend_form_content {margin-top:40px} -#sendfriendpage #send_friend_form_content .text { - padding-bottom: 10px -} -#sendfriendpage #send_friend_form_content .text label { - display: inline-block; - padding: 6px 15px; - width: 180px; - font-size: 12px; - text-align: right -} -#sendfriendpage #send_friend_form_content .text input { - padding: 0 5px; - height: 22px; - width: 260px; - border: 1px solid #ccc; - font-size: 12px -} -#sendfriendpage #send_friend_form_content .submit { - margin:0 20px 0 0; - padding:5px 0; - text-align:right +#fancybox-wrap {width:585px !important} +#fancybox-content { + width:585px !important; + border-width:0 !important +} + +#send_friend_form { + width:585px; + color: #333; + text-align: left; + background-color: #fff +} +#send_friend_form .title { + padding:10px; + font-size: 13px; + color: #fff; + text-transform: uppercase; + background: #333 +} + +#send_friend_form .product {padding:15px} +#send_friend_form .product img { + float:left; + border: 1px solid #ccc; +} +#send_friend_form .product .product_desc { + float:left; + margin-left:15px; + width:300px; + line-height:18px; + color:#666 +} +#send_friend_form .product .product_desc .product_name { + padding-bottom:5px; + font-size:13px; + color:#000 +} + +.send_friend_form_content { + padding:15px; + background:#f8f8f8 +} +.send_friend_form_content .intro_form { + padding-bottom: 10px; + font-weight: bold; + font-size: 12px +} + + +#send_friend_form .form_container { + clear:both; + margin-top:20px +} +#send_friend_form p.text { + margin-bottom:0; + padding-bottom:0 +} +#send_friend_form p.text label, #send_friend_form p.textarea label { + display: block; + margin:12px 0 4px 0; + font-weight: bold; + font-size: 12px; +} +#send_friend_form p.text input { + padding: 0 5px; + height: 28px; + width: 540px; + border: 1px solid #ccc; + background: url(../img/bg_input.png) repeat-x scroll 0 0 #fff; +} + +#send_friend_form .submit { + padding:0; + font-size:13px; + text-align:right +} +#send_friend_form button { + cursor: pointer; + cursor: pointer; + display: inline-block; + padding: 4px 7px 3px 7px; + border: 1px solid #CC9900; + border-radius: 3px 3px 3px 3px; + font-weight: bold; + color: #000; + background: url(../img/bg_bt.gif) repeat-x scroll 0 0 #F4B61B +} +#send_friend_form .submit .txt_required { + float:left; + font-size:12px; + font-style:italic; + color:#666 +} +#send_friend_form_error { + color:red; + font-size:13px; + text-align:left; + display:hidden; } \ No newline at end of file diff --git a/modules/sendtoafriend/sendtoafriend.php b/modules/sendtoafriend/sendtoafriend.php index 4608962b1..2900c8c23 100644 --- a/modules/sendtoafriend/sendtoafriend.php +++ b/modules/sendtoafriend/sendtoafriend.php @@ -20,7 +20,7 @@ * * @author PrestaShop SA * @copyright 2007-2011 PrestaShop SA -* @version Release: $Revision: 8005 $ +* @version Release: $Revision: 7040 $ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA */ @@ -30,13 +30,17 @@ if (!defined('_PS_VERSION_')) class sendToAFriend extends Module { + private $_html = ''; + private $_postErrors = array(); + function __construct($dontTranslate = false) - { - $this->name = 'sendtoafriend'; - $this->version = '1.3'; + { + $this->name = 'sendtoafriend'; + $this->version = '1.2'; $this->author = 'PrestaShop'; - $this->tab = 'front_office_features'; + $this->tab = 'front_office_features'; $this->need_instance = 0; + $this->secure_key = Tools::encrypt($this->name); parent::__construct(); @@ -44,101 +48,40 @@ class sendToAFriend extends Module { $this->displayName = $this->l('Send to a Friend module'); $this->description = $this->l('Allows customers to send a product link to a friend.'); - } + } } - function install() + public function install() { - return (parent::install() AND $this->registerHook('extraLeft') && $this->registerHook('header')); - } - - public function hookHeader() - { - $this->context->controller->addCSS(($this->_path).'sendtoafriend.css', 'all'); + return (parent::install() AND $this->registerHook('extraLeft') + AND $this->registerHook('header')); } - function hookExtraLeft($params) + public function uninstall() { - $this->context->smarty->assign('this_path', $this->_path); - return $this->display(__FILE__, 'product_page.tpl'); - } - - public function displayPageForm() - { - if (!$this->active) - Tools::display404Error(); - - include(dirname(__FILE__).'/../../header.php'); - echo $this->displayFrontForm(); - include(dirname(__FILE__).'/../../footer.php'); + return (parent::uninstall() AND $this->unregisterHook('header') AND $this->unregisterHook('extraLeft')); } - public function displayFrontForm() + public function hookExtraLeft($params) { - $error = false; - $confirm = false; + /* Product informations */ + $product = new Product((int)Tools::getValue('id_product'), false, $this->context->language->id); + $productLink = $this->context->link->getProductLink($product); + $image = Product::getCover((int)($_GET['id_product'])); - if (isset($_POST['submitAddtoafriend'])) - { - /* Product informations */ - $product = new Product((int)Tools::getValue('id_product'), false, (int)$this->context->cookie->id_lang); - $productLink = $this->context->link->getProductLink($product); - /* Fields verifications */ - if (empty($_POST['email']) OR empty($_POST['name'])) - $error = $this->l('You must fill in all fields.'); - elseif (empty($_POST['email']) OR !Validate::isEmail($_POST['email'])) - $error = $this->l('The e-mail given is invalid.'); - elseif (!Validate::isName($_POST['name'])) - $error = $this->l('The name given is invalid.'); - elseif (!isset($_GET['id_product']) OR !is_numeric($_GET['id_product'])) - $error = $this->l('An error occurred during the process.'); - else - { - /* Email generation */ - $subject = ($this->context->cookie->customer_firstname ? $this->context->cookie->customer_firstname.' '.$this->context->cookie->customer_lastname : $this->l('A friend')).' '.$this->l('sent you a link to').' '.$product->name; - $templateVars = array( - '{product}' => $product->name, - '{product_link}' => $productLink, - '{customer}' => ($this->context->cookie->customer_firstname ? $this->context->cookie->customer_firstname.' '.$this->context->cookie->customer_lastname : $this->l('A friend')), - '{name}' => Tools::safeOutput($_POST['name']) - ); - - /* Email sending */ - if (!Mail::Send((int)$this->context->cookie->id_lang, 'send_to_a_friend', Mail::l('A friend sent you a link to').' '.$product->name, $templateVars, $_POST['email'], NULL, ($this->context->cookie->email ? $this->context->cookie->email : NULL), ($this->context->cookie->customer_firstname ? $this->context->cookie->customer_firstname.' '.$this->context->cookie->customer_lastname : NULL), NULL, NULL, dirname(__FILE__).'/mails/')) - $error = $this->l('An error occurred during the process.'); - else - Tools::redirect(_MODULE_DIR_.'/'.$this->name.'/sendtoafriend-form.php?id_product='.(int)$product->id.'&submited'); - } - } - else - { - /* Product informations */ - $product = new Product((int)Tools::getValue('id_product'), false, (int)$this->context->cookie->id_lang); - $productLink = $this->context->link->getProductLink($product); - } - - /* Image */ - $images = $product->getImages((int)$this->context->cookie->id_lang); - foreach ($images AS $k => $image) - if ($image['cover']) - { - $cover['id_image'] = (int)$product->id.'-'.(int)$image['id_image']; - $cover['legend'] = $image['legend']; - } - - if (!isset($cover)) - $cover = array('id_image' => Language::getIsoById((int)$this->context->cookie->id_lang).'-default', 'legend' => 'No picture'); - - $this->context->smarty->assign(array( - 'cover' => $cover, - 'errors' => $error, - 'confirm' => $confirm, - 'product' => $product, - 'productLink' => $productLink + Context::getContext()->smarty->assign(array( + 'stf_id_product' => (int)Tools::getValue('id_product'), + 'stf_product_link' => $productLink, + 'stf_product_cover' => (int)Tools::getValue('id_product').'-'.(int)$image['id_image'], + 'stf_secure_key' => $this->secure_key, )); - return $this->display(__FILE__, 'sendtoafriend.tpl'); + return $this->display(__FILE__, 'sendtoafriend-extra.tpl'); } -} + public function hookHeader($params) + { + $this->context->controller->addCSS($this->_path.'sendtoafriend.css', 'all'); + } +} \ No newline at end of file diff --git a/modules/sendtoafriend/sendtoafriend.tpl b/modules/sendtoafriend/sendtoafriend.tpl index 141842750..46d2e154b 100644 --- a/modules/sendtoafriend/sendtoafriend.tpl +++ b/modules/sendtoafriend/sendtoafriend.tpl @@ -26,41 +26,40 @@ {capture name=path}{l s='Send to a friend' mod='sendtoafriend'}{/capture} {include file="$tpl_dir./breadcrumb.tpl"} -
-

{l s='Send to a friend' mod='sendtoafriend'}

-

{l s='Send this page to a friend who might be interested in the item below.' mod='sendtoafriend'}.

- {include file="$tpl_dir./errors.tpl"} +

{l s='Send to a friend' mod='sendtoafriend'}

- {if isset($smarty.get.submited)} -

{l s='Your email has been sent successfully' mod='sendtoafriend'}

- {else} -
-
- +

{l s='Send this page to a friend who might be interested in the item below.' mod='sendtoafriend'}.

+{include file="$tpl_dir./errors.tpl"} -
-

- - -

-

- - -

+{if isset($smarty.get.submited)} +

{l s='Your email has been sent successfully' mod='sendtoafriend'}

+{else} + +
+

{l s='Send a message' mod='sendtoafriend'}

-

- -

-
-
-
- {/if} +

+
+ {$product->name|escape:'htmlall':'UTF-8'} +

- -
+

+ + +

+

+ + +

+ +

+ +

+ + +{/if} + + \ No newline at end of file