[*] classes : new module architecture
This commit is contained in:
+14
-14
@@ -33,8 +33,8 @@ class Cheque extends PaymentModule
|
||||
private $_html = '';
|
||||
private $_postErrors = array();
|
||||
|
||||
public $chequeName;
|
||||
public $address;
|
||||
public $chequeName;
|
||||
public $address;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@@ -58,22 +58,22 @@ class Cheque extends PaymentModule
|
||||
$this->description = $this->l('Module for accepting payments by check.');
|
||||
$this->confirmUninstall = $this->l('Are you sure you want to delete your details ?');
|
||||
|
||||
if (!isset($this->chequeName) OR !isset($this->address) OR empty($this->chequeName) OR empty($this->address))
|
||||
if (!isset($this->chequeName) || !isset($this->address) || empty($this->chequeName) || empty($this->address))
|
||||
$this->warning = $this->l('\'To the order of\' and address must be configured in order to use this module correctly.');
|
||||
if (!sizeof(Currency::checkPaymentCurrencies($this->id)))
|
||||
if (!count(Currency::checkPaymentCurrencies($this->id)))
|
||||
$this->warning = $this->l('No currency set for this module');
|
||||
}
|
||||
|
||||
public function install()
|
||||
{
|
||||
if (!parent::install() OR !$this->registerHook('payment') OR !$this->registerHook('paymentReturn'))
|
||||
if (!parent::install() || !$this->registerHook('payment') || !$this->registerHook('paymentReturn'))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public function uninstall()
|
||||
{
|
||||
if (!Configuration::deleteByName('CHEQUE_NAME') OR !Configuration::deleteByName('CHEQUE_ADDRESS') OR !parent::uninstall())
|
||||
if (!Configuration::deleteByName('CHEQUE_NAME') || !Configuration::deleteByName('CHEQUE_ADDRESS') || !parent::uninstall())
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
@@ -132,11 +132,11 @@ class Cheque extends PaymentModule
|
||||
if (Tools::isSubmit('btnSubmit'))
|
||||
{
|
||||
$this->_postValidation();
|
||||
if (!sizeof($this->_postErrors))
|
||||
if (!count($this->_postErrors))
|
||||
$this->_postProcess();
|
||||
else
|
||||
foreach ($this->_postErrors AS $err)
|
||||
$this->_html .= '<div class="alert error">'. $err .'</div>';
|
||||
foreach ($this->_postErrors as $err)
|
||||
$this->_html .= '<div class="alert error">'.$err.'</div>';
|
||||
}
|
||||
else
|
||||
$this->_html .= '<br />';
|
||||
@@ -150,9 +150,9 @@ class Cheque extends PaymentModule
|
||||
public function hookPayment($params)
|
||||
{
|
||||
if (!$this->active)
|
||||
return ;
|
||||
return;
|
||||
if (!$this->checkCurrency($params['cart']))
|
||||
return ;
|
||||
return;
|
||||
|
||||
$this->smarty->assign(array(
|
||||
'this_path' => $this->_path,
|
||||
@@ -164,10 +164,10 @@ class Cheque extends PaymentModule
|
||||
public function hookPaymentReturn($params)
|
||||
{
|
||||
if (!$this->active)
|
||||
return ;
|
||||
return;
|
||||
|
||||
$state = $params['objOrder']->getCurrentState();
|
||||
if ($state == Configuration::get('PS_OS_CHEQUE') OR $state == Configuration::get('PS_OS_OUTOFSTOCK'))
|
||||
if ($state == Configuration::get('PS_OS_CHEQUE') || $state == Configuration::get('PS_OS_OUTOFSTOCK'))
|
||||
{
|
||||
$this->smarty->assign(array(
|
||||
'total_to_pay' => Tools::displayPrice($params['total_to_pay'], $params['currencyObj'], false),
|
||||
@@ -190,7 +190,7 @@ class Cheque extends PaymentModule
|
||||
$currencies_module = $this->getCurrency((int)$cart->id_currency);
|
||||
|
||||
if (is_array($currencies_module))
|
||||
foreach ($currencies_module AS $currency_module)
|
||||
foreach ($currencies_module as $currency_module)
|
||||
if ($currency_order->id == $currency_module['id_currency'])
|
||||
return true;
|
||||
return false;
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
<?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 ChequePaymentModuleFrontController extends ModuleFrontController
|
||||
{
|
||||
public $display_column_left = false;
|
||||
|
||||
/**
|
||||
* @see FrontController::initContent()
|
||||
*/
|
||||
public function initContent()
|
||||
{
|
||||
parent::initContent();
|
||||
|
||||
$cart = $this->context->cart;
|
||||
if (!$this->module->checkCurrency($cart))
|
||||
Tools::redirect('index.php?controller=order');
|
||||
|
||||
$this->context->smarty->assign(array(
|
||||
'nbProducts' => $cart->nbProducts(),
|
||||
'cust_currency' => $cart->id_currency,
|
||||
'currencies' => $this->module->getCurrency((int)$cart->id_currency),
|
||||
'total' => $cart->getOrderTotal(true, Cart::BOTH),
|
||||
'isoCode' => $this->context->language->iso_code,
|
||||
'chequeName' => $this->module->chequeName,
|
||||
'chequeAddress' => Tools::nl2br($this->module->address),
|
||||
'this_path' => $this->module->getPathUri(),
|
||||
'this_path_ssl' => Tools::getShopDomainSsl(true, true).__PS_BASE_URI__.'modules/'.$this->module->name.'/'
|
||||
));
|
||||
|
||||
$this->setTemplate('payment_execution.tpl');
|
||||
}
|
||||
}
|
||||
+1
-49
@@ -28,22 +28,9 @@
|
||||
/**
|
||||
* @since 1.5.0
|
||||
*/
|
||||
class ModuleChequeController extends ModuleController
|
||||
class ChequeValidationModuleFrontController extends ModuleFrontController
|
||||
{
|
||||
/**
|
||||
* @see FrontController::postProcess()
|
||||
*/
|
||||
public function postProcess()
|
||||
{
|
||||
$this->display_column_left = false;
|
||||
if ($this->process == 'validation')
|
||||
$this->processValidation();
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate cheque payment
|
||||
*/
|
||||
public function processValidation()
|
||||
{
|
||||
$cart = $this->context->cart;
|
||||
|
||||
@@ -78,39 +65,4 @@ class ModuleChequeController extends ModuleController
|
||||
$this->module->validateOrder((int)$cart->id, Configuration::get('PS_OS_CHEQUE'), $total, $this->module->displayName, NULL, $mailVars, (int)$currency->id, false, $customer->secure_key);
|
||||
Tools::redirect('index.php?controller=order-confirmation&id_cart='.(int)$cart->id.'&id_module='.(int)$this->module->id.'&id_order='.$this->module->currentOrder.'&key='.$customer->secure_key);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see FrontController::initContent()
|
||||
*/
|
||||
public function initContent()
|
||||
{
|
||||
parent::initContent();
|
||||
|
||||
if ($this->process == 'payment')
|
||||
$this->assignPaymentExecution();
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign cheque payment template
|
||||
*/
|
||||
public function assignPaymentExecution()
|
||||
{
|
||||
$cart = $this->context->cart;
|
||||
if (!$this->module->checkCurrency($cart))
|
||||
Tools::redirect('index.php?controller=order');
|
||||
|
||||
$this->context->smarty->assign(array(
|
||||
'nbProducts' => $cart->nbProducts(),
|
||||
'cust_currency' => $cart->id_currency,
|
||||
'currencies' => $this->module->getCurrency((int)$cart->id_currency),
|
||||
'total' => $cart->getOrderTotal(true, Cart::BOTH),
|
||||
'isoCode' => $this->context->language->iso_code,
|
||||
'chequeName' => $this->module->chequeName,
|
||||
'chequeAddress' => Tools::nl2br($this->module->address),
|
||||
'this_path' => $this->module->getPathUri(),
|
||||
'this_path_ssl' => Tools::getShopDomainSsl(true, true).__PS_BASE_URI__.'modules/'.$this->module->name.'/'
|
||||
));
|
||||
|
||||
$this->setTemplate('payment_execution.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=cheque&process=payment');
|
||||
Tools::redirect(Context::getContext()->link->getModuleLink('cheque', 'payment'));
|
||||
@@ -19,8 +19,6 @@ $_MODULE['<{cheque}prestashop>cheque_d75e7b0f61c58d5d1cef7b56322c8b21'] = 'Merci
|
||||
$_MODULE['<{cheque}prestashop>cheque_75475839e69bef6ed57a8200a5a71d37'] = 'A l\'ordre de';
|
||||
$_MODULE['<{cheque}prestashop>cheque_dd7bf230fde8d4836917806aff6a6b27'] = 'Adresse';
|
||||
$_MODULE['<{cheque}prestashop>cheque_b17f3f4dcf653a5776792498a9b44d6a'] = 'Mettre à jour';
|
||||
$_MODULE['<{cheque}prestashop>payment_a5967aadef7d23b5027d46e107faf6d0'] = 'Payer par chèque';
|
||||
$_MODULE['<{cheque}prestashop>payment_30bee0e9549e97b2f65f8fd8fc5948be'] = 'Payer par chèque (traitement plus long)';
|
||||
$_MODULE['<{cheque}prestashop>payment_execution_83aa0e5744c86bf2d9d006319db14839'] = 'Paiement par chèque';
|
||||
$_MODULE['<{cheque}prestashop>payment_execution_f1d3b424cd68795ecaa552883759aceb'] = 'Récapitulatif de commande';
|
||||
$_MODULE['<{cheque}prestashop>payment_execution_879f6b8877752685a966564d072f498f'] = 'Votre panier est vide.';
|
||||
@@ -36,6 +34,8 @@ $_MODULE['<{cheque}prestashop>payment_execution_504be670f962fa7630863857a0085632
|
||||
$_MODULE['<{cheque}prestashop>payment_execution_0881a11f7af33bc1b43e437391129d66'] = 'Merci de confirmer votre commande en cliquant sur \"Je confirme ma commande\"';
|
||||
$_MODULE['<{cheque}prestashop>payment_execution_46b9e3665f187c739c55983f757ccda0'] = 'Je confirme ma commande';
|
||||
$_MODULE['<{cheque}prestashop>payment_execution_569fd05bdafa1712c4f6be5b153b8418'] = 'Autres moyens de paiement';
|
||||
$_MODULE['<{cheque}prestashop>payment_a5967aadef7d23b5027d46e107faf6d0'] = 'Payer par chèque';
|
||||
$_MODULE['<{cheque}prestashop>payment_30bee0e9549e97b2f65f8fd8fc5948be'] = 'Payer par chèque (traitement plus long)';
|
||||
$_MODULE['<{cheque}prestashop>payment_return_2e2117b7c81aa9ea6931641ea2c6499f'] = 'Votre commande sur';
|
||||
$_MODULE['<{cheque}prestashop>payment_return_75fbf512d744977d62599cc3f0ae2bb4'] = 'est bien enregistrée.';
|
||||
$_MODULE['<{cheque}prestashop>payment_return_e4ee6e0eac588fe2611cc6fd195828af'] = 'Merci de nous envoyer un chèque :';
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
include(dirname(__FILE__).'/../../config/config.inc.php');
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@
|
||||
{else}
|
||||
|
||||
<h3>{l s='Cheque payment' mod='cheque'}</h3>
|
||||
<form action="{$link->getModuleLink('cheque', 'validation', true)}" method="post">
|
||||
<form action="{$link->getModuleLink('cheque', 'validation', [], true)}" method="post">
|
||||
<p>
|
||||
<img src="{$this_path}cheque.jpg" alt="{l s='cheque' mod='cheque'}" width="86" height="49" style="float:left; margin: 0px 10px 5px 0px;" />
|
||||
{l s='You have chosen to pay by cheque.' mod='cheque'}
|
||||
@@ -25,7 +25,7 @@
|
||||
*}
|
||||
|
||||
<p class="payment_module">
|
||||
<a href="{$link->getModuleLink('cheque', 'payment', true)}" title="{l s='Pay by cheque' mod='cheque'}">
|
||||
<a href="{$link->getModuleLink('cheque', 'payment', [], true)}" title="{l s='Pay by cheque' mod='cheque'}">
|
||||
<img src="{$this_path}cheque.jpg" alt="{l s='Pay by cheque' mod='cheque'}" width="86" height="49" />
|
||||
{l s='Pay by cheque (order process will be longer)' mod='cheque'}
|
||||
</a>
|
||||
Reference in New Issue
Block a user