[*] classes : new module architecture

This commit is contained in:
rMalie
2012-01-31 16:57:19 +00:00
parent 62f105ae6e
commit 4f7b3d4550
71 changed files with 815 additions and 622 deletions
@@ -0,0 +1,53 @@
<?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
*/
/**
* @since 1.5.0
*/
class FavoriteproductsAccountModuleFrontController extends ModuleFrontController
{
public function init()
{
parent::init();
require_once($this->module->getLocalPath().'FavoriteProduct.php');
}
public function initContent()
{
parent::initContent();
if (!Context::getContext()->customer->isLogged())
Tools::redirect('index.php?controller=auth&redirect=module&module=favoriteproducts&action=account');
if (Context::getContext()->customer->id)
{
$this->context->smarty->assign('favoriteProducts', FavoriteProduct::getFavoriteProducts((int)Context::getContext()->customer->id, (int)Context::getContext()->language->id));
$this->setTemplate('favoriteproducts-account.tpl');
}
}
}
@@ -28,7 +28,7 @@
/**
* @since 1.5.0
*/
class ModuleFavoriteproductsController extends ModuleController
class FavoriteproductsActionsModuleFrontController extends ModuleFrontController
{
/**
* @var int
@@ -39,16 +39,17 @@ class ModuleFavoriteproductsController extends ModuleController
{
parent::init();
require_once(dirname(__FILE__).'/FavoriteProduct.php');
require_once($this->module->getLocalPath().'FavoriteProduct.php');
$this->id_product = (int)Tools::getValue('id_product');
}
public function postProcess()
{
if ($this->process == 'remove')
if (Tools::getValue('process') == 'remove')
$this->processRemove();
else if ($this->process == 'add')
else if (Tools::getValue('process') == 'add')
$this->processAdd();
exit;
}
/**
@@ -84,26 +85,4 @@ class ModuleFavoriteproductsController extends ModuleController
die('0');
die(1);
}
public function initContent()
{
parent::initContent();
if ($this->process == 'account')
$this->assignAccount();
}
/**
* Prepare account page
*/
public function assignAccount()
{
if (!Context::getContext()->customer->isLogged())
Tools::redirect('index.php?controller=auth&redirect=module&module=favoriteproducts&action=account');
if (Context::getContext()->customer->id)
{
$this->context->smarty->assign('favoriteProducts', FavoriteProduct::getFavoriteProducts((int)Context::getContext()->customer->id, (int)Context::getContext()->language->id));
$this->setTemplate('favoriteproducts-account.tpl');
}
}
}
@@ -26,7 +26,7 @@
*/
/**
* @deprecated 1.5.0 This file is deprecated, use moduleController instead
* @deprecated 1.5.0 This file is deprecated, use moduleFrontController instead
*/
/* SSL Management */
@@ -39,4 +39,4 @@ Tools::displayFileAsDeprecated();
$controller = new FrontController();
$controller->init();
Tools::redirect('index.php?controller=module&module=favoriteproducts&process=account');
Tools::redirect(Context::getContext()->link->getModuleLink('favoriteproducts', 'account'));
@@ -26,7 +26,7 @@
*/
/**
* @deprecated 1.5.0 This file is deprecated, use moduleController instead
* @deprecated 1.5.0 This file is deprecated, use moduleFrontController instead
*/
require_once(dirname(__FILE__).'/../../config/config.inc.php');
+2 -2
View File
@@ -2,12 +2,12 @@
global $_MODULE;
$_MODULE = array();
$_MODULE['<{favoriteproducts}prestashop>favoriteproducts_c249aeb21294d5e97598462b550e73eb'] = 'Produits Favoris';
$_MODULE['<{favoriteproducts}prestashop>favoriteproducts_0db149d6f1284b51aa48c72dd1b0e7c6'] = 'Affiche une page avec les produits favoris de l\'utilisateur';
$_MODULE['<{favoriteproducts}prestashop>favoriteproducts-account_d95cf4ab2cbf1dfb63f066b50558b07d'] = 'Mon compte';
$_MODULE['<{favoriteproducts}prestashop>favoriteproducts-account_a34e0796b9c15d09300f67d972379722'] = 'Mes produits favoris';
$_MODULE['<{favoriteproducts}prestashop>favoriteproducts-account_e2233f8a7cec20324ed48bc32ec98a5d'] = 'Vous ne possédez pas de produit favoris pour le moment';
$_MODULE['<{favoriteproducts}prestashop>favoriteproducts-account_0b3db27bc15f682e92ff250ebb167d4b'] = 'Retour à votre compte';
$_MODULE['<{favoriteproducts}prestashop>favoriteproducts-extra_77b65985b439ff157c1c13d63c9dc294'] = 'Ajouter ce produit à mes favoris';
$_MODULE['<{favoriteproducts}prestashop>favoriteproducts-extra_84934524b3493305f6faf3074258b512'] = 'Retirer ce produit de mes favoris';
$_MODULE['<{favoriteproducts}prestashop>favoriteproducts_c249aeb21294d5e97598462b550e73eb'] = 'Produits Favoris';
$_MODULE['<{favoriteproducts}prestashop>favoriteproducts_0db149d6f1284b51aa48c72dd1b0e7c6'] = 'Affiche une page avec les produits favoris de l\'utilisateur';
$_MODULE['<{favoriteproducts}prestashop>my-account_a34e0796b9c15d09300f67d972379722'] = 'Mes produits favoris';
@@ -33,7 +33,7 @@ $('document').ready(function()
var parent = $(this).parent().parent();
$.ajax({
url: "{$link->getModuleLink('favoriteproducts', 'remove')}",
url: "{$link->getModuleLink('favoriteproducts', 'actions', ['process' => 'remove'])}",
type: "POST",
data: {
'id_product': idFavoriteProduct
@@ -28,7 +28,7 @@
$('document').ready(function(){
$('#favoriteproducts_block_extra_add').click(function(){
$.ajax({
url: "{$link->getModuleLink('favoriteproducts', 'add')}",
url: "{$link->getModuleLink('favoriteproducts', 'actions', ['process' => 'add'])}",
type: "POST",
data: {
"id_product": {$smarty.get.id_product}
@@ -46,7 +46,7 @@ $('document').ready(function(){
});
$('#favoriteproducts_block_extra_remove').click(function(){
$.ajax({
url: "{$link->getModuleLink('favoriteproducts', 'remove')}",
url: "{$link->getModuleLink('favoriteproducts', 'actions', ['process' => 'remove'])}",
type: "POST",
data: {
"id_product": {$smarty.get.id_product}
@@ -64,7 +64,7 @@ $('document').ready(function(){
});
$('#favoriteproducts_block_extra_added').click(function(){
$.ajax({
url: "{$link->getModuleLink('favoriteproducts', 'remove')}",
url: "{$link->getModuleLink('favoriteproducts', 'actions', ['process' => 'remove'])}",
type: "POST",
data: {
"id_product": {$smarty.get.id_product}
@@ -82,7 +82,7 @@ $('document').ready(function(){
});
$('#favoriteproducts_block_extra_removed').click(function(){
$.ajax({
url: "{$link->getModuleLink('favoriteproducts', 'add')}",
url: "{$link->getModuleLink('favoriteproducts', 'actions', ['process' => 'add'])}",
type: "POST",
data: {
"id_product": {$smarty.get.id_product}