This commit is contained in:
@@ -1,190 +0,0 @@
|
||||
<?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: 1.4 $
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
if (!defined('_CAN_LOAD_FILES_'))
|
||||
exit;
|
||||
|
||||
class BlockViewed extends Module
|
||||
{
|
||||
private $_html = '';
|
||||
private $_postErrors = array();
|
||||
|
||||
function __construct()
|
||||
{
|
||||
$this->name = 'blockviewed';
|
||||
$this->tab = 'front_office_features';
|
||||
$this->version = 0.9;
|
||||
$this->author = 'PrestaShop';
|
||||
|
||||
parent::__construct();
|
||||
|
||||
$this->displayName = $this->l('Viewed products block');
|
||||
$this->description = $this->l('Adds a block displaying last-viewed products.');
|
||||
}
|
||||
|
||||
function install()
|
||||
{
|
||||
if (!parent::install()
|
||||
OR !$this->registerHook('leftColumn')
|
||||
OR !$this->registerHook('header')
|
||||
OR !Configuration::updateValue('PRODUCTS_VIEWED_NBR', 2))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public function getContent()
|
||||
{
|
||||
$output = '<h2>'.$this->displayName.'</h2>';
|
||||
if (Tools::isSubmit('submitBlockViewed'))
|
||||
{
|
||||
if (!$productNbr = Tools::getValue('productNbr') OR empty($productNbr))
|
||||
$output .= '<div class="alert error">'.$this->l('You must fill in the \'Products displayed\' field.').'</div>';
|
||||
elseif ((int)($productNbr) == 0)
|
||||
$output .= '<div class="alert error">'.$this->l('Invalid number.').'</div>';
|
||||
else
|
||||
{
|
||||
Configuration::updateValue('PRODUCTS_VIEWED_NBR', (int)($productNbr));
|
||||
$output .= '<div class="conf confirm"><img src="../img/admin/ok.gif" alt="'.$this->l('Confirmation').'" />'.$this->l('Settings updated').'</div>';
|
||||
}
|
||||
}
|
||||
return $output.$this->displayForm();
|
||||
}
|
||||
|
||||
public function displayForm()
|
||||
{
|
||||
$output = '
|
||||
<form action="'.$_SERVER['REQUEST_URI'].'" method="post">
|
||||
<fieldset><legend><img src="'.$this->_path.'logo.gif" alt="" title="" />'.$this->l('Settings').'</legend>
|
||||
<label>'.$this->l('Products displayed').'</label>
|
||||
<div class="margin-form">
|
||||
<input type="text" name="productNbr" value="'.Configuration::get('PRODUCTS_VIEWED_NBR').'" />
|
||||
<p class="clear">'.$this->l('Define the number of products displayed in this block').'</p>
|
||||
</div>
|
||||
<center><input type="submit" name="submitBlockViewed" value="'.$this->l('Save').'" class="button" /></center>
|
||||
</fieldset>
|
||||
</form>';
|
||||
return $output;
|
||||
}
|
||||
|
||||
function hookRightColumn($params)
|
||||
{
|
||||
global $link, $smarty, $cookie;
|
||||
|
||||
$id_product = (int)(Tools::getValue('id_product'));
|
||||
$productsViewed = (isset($params['cookie']->viewed) AND !empty($params['cookie']->viewed)) ? array_slice(explode(',', $params['cookie']->viewed), 0, Configuration::get('PRODUCTS_VIEWED_NBR')) : array();
|
||||
|
||||
if (sizeof($productsViewed))
|
||||
{
|
||||
$defaultCover = Language::getIsoById($params['cookie']->id_lang).'-default';
|
||||
|
||||
$productIds = implode(',', $productsViewed);
|
||||
$productsImages = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
|
||||
SELECT i.id_image, p.id_product, il.legend, p.active, pl.name, pl.description_short, pl.link_rewrite, cl.link_rewrite AS category_rewrite
|
||||
FROM '._DB_PREFIX_.'product p
|
||||
LEFT JOIN '._DB_PREFIX_.'product_lang pl ON (pl.id_product = p.id_product)
|
||||
LEFT JOIN '._DB_PREFIX_.'image i ON (i.id_product = p.id_product AND i.cover = 1)
|
||||
LEFT JOIN '._DB_PREFIX_.'image_lang il ON (il.id_image = i.id_image)
|
||||
LEFT JOIN '._DB_PREFIX_.'category_lang cl ON (cl.id_category = p.id_category_default)
|
||||
WHERE p.id_product IN ('.$productIds.')
|
||||
AND pl.id_lang = '.(int)($params['cookie']->id_lang).'
|
||||
AND cl.id_lang = '.(int)($params['cookie']->id_lang)
|
||||
);
|
||||
|
||||
$productsImagesArray = array();
|
||||
foreach ($productsImages AS $pi)
|
||||
$productsImagesArray[$pi['id_product']] = $pi;
|
||||
|
||||
$productsViewedObj = array();
|
||||
foreach ($productsViewed AS $productViewed)
|
||||
{
|
||||
$obj = (object)'Product';
|
||||
if (!isset($productsImagesArray[$productViewed]) || (!$obj->active = $productsImagesArray[$productViewed]['active']))
|
||||
continue;
|
||||
else
|
||||
{
|
||||
$obj->id = (int)($productsImagesArray[$productViewed]['id_product']);
|
||||
$obj->cover = (int)($productsImagesArray[$productViewed]['id_product']).'-'.(int)($productsImagesArray[$productViewed]['id_image']);
|
||||
$obj->legend = $productsImagesArray[$productViewed]['legend'];
|
||||
$obj->name = $productsImagesArray[$productViewed]['name'];
|
||||
$obj->description_short = $productsImagesArray[$productViewed]['description_short'];
|
||||
$obj->link_rewrite = $productsImagesArray[$productViewed]['link_rewrite'];
|
||||
$obj->category_rewrite = $productsImagesArray[$productViewed]['category_rewrite'];
|
||||
|
||||
if (!isset($obj->cover) || !$productsImagesArray[$productViewed]['id_image'])
|
||||
{
|
||||
$obj->cover = $defaultCover;
|
||||
$obj->legend = '';
|
||||
}
|
||||
$productsViewedObj[] = $obj;
|
||||
}
|
||||
}
|
||||
|
||||
if ($id_product AND !in_array($id_product, $productsViewed))
|
||||
{
|
||||
// Check if the user to the right of access to this product
|
||||
$result = Db::getInstance()->getRow('
|
||||
SELECT COUNT(cug.`id_customer`) AS total
|
||||
FROM `'._DB_PREFIX_.'product` p
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_product` cp ON (cp.`id_product` = p.`id_product`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_group` cg ON (cg.`id_category` = cp.`id_category`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'customer_group` cug ON (cug.`id_group` = cg.`id_group`)
|
||||
WHERE p.`id_product` = '.(int)($id_product).'
|
||||
'.($cookie->id_customer ? 'AND cug.`id_customer` = '.(int)($cookie->id_customer) :
|
||||
'AND cg.`id_group` = 1')
|
||||
);
|
||||
if ($result['total'])
|
||||
array_unshift($productsViewed, $id_product);
|
||||
}
|
||||
$viewed = '';
|
||||
foreach ($productsViewed AS $id_product_viewed)
|
||||
$viewed .= (int)($id_product_viewed).',';
|
||||
$params['cookie']->viewed = rtrim($viewed, ',');
|
||||
|
||||
if (!sizeof($productsViewedObj))
|
||||
return ;
|
||||
|
||||
$smarty->assign(array(
|
||||
'productsViewedObj' => $productsViewedObj,
|
||||
'mediumSize' => Image::getSize('medium')));
|
||||
|
||||
return $this->display(__FILE__, 'blockviewed.tpl');
|
||||
}
|
||||
elseif ($id_product)
|
||||
$params['cookie']->viewed = (int)($id_product);
|
||||
return ;
|
||||
}
|
||||
|
||||
function hookLeftColumn($params)
|
||||
{
|
||||
return $this->hookRightColumn($params);
|
||||
}
|
||||
|
||||
function hookHeader($params)
|
||||
{
|
||||
Tools::addCSS(($this->_path).'blockviewed.css', 'all');
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
{*
|
||||
* 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: 1.4 $
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*}
|
||||
|
||||
<!-- Block Viewed products -->
|
||||
<div id="viewed-products_block_left" class="block products_block">
|
||||
<h4>{l s='Viewed products' mod='blockviewed'}</h4>
|
||||
<div class="block_content">
|
||||
<ul class="products clearfix">
|
||||
{foreach from=$productsViewedObj item=viewedProduct name=myLoop}
|
||||
<li class="clearfix{if $smarty.foreach.myLoop.last} last_item{elseif $smarty.foreach.myLoop.first} first_item{else} item{/if}">
|
||||
<a href="{$link->getProductLink($viewedProduct->id, $viewedProduct->link_rewrite, $viewedProduct->category_rewrite)}" title="{l s='More about' mod='blockviewed'} {$viewedProduct->name|escape:html:'UTF-8'}"><img src="{$link->getImageLink($viewedProduct->link_rewrite, $viewedProduct->cover, 'medium')}" height="{$mediumSize.height}" width="{$mediumSize.width}" alt="{$viewedProduct->legend|escape:html:'UTF-8'}" /></a>
|
||||
<h5><a href="{$link->getProductLink($viewedProduct->id, $viewedProduct->link_rewrite, $viewedProduct->category_rewrite)}" title="{l s='More about' mod='blockviewed'} {$viewedProduct->name|escape:html:'UTF-8'}">{$viewedProduct->name|truncate:14:'...'|escape:html:'UTF-8'}</a></h5>
|
||||
<p>{m s=$viewedProduct->description_short|strip_tags:'UTF-8'|truncate:44 n=12}<a href="{$link->getProductLink($viewedProduct->id, $viewedProduct->link_rewrite, $viewedProduct->category_rewrite)}" title="{l s='More about' mod='blockviewed'} {$viewedProduct->name|escape:html:'UTF-8'}"><img src="{$img_dir}bullet.gif" alt=">>" width="10" height="7" /></a></p>
|
||||
</li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,11 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<module>
|
||||
<name>blockviewed</name>
|
||||
<displayName>Viewed products block</displayName>
|
||||
<version>0.9</version>
|
||||
<description>Adds a block displaying last-viewed products.</description>
|
||||
<author>PrestaShop</author>
|
||||
<tab>front_office_features</tab>
|
||||
<is_configurable>1</is_configurable>
|
||||
<need_instance>1</need_instance>
|
||||
</module>
|
||||
@@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
global $_MODULE;
|
||||
$_MODULE = array();
|
||||
$_MODULE['<{blockviewed}prestashop>blockviewed_859e85774d372c6084d62d02324a1cc3'] = 'Angesehene Produkte-Block';
|
||||
$_MODULE['<{blockviewed}prestashop>blockviewed_fad87bb9a90d9e42854af13633aac252'] = 'Fügt einen Block hinzu, der die zuletzt angesehenen Produkte anzeigt';
|
||||
$_MODULE['<{blockviewed}prestashop>blockviewed_2e57399079951d84b435700493b8a8c1'] = 'Sie müssen das Feld \"Angezeigte Produkte\" ausfüllen';
|
||||
$_MODULE['<{blockviewed}prestashop>blockviewed_73293a024e644165e9bf48f270af63a0'] = 'Ungültige Anzahl.';
|
||||
$_MODULE['<{blockviewed}prestashop>blockviewed_f4d1ea475eaa85102e2b4e6d95da84bd'] = 'Bestätigung';
|
||||
$_MODULE['<{blockviewed}prestashop>blockviewed_c888438d14855d7d96a2724ee9c306bd'] = 'Einstellungen aktualisiert';
|
||||
$_MODULE['<{blockviewed}prestashop>blockviewed_f4f70727dc34561dfde1a3c529b6205c'] = 'Einstellungen';
|
||||
$_MODULE['<{blockviewed}prestashop>blockviewed_e451e6943bb539d1bd804d2ede6474b5'] = 'Angezeigte Produkte';
|
||||
$_MODULE['<{blockviewed}prestashop>blockviewed_8ce2b5b3ffa27a8a66220a49357a1582'] = 'Definieren Sie die Anzahl der Produkte, die in diesem Block angezeigt werden';
|
||||
$_MODULE['<{blockviewed}prestashop>blockviewed_c9cc8cce247e49bae79f15173ce97354'] = 'Speichern';
|
||||
$_MODULE['<{blockviewed}prestashop>blockviewed_43560641f91e63dc83682bc598892fa1'] = 'Angesehene Produkte';
|
||||
$_MODULE['<{blockviewed}prestashop>blockviewed_49fa2426b7903b3d4c89e2c1874d9346'] = 'Mehr darüber';
|
||||
@@ -1,4 +0,0 @@
|
||||
<?php
|
||||
|
||||
global $_MODULE;
|
||||
$_MODULE = array();
|
||||
@@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
global $_MODULE;
|
||||
$_MODULE = array();
|
||||
$_MODULE['<{blockviewed}prestashop>blockviewed_859e85774d372c6084d62d02324a1cc3'] = 'Bloque de productos vistos';
|
||||
$_MODULE['<{blockviewed}prestashop>blockviewed_fad87bb9a90d9e42854af13633aac252'] = 'Añadir un bloque para mostrar los últimos productos vistos';
|
||||
$_MODULE['<{blockviewed}prestashop>blockviewed_2e57399079951d84b435700493b8a8c1'] = 'Debe rellenar el campo\'Productos mostrados';
|
||||
$_MODULE['<{blockviewed}prestashop>blockviewed_73293a024e644165e9bf48f270af63a0'] = 'Número no válido.';
|
||||
$_MODULE['<{blockviewed}prestashop>blockviewed_f4d1ea475eaa85102e2b4e6d95da84bd'] = 'Confirmación';
|
||||
$_MODULE['<{blockviewed}prestashop>blockviewed_c888438d14855d7d96a2724ee9c306bd'] = 'Configuración actualizada';
|
||||
$_MODULE['<{blockviewed}prestashop>blockviewed_f4f70727dc34561dfde1a3c529b6205c'] = 'Configuración';
|
||||
$_MODULE['<{blockviewed}prestashop>blockviewed_e451e6943bb539d1bd804d2ede6474b5'] = 'Productos mostrados';
|
||||
$_MODULE['<{blockviewed}prestashop>blockviewed_8ce2b5b3ffa27a8a66220a49357a1582'] = 'Definir el número de productos mostrados en cada bloque';
|
||||
$_MODULE['<{blockviewed}prestashop>blockviewed_c9cc8cce247e49bae79f15173ce97354'] = 'Guardar';
|
||||
$_MODULE['<{blockviewed}prestashop>blockviewed_43560641f91e63dc83682bc598892fa1'] = 'Productos más vistos';
|
||||
$_MODULE['<{blockviewed}prestashop>blockviewed_49fa2426b7903b3d4c89e2c1874d9346'] = 'Más sobre';
|
||||
@@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
global $_MODULE;
|
||||
$_MODULE = array();
|
||||
$_MODULE['<{blockviewed}prestashop>blockviewed_859e85774d372c6084d62d02324a1cc3'] = 'Bloc produits déjà vus';
|
||||
$_MODULE['<{blockviewed}prestashop>blockviewed_fad87bb9a90d9e42854af13633aac252'] = 'Ajoute un bloc proposant les derniers produits vus par le client';
|
||||
$_MODULE['<{blockviewed}prestashop>blockviewed_2e57399079951d84b435700493b8a8c1'] = 'Champ \"Produits vus\" obligatoire';
|
||||
$_MODULE['<{blockviewed}prestashop>blockviewed_73293a024e644165e9bf48f270af63a0'] = 'Nombre invalide.';
|
||||
$_MODULE['<{blockviewed}prestashop>blockviewed_f4d1ea475eaa85102e2b4e6d95da84bd'] = 'Confirmation';
|
||||
$_MODULE['<{blockviewed}prestashop>blockviewed_c888438d14855d7d96a2724ee9c306bd'] = 'Configuration mise à jour';
|
||||
$_MODULE['<{blockviewed}prestashop>blockviewed_f4f70727dc34561dfde1a3c529b6205c'] = 'Configuration';
|
||||
$_MODULE['<{blockviewed}prestashop>blockviewed_e451e6943bb539d1bd804d2ede6474b5'] = 'Nombre de produits affichés';
|
||||
$_MODULE['<{blockviewed}prestashop>blockviewed_8ce2b5b3ffa27a8a66220a49357a1582'] = 'Détermine le nombre de produits affichés dans ce bloc';
|
||||
$_MODULE['<{blockviewed}prestashop>blockviewed_c9cc8cce247e49bae79f15173ce97354'] = 'Sauvegarder';
|
||||
$_MODULE['<{blockviewed}prestashop>blockviewed_43560641f91e63dc83682bc598892fa1'] = 'Déjà vus';
|
||||
$_MODULE['<{blockviewed}prestashop>blockviewed_49fa2426b7903b3d4c89e2c1874d9346'] = 'En savoir plus à propos de';
|
||||
@@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
global $_MODULE;
|
||||
$_MODULE = array();
|
||||
$_MODULE['<{blockviewed}prestashop>blockviewed_859e85774d372c6084d62d02324a1cc3'] = 'Blocco prodotti visti';
|
||||
$_MODULE['<{blockviewed}prestashop>blockviewed_fad87bb9a90d9e42854af13633aac252'] = 'Aggiunge un blocco che visualizza i prodotti visti recentemente';
|
||||
$_MODULE['<{blockviewed}prestashop>blockviewed_2e57399079951d84b435700493b8a8c1'] = 'È necessario compilare il campo \"prodotti esposti\"';
|
||||
$_MODULE['<{blockviewed}prestashop>blockviewed_73293a024e644165e9bf48f270af63a0'] = 'Numero non valido.';
|
||||
$_MODULE['<{blockviewed}prestashop>blockviewed_f4d1ea475eaa85102e2b4e6d95da84bd'] = 'Conferma';
|
||||
$_MODULE['<{blockviewed}prestashop>blockviewed_c888438d14855d7d96a2724ee9c306bd'] = 'Impostazioni aggiornate';
|
||||
$_MODULE['<{blockviewed}prestashop>blockviewed_f4f70727dc34561dfde1a3c529b6205c'] = 'Impostazioni';
|
||||
$_MODULE['<{blockviewed}prestashop>blockviewed_e451e6943bb539d1bd804d2ede6474b5'] = 'Prodotti esposti';
|
||||
$_MODULE['<{blockviewed}prestashop>blockviewed_8ce2b5b3ffa27a8a66220a49357a1582'] = 'Definisci il numero di prodotti esposti in questo blocco';
|
||||
$_MODULE['<{blockviewed}prestashop>blockviewed_c9cc8cce247e49bae79f15173ce97354'] = 'Salva';
|
||||
$_MODULE['<{blockviewed}prestashop>blockviewed_43560641f91e63dc83682bc598892fa1'] = 'Prodotti visti';
|
||||
$_MODULE['<{blockviewed}prestashop>blockviewed_49fa2426b7903b3d4c89e2c1874d9346'] = 'Maggiori informazioni su';
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 954 B |
Reference in New Issue
Block a user