// Module changes for new native template

This commit is contained in:
aFolletete
2011-11-14 10:56:15 +00:00
parent 33528a2cdc
commit a45cd52f13
10 changed files with 293 additions and 171 deletions
@@ -115,6 +115,7 @@ class BlockBestSellers extends Module
$this->context->smarty->assign(array( $this->context->smarty->assign(array(
'best_sellers' => $best_sellers, 'best_sellers' => $best_sellers,
'mediumSize' => Image::getSize('medium'), 'mediumSize' => Image::getSize('medium'),
'smallSize' => Image::getSize('small')
)); ));
return $this->display(__FILE__, 'blockbestsellers.tpl'); return $this->display(__FILE__, 'blockbestsellers.tpl');
} }
+14 -8
View File
@@ -30,15 +30,21 @@
<div class="block_content"> <div class="block_content">
{if $best_sellers|@count > 0} {if $best_sellers|@count > 0}
<ul class="product_images"> <ul class="product_images">
<li><a href="{$best_sellers.0.link}" title="{$best_sellers.0.legend|escape:'htmlall':'UTF-8'}"><img src="{$link->getImageLink($best_sellers.0.link_rewrite, $best_sellers.0.id_image, 'medium')}" height="{$mediumSize.height}" width="{$mediumSize.width}" alt="{$best_sellers.0.legend|escape:'htmlall':'UTF-8'}" /></a></li> {foreach from=$best_sellers item=product name=myLoop}
{if $best_sellers|@count > 1}<li><a href="{$best_sellers.1.link}" title="{$best_sellers.1.legend|escape:'htmlall':'UTF-8'}"><img src="{$link->getImageLink($best_sellers.1.link_rewrite, $best_sellers.1.id_image, 'medium')}" height="{$mediumSize.height}" width="{$mediumSize.width}" alt="{$best_sellers.1.legend|escape:'htmlall':'UTF-8'}" /></a></li>{/if} <li class="{if $smarty.foreach.myLoop.first}first_item{elseif $smarty.foreach.myLoop.last}last_item{else}item{/if} clearfix">
</ul> <a href="{$product.link}" title="{$product.legend|escape:'htmlall':'UTF-8'}" class="content_img clearfix">
<dl> <span class="number">{$smarty.foreach.myLoop.iteration}</span>
{foreach from=$best_sellers item=product name=myLoop} <img src="{$link->getImageLink($product.link_rewrite, $product.id_image, 'small')}" height="{$smallSize.height}" width="{$smallSize.width}" alt="{$product.legend|escape:'htmlall':'UTF-8'}" />
<dt class="{if $smarty.foreach.myLoop.first}first_item{elseif $smarty.foreach.myLoop.last}last_item{else}item{/if}"><a href="{$product.link}" title="{$product.name|escape:'htmlall':'UTF-8'}">{$product.name|strip_tags:'UTF-8'|escape:'htmlall':'UTF-8'}</a></dt>
</a>
<p><a href="{$product.link}" title="{$product.legend|escape:'htmlall':'UTF-8'}">
{$product.name|strip_tags:'UTF-8'|escape:'htmlall':'UTF-8'}<br />
<span class="price">{$product.price}</span>
</a></p>
</li>
{/foreach} {/foreach}
</dl> </ul>
<p><a href="{$link->getPageLink('best-sales')}" title="{l s='All best sellers' mod='blockbestsellers'}" class="button_large">{l s='All best sellers' mod='blockbestsellers'}</a></p> <p class="lnk"><a href="{$link->getPageLink('best-sales')}" title="{l s='All best sellers' mod='blockbestsellers'}" class="button_large">&raquo; {l s='All best sellers' mod='blockbestsellers'}</a></p>
{else} {else}
<p>{l s='No best sellers at this time' mod='blockbestsellers'}</p> <p>{l s='No best sellers at this time' mod='blockbestsellers'}</p>
{/if} {/if}
+6 -1
View File
@@ -146,7 +146,7 @@ class BlockCart extends Module
if if
( (
parent::install() == false parent::install() == false
OR $this->registerHook('rightColumn') == false OR $this->registerHook('top') == false
OR $this->registerHook('header') == false OR $this->registerHook('header') == false
OR Configuration::updateValue('PS_BLOCK_CART_AJAX', 1) == false OR Configuration::updateValue('PS_BLOCK_CART_AJAX', 1) == false
) )
@@ -188,5 +188,10 @@ class BlockCart extends Module
if ((int)(Configuration::get('PS_BLOCK_CART_AJAX'))) if ((int)(Configuration::get('PS_BLOCK_CART_AJAX')))
$this->context->controller->addJS(($this->_path).'ajax-cart.js'); $this->context->controller->addJS(($this->_path).'ajax-cart.js');
} }
public function hookTop($params)
{
return $this->hookRightColumn($params);
}
} }
+45
View File
@@ -0,0 +1,45 @@
{*
* 2007-2011 PrestaShop
*
* 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.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@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision$
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
<!-- Block permanent links module -->
<div id="permanent_links">
<!-- Sitemap -->
<div class="sitemap">
<a href="{$link->getPageLink('sitemap')}"><img src="{$img_dir}icon/sitemap.gif" alt="{l s='sitemap' mod='blockpermanentlinks'}" title="{l s='sitemap' mod='blockpermanentlinks'}" /></a>&nbsp;
<a href="{$link->getPageLink('sitemap')}">{l s='sitemap' mod='blockpermanentlinks'}</a>
</div>
<!-- Contact -->
<div class="contact">
<a href="{$link->getPageLink('contact', true)}"><img src="{$img_dir}icon/contact.gif" alt="{l s='contact' mod='blockpermanentlinks'}" title="{l s='contact' mod='blockpermanentlinks'}" /></a>&nbsp;
<a href="{$link->getPageLink('contact', true)}">{l s='contact' mod='blockpermanentlinks'}</a>
</div>
<!-- Bookmark -->
<div class="add_bookmark">
<script type="text/javascript">
writeBookmarkLink('{$come_from}', '{$shop_name|addslashes|addslashes}', '{l s='bookmark this page' mod='blockpermanentlinks'}', '{$img_dir}icon/star.gif');</script>&nbsp;
</div>
</div>
<!-- /Block permanent links module -->
@@ -78,7 +78,7 @@ class BlockPermanentLinks extends Module
function hookFooter($params) function hookFooter($params)
{ {
return $this->hookLeftColumn($params); return $this->display(__FILE__, 'blockpermanentlinks-footer.tpl');
} }
function hookHeader($params) function hookHeader($params)
+27
View File
@@ -0,0 +1,27 @@
{*
* 2007-2011 PrestaShop
*
* 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.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@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision$
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*}
<li class="sendtofriend"><a href="{$this_path}sendtoafriend-form.php?id_product={$smarty.get.id_product|intval}">{l s='Send to a friend' mod='sendtoafriend'}</a></li>
+33
View File
@@ -0,0 +1,33 @@
<?php
/*
* 2007-2011 PrestaShop
*
* 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.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@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision$
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
include(dirname(__FILE__).'/../../config/config.inc.php');
require_once(dirname(__FILE__).'/sendtoafriend.php');
$sendtoafriend = new sendToAFriend($dontTranslate = true);
echo $sendtoafriend->displayPageForm();
+45 -98
View File
@@ -1,99 +1,46 @@
#fancybox-wrap {width:585px !important} /* ************************************************************************************************
#fancybox-content { PAGE SEND TO FRIEND
width:585px !important; ************************************************************************************************ */
border-width:0 !important #sendfriendpage form.std fieldset {
} margin:0 0 20px 0;
padding: 10px 15px;
#send_friend_form { background: none repeat scroll 0 0 #eee
width:585px; }
color: #333;
text-align: left; #sendfriendpage .product {}
background-color: #fff #sendfriendpage .product .img_link {float:left}
} #sendfriendpage .product .img_link img {
#send_friend_form .title { margin:0 10px 0 0;
padding:10px; border:1px solid #ccc;
font-size: 13px; }
color: #fff; #sendfriendpage .product .product_desc {
text-transform: uppercase; float:left;
background: #333 width:200px;
} font-weight:bold;
font-size:12px;
#send_friend_form .product {padding:15px} color:#000;
#send_friend_form .product img { }
float:left;
border: 1px solid #ccc; #sendfriendpage #send_friend_form_content {margin-top:40px}
} #sendfriendpage #send_friend_form_content .text {
#send_friend_form .product .product_desc { padding-bottom: 10px
float:left; }
margin-left:15px; #sendfriendpage #send_friend_form_content .text label {
width:300px; display: inline-block;
line-height:18px; padding: 6px 15px;
color:#666 width: 180px;
} font-size: 12px;
#send_friend_form .product .product_desc .product_name { text-align: right
padding-bottom:5px; }
font-size:13px; #sendfriendpage #send_friend_form_content .text input {
color:#000 padding: 0 5px;
} height: 22px;
width: 260px;
.send_friend_form_content { border: 1px solid #ccc;
padding:15px; font-size: 12px
background:#f8f8f8 }
} #sendfriendpage #send_friend_form_content .submit {
.send_friend_form_content .intro_form { margin:0 20px 0 0;
padding-bottom: 10px; padding:5px 0;
font-weight: bold; text-align:right
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;
} }
+88 -31
View File
@@ -20,7 +20,7 @@
* *
* @author PrestaShop SA <contact@prestashop.com> * @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA * @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 7040 $ * @version Release: $Revision: 8005 $
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA * International Registered Trademark & Property of PrestaShop SA
*/ */
@@ -30,17 +30,13 @@ if (!defined('_PS_VERSION_'))
class sendToAFriend extends Module class sendToAFriend extends Module
{ {
private $_html = '';
private $_postErrors = array();
function __construct($dontTranslate = false) function __construct($dontTranslate = false)
{ {
$this->name = 'sendtoafriend'; $this->name = 'sendtoafriend';
$this->version = '1.2'; $this->version = '1.3';
$this->author = 'PrestaShop'; $this->author = 'PrestaShop';
$this->tab = 'front_office_features'; $this->tab = 'front_office_features';
$this->need_instance = 0; $this->need_instance = 0;
$this->secure_key = Tools::encrypt($this->name);
parent::__construct(); parent::__construct();
@@ -48,40 +44,101 @@ class sendToAFriend extends Module
{ {
$this->displayName = $this->l('Send to a Friend module'); $this->displayName = $this->l('Send to a Friend module');
$this->description = $this->l('Allows customers to send a product link to a friend.'); $this->description = $this->l('Allows customers to send a product link to a friend.');
} }
} }
public function install() function install()
{ {
return (parent::install() AND $this->registerHook('extraLeft') return (parent::install() AND $this->registerHook('extraLeft') && $this->registerHook('header'));
AND $this->registerHook('header')); }
public function hookHeader()
{
$this->context->controller->addCSS(($this->_path).'sendtoafriend.css', 'all');
} }
public function uninstall() function hookExtraLeft($params)
{ {
return (parent::uninstall() AND $this->unregisterHook('header') AND $this->unregisterHook('extraLeft')); $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');
} }
public function hookExtraLeft($params) public function displayFrontForm()
{ {
/* Product informations */ $error = false;
$product = new Product((int)Tools::getValue('id_product'), false, $this->context->language->id); $confirm = false;
$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);
Context::getContext()->smarty->assign(array( /* Fields verifications */
'stf_id_product' => (int)Tools::getValue('id_product'), if (empty($_POST['email']) OR empty($_POST['name']))
'stf_product_link' => $productLink, $error = $this->l('You must fill in all fields.');
'stf_product_cover' => (int)Tools::getValue('id_product').'-'.(int)$image['id_image'], elseif (empty($_POST['email']) OR !Validate::isEmail($_POST['email']))
'stf_secure_key' => $this->secure_key, $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
)); ));
return $this->display(__FILE__, 'sendtoafriend-extra.tpl'); return $this->display(__FILE__, 'sendtoafriend.tpl');
} }
}
public function hookHeader($params)
{
$this->context->controller->addCSS($this->_path.'sendtoafriend.css', 'all');
}
}
+33 -32
View File
@@ -26,40 +26,41 @@
{capture name=path}{l s='Send to a friend' mod='sendtoafriend'}{/capture} {capture name=path}{l s='Send to a friend' mod='sendtoafriend'}{/capture}
{include file="$tpl_dir./breadcrumb.tpl"} {include file="$tpl_dir./breadcrumb.tpl"}
<div id="sendfriendpage">
<h1>{l s='Send to a friend' mod='sendtoafriend'}</h1>
<h1>{l s='Send to a friend' mod='sendtoafriend'}</h1> <p class="bold">{l s='Send this page to a friend who might be interested in the item below.' mod='sendtoafriend'}.</p>
{include file="$tpl_dir./errors.tpl"}
<p class="bold">{l s='Send this page to a friend who might be interested in the item below.' mod='sendtoafriend'}.</p> {if isset($smarty.get.submited)}
{include file="$tpl_dir./errors.tpl"} <p class="success">{l s='Your email has been sent successfully' mod='sendtoafriend'}</p>
{else}
<form method="post" action="{$request_uri}" class="std">
<fieldset>
<div class="product clearfix">
<a href="{$productLink}" class="img_link"><img src="{$link->getImageLink($product->link_rewrite, $cover.id_image, 'small')}" alt="" title="{$cover.legend}" /></a>
<a href="{$productLink}" class="product_desc"><br />{$product->name}</a>
</div>
{if isset($smarty.get.submited)} <div id="send_friend_form_content">
<p class="success">{l s='Your email has been sent successfully' mod='sendtoafriend'}</p> <p class="text">
{else} <label for="friend-name">{l s='Friend\'s name:' mod='sendtoafriend'}</label>
<form method="post" action="{$request_uri}" class="std"> <input type="text" id="friend-name" name="name" value="{if isset($smarty.post.name)}{$smarty.post.name|escape:'htmlall':'UTF-8'|stripslashes}{/if}" />
<fieldset> </p>
<h3>{l s='Send a message' mod='sendtoafriend'}</h3> <p class="text">
<label for="friend-address">{l s='Friend\'s email:' mod='sendtoafriend'}</label>
<input type="text" id="friend-address" name="email" value="{if isset($smarty.post.name)}{$smarty.post.email|escape:'htmlall'|stripslashes}{/if}" />
</p>
<p class="align_center"> <p class="submit">
<a href="{$productLink}"><img src="{$link->getImageLink($product->link_rewrite, $cover.id_image, 'small')}" alt="" title="{$cover.legend|escape:'htmlall':'UTF-8'}" /></a><br/> <input type="submit" name="submitAddtoafriend" value="{l s='send' mod='sendtoafriend'}" class="button" />
<a href="{$productLink}">{$product->name|escape:'htmlall':'UTF-8'}</a> </p>
</p> </div>
</fieldset>
</form>
{/if}
<p> <ul class="footer_links">
<label for="friend-name">{l s='Friend\'s name:' mod='sendtoafriend'}</label> <li><a href="{$productLink}">&laquo; {l s='Back to product page' mod='sendtoafriend'}</a></li>
<input type="text" id="friend-name" name="name" value="{if isset($smarty.post.name)}{$smarty.post.name|escape:'htmlall':'UTF-8'|stripslashes}{/if}" /> </ul>
</p> </div>
<p>
<label for="friend-address">{l s='Friend\'s email:' mod='sendtoafriend'}</label>
<input type="text" id="friend-address" name="email" value="{if isset($smarty.post.name)}{$smarty.post.email|escape:'htmlall'|stripslashes}{/if}" />
</p>
<p class="submit">
<input type="submit" name="submitAddtoafriend" value="{l s='send' mod='sendtoafriend'}" class="button" />
</p>
</fieldset>
</form>
{/if}
<ul class="footer_links">
<li><a href="{$productLink}" class="button_large">{l s='Back to product page' mod='sendtoafriend'}</a></li>
</ul>