[*] 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,55 @@
<?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 MailalertsAccountModuleFrontController extends ModuleFrontController
{
public function init()
{
parent::init();
require_once($this->module->getLocalPath().'MailAlert.php');
}
public function initContent()
{
parent::initContent();
if (!Context::getContext()->customer->isLogged())
Tools::redirect('index.php?controller=auth&redirect=account&module=mailalerts&fc=module');
if (Context::getContext()->customer->id)
{
$this->context->smarty->assign('id_customer', Context::getContext()->customer->id);
$this->context->smarty->assign('mailAlerts', MailAlert::getMailAlerts((int)Context::getContext()->customer->id, (int)Context::getContext()->language->id));
$this->setTemplate('mailalerts-account.tpl');
}
}
}
@@ -20,7 +20,7 @@
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 11894 $
* @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
*/
@@ -28,7 +28,7 @@
/**
* @since 1.5.0
*/
class ModulemailalertsController extends ModuleController
class MailalertsActionsModuleFrontController extends ModuleFrontController
{
/**
* @var int
@@ -39,17 +39,17 @@ class ModulemailalertsController extends ModuleController
{
parent::init();
require_once(dirname(__FILE__).'/MailAlert.php');
require_once($this->module->getLocalPath().'MailAlert.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();
else if ($this->process == 'check')
else if (Tools::getValue('process') == 'check')
$this->processCheck();
}
@@ -133,28 +133,4 @@ class ModulemailalertsController extends ModuleController
die('0');
}
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=mailalerts&action=account');
if (Context::getContext()->customer->id)
{
$this->context->smarty->assign('id_customer', Context::getContext()->customer->id);
$this->context->smarty->assign('mailAlerts', MailAlert::getMailAlerts((int)Context::getContext()->customer->id, (int)Context::getContext()->language->id));
$this->setTemplate('mailalerts-account.tpl');
}
}
}
+8 -8
View File
@@ -2,14 +2,6 @@
global $_MODULE;
$_MODULE = array();
$_MODULE['<{mailalerts}prestashop>mailalerts-account_d95cf4ab2cbf1dfb63f066b50558b07d'] = 'Mon compte';
$_MODULE['<{mailalerts}prestashop>mailalerts-account_4edfd10d0bb5f51e0fd2327df608b5a8'] = 'Mes alertes';
$_MODULE['<{mailalerts}prestashop>mailalerts-account_deb10517653c255364175796ace3553f'] = 'Produit';
$_MODULE['<{mailalerts}prestashop>mailalerts-account_f2a6c498fb90ee345d997f888fce3b18'] = 'Supprimer';
$_MODULE['<{mailalerts}prestashop>mailalerts-account_074c07016d3e5a9f011aa8e62abe4517'] = 'Vous n\'êtes inscris à aucune alerte.';
$_MODULE['<{mailalerts}prestashop>mailalerts-account_0b3db27bc15f682e92ff250ebb167d4b'] = 'Retour à votre compte';
$_MODULE['<{mailalerts}prestashop>mailalerts-account_8cf04a9734132302f96da8e113e80ce5'] = 'Accueil';
$_MODULE['<{mailalerts}prestashop>mailalerts-account_8bb23c2ae698681ebb650f43acb54dab'] = 'Aucune alerte mail.';
$_MODULE['<{mailalerts}prestashop>mailalerts_fd30254803e8db32521d3390131a44da'] = 'Alertes email';
$_MODULE['<{mailalerts}prestashop>mailalerts_2d51f4a7ab8a12c4f35b507019523b8c'] = 'Envoie des notifications par e-mail aux clients et aux marchands.';
$_MODULE['<{mailalerts}prestashop>mailalerts_8fd3b84964bd6dfec8095f658d200b29'] = 'Etes-vous sûr de vouloir supprimer toutes les notifications clients ?';
@@ -33,6 +25,14 @@ $_MODULE['<{mailalerts}prestashop>mailalerts_f77ed609e48d550f0166dfbafc102710']
$_MODULE['<{mailalerts}prestashop>mailalerts_7cb9a154f101c674c945f88dad5c5e28'] = 'Aucun message';
$_MODULE['<{mailalerts}prestashop>mailalerts_9137796c15dd92e5553c3f29574d0968'] = 'Code de réduction :';
$_MODULE['<{mailalerts}prestashop>mailalerts_4c9120f1a5947445c0e9620254ceb30b'] = 'Nouvelle commande';
$_MODULE['<{mailalerts}prestashop>mailalerts-account_d95cf4ab2cbf1dfb63f066b50558b07d'] = 'Mon compte';
$_MODULE['<{mailalerts}prestashop>mailalerts-account_4edfd10d0bb5f51e0fd2327df608b5a8'] = 'Mes alertes';
$_MODULE['<{mailalerts}prestashop>mailalerts-account_deb10517653c255364175796ace3553f'] = 'Produit';
$_MODULE['<{mailalerts}prestashop>mailalerts-account_f2a6c498fb90ee345d997f888fce3b18'] = 'Supprimer';
$_MODULE['<{mailalerts}prestashop>mailalerts-account_074c07016d3e5a9f011aa8e62abe4517'] = 'Vous n\'êtes inscris à aucune alerte.';
$_MODULE['<{mailalerts}prestashop>mailalerts-account_0b3db27bc15f682e92ff250ebb167d4b'] = 'Retour à votre compte';
$_MODULE['<{mailalerts}prestashop>mailalerts-account_8cf04a9734132302f96da8e113e80ce5'] = 'Accueil';
$_MODULE['<{mailalerts}prestashop>mailalerts-account_8bb23c2ae698681ebb650f43acb54dab'] = 'Aucune alerte mail.';
$_MODULE['<{mailalerts}prestashop>my-account_4edfd10d0bb5f51e0fd2327df608b5a8'] = 'Mes alertes';
$_MODULE['<{mailalerts}prestashop>product_67135a14d3ac4f1369633dd006d6efec'] = 'votre@email.com';
$_MODULE['<{mailalerts}prestashop>product_61172eb93737ebf095d3fa02119ce1df'] = 'Demande de notification enregistrée';
+4 -4
View File
@@ -28,7 +28,7 @@
$('document').ready(function(){
$('#mailalerts_block_extra_add').click(function(){
$.ajax({
url: "{$link->getModuleLink('mailalerts', 'add')}",
url: "{$link->getModuleLink('mailalerts', 'actions', ['process' => 'add'])}",
type: "POST",
data: {
"id_product": {$smarty.get.id_product}
@@ -46,7 +46,7 @@ $('document').ready(function(){
});
$('#mailalerts_block_extra_remove').click(function(){
$.ajax({
url: "{$link->getModuleLink('mailalerts', 'remove')}",
url: "{$link->getModuleLink('mailalerts', 'actions', ['process' => 'remove'])}",
type: "POST",
data: {
"id_product": {$smarty.get.id_product}
@@ -64,7 +64,7 @@ $('document').ready(function(){
});
$('#mailalerts_block_extra_added').click(function(){
$.ajax({
url: "{$link->getModuleLink('mailalerts', 'remove')}",
url: "{$link->getModuleLink('mailalerts', 'actions', ['process' => 'remove'])}",
type: "POST",
data: {
"id_product": {$smarty.get.id_product}
@@ -82,7 +82,7 @@ $('document').ready(function(){
});
$('#mailalerts_block_extra_removed').click(function(){
$.ajax({
url: "{$link->getModuleLink('mailalerts', 'add')}",
url: "{$link->getModuleLink('mailalerts', 'actions', ['process' => 'add'])}",
type: "POST",
data: {
"id_product": {$smarty.get.id_product}
@@ -83,7 +83,7 @@ $('document').ready(function()
var parent = $(this).parent().parent();
$.ajax({
url: "{$link->getModuleLink('mailalerts', 'remove')}",
url: "{$link->getModuleLink('mailalerts', 'actions', ['process' => 'remove'])}",
type: "POST",
data: {
'id_product': idMailAlert
@@ -35,7 +35,7 @@ function clearText() {
function oosHookJsCodeMailAlert() {
$.ajax({
type: 'POST',
url: "{/literal}{$link->getModuleLink('mailalerts', 'check')}{literal}",
url: "{/literal}{$link->getModuleLink('mailalerts', 'actions', ['process' => 'check'])}{literal}",
data: 'id_product={/literal}{$id_product}{literal}&id_product_attribute='+$('#idCombination').val(),
success: function (msg) {
if (msg == '0') {
@@ -53,7 +53,7 @@ function oosHookJsCodeMailAlert() {
function addNotification() {
$.ajax({
type: 'POST',
url: "{/literal}{$link->getModuleLink('mailalerts', 'add')}{literal}",
url: "{/literal}{$link->getModuleLink('mailalerts', 'actions', ['process' => 'add'])}{literal}",
data: 'id_product={/literal}{$id_product}{literal}&id_product_attribute='+$('#idCombination').val()+'&customer_email='+$('#oos_customer_email').val()+'',
success: function (msg) {
if (msg == '1') {