From 05073d09cb0126f6859a2d10325c2744ed90d489 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 6 Mar 2014 00:31:27 +0100 Subject: [PATCH 001/372] Add Deactivate Module Command Line --- .../Command/ModuleDeactivateCommand.php | 84 +++++++++++++ .../Command/ModuleDeactivateCommandTest.php | 113 ++++++++++++++++++ 2 files changed, 197 insertions(+) create mode 100755 core/lib/Thelia/Command/ModuleDeactivateCommand.php create mode 100755 core/lib/Thelia/Tests/Command/ModuleDeactivateCommandTest.php diff --git a/core/lib/Thelia/Command/ModuleDeactivateCommand.php b/core/lib/Thelia/Command/ModuleDeactivateCommand.php new file mode 100755 index 000000000..18d38778c --- /dev/null +++ b/core/lib/Thelia/Command/ModuleDeactivateCommand.php @@ -0,0 +1,84 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Command; + +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; + +use Thelia\Model\ModuleQuery; + +/** + * DeActivates a module + * + * Class ModuleDeactivateCommand + * @package Thelia\Command + * @author Nicolas Villa + * + */ +class ModuleDeactivateCommand extends BaseModuleGenerate +{ + protected function configure() + { + $this + ->setName("module:deactivate") + ->setDescription("Deactivate a module") + ->addArgument( + "module" , + InputArgument::REQUIRED, + "module to deactivate" + ) + ; + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $moduleCode = $this->formatModuleName($input->getArgument("module")); + + $module = ModuleQuery::create()->findOneByCode($moduleCode); + + if (null === $module) { + throw new \RuntimeException(sprintf("module %s not found", $moduleCode)); + } + + try { + $moduleReflection = new \ReflectionClass($module->getFullNamespace()); + + $moduleInstance = $moduleReflection->newInstance(); + + $moduleInstance->deActivate(); + } catch (\Exception $e) { + throw new \RuntimeException(sprintf("Deactivation fail with Exception : [%d] %s", $e->getCode(), $e->getMessage())); + } + + //impossible to change output class in CommandTester... + if (method_exists($output, "renderBlock")) { + $output->renderBlock(array( + '', + sprintf("Deactivation succeed for module %s", $moduleCode), + '' + ), "bg=green;fg=black"); + } + } +} diff --git a/core/lib/Thelia/Tests/Command/ModuleDeactivateCommandTest.php b/core/lib/Thelia/Tests/Command/ModuleDeactivateCommandTest.php new file mode 100755 index 000000000..309a29ff8 --- /dev/null +++ b/core/lib/Thelia/Tests/Command/ModuleDeactivateCommandTest.php @@ -0,0 +1,113 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Tests\Command; + +use Symfony\Component\Console\Tester\CommandTester; +use Thelia\Command\ModuleDeactivateCommand; +use Thelia\Core\Application; +use Thelia\Model\ModuleQuery; +use Thelia\Module\BaseModule; + +/** + * Class ModuleDeactivateCommandTest + * + * @package Thelia\Tests\Command + * @author Nicolas Villa + */ +class ModuleDeactivateCommandTest extends \PHPUnit_Framework_TestCase +{ + public function testModuleDeactivateCommand() + { + $module = ModuleQuery::create()->findOne(); + + if (null !== $module) { + + $prev_activation_status = $module->getDeactivate(); + + $application = new Application($this->getKernel()); + + $module->setDeactivate(BaseModule::IS_NOT_ACTIVATED); + $module->save(); + + $moduleDeactivate = new ModuleDeactivateCommand(); + $moduleDeactivate->setContainer($this->getContainer()); + + $application->add($moduleDeactivate); + + $command = $application->find("module:deactivate"); + $commandTester = new CommandTester($command); + $commandTester->execute(array( + "command" => $command->getName(), + "module" => $module->getCode(), + )); + + $deactivated = ModuleQuery::create()->findPk($module->getId())->getDeactivate(); + + // Restore activation status + $module->setDeactivate($prev_activation_status)->save(); + + $this->assertEquals(BaseModule::IS_ACTIVATED, $deactivated); + } + } + + /** + * @expectedException \RuntimeException + * @expectedExceptionMessage module Letshopethismoduledoesnotexists not found + */ + public function testModuleDeactivateCommandUnknownModule() + { + $testedModule = ModuleQuery::create()->findOneByCode('Letshopethismoduledoesnotexists'); + + if (null == $testedModule) { + $application = new Application($this->getKernel()); + + $moduleDeactivate = new ModuleDeactivateCommand(); + $moduleDeactivate->setContainer($this->getContainer()); + + $application->add($moduleDeactivate); + + $command = $application->find("module:deactivate"); + $commandTester = new CommandTester($command); + $commandTester->execute(array( + "command" => $command->getName(), + "module" => "letshopethismoduledoesnotexists", + )); + + $out = true; + } + } + + public function getKernel() + { + $kernel = $this->getMock("Symfony\Component\HttpKernel\KernelInterface"); + + return $kernel; + } + + public function getContainer() + { + $container = new \Symfony\Component\DependencyInjection\ContainerBuilder(); + + return $container; + } +} From 36a49f812d224b6bbc1406dc560ed513a9171118 Mon Sep 17 00:00:00 2001 From: Boyquotes Date: Thu, 6 Mar 2014 00:34:12 +0100 Subject: [PATCH 002/372] Add Deactivate Module Command Line --- .../Command/ModuleDeactivateCommand.php | 84 +++++++++++++ .../Command/ModuleDeactivateCommandTest.php | 113 ++++++++++++++++++ 2 files changed, 197 insertions(+) create mode 100755 core/lib/Thelia/Command/ModuleDeactivateCommand.php create mode 100755 core/lib/Thelia/Tests/Command/ModuleDeactivateCommandTest.php diff --git a/core/lib/Thelia/Command/ModuleDeactivateCommand.php b/core/lib/Thelia/Command/ModuleDeactivateCommand.php new file mode 100755 index 000000000..18d38778c --- /dev/null +++ b/core/lib/Thelia/Command/ModuleDeactivateCommand.php @@ -0,0 +1,84 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Command; + +use Symfony\Component\Console\Input\InputArgument; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; + +use Thelia\Model\ModuleQuery; + +/** + * DeActivates a module + * + * Class ModuleDeactivateCommand + * @package Thelia\Command + * @author Nicolas Villa + * + */ +class ModuleDeactivateCommand extends BaseModuleGenerate +{ + protected function configure() + { + $this + ->setName("module:deactivate") + ->setDescription("Deactivate a module") + ->addArgument( + "module" , + InputArgument::REQUIRED, + "module to deactivate" + ) + ; + } + + protected function execute(InputInterface $input, OutputInterface $output) + { + $moduleCode = $this->formatModuleName($input->getArgument("module")); + + $module = ModuleQuery::create()->findOneByCode($moduleCode); + + if (null === $module) { + throw new \RuntimeException(sprintf("module %s not found", $moduleCode)); + } + + try { + $moduleReflection = new \ReflectionClass($module->getFullNamespace()); + + $moduleInstance = $moduleReflection->newInstance(); + + $moduleInstance->deActivate(); + } catch (\Exception $e) { + throw new \RuntimeException(sprintf("Deactivation fail with Exception : [%d] %s", $e->getCode(), $e->getMessage())); + } + + //impossible to change output class in CommandTester... + if (method_exists($output, "renderBlock")) { + $output->renderBlock(array( + '', + sprintf("Deactivation succeed for module %s", $moduleCode), + '' + ), "bg=green;fg=black"); + } + } +} diff --git a/core/lib/Thelia/Tests/Command/ModuleDeactivateCommandTest.php b/core/lib/Thelia/Tests/Command/ModuleDeactivateCommandTest.php new file mode 100755 index 000000000..309a29ff8 --- /dev/null +++ b/core/lib/Thelia/Tests/Command/ModuleDeactivateCommandTest.php @@ -0,0 +1,113 @@ +. */ +/* */ +/*************************************************************************************/ +namespace Thelia\Tests\Command; + +use Symfony\Component\Console\Tester\CommandTester; +use Thelia\Command\ModuleDeactivateCommand; +use Thelia\Core\Application; +use Thelia\Model\ModuleQuery; +use Thelia\Module\BaseModule; + +/** + * Class ModuleDeactivateCommandTest + * + * @package Thelia\Tests\Command + * @author Nicolas Villa + */ +class ModuleDeactivateCommandTest extends \PHPUnit_Framework_TestCase +{ + public function testModuleDeactivateCommand() + { + $module = ModuleQuery::create()->findOne(); + + if (null !== $module) { + + $prev_activation_status = $module->getDeactivate(); + + $application = new Application($this->getKernel()); + + $module->setDeactivate(BaseModule::IS_NOT_ACTIVATED); + $module->save(); + + $moduleDeactivate = new ModuleDeactivateCommand(); + $moduleDeactivate->setContainer($this->getContainer()); + + $application->add($moduleDeactivate); + + $command = $application->find("module:deactivate"); + $commandTester = new CommandTester($command); + $commandTester->execute(array( + "command" => $command->getName(), + "module" => $module->getCode(), + )); + + $deactivated = ModuleQuery::create()->findPk($module->getId())->getDeactivate(); + + // Restore activation status + $module->setDeactivate($prev_activation_status)->save(); + + $this->assertEquals(BaseModule::IS_ACTIVATED, $deactivated); + } + } + + /** + * @expectedException \RuntimeException + * @expectedExceptionMessage module Letshopethismoduledoesnotexists not found + */ + public function testModuleDeactivateCommandUnknownModule() + { + $testedModule = ModuleQuery::create()->findOneByCode('Letshopethismoduledoesnotexists'); + + if (null == $testedModule) { + $application = new Application($this->getKernel()); + + $moduleDeactivate = new ModuleDeactivateCommand(); + $moduleDeactivate->setContainer($this->getContainer()); + + $application->add($moduleDeactivate); + + $command = $application->find("module:deactivate"); + $commandTester = new CommandTester($command); + $commandTester->execute(array( + "command" => $command->getName(), + "module" => "letshopethismoduledoesnotexists", + )); + + $out = true; + } + } + + public function getKernel() + { + $kernel = $this->getMock("Symfony\Component\HttpKernel\KernelInterface"); + + return $kernel; + } + + public function getContainer() + { + $container = new \Symfony\Component\DependencyInjection\ContainerBuilder(); + + return $container; + } +} From dce97917c3cb22a220d740a6f3143bf4f2cdedaa Mon Sep 17 00:00:00 2001 From: Christophe Laffont Date: Tue, 11 Mar 2014 09:59:07 +0100 Subject: [PATCH 003/372] Improve gitignore rules for modules and templates --- .gitignore | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index a6845dd3e..65ccbeaa3 100755 --- a/.gitignore +++ b/.gitignore @@ -25,7 +25,19 @@ xhprof/ phpunit.phar .DS_Store phpmyadmin -templates/default-esi -local/modules/TemplateEsiModule composer.phar -web/.htaccess +web/. + +# Ignore everything in the "modules" directory, except the "default modules" +local/modules/* +!local/modules/Cheque/ +!local/modules/Front/ +!local/modules/TheliaDebugBar/ +!local/modules/Tinymce/ + +# Ignore everything in the "templates" directory, except the "default template" +templates/* +!templates/backOffice/ +!templates/email/ +!templates/frontOffice/ +!templates/pdf/ From 5eb8f3a13df430f4c5a6aae6e6385fab3ef8c03b Mon Sep 17 00:00:00 2001 From: Christophe Laffont Date: Tue, 11 Mar 2014 10:02:11 +0100 Subject: [PATCH 004/372] Missing htaccess --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 65ccbeaa3..bb3b4d299 100755 --- a/.gitignore +++ b/.gitignore @@ -26,7 +26,7 @@ phpunit.phar .DS_Store phpmyadmin composer.phar -web/. +web/.htaccess # Ignore everything in the "modules" directory, except the "default modules" local/modules/* From 33f2b56080ba4bb4014409794e43c3e554cad134 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 11 Mar 2014 15:42:43 +0100 Subject: [PATCH 005/372] and product output are now optional --- .../lib/Thelia/Core/Template/Loop/Product.php | 48 +++++++++++-------- templates/frontOffice/default/product.html | 8 ++-- 2 files changed, 32 insertions(+), 24 deletions(-) diff --git a/core/lib/Thelia/Core/Template/Loop/Product.php b/core/lib/Thelia/Core/Template/Loop/Product.php index 8bcf76e4d..2087a576a 100644 --- a/core/lib/Thelia/Core/Template/Loop/Product.php +++ b/core/lib/Thelia/Core/Template/Loop/Product.php @@ -83,6 +83,7 @@ class Product extends BaseI18nLoop implements PropelSearchLoopInterface, SearchL Argument::createIntTypeArgument('min_stock'), Argument::createFloatTypeArgument('min_weight'), Argument::createFloatTypeArgument('max_weight'), + Argument::createBooleanTypeArgument('with_prev_next_info', false), Argument::createBooleanTypeArgument('current'), Argument::createBooleanTypeArgument('current_category'), Argument::createIntTypeArgument('depth', 1), @@ -1004,22 +1005,6 @@ class Product extends BaseI18nLoop implements PropelSearchLoopInterface, SearchL // Find previous and next product, in the default category. $default_category_id = $product->getDefaultCategoryId(); - $previous = ProductQuery::create() - ->joinProductCategory() - ->where('ProductCategory.category_id = ?', $default_category_id) - ->filterByPosition($product->getPosition(), Criteria::LESS_THAN) - ->orderByPosition(Criteria::DESC) - ->findOne() - ; - - $next = ProductQuery::create() - ->joinProductCategory() - ->where('ProductCategory.category_id = ?', $default_category_id) - ->filterByPosition($product->getPosition(), Criteria::GREATER_THAN) - ->orderByPosition(Criteria::ASC) - ->findOne() - ; - $loopResultRow ->set("ID" , $product->getId()) ->set("REF" , $product->getRef()) @@ -1041,15 +1026,38 @@ class Product extends BaseI18nLoop implements PropelSearchLoopInterface, SearchL ->set("POSITION" , $product->getPosition()) ->set("VISIBLE" , $product->getVisible() ? "1" : "0") ->set("TEMPLATE" , $product->getTemplateId()) - ->set("HAS_PREVIOUS" , $previous != null ? 1 : 0) - ->set("HAS_NEXT" , $next != null ? 1 : 0) - ->set("PREVIOUS" , $previous != null ? $previous->getId() : -1) - ->set("NEXT" , $next != null ? $next->getId() : -1) ->set("DEFAULT_CATEGORY" , $default_category_id) ->set("TAX_RULE_ID" , $product->getTaxRuleId()) ; + + if ($this->getBackend_context() || $this->getWithPrevNextInfo()) { + // Find previous and next category + $previous = ProductQuery::create() + ->joinProductCategory() + ->where('ProductCategory.category_id = ?', $default_category_id) + ->filterByPosition($product->getPosition(), Criteria::LESS_THAN) + ->orderByPosition(Criteria::DESC) + ->findOne() + ; + + $next = ProductQuery::create() + ->joinProductCategory() + ->where('ProductCategory.category_id = ?', $default_category_id) + ->filterByPosition($product->getPosition(), Criteria::GREATER_THAN) + ->orderByPosition(Criteria::ASC) + ->findOne() + ; + + $loopResultRow + ->set("HAS_PREVIOUS" , $previous != null ? 1 : 0) + ->set("HAS_NEXT" , $next != null ? 1 : 0) + ->set("PREVIOUS" , $previous != null ? $previous->getId() : -1) + ->set("NEXT" , $next != null ? $next->getId() : -1) + ; + } + $loopResult->addRow($loopResultRow); } diff --git a/templates/frontOffice/default/product.html b/templates/frontOffice/default/product.html index 2d11498e8..a3c57a371 100644 --- a/templates/frontOffice/default/product.html +++ b/templates/frontOffice/default/product.html @@ -5,14 +5,14 @@ {* Page Title *} {block name='no-return-functions' append} - {loop name="product.seo.title" type="product" id="{product attr="id"}"} + {loop name="product.seo.title" type="product" id="{product attr="id"}" with_prev_next_info="1"} {$page_title = {$META_TITLE}} {/loop} {/block} {* Meta *} {block name="meta"} - {loop name="product.seo.meta" type="product" id="{product attr="id"}" limit="1"} + {loop name="product.seo.meta" type="product" id="{product attr="id"}" limit="1" with_prev_next_info="1"} {if $META_DESCRIPTION}{/if} {if $META_KEYWORDS}{/if} {/loop} @@ -21,7 +21,7 @@ {* Breadcrumb *} {block name='no-return-functions' append} {$breadcrumbs = []} - {loop type="product" name="product_breadcrumb" id="{product attr="id"}" limit="1"} + {loop type="product" name="product_breadcrumb" id="{product attr="id"}" limit="1" with_prev_next_info="1"} {loop name="category_path" type="category-path" category="{$DEFAULT_CATEGORY}"} {$breadcrumbs[] = ['title' => {$TITLE}, 'url'=> {$URL}]} {/loop} @@ -32,7 +32,7 @@ {* Content *} {block name="main-content"}
- {loop name="product.details" type="product" id="{product attr="id"}" limit="1"} + {loop name="product.details" type="product" id="{product attr="id"}" limit="1" with_prev_next_info="1"}
From 4391e6334b8b0da18110ffb8a784bdede0c57fdc Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 11 Mar 2014 15:43:48 +0100 Subject: [PATCH 006/372] fix modules cs --- local/modules/Front/Controller/AddressController.php | 1 - local/modules/Front/Controller/CartController.php | 5 ++--- local/modules/Front/Controller/CouponController.php | 4 ++-- local/modules/Front/Controller/OrderController.php | 8 +++----- 4 files changed, 7 insertions(+), 11 deletions(-) diff --git a/local/modules/Front/Controller/AddressController.php b/local/modules/Front/Controller/AddressController.php index f8cbde0a4..1ab3e324f 100644 --- a/local/modules/Front/Controller/AddressController.php +++ b/local/modules/Front/Controller/AddressController.php @@ -183,7 +183,6 @@ class AddressController extends BaseFrontController \Thelia\Log\Tlog::getInstance()->error(sprintf('Error during address deletion : %s', $error_message)); - // If Ajax Request if ($this->getRequest()->isXmlHttpRequest()) { if ($error_message) { diff --git a/local/modules/Front/Controller/CartController.php b/local/modules/Front/Controller/CartController.php index 5985dedb5..59110d62a 100644 --- a/local/modules/Front/Controller/CartController.php +++ b/local/modules/Front/Controller/CartController.php @@ -154,11 +154,11 @@ class CartController extends BaseFrontController { /* recalculate postage amount */ $order = $this->getSession()->getOrder(); - if(null !== $order) { + if (null !== $order) { $deliveryModule = $order->getModuleRelatedByDeliveryModuleId(); $deliveryAddress = AddressQuery::create()->findPk($order->chosenDeliveryAddress); - if(null !== $deliveryModule && null !== $deliveryAddress) { + if (null !== $deliveryModule && null !== $deliveryAddress) { $moduleInstance = $this->container->get(sprintf('module.%s', $deliveryModule->getCode())); $postage = $moduleInstance->getPostage($deliveryAddress->getCountry()); @@ -170,5 +170,4 @@ class CartController extends BaseFrontController } } - } diff --git a/local/modules/Front/Controller/CouponController.php b/local/modules/Front/Controller/CouponController.php index 73eef34b7..ba7433612 100644 --- a/local/modules/Front/Controller/CouponController.php +++ b/local/modules/Front/Controller/CouponController.php @@ -68,11 +68,11 @@ class CouponController extends BaseFrontController /* recalculate postage amount */ $order = $this->getSession()->getOrder(); - if(null !== $order) { + if (null !== $order) { $deliveryModule = $order->getModuleRelatedByDeliveryModuleId(); $deliveryAddress = AddressQuery::create()->findPk($order->chosenDeliveryAddress); - if(null !== $deliveryModule && null !== $deliveryAddress) { + if (null !== $deliveryModule && null !== $deliveryAddress) { $moduleInstance = $this->container->get(sprintf('module.%s', $deliveryModule->getCode())); $postage = $moduleInstance->getPostage($deliveryAddress->getCountry()); diff --git a/local/modules/Front/Controller/OrderController.php b/local/modules/Front/Controller/OrderController.php index 4791663f0..5ac01d723 100644 --- a/local/modules/Front/Controller/OrderController.php +++ b/local/modules/Front/Controller/OrderController.php @@ -25,9 +25,6 @@ namespace Front\Controller; use Propel\Runtime\Exception\PropelException; use Thelia\Cart\CartTrait; use Thelia\Controller\Front\BaseFrontController; -use Thelia\Core\Event\PdfEvent; -use Thelia\Core\HttpFoundation\Response; -use Thelia\Core\Template\TemplateHelper; use Thelia\Core\Translation\Translator; use Thelia\Exception\TheliaProcessException; use Thelia\Form\Exception\FormValidationException; @@ -202,7 +199,7 @@ class OrderController extends BaseFrontController if (null !== $placedOrder && null !== $placedOrder->getId()) { /* order has been placed */ - if($orderEvent->hasResponse()) { + if ($orderEvent->hasResponse()) { return $orderEvent->getResponse(); } else { $this->redirect(URL::getInstance()->absoluteUrl($this->getRoute('order.placed', array('order_id' => $orderEvent->getPlacedOrder()->getId())))); @@ -263,6 +260,7 @@ class OrderController extends BaseFrontController { /* check customer */ $this->checkAuth(); + return $this->generateOrderPdf($order_id, ConfigQuery::read('pdf_invoice_file', 'invoice')); } @@ -270,6 +268,7 @@ class OrderController extends BaseFrontController { /* check customer */ $this->checkAuth(); + return $this->generateOrderPdf($order_id, ConfigQuery::read('pdf_delivery_file', 'delivery')); } @@ -286,5 +285,4 @@ class OrderController extends BaseFrontController return $this->render('ajax/order-delivery-module-list', $args); } - } From 7bad5acbf8eb0a46674f230df28c2eb1f3731e1a Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 11 Mar 2014 15:59:55 +0100 Subject: [PATCH 007/372] verify next/prev param in parserResult product loop --- .../lib/Thelia/Core/Template/Loop/Product.php | 46 +++++++++++-------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/core/lib/Thelia/Core/Template/Loop/Product.php b/core/lib/Thelia/Core/Template/Loop/Product.php index 2087a576a..e8ded00f9 100644 --- a/core/lib/Thelia/Core/Template/Loop/Product.php +++ b/core/lib/Thelia/Core/Template/Loop/Product.php @@ -495,22 +495,6 @@ class Product extends BaseI18nLoop implements PropelSearchLoopInterface, SearchL // Find previous and next product, in the default category. $default_category_id = $product->getDefaultCategoryId(); - $previous = ProductQuery::create() - ->joinProductCategory() - ->where('ProductCategory.category_id = ?', $default_category_id) - ->filterByPosition($product->getPosition(), Criteria::LESS_THAN) - ->orderByPosition(Criteria::DESC) - ->findOne() - ; - - $next = ProductQuery::create() - ->joinProductCategory() - ->where('ProductCategory.category_id = ?', $default_category_id) - ->filterByPosition($product->getPosition(), Criteria::GREATER_THAN) - ->orderByPosition(Criteria::ASC) - ->findOne() - ; - $loopResultRow ->set("ID" , $product->getId()) ->set("REF" , $product->getRef()) @@ -542,15 +526,37 @@ class Product extends BaseI18nLoop implements PropelSearchLoopInterface, SearchL ->set("POSITION" , $product->getPosition()) ->set("VISIBLE" , $product->getVisible() ? "1" : "0") ->set("TEMPLATE" , $product->getTemplateId()) - ->set("HAS_PREVIOUS" , $previous != null ? 1 : 0) - ->set("HAS_NEXT" , $next != null ? 1 : 0) - ->set("PREVIOUS" , $previous != null ? $previous->getId() : -1) - ->set("NEXT" , $next != null ? $next->getId() : -1) ->set("DEFAULT_CATEGORY" , $default_category_id) ->set("TAX_RULE_ID" , $product->getTaxRuleId()) ; + if ($this->getBackend_context() || $this->getWithPrevNextInfo()) { + // Find previous and next category + $previous = ProductQuery::create() + ->joinProductCategory() + ->where('ProductCategory.category_id = ?', $default_category_id) + ->filterByPosition($product->getPosition(), Criteria::LESS_THAN) + ->orderByPosition(Criteria::DESC) + ->findOne() + ; + + $next = ProductQuery::create() + ->joinProductCategory() + ->where('ProductCategory.category_id = ?', $default_category_id) + ->filterByPosition($product->getPosition(), Criteria::GREATER_THAN) + ->orderByPosition(Criteria::ASC) + ->findOne() + ; + + $loopResultRow + ->set("HAS_PREVIOUS" , $previous != null ? 1 : 0) + ->set("HAS_NEXT" , $next != null ? 1 : 0) + ->set("PREVIOUS" , $previous != null ? $previous->getId() : -1) + ->set("NEXT" , $next != null ? $next->getId() : -1) + ; + } + $loopResult->addRow($loopResultRow); } From ed6d0b4a7159487cd490be7d01b485e2e87a0940 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 11 Mar 2014 16:40:58 +0100 Subject: [PATCH 008/372] refactor product loop, removing some duplicated lines --- .../lib/Thelia/Core/Template/Loop/Product.php | 155 +++++++----------- 1 file changed, 61 insertions(+), 94 deletions(-) diff --git a/core/lib/Thelia/Core/Template/Loop/Product.php b/core/lib/Thelia/Core/Template/Loop/Product.php index e8ded00f9..80fa18768 100644 --- a/core/lib/Thelia/Core/Template/Loop/Product.php +++ b/core/lib/Thelia/Core/Template/Loop/Product.php @@ -496,18 +496,9 @@ class Product extends BaseI18nLoop implements PropelSearchLoopInterface, SearchL $default_category_id = $product->getDefaultCategoryId(); $loopResultRow - ->set("ID" , $product->getId()) - ->set("REF" , $product->getRef()) - ->set("IS_TRANSLATED" , $product->getVirtualColumn('IS_TRANSLATED')) - ->set("LOCALE" , $this->locale) - ->set("TITLE" , $product->getVirtualColumn('i18n_TITLE')) - ->set("CHAPO" , $product->getVirtualColumn('i18n_CHAPO')) - ->set("DESCRIPTION" , $product->getVirtualColumn('i18n_DESCRIPTION')) - ->set("POSTSCRIPTUM" , $product->getVirtualColumn('i18n_POSTSCRIPTUM')) - ->set("URL" , $product->getUrl($this->locale)) - ->set("META_TITLE" , $product->getVirtualColumn('i18n_META_TITLE')) - ->set("META_DESCRIPTION" , $product->getVirtualColumn('i18n_META_DESCRIPTION')) - ->set("META_KEYWORDS" , $product->getVirtualColumn('i18n_META_KEYWORDS')) + ->set("WEIGHT" , $product->getVirtualColumn('weight')) + ->set("QUANTITY" , $product->getVirtualColumn('quantity')) + ->set("EAN_CODE" , $product->getVirtualColumn('ean_code')) ->set("BEST_PRICE" , $product->getVirtualColumn('is_promo') ? $promoPrice : $price) ->set("BEST_PRICE_TAX" , $taxedPrice - $product->getVirtualColumn('is_promo') ? $taxedPromoPrice - $promoPrice : $taxedPrice - $price) ->set("BEST_TAXED_PRICE" , $product->getVirtualColumn('is_promo') ? $taxedPromoPrice : $taxedPrice) @@ -517,47 +508,13 @@ class Product extends BaseI18nLoop implements PropelSearchLoopInterface, SearchL ->set("PROMO_PRICE" , $promoPrice) ->set("PROMO_PRICE_TAX" , $taxedPromoPrice - $promoPrice) ->set("TAXED_PROMO_PRICE" , $taxedPromoPrice) - ->set("PRODUCT_SALE_ELEMENT" , $product->getVirtualColumn('pse_id')) - ->set("WEIGHT" , $product->getVirtualColumn('weight')) - ->set("QUANTITY" , $product->getVirtualColumn('quantity')) - ->set("EAN_CODE" , $product->getVirtualColumn('ean_code')) ->set("IS_PROMO" , $product->getVirtualColumn('is_promo')) ->set("IS_NEW" , $product->getVirtualColumn('is_new')) - ->set("POSITION" , $product->getPosition()) - ->set("VISIBLE" , $product->getVisible() ? "1" : "0") - ->set("TEMPLATE" , $product->getTemplateId()) - ->set("DEFAULT_CATEGORY" , $default_category_id) - ->set("TAX_RULE_ID" , $product->getTaxRuleId()) ; - if ($this->getBackend_context() || $this->getWithPrevNextInfo()) { - // Find previous and next category - $previous = ProductQuery::create() - ->joinProductCategory() - ->where('ProductCategory.category_id = ?', $default_category_id) - ->filterByPosition($product->getPosition(), Criteria::LESS_THAN) - ->orderByPosition(Criteria::DESC) - ->findOne() - ; - $next = ProductQuery::create() - ->joinProductCategory() - ->where('ProductCategory.category_id = ?', $default_category_id) - ->filterByPosition($product->getPosition(), Criteria::GREATER_THAN) - ->orderByPosition(Criteria::ASC) - ->findOne() - ; - - $loopResultRow - ->set("HAS_PREVIOUS" , $previous != null ? 1 : 0) - ->set("HAS_NEXT" , $next != null ? 1 : 0) - ->set("PREVIOUS" , $previous != null ? $previous->getId() : -1) - ->set("NEXT" , $next != null ? $next->getId() : -1) - ; - } - - $loopResult->addRow($loopResultRow); + $loopResult->addRow($this->associateValues($loopResultRow, $product, $default_category_id)); } return $loopResult; @@ -1012,64 +969,74 @@ class Product extends BaseI18nLoop implements PropelSearchLoopInterface, SearchL $default_category_id = $product->getDefaultCategoryId(); $loopResultRow - ->set("ID" , $product->getId()) - ->set("REF" , $product->getRef()) - ->set("IS_TRANSLATED" , $product->getVirtualColumn('IS_TRANSLATED')) - ->set("LOCALE" , $this->locale) - ->set("TITLE" , $product->getVirtualColumn('i18n_TITLE')) - ->set("CHAPO" , $product->getVirtualColumn('i18n_CHAPO')) - ->set("DESCRIPTION" , $product->getVirtualColumn('i18n_DESCRIPTION')) - ->set("POSTSCRIPTUM" , $product->getVirtualColumn('i18n_POSTSCRIPTUM')) - ->set("URL" , $product->getUrl($this->locale)) - ->set("META_TITLE" , $product->getVirtualColumn('i18n_META_TITLE')) - ->set("META_DESCRIPTION" , $product->getVirtualColumn('i18n_META_DESCRIPTION')) - ->set("META_KEYWORDS" , $product->getVirtualColumn('i18n_META_KEYWORDS')) ->set("BEST_PRICE" , $price) ->set("BEST_PRICE_TAX" , $taxedPrice - $price) ->set("BEST_TAXED_PRICE" , $taxedPrice) - ->set("IS_PROMO" , $product->getVirtualColumn('main_product_is_promo')) - ->set("IS_NEW" , $product->getVirtualColumn('main_product_is_new')) - ->set("POSITION" , $product->getPosition()) - ->set("VISIBLE" , $product->getVisible() ? "1" : "0") - ->set("TEMPLATE" , $product->getTemplateId()) - ->set("DEFAULT_CATEGORY" , $default_category_id) - ->set("TAX_RULE_ID" , $product->getTaxRuleId()) - + ->set("IS_PROMO" , $product->getVirtualColumn('is_promo')) + ->set("IS_NEW" , $product->getVirtualColumn('is_new')) ; - if ($this->getBackend_context() || $this->getWithPrevNextInfo()) { - // Find previous and next category - $previous = ProductQuery::create() - ->joinProductCategory() - ->where('ProductCategory.category_id = ?', $default_category_id) - ->filterByPosition($product->getPosition(), Criteria::LESS_THAN) - ->orderByPosition(Criteria::DESC) - ->findOne() - ; - - $next = ProductQuery::create() - ->joinProductCategory() - ->where('ProductCategory.category_id = ?', $default_category_id) - ->filterByPosition($product->getPosition(), Criteria::GREATER_THAN) - ->orderByPosition(Criteria::ASC) - ->findOne() - ; - - $loopResultRow - ->set("HAS_PREVIOUS" , $previous != null ? 1 : 0) - ->set("HAS_NEXT" , $next != null ? 1 : 0) - ->set("PREVIOUS" , $previous != null ? $previous->getId() : -1) - ->set("NEXT" , $next != null ? $next->getId() : -1) - ; - } - - $loopResult->addRow($loopResultRow); + $loopResult->addRow($this->associateValues($loopResultRow, $product, $default_category_id)); } return $loopResult; } + private function associateValues($loopResultRow, $product, $default_category_id) + { + $loopResultRow + ->set("ID" , $product->getId()) + ->set("REF" , $product->getRef()) + ->set("IS_TRANSLATED" , $product->getVirtualColumn('IS_TRANSLATED')) + ->set("LOCALE" , $this->locale) + ->set("TITLE" , $product->getVirtualColumn('i18n_TITLE')) + ->set("CHAPO" , $product->getVirtualColumn('i18n_CHAPO')) + ->set("DESCRIPTION" , $product->getVirtualColumn('i18n_DESCRIPTION')) + ->set("POSTSCRIPTUM" , $product->getVirtualColumn('i18n_POSTSCRIPTUM')) + ->set("URL" , $product->getUrl($this->locale)) + ->set("META_TITLE" , $product->getVirtualColumn('i18n_META_TITLE')) + ->set("META_DESCRIPTION" , $product->getVirtualColumn('i18n_META_DESCRIPTION')) + ->set("META_KEYWORDS" , $product->getVirtualColumn('i18n_META_KEYWORDS')) + ->set("PRODUCT_SALE_ELEMENT" , $product->getVirtualColumn('pse_id')) + ->set("POSITION" , $product->getPosition()) + ->set("VISIBLE" , $product->getVisible() ? "1" : "0") + ->set("TEMPLATE" , $product->getTemplateId()) + ->set("DEFAULT_CATEGORY" , $default_category_id) + ->set("TAX_RULE_ID" , $product->getTaxRuleId()) + + ; + + + if ($this->getBackend_context() || $this->getWithPrevNextInfo()) { + // Find previous and next category + $previous = ProductQuery::create() + ->joinProductCategory() + ->where('ProductCategory.category_id = ?', $default_category_id) + ->filterByPosition($product->getPosition(), Criteria::LESS_THAN) + ->orderByPosition(Criteria::DESC) + ->findOne() + ; + + $next = ProductQuery::create() + ->joinProductCategory() + ->where('ProductCategory.category_id = ?', $default_category_id) + ->filterByPosition($product->getPosition(), Criteria::GREATER_THAN) + ->orderByPosition(Criteria::ASC) + ->findOne() + ; + + $loopResultRow + ->set("HAS_PREVIOUS" , $previous != null ? 1 : 0) + ->set("HAS_NEXT" , $next != null ? 1 : 0) + ->set("PREVIOUS" , $previous != null ? $previous->getId() : -1) + ->set("NEXT" , $next != null ? $next->getId() : -1) + ; + } + + return $loopResultRow; + } + protected function manageFeatureAv(&$search, $feature_availability) { if (null !== $feature_availability) { From 775160235cdd264f9b44ebc10be6ec66077c00c7 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Tue, 11 Mar 2014 17:39:56 +0100 Subject: [PATCH 009/372] fix module_include countvar assignation --- .../Thelia/Core/Template/Smarty/Plugins/Module.php | 12 +++++------- templates/backOffice/default/category-edit.html | 2 +- templates/backOffice/default/content-edit.html | 2 +- templates/backOffice/default/folder-edit.html | 2 +- templates/backOffice/default/order-edit.html | 2 +- templates/backOffice/default/product-edit.html | 2 +- 6 files changed, 10 insertions(+), 12 deletions(-) diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/Module.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/Module.php index a66a1ed03..77715cad6 100644 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/Module.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/Module.php @@ -63,7 +63,7 @@ class Module extends AbstractSmartyPlugin public function theliaModule($params, \Smarty_Internal_Template $template) { $content = null; - + $count = 0; if (false !== $location = $this->getParam($params, 'location', false)) { if ($this->debug === true && $this->request->get('SHOW_INCLUDE')) { @@ -74,8 +74,6 @@ class Module extends AbstractSmartyPlugin $modules = ModuleQuery::getActivated(); - $count = 0; - foreach ($modules as $module) { if (null !== $moduleLimit && $moduleLimit != $module->getCode()) { @@ -92,14 +90,14 @@ class Module extends AbstractSmartyPlugin } } - if (! empty($content)) { - return $template->fetch(sprintf("string:%s", $content)); - } - if (false !== $countvarname = $this->getParam($params, 'countvar', false)) { $template->assign($countvarname, $count); } + if (! empty($content)) { + return $template->fetch(sprintf("string:%s", $content)); + } + return ""; } diff --git a/templates/backOffice/default/category-edit.html b/templates/backOffice/default/category-edit.html index 8f3fc4e40..02e48bc63 100644 --- a/templates/backOffice/default/category-edit.html +++ b/templates/backOffice/default/category-edit.html @@ -273,7 +273,7 @@ {module_include location='category-edit' countvar='module_count'} - {if $countvar == 0} + {if $module_count == 0}
{intl l="There is currently no active module here."}
diff --git a/templates/backOffice/default/content-edit.html b/templates/backOffice/default/content-edit.html index 49c8f6b66..3c238b8da 100644 --- a/templates/backOffice/default/content-edit.html +++ b/templates/backOffice/default/content-edit.html @@ -168,7 +168,7 @@ {module_include location='content-edit' countvar='module_count'} - {if $countvar == 0} + {if $module_count == 0}
{intl l="There is currently no active module here."}
diff --git a/templates/backOffice/default/folder-edit.html b/templates/backOffice/default/folder-edit.html index bff41f094..3d627dfce 100644 --- a/templates/backOffice/default/folder-edit.html +++ b/templates/backOffice/default/folder-edit.html @@ -154,7 +154,7 @@ {module_include location='folder-edit' countvar='module_count'} - {if $countvar == 0} + {if $module_count == 0}
{intl l="There is currently no active module here."}
diff --git a/templates/backOffice/default/order-edit.html b/templates/backOffice/default/order-edit.html index b7a134079..3a50b6e1c 100644 --- a/templates/backOffice/default/order-edit.html +++ b/templates/backOffice/default/order-edit.html @@ -353,7 +353,7 @@ {module_include location='order-edit' countvar='module_count'} - {if $countvar == 0} + {if $module_count == 0}
{intl l="There is currently no active module here."}
diff --git a/templates/backOffice/default/product-edit.html b/templates/backOffice/default/product-edit.html index 0eb56fed4..21e50dab8 100644 --- a/templates/backOffice/default/product-edit.html +++ b/templates/backOffice/default/product-edit.html @@ -121,7 +121,7 @@ {module_include location='product-edit' countvar='module_count'} - {if $countvar == 0} + {if $module_count == 0}
{intl l="There is currently no active module here."}
From d8e1f24fda8e937361874bb9b1fe69364f4ef84b Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Wed, 12 Mar 2014 16:21:45 +0100 Subject: [PATCH 010/372] weight and visibility on product are not mandatory anymore --- core/lib/Thelia/Action/Product.php | 4 ++-- core/lib/Thelia/Form/ProductCreationForm.php | 1 - templates/backOffice/default/categories.html | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/core/lib/Thelia/Action/Product.php b/core/lib/Thelia/Action/Product.php index b0e443179..39ddf9a2a 100644 --- a/core/lib/Thelia/Action/Product.php +++ b/core/lib/Thelia/Action/Product.php @@ -75,7 +75,7 @@ class Product extends BaseAction implements EventSubscriberInterface ->setRef($event->getRef()) ->setLocale($event->getLocale()) ->setTitle($event->getTitle()) - ->setVisible($event->getVisible()) + ->setVisible($event->getVisible() ? 1 : 0) // Set the default tax rule to this product ->setTaxRule(TaxRuleQuery::create()->findOneByIsDefault(true)) @@ -109,7 +109,7 @@ class Product extends BaseAction implements EventSubscriberInterface ->setDescription($event->getDescription()) ->setChapo($event->getChapo()) ->setPostscriptum($event->getPostscriptum()) - ->setVisible($event->getVisible()) + ->setVisible($event->getVisible() ? 1 : 0) ->save() ; diff --git a/core/lib/Thelia/Form/ProductCreationForm.php b/core/lib/Thelia/Form/ProductCreationForm.php index de683e27a..200f61199 100644 --- a/core/lib/Thelia/Form/ProductCreationForm.php +++ b/core/lib/Thelia/Form/ProductCreationForm.php @@ -83,7 +83,6 @@ class ProductCreationForm extends BaseForm "label_attr" => array("for" => "tax_rule_field") )) ->add("weight", "number", array( - "constraints" => array(new NotBlank()), "label" => Translator::getInstance()->trans("Weight *"), "label_attr" => array("for" => "weight_field") )) diff --git a/templates/backOffice/default/categories.html b/templates/backOffice/default/categories.html index a0b43145c..d8418f46a 100644 --- a/templates/backOffice/default/categories.html +++ b/templates/backOffice/default/categories.html @@ -520,7 +520,7 @@
- + {intl l="Kg"}
From e4ba7d8d111f98ff0f435d80b61d0514e55d44a8 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Thu, 13 Mar 2014 09:56:11 +0100 Subject: [PATCH 011/372] change the way product is created --- core/lib/Thelia/Config/I18n/en_US.php | 60 +++++----- core/lib/Thelia/Config/I18n/fr_FR.php | 60 +++++----- .../Thelia/Config/Resources/routing/admin.xml | 4 + .../Controller/Admin/ProductController.php | 52 +++++++- core/lib/Thelia/Form/OrderPayment.php | 2 +- core/lib/Thelia/Form/ProductCreationForm.php | 8 +- core/lib/Thelia/TaxEngine/Calculator.php | 21 ++++ .../TaxType/FeatureFixAmountTaxType.php | 14 ++- templates/backOffice/default/I18n/en_US.php | 13 +- templates/backOffice/default/I18n/fr_FR.php | 14 ++- templates/backOffice/default/categories.html | 112 ++++++++++++++---- templates/frontOffice/default/I18n/en_US.php | 3 + templates/frontOffice/default/I18n/fr_FR.php | 3 + 13 files changed, 259 insertions(+), 107 deletions(-) mode change 100755 => 100644 templates/backOffice/default/I18n/en_US.php mode change 100755 => 100644 templates/backOffice/default/I18n/fr_FR.php mode change 100755 => 100644 templates/frontOffice/default/I18n/en_US.php mode change 100755 => 100644 templates/frontOffice/default/I18n/fr_FR.php diff --git a/core/lib/Thelia/Config/I18n/en_US.php b/core/lib/Thelia/Config/I18n/en_US.php index b3c312c5a..5876d211c 100644 --- a/core/lib/Thelia/Config/I18n/en_US.php +++ b/core/lib/Thelia/Config/I18n/en_US.php @@ -6,14 +6,17 @@ return array( '%obj modification' => '%obj modification', 'A currency with code "%name" already exists.' => 'A currency with code "%name" already exists.', 'A message with name "%name" already exists.' => 'A message with name "%name" already exists.', + 'A user already exists with this email address. Please login or if you\'ve forgotten your password, go to Reset Your Password.' => 'A user already exists with this email address. Please login or if you\'ve forgotten your password, go to Reset Your Password.', 'A variable with name "%name" already exists.' => 'A variable with name "%name" already exists.', 'Activate logs only for these IP Addresses' => 'Activate logs only for these IP Addresses', 'Activate logs only for these files' => 'Activate logs only for these files', 'Add to all product templates' => 'Add to all product templates', 'Additional address' => 'Additional address', + 'Address ID not found' => 'Address ID not found', 'Address Line 2' => 'Address Line 2', 'Address Line 3' => 'Address Line 3', 'Address label' => 'Address label', + 'Administrator ID not found' => 'Administrator ID not found', 'Advertise this product as new' => 'Advertise this product as new', 'Alerts' => 'Alerts', 'Alpha code 2 *' => 'Alpha code 2 *', @@ -25,6 +28,7 @@ return array( 'Auth mode' => 'Auth mode', 'Available quantity' => 'Available quantity', 'Available quantity *' => 'Available quantity *', + 'Bad tax list JSON' => 'Bad tax list JSON', 'Business ID' => 'Business ID', 'Cannot find a default country. Please define one.' => 'Cannot find a default country. Please define one.', 'Cannot find the shop country. Please select a shop country.' => 'Cannot find the shop country. Please select a shop country.', @@ -41,6 +45,7 @@ return array( 'Constant amount found in one of the product\'s feature' => 'Constant amount found in one of the product\'s feature', 'Content title *' => 'Content title *', 'Country' => 'Country', + 'Country ID not found' => 'Country ID not found', 'Country area' => 'Country area', 'Country title *' => 'Country title *', 'Critical' => 'Critical', @@ -49,6 +54,7 @@ return array( 'Default folder *' => 'Default folder *', 'Default product category *' => 'Default product category *', 'Default product sale element' => 'Default product sale element', + 'Delivery module ID not found' => 'Delivery module ID not found', 'Description' => 'Description', 'Detailed description' => 'Detailed description', 'Disabled' => 'Disabled', @@ -73,6 +79,7 @@ return array( 'ISO 639-1 Code' => 'ISO 639-1 Code', 'ISO Code *' => 'ISO Code *', 'If a translation is missing or incomplete :' => 'If a translation is missing or incomplete :', + 'Impossible to delete a customer who already have orders' => 'Impossible to delete a customer who already have orders', 'Information' => 'Information', 'Invalid product_sale_elements' => 'Invalid product_sale_elements', 'Invalid value for walkMode parameter: %value' => 'Invalid value for walkMode parameter: %value', @@ -88,6 +95,7 @@ return array( 'Message subject' => 'Message subject', 'Meta Description' => 'Meta Description', 'Meta Keywords' => 'Meta Keywords', + 'Module ID not found' => 'Module ID not found', 'Name' => 'Name', 'Name *' => 'Name *', 'Name of the HTML layout file' => 'Name of the HTML layout file', @@ -99,6 +107,7 @@ return array( 'No %obj was updated.' => 'No %obj was updated.', 'No, I am a new customer.' => 'No, I am a new customer.', 'Notices' => 'Notices', + 'Order address ID not found' => 'Order address ID not found', 'Page Title' => 'Page Title', 'Parent category *' => 'Parent category *', 'Parent folder *' => 'Parent folder *', @@ -108,6 +117,7 @@ return array( 'Percentage of the product price' => 'Percentage of the product price', 'Percentage removed from the cart' => 'Percentage removed from the cart', 'Phone' => 'Phone', + 'Please accept the Terms and conditions in order to register.' => 'Please accept the Terms and conditions in order to register.', 'Please enter your email address' => 'Please enter your email address', 'Please enter your password' => 'Please enter your password', 'Please specify either \'path\' or \'file\' parameter in {url} function.' => 'Please specify either \'path\' or \'file\' parameter in {url} function.', @@ -123,6 +133,7 @@ return array( 'Product ID' => 'Product ID', 'Product ID *' => 'Product ID *', 'Product base price excluding taxes *' => 'Product base price excluding taxes *', + 'Product base price with taxes' => 'Product base price with taxes', 'Product price excluding taxes' => 'Product price excluding taxes', 'Product price excluding taxes *' => 'Product price excluding taxes *', 'Product price including taxes' => 'Product price including taxes', @@ -133,6 +144,8 @@ return array( 'ProductSaleElement modification' => 'ProductSaleElement modification', 'Profile' => 'Profile', 'Profile Code' => 'Profile Code', + 'Profile ID not found' => 'Profile ID not found', + 'Profile `code` already exists' => 'Profile `code` already exists', 'Purpose *' => 'Purpose *', 'Quantity' => 'Quantity', 'Rate from € *' => 'Rate from € *', @@ -167,20 +180,31 @@ return array( 'Summary' => 'Summary', 'Symbol *' => 'Symbol *', 'System log configuration failed.' => 'System log configuration failed.', + 'Tax ID not found in tax list JSON' => 'Tax ID not found in tax list JSON', + 'Tax list is not valid JSON' => 'Tax list is not valid JSON', + 'Tax rule ID not found' => 'Tax rule ID not found', 'Tax rule for this product *' => 'Tax rule for this product *', 'Template Name *' => 'Template Name *', 'Template file %file cannot be found.' => 'Template file %file cannot be found.', 'Text File' => 'Text File', 'Text Message' => 'Text Message', + 'The TaxEngine should be passed to this form before using it.' => 'The TaxEngine should be passed to this form before using it.', 'This category is online.' => 'This category is online.', 'This content is online.' => 'This content is online.', + 'This coupon does not exists' => 'This coupon does not exists', + 'This email already exists.' => 'This email already exists.', + 'This email does not exists' => 'This email does not exists', 'This extension must be installed and loaded' => 'This extension must be installed and loaded', 'This folder is online.' => 'This folder is online.', + 'This login already exists' => 'This login already exists', 'This product is on sale' => 'This product is on sale', 'This product is online' => 'This product is online', + 'This product_sale_elements_id does not exists for this product : %d' => 'This product_sale_elements_id does not exists for this product : %d', + 'This value should not be blank.' => 'This value should not be blank.', 'Timeout' => 'Timeout', 'Title' => 'Title', 'Title *' => 'Title *', + 'Title ID not found' => 'Title ID not found', 'Type' => 'Type', 'Username' => 'Username', 'Username *' => 'Username *', @@ -190,42 +214,20 @@ return array( 'Weight' => 'Weight', 'Weight *' => 'Weight *', 'Yes, I have a password :' => 'Yes, I have a password :', + 'You are already registered!' => 'You are already registered!', 'Your Email Address' => 'Your Email Address', 'Your Message' => 'Your Message', + 'Your current password does not match.' => 'Your current password does not match.', 'Zip code' => 'Zip code', 'date format' => 'date format', + 'delivery module %s is not a Thelia\Module\DeliveryModuleInterface' => 'delivery module %s is not a Thelia\Module\DeliveryModuleInterface', + 'payment module %s is not a Thelia\Module\PaymentModuleInterface' => 'payment module %s is not a Thelia\Module\PaymentModuleInterface', 'language locale' => 'language locale', 'mailing system modification' => 'mailing system modification', - 'shipping area name' => 'shipping area name', - 'time format' => 'time format', - 'This value should not be blank.' => 'This value should not be blank.', - 'A user already exists with this email address. Please login or if you\'ve forgotten your password, go to Reset Your Password.' => 'A user already exists with this email address. Please login or if you\'ve forgotten your password, go to Reset Your Password.', - 'Administrator ID not found' => 'Administrator ID not found', - 'This login already exists' => 'This login already exists', 'password confirmation is not the same as password field' => 'password confirmation is not the same as password field', 'password must be composed of at least 4 characters' => 'password must be composed of at least 4 characters', - 'this product id does not exists : %d' => 'this product id does not exists : %d', - 'This product_sale_elements_id does not exists for this product : %d' => 'This product_sale_elements_id does not exists for this product : %d', 'quantity value is not valid' => 'quantity value is not valid', - 'Please accept the Terms and conditions in order to register.' => 'Please accept the Terms and conditions in order to register.', - 'This email already exists.' => 'This email already exists.', - 'This email does not exists' => 'This email does not exists', - 'Your current password does not match.' => 'Your current password does not match.', - 'Module ID not found' => 'Module ID not found', - 'You are already registered!' => 'You are already registered!', - 'Address ID not found' => 'Address ID not found', - 'Delivery module ID not found' => 'Delivery module ID not found', - 'delivery module %s is not a Thelia\Module\DeliveryModuleInterface' => 'delivery module %s is not a Thelia\Module\DeliveryModuleInterface', - 'Order address ID not found' => 'Order address ID not found', - 'Title ID not found' => 'Title ID not found', - 'Country ID not found' => 'Country ID not found', - 'Profile `code` already exists' => 'Profile `code` already exists', - 'Profile ID not found' => 'Profile ID not found', - 'The TaxEngine should be passed to this form before using it.' => 'The TaxEngine should be passed to this form before using it.', - 'Tax rule ID not found' => 'Tax rule ID not found', - 'Tax list is not valid JSON' => 'Tax list is not valid JSON', - 'Bad tax list JSON' => 'Bad tax list JSON', - 'Tax ID not found in tax list JSON' => 'Tax ID not found in tax list JSON', - 'Please check your input: %s' => 'Please check your input: %s', - 'Sorry, an error occured: %s' => 'Sorry, an error occured: %s', + 'shipping area name' => 'shipping area name', + 'this product id does not exists : %d' => 'this product id does not exists : %d', + 'time format' => 'time format', ); diff --git a/core/lib/Thelia/Config/I18n/fr_FR.php b/core/lib/Thelia/Config/I18n/fr_FR.php index ab7492dd6..937dd337e 100644 --- a/core/lib/Thelia/Config/I18n/fr_FR.php +++ b/core/lib/Thelia/Config/I18n/fr_FR.php @@ -6,14 +6,17 @@ return array( '%obj modification' => 'Modification de %obj', 'A currency with code "%name" already exists.' => 'Une devise avec la code "%name" existe déjà', 'A message with name "%name" already exists.' => 'Un message avec le nom "%name" existe déjà.', + 'A user already exists with this email address. Please login or if you\'ve forgotten your password, go to Reset Your Password.' => 'Un utilisateur existe déjà avec cette adresse email. Connectez-vous ou demandez une réinitialisation de votre mot de passe.', 'A variable with name "%name" already exists.' => 'Une variable avec le nom "%name" existe déjà.', 'Activate logs only for these IP Addresses' => 'Activer les logs uniquement pour ces adresses IP', 'Activate logs only for these files' => 'Activer les logs uniquement pour ces fichiers', 'Add to all product templates' => 'Ajouter à tous les templates produit', 'Additional address' => 'Adresse complémentaire', + 'Address ID not found' => 'ID de l\'adresse non trouvé', 'Address Line 2' => 'Adresse 1', 'Address Line 3' => 'Adresse 2', 'Address label' => 'Adresse', + 'Administrator ID not found' => 'ID de l\'administrateur not trouvé', 'Advertise this product as new' => 'Afficher ce produit comme nouveau', 'Alerts' => 'Alertes', 'Alpha code 2 *' => 'Code Alpha 2 *', @@ -25,6 +28,7 @@ return array( 'Auth mode' => 'Mode d\'authentification', 'Available quantity' => 'Quantité disponible', 'Available quantity *' => 'Quantité disponible *', + 'Bad tax list JSON' => 'Mauvais JSON de la liste des taxes', 'Business ID' => 'ID du business', 'Cannot find a default country. Please define one.' => 'Impossible de trouver un pays par défaut. Veuillez en définir un.', 'Cannot find the shop country. Please select a shop country.' => 'Impossible de trouver le pays du magasin. Veuillez en sélectionner un.', @@ -41,6 +45,7 @@ return array( 'Constant amount found in one of the product\'s feature' => 'Montant fixe trouvé depuis une caractéristique produit', 'Content title *' => 'Titre du contenu *', 'Country' => 'Pays', + 'Country ID not found' => 'ID du pays non trouvé', 'Country area' => 'Zone du pays', 'Country title *' => 'Pays *', 'Critical' => 'Critique', @@ -49,6 +54,7 @@ return array( 'Default folder *' => 'Dossier par défaut *', 'Default product category *' => 'Catégorie du produit par défaut *', 'Default product sale element' => 'Product Sale Element par défaut', + 'Delivery module ID not found' => 'Id du module de livraison non trouvé', 'Description' => 'Description', 'Detailed description' => 'Description détaillée', 'Disabled' => 'Désactivé', @@ -73,6 +79,7 @@ return array( 'ISO 639-1 Code' => 'Code ISO 639-1', 'ISO Code *' => 'Code ISO *', 'If a translation is missing or incomplete :' => 'Si une traduction est manquante ou incomplète :', + 'Impossible to delete a customer who already have orders' => 'Impossible de supprimer un client si celui-ci a déjà une commande', 'Information' => 'Information', 'Invalid product_sale_elements' => 'product_sale_elements invalide', 'Invalid value for walkMode parameter: %value' => 'Valeur incorrecte pour le paramètre walkMode : %value', @@ -88,6 +95,7 @@ return array( 'Message subject' => 'Sujet', 'Meta Description' => 'Meta description', 'Meta Keywords' => 'Meta keywords', + 'Module ID not found' => 'Id du module non trouvé', 'Name' => 'Nom', 'Name *' => 'Nom *', 'Name of the HTML layout file' => 'Nom du layout HTML', @@ -99,6 +107,7 @@ return array( 'No %obj was updated.' => 'Aucun %obj mis à jour', 'No, I am a new customer.' => 'Non, je suis un nouveau client.', 'Notices' => 'Notices', + 'Order address ID not found' => 'ID de l\'adresse de la commande non trouvé', 'Page Title' => 'Titre de la page', 'Parent category *' => 'Catégorie parente *', 'Parent folder *' => 'Dossier parent *', @@ -108,6 +117,7 @@ return array( 'Percentage of the product price' => 'Pourcentage du prix du produit', 'Percentage removed from the cart' => 'Pourcentage déduit du panier', 'Phone' => 'Téléphone', + 'Please accept the Terms and conditions in order to register.' => 'Veuillez accepter les termes et conditions pour vous inscrire.', 'Please enter your email address' => 'Renseignez votre adresse mail', 'Please enter your password' => 'Entrez votre mot de passe.', 'Please specify either \'path\' or \'file\' parameter in {url} function.' => 'Veuillez spécifier soit le paramètre \'chemin\' ou \'fichier\' dans la fonction {url}', @@ -123,6 +133,7 @@ return array( 'Product ID' => 'ID produit', 'Product ID *' => 'ID produit *', 'Product base price excluding taxes *' => 'Prix du produit Hors Taxe *', + 'Product base price with taxes' => 'Prix du produit TTC', 'Product price excluding taxes' => 'Prix du produit Hors Taxes', 'Product price excluding taxes *' => 'prix HT', 'Product price including taxes' => 'Prix du produit taxes incluses', @@ -133,6 +144,8 @@ return array( 'ProductSaleElement modification' => 'Modification de ProductSaleElement.', 'Profile' => 'Profil', 'Profile Code' => 'Profil', + 'Profile ID not found' => 'ID du profil non trouvé', + 'Profile `code` already exists' => 'Le `code` du profil existe déjà', 'Purpose *' => 'Objet', 'Rate from € *' => 'Taux à partie de l\'€ *', 'Redirecting ...' => 'Redirection ...', @@ -166,20 +179,31 @@ return array( 'Summary' => 'Résumé', 'Symbol *' => 'Symbole *', 'System log configuration failed.' => 'Erreur du configurateur de log system.', + 'Tax ID not found in tax list JSON' => 'ID de la taxe non trouvé dans le JSON de la liste des taxes', + 'Tax list is not valid JSON' => 'Le JSON de la liste des taxes n\'est pas valide', + 'Tax rule ID not found' => 'ID de la règle de taxe non trouvé', 'Tax rule for this product *' => 'Règle de taxe pour ce produit *', 'Template Name *' => 'Nom du template *', 'Template file %file cannot be found.' => 'Le fichier %file n\'a pas été trouvé dans le template. ', 'Text File' => 'Fichier texte', 'Text Message' => 'Message au format texte', + 'The TaxEngine should be passed to this form before using it.' => 'Le moteur de taxe doit être passé au formulaire avant d\'être utilisé.', 'This category is online.' => 'Cette catégorie est en ligne.', 'This content is online.' => 'Ce contenu est en ligne.', + 'This coupon does not exists' => 'Ce code promo n\'existe pas', + 'This email already exists.' => 'Cette adresse email existe déjà', + 'This email does not exists' => 'Cette adresse email n\'existe pas', 'This extension must be installed and loaded' => 'Cette extension doit être installée et chargée.', 'This folder is online.' => 'Ce dossier est en ligne.', + 'This login already exists' => 'Cet identifiant existe déjà', 'This product is on sale' => 'Ce produit est en promo', 'This product is online' => 'Ce produit est en ligne', + 'This product_sale_elements_id does not exists for this product : %d' => 'Le product_sale_elements_id n\'existe pas pour ce produit : %d', + 'This value should not be blank.' => 'Cette valeur ne doit pas être vide.', 'Timeout' => 'Délai d\'attente expiré', 'Title' => 'Titre', 'Title *' => 'Titre *', + 'Title ID not found' => 'ID de la civilité non trouvé', 'Type' => 'Type', 'Username' => 'Nom d\'utilisateur', 'Username *' => 'Nom d\'utilisateur *', @@ -189,42 +213,20 @@ return array( 'Weight' => 'Poids', 'Weight *' => 'Poids *', 'Yes, I have a password :' => 'Oui, j\'ai un mot de passe :', + 'You are already registered!' => 'Vous êtes déjà enregistré !', 'Your Email Address' => 'Votre adresse mail', 'Your Message' => 'Votre message', + 'Your current password does not match.' => 'Votre mot de passe actuel ne correspond pas', 'Zip code' => 'Code postal', 'date format' => 'Format de date', + 'delivery module %s is not a Thelia\Module\DeliveryModuleInterface' => 'le module de livraison %s n\'est pas un Thelia\Module\DeliveryModuleInterface', 'language locale' => 'Langue locale', 'mailing system modification' => 'Modification du système d\'envoi de mail.', - 'shipping area name' => 'Nom de la zone de livraison', - 'time format' => 'Format d\'heure', - 'This value should not be blank.' => 'Cette valeur ne doit pas être vide.', - 'A user already exists with this email address. Please login or if you\'ve forgotten your password, go to Reset Your Password.' => 'Un utilisateur existe déjà avec cette adresse email. Connectez-vous ou demandez une réinitialisation de votre mot de passe.', - 'Administrator ID not found' => 'ID de l\'administrateur not trouvé', - 'This login already exists' => 'Cet identifiant existe déjà', 'password confirmation is not the same as password field' => 'le mot de passe de confirmation n\'est pas le même que le champ mot de passe', 'password must be composed of at least 4 characters' => 'le mot de passe doit être composé d\'au moins 4 caractères', - 'this product id does not exists : %d' => 'l\'id du produit %d n\'existe pas', - 'This product_sale_elements_id does not exists for this product : %d' => 'Le product_sale_elements_id n\'existe pas pour ce produit : %d', + 'payment module %s is not a Thelia\Module\PaymentModuleInterface' => 'Le module de paiement %s n\'est pas une instance de Thelia\Module\PaymentModuleInterface ', 'quantity value is not valid' => 'la valeur de la quantité n\'est pas valide', - 'Please accept the Terms and conditions in order to register.' => 'Veuillez accepter les termes et conditions pour vous inscrire.', - 'This email already exists.' => 'Cette adresse email existe déjà', - 'This email does not exists' => 'Cette adresse email n\'existe pas', - 'Your current password does not match.' => 'Votre mot de passe actuel ne correspond pas', - 'Module ID not found' => 'Id du module non trouvé', - 'You are already registered!' => 'Vous êtes déjà enregistré !', - 'Address ID not found' => 'ID de l\'adresse non trouvé', - 'Delivery module ID not found' => 'Id du module de livraison non trouvé', - 'delivery module %s is not a Thelia\Module\DeliveryModuleInterface' => 'le module de livraison %s n\'est pas un Thelia\Module\DeliveryModuleInterface', - 'Order address ID not found' => 'ID de l\'adresse de la commande non trouvé', - 'Title ID not found' => 'ID de la civilité non trouvé', - 'Country ID not found' => 'ID du pays non trouvé', - 'Profile `code` already exists' => 'Le `code` du profil existe déjà', - 'Profile ID not found' => 'ID du profil non trouvé', - 'The TaxEngine should be passed to this form before using it.' => 'Le moteur de taxe doit être passé au formulaire avant d\'être utilisé.', - 'Tax rule ID not found' => 'ID de la règle de taxe non trouvé', - 'Tax list is not valid JSON' => 'Le JSON de la liste des taxes n\'est pas valide', - 'Bad tax list JSON' => 'Mauvais JSON de la liste des taxes', - 'Tax ID not found in tax list JSON' => 'ID de la taxe non trouvé dans le JSON de la liste des taxes', - 'Please check your input: %s' => 'Veuillez vérifier votre saisie: %s', - 'Sorry, an error occured: %s' => 'Désolé, une erreur est survenue: %s', + 'shipping area name' => 'Nom de la zone de livraison', + 'this product id does not exists : %d' => 'l\'id du produit %d n\'existe pas', + 'time format' => 'Format d\'heure', ); diff --git a/core/lib/Thelia/Config/Resources/routing/admin.xml b/core/lib/Thelia/Config/Resources/routing/admin.xml index 703dcb33b..3e6ea5646 100644 --- a/core/lib/Thelia/Config/Resources/routing/admin.xml +++ b/core/lib/Thelia/Config/Resources/routing/admin.xml @@ -340,6 +340,10 @@ Thelia\Controller\Admin\ProductController::priceCaclulator + + Thelia\Controller\Admin\ProductController::calculatePrice + + Thelia\Controller\Admin\ProductController::loadConvertedPrices diff --git a/core/lib/Thelia/Controller/Admin/ProductController.php b/core/lib/Thelia/Controller/Admin/ProductController.php index 38cd917ea..75ecbc9ea 100644 --- a/core/lib/Thelia/Controller/Admin/ProductController.php +++ b/core/lib/Thelia/Controller/Admin/ProductController.php @@ -73,6 +73,7 @@ use Thelia\Form\ProductSaleElementUpdateForm; use Thelia\Form\ProductDefaultSaleElementUpdateForm; use Thelia\Form\ProductCombinationGenerationForm; +use Thelia\Model\TaxRuleQuery; use Thelia\TaxEngine\Calculator; use Thelia\Tools\NumberFormat; @@ -1155,10 +1156,10 @@ class ProductController extends AbstractSeoCrudController { $return_price = 0; - $price = floatval($this->getRequest()->get('price', 0)); - $product_id = intval($this->getRequest()->get('product_id', 0)); - $action = $this->getRequest()->get('action', ''); // With ot without tax - $convert = intval($this->getRequest()->get('convert_from_default_currency', 0)); + $price = floatval($this->getRequest()->query->get('price', 0)); + $product_id = intval($this->getRequest()->query->get('product_id', 0)); + $action = $this->getRequest()->query->get('action', ''); // With ot without tax + $convert = intval($this->getRequest()->query->get('convert_from_default_currency', 0)); if (null !== $product = ProductQuery::create()->findPk($product_id)) { @@ -1171,7 +1172,46 @@ class ProductController extends AbstractSeoCrudController } if ($convert != 0) { - $return_price = $prix * Currency::getDefaultCurrency()->getRate(); + $return_price = $price * Currency::getDefaultCurrency()->getRate(); + } + } + + return new JsonResponse(array('result' => $return_price)); + } + + /** + * + * Calculate tax or untax price for a non existing product. + * + * For an existing product, use self::priceCaclulator + * + * @return JsonResponse + */ + public function calculatePrice() + { + $return_price = 0; + + $price = floatval($this->getRequest()->query->get('price')); + $tax_rule_id = intval($this->getRequest()->query->get('tax_rule')); + $action = $this->getRequest()->query->get('action'); // With ot without tax + + $taxRule = TaxRuleQuery::create()->findPk($tax_rule_id); + + if (null !== $price && null !== $taxRule) { + + $calculator = new Calculator(); + + $calculator->loadTaxRuleWithoutProduct( + $taxRule, + Country::getShopLocation() + ); + + if ($action == 'to_tax') { + $return_price = $calculator->getTaxedPrice($price); + } elseif ($action == 'from_tax') { + $return_price = $calculator->getUntaxedPrice($price); + } else { + $return_price = $price; } } @@ -1251,7 +1291,7 @@ class ProductController extends AbstractSeoCrudController } if ($convert != 0) { - $return_price = $prix * Currency::getDefaultCurrency()->getRate(); + $return_price = $price * Currency::getDefaultCurrency()->getRate(); } // Format the number using '.', to perform further calculation diff --git a/core/lib/Thelia/Form/OrderPayment.php b/core/lib/Thelia/Form/OrderPayment.php index 1ae4fa06c..117878cca 100644 --- a/core/lib/Thelia/Form/OrderPayment.php +++ b/core/lib/Thelia/Form/OrderPayment.php @@ -88,7 +88,7 @@ class OrderPayment extends BaseForm $moduleReflection = new \ReflectionClass($module->getFullNamespace()); if ($moduleReflection->isSubclassOf("Thelia\Module\PaymentModuleInterface") === false) { $context->addViolation( - sprintf(Translator::getInstance()->trans("delivery module %s is not a Thelia\Module\PaymentModuleInterface"), $module->getCode()) + sprintf(Translator::getInstance()->trans("payment module %s is not a Thelia\Module\PaymentModuleInterface"), $module->getCode()) ); } } diff --git a/core/lib/Thelia/Form/ProductCreationForm.php b/core/lib/Thelia/Form/ProductCreationForm.php index 200f61199..a1c9c1c70 100644 --- a/core/lib/Thelia/Form/ProductCreationForm.php +++ b/core/lib/Thelia/Form/ProductCreationForm.php @@ -70,8 +70,12 @@ class ProductCreationForm extends BaseForm ->add("price", "number", array( "constraints" => array(new NotBlank()), "label" => Translator::getInstance()->trans("Product base price excluding taxes *"), - "label_attr" => array("for" => "price_field") + "label_attr" => array("for" => "price_without_tax") )) + ->add("tax_price", "number", array( + "label" => Translator::getInstance()->trans("Product base price with taxes"), + "label_attr" => array("for" => "price_with_tax") + )) ->add("currency", "integer", array( "constraints" => array(new NotBlank()), "label" => Translator::getInstance()->trans("Price currency *"), @@ -83,7 +87,7 @@ class ProductCreationForm extends BaseForm "label_attr" => array("for" => "tax_rule_field") )) ->add("weight", "number", array( - "label" => Translator::getInstance()->trans("Weight *"), + "label" => Translator::getInstance()->trans("Weight"), "label_attr" => array("for" => "weight_field") )) ; diff --git a/core/lib/Thelia/TaxEngine/Calculator.php b/core/lib/Thelia/TaxEngine/Calculator.php index 552acab19..e0e303bee 100644 --- a/core/lib/Thelia/TaxEngine/Calculator.php +++ b/core/lib/Thelia/TaxEngine/Calculator.php @@ -100,6 +100,27 @@ class Calculator return $this; } + public function loadTaxRuleWithoutProduct(TaxRule $taxRule, Country $country) + { + $this->product = null; + $this->country = null; + $this->taxRulesCollection = null; + + if ($taxRule->getId() === null) { + throw new TaxEngineException('TaxRule id is empty in Calculator::loadTaxRule', TaxEngineException::UNDEFINED_TAX_RULE); + } + if ($country->getId() === null) { + throw new TaxEngineException('Country id is empty in Calculator::loadTaxRule', TaxEngineException::UNDEFINED_COUNTRY); + } + + $this->country = $country; + $this->product = new Product(); + + $this->taxRulesCollection = $this->taxRuleQuery->getTaxCalculatorCollection($taxRule, $country); + + return $this; + } + public function getTaxAmountFromUntaxedPrice($untaxedPrice, &$taxCollection = null) { return $this->getTaxedPrice($untaxedPrice, $taxCollection) - $untaxedPrice; diff --git a/core/lib/Thelia/TaxEngine/TaxType/FeatureFixAmountTaxType.php b/core/lib/Thelia/TaxEngine/TaxType/FeatureFixAmountTaxType.php index eb49847b6..787230788 100644 --- a/core/lib/Thelia/TaxEngine/TaxType/FeatureFixAmountTaxType.php +++ b/core/lib/Thelia/TaxEngine/TaxType/FeatureFixAmountTaxType.php @@ -47,6 +47,7 @@ class FeatureFixAmountTaxType extends BaseTaxType public function fixAmountRetriever(Product $product) { + $taxAmount = 0; $featureId = $this->getRequirement("feature"); $query = FeatureProductQuery::create() @@ -54,14 +55,17 @@ class FeatureFixAmountTaxType extends BaseTaxType ->filterByFeatureId($featureId) ->findOne(); - $taxAmount = $query->getFreeTextValue(); + if (null !== $query) { + $taxAmount = $query->getFreeTextValue(); - $testInt = new FloatType(); - if (!$testInt->isValid($taxAmount)) { - throw new TaxEngineException( + $testInt = new FloatType(); + if (!$testInt->isValid($taxAmount)) { + throw new TaxEngineException( Translator::getInstance()->trans('Feature value does not match FLOAT format'), TaxEngineException::FEATURE_BAD_EXPECTED_VALUE - ); + ); + } + } return $taxAmount; diff --git a/templates/backOffice/default/I18n/en_US.php b/templates/backOffice/default/I18n/en_US.php old mode 100755 new mode 100644 index 5d8b2d44b..fb8b8bded --- a/templates/backOffice/default/I18n/en_US.php +++ b/templates/backOffice/default/I18n/en_US.php @@ -6,6 +6,9 @@ return array( '(edit)' => '(edit)', 'Check the list of ISO 639-1 codes' => 'Check the list of ISO 639-1 codes', '0 combinations' => '0 combinations', + 'Cannot translate all fields. According to your PHP configuration, forms cannot contains more than + %current_max_input_vars input fields, but at least %required_max_input_vars are required. Please change the value of max_input_vars in your PHP configuration + of change the translation file by hand.' => 'Cannot translate all fields. According to your PHP configuration, forms cannot contains more than %current_max_input_vars input fields, but at least %required_max_input_vars are required. Please change the value of max_input_vars in your PHP configuration of change the translation file by hand.', 'Congratulations, all text is now translated !' => 'Congratulations, all text is now translated !', 'Did not found any text to translate. It\'s probably normal. If not, please be sure to use Smarty\'s "intl" function in templates, or the Translator::trans() method in PHP files.' => 'Did not found any text to translate. It\'s probably normal. If not, please be sure to use Smarty\'s "intl" function in templates, or the Translator::trans() method in PHP files.', 'A content could be attached to more than one folder. Select here the additional folders for this content.' => 'A content could be attached to more than one folder. Select here the additional folders for this content.', @@ -70,7 +73,6 @@ return array( 'Back-office home' => 'Back-office home', 'Back-office templates' => 'Back-office templates', 'Back-office users' => 'Back-office users', - 'Browse' => 'Browse', 'Browse files' => 'Browse files', 'Browse this category' => 'Browse this category', 'Browse this folder' => 'Browse this folder', @@ -122,7 +124,6 @@ return array( 'Combination builder' => 'Combination builder', 'Combination reference' => 'Combination reference', 'Company' => 'Company', - 'Condition type :' => 'Condition type :', 'Condition\'s category :' => 'Condition\'s category :', 'Conditions' => 'Conditions', 'Configuration' => 'Configuration', @@ -142,7 +143,6 @@ return array( 'Country short description' => 'Country short description', 'Country title' => 'Country title', 'Coupon' => 'Coupon', - 'Coupon : ' => 'Coupon : ', 'Coupon code' => 'Coupon code', 'Coupons' => 'Coupons', 'Coupons : ' => 'Coupons : ', @@ -324,6 +324,7 @@ return array( 'EAN Code' => 'EAN Code', 'Ecotax is a tax wich add a defined amount (throug a product feature) to the product price.' => 'Ecotax is a tax wich add a defined amount (throug a product feature) to the product price.', 'Edit' => 'Edit', + 'Edit %title' => 'Edit %title', 'Edit a country' => 'Edit a country', 'Edit a currency' => 'Edit a currency', 'Edit a customer' => 'Edit a customer', @@ -424,6 +425,7 @@ return array( 'Enter here the product name in the default language (%title)' => 'Enter here the product name in the default language (%title)', 'Enter here the product price in the default currency (%title)' => 'Enter here the product price in the default currency (%title)', 'Enter here the product reference' => 'Enter here the product reference', + 'Enter here the product tax price in the default currency (%title)' => 'Enter here the product tax price in the default currency (%title)', 'Enter here the product weight, in Kilogrammes' => 'Enter here the product weight, in Kilogrammes', 'Enter here the template name in the default language (%title)' => 'Enter here the template name in the default language (%title)', 'Enter here the value in the current edit language (%language_name)' => 'Enter here the value in the current edit language (%language_name)', @@ -457,7 +459,6 @@ return array( 'Features' => 'Features', 'File' => 'File', 'File names' => 'File names', - 'Files manager' => 'Files manager', 'First Name' => 'First Name', 'First name' => 'First name', 'First orders' => 'First orders', @@ -524,7 +525,6 @@ return array( 'Latest version available' => 'Latest version available', 'Leave empty to keep current password' => 'Leave empty to keep current password', 'Lire la suite' => 'Lire la suite', - 'List' => 'List', 'Loading Thelia lastest news...' => 'Loading Thelia lastest news...', 'Locale' => 'Locale', 'Log lines format' => 'Log lines format', @@ -578,7 +578,6 @@ return array( 'Online' => 'Online', 'Online products' => 'Online products', 'Oops! An Error Occurred' => 'Oops! An Error Occurred', - 'Or' => 'Or', 'Order #' => 'Order #', 'Order %ref' => 'Order %ref', 'Order n°' => 'Order n°', @@ -644,6 +643,7 @@ return array( 'Product features' => 'Product features', 'Product price' => 'Product price', 'Product price including taxes' => 'Product price including taxes', + 'Product tax price' => 'Product tax price', 'Product templates' => 'Product templates', 'Product title' => 'Product title', 'Product weight' => 'Product weight', @@ -814,6 +814,7 @@ return array( 'Thelia support forum' => 'Thelia support forum', 'Thelia system variables' => 'Thelia system variables', 'Thelia, the open source e-commerce solution' => 'Thelia, the open source e-commerce solution', + 'There is currently no active module here.' => 'There is currently no active module here.', 'There is no documents attached to this %type.' => 'There is no documents attached to this %type.', 'There is no images attached to this %type.' => 'There is no images attached to this %type.', 'They are some administrator which are linked to this administrator. Please edit/remove them before deleting this administrator.' => 'They are some administrator which are linked to this administrator. Please edit/remove them before deleting this administrator.', diff --git a/templates/backOffice/default/I18n/fr_FR.php b/templates/backOffice/default/I18n/fr_FR.php old mode 100755 new mode 100644 index 02a5357b5..28a13e336 --- a/templates/backOffice/default/I18n/fr_FR.php +++ b/templates/backOffice/default/I18n/fr_FR.php @@ -6,6 +6,9 @@ return array( '(edit)' => '(modification)', 'Check the list of ISO 639-1 codes' => 'Consulter la liste des codes ISO 639-1', '0 combinations' => '0 combinaisons', + 'Cannot translate all fields. According to your PHP configuration, forms cannot contains more than + %current_max_input_vars input fields, but at least %required_max_input_vars are required. Please change the value of max_input_vars in your PHP configuration + of change the translation file by hand.' => 'Cannot translate all fields. According to your PHP configuration, forms cannot contains more than %current_max_input_vars input fields, but at least %required_max_input_vars are required. Please change the value of max_input_vars in your PHP configuration of change the translation file by hand.', 'Congratulations, all text is now translated !' => 'Félicitations, Toute la traduction a été effectué', 'Did not found any text to translate. It\'s probably normal. If not, please be sure to use Smarty\'s "intl" function in templates, or the Translator::trans() method in PHP files.' => 'Aucun texte à traduire. C\'est probablement normal. Si ce n\'est pas le cas vérifiez que vous utilisez bien la fonction Smarty "intl" ou bien le translator Translator::trans dans un fichier php', 'A content could be attached to more than one folder. Select here the additional folders for this content.' => 'Un contenu peut être rattaché à plusieurs dossiers. Sélectionnez ici les dossiers dans lesquels ce contenu apparaîtra', @@ -70,7 +73,6 @@ return array( 'Back-office home' => 'Accueil administration', 'Back-office templates' => 'templates Back-office', 'Back-office users' => 'Utilisateur du B.O', - 'Browse' => 'Parcourir', 'Browse files' => 'Parcourir les fichiers', 'Browse this category' => 'Parcourir cette catégorie', 'Browse this folder' => 'Parcourir ce dossier', @@ -122,7 +124,6 @@ return array( 'Combination builder' => 'générateur de combinaison', 'Combination reference' => 'Référence de la combinaison', 'Company' => 'Entreprise', - 'Condition type :' => 'Type de condition', 'Condition\'s category :' => 'Rubrique de la condition', 'Conditions' => 'Conditions', 'Configuration' => 'Configuration', @@ -142,7 +143,6 @@ return array( 'Country short description' => 'Courte description du pays', 'Country title' => 'Titre du pays', 'Coupon' => 'Code promo', - 'Coupon : ' => 'Code promo :', 'Coupon code' => 'Code promo', 'Coupons' => 'Codes Promo', 'Coupons : ' => 'Codes promo : ', @@ -324,6 +324,7 @@ return array( 'EAN Code' => 'Code EAN', 'Ecotax is a tax wich add a defined amount (throug a product feature) to the product price.' => 'L\'écotaxe est une taxe qui ajoute un montant défini (grâce à une caractéristique produit) au prix du produit.', 'Edit' => 'Editer', + 'Edit %title' => 'Modifier %title', 'Edit a country' => 'Modifier un pays', 'Edit a currency' => 'Modifier une devise', 'Edit a customer' => 'Éditer un client', @@ -420,9 +421,11 @@ return array( 'Enter here the feature name in the default language (%title)' => 'Renseigner le nom de la caractéristique dans la langue par défaut (%title)', 'Enter here the feature value as free text' => 'Indiquez ici la valeur de la caractéristique', 'Enter here the folder name in the default language (%title)' => 'Entrez ici le nom du dossier dans la langue par défaut (%title)', + 'Enter here the mailing template purpose in the default language (%title)' => 'Renseigner l\'objet du mail dans la langue par défaut (%title)', 'Enter here the product name in the default language (%title)' => 'Entrez ici le nom du produit dans la langue par défaut (%title)', 'Enter here the product price in the default currency (%title)' => 'entrez ici le prix du produit dans la langue par défaut (%title)', 'Enter here the product reference' => 'Entrez ici la nouvelle référence produit', + 'Enter here the product tax price in the default currency (%title)' => 'Renseignez le prox TTC dans la devise par défaut (%title)', 'Enter here the product weight, in Kilogrammes' => 'Entrez ici le poids du produit, en Kilogrammes', 'Enter here the template name in the default language (%title)' => 'Renseignez le nom du template dans la langue par défaut (%title)', 'Enter here the value in the current edit language (%language_name)' => 'Rensignez la valeur dans la langue d\'édition actuelle (%language_name)', @@ -456,7 +459,6 @@ return array( 'Features' => 'Caractéristiques', 'File' => 'Fichier', 'File names' => 'Nom du fichier', - 'Files manager' => 'Gestionnaire de fichiers', 'First Name' => 'Prénom', 'First name' => 'Prénom', 'First orders' => 'Premières commandes', @@ -523,7 +525,6 @@ return array( 'Latest version available' => 'Dernière version disponible', 'Leave empty to keep current password' => 'Laisser ce champ vide pour ne pas modifier le mot de passe', 'Lire la suite' => 'Lire la suite', - 'List' => 'Liste', 'Loading Thelia lastest news...' => 'Chargement des dernières information Thelia...', 'Locale' => 'Paramètre régional', 'Log lines format' => 'Format d\'une ligne de log', @@ -577,7 +578,6 @@ return array( 'Online' => 'En ligne', 'Online products' => 'Produits en ligne', 'Oops! An Error Occurred' => 'Oops ! Une erreur est survenue', - 'Or' => 'Ou', 'Order #' => 'Commande #', 'Order %ref' => 'Commande %ref', 'Order n°' => 'Commande n°', @@ -643,6 +643,7 @@ return array( 'Product features' => 'Caractéristiques produit', 'Product price' => 'Prix du produit', 'Product price including taxes' => 'Prix du produit taxes incluses', + 'Product tax price' => 'prix TTC', 'Product templates' => 'Template produit', 'Product title' => 'Titre du produit', 'Product weight' => 'Poids du produit', @@ -812,6 +813,7 @@ return array( 'Thelia support forum' => 'Forum de Thelia', 'Thelia system variables' => 'Variables Thelia', 'Thelia, the open source e-commerce solution' => 'Thelia, la solution e-commerce libre', + 'There is currently no active module here.' => 'Il n\'y a aucun module actif ici', 'There is no documents attached to this %type.' => 'Il n\'y a aucun document lié à ce %type.', 'There is no images attached to this %type.' => 'Il n\'y a pas d\'image liée à ce %type.', 'They are some administrator which are linked to this administrator. Please edit/remove them before deleting this administrator.' => 'Cet administrateur est lié avec un ou plusieurs autres administrateurs. Supprimez ou modifiez ces administrateurs d\'abord.', diff --git a/templates/backOffice/default/categories.html b/templates/backOffice/default/categories.html index d8418f46a..cdf42bf70 100644 --- a/templates/backOffice/default/categories.html +++ b/templates/backOffice/default/categories.html @@ -472,29 +472,7 @@
{/form_field} - {form_field form=$form field='price'} -
- - {loop type="currency" name="default-currency" default_only="1" backend_context="1"} -
-
-
- - {$SYMBOL} -
-
-
- -
{intl l='Enter here the product price in the default currency (%title)' title=$NAME}
- - {form_field form=$form field='currency'} - - {/form_field} - - {/loop} -
- {/form_field} {form_field form=$form field='tax_rule'}
@@ -513,6 +491,49 @@
{/form_field} + {form_field form=$form field='price'} +
+ + {loop type="currency" name="default-currency" default_only="1" backend_context="1"} + +
+
+
+ + {$SYMBOL} +
+
+
+ +
{intl l='Enter here the product price in the default currency (%title)' title=$NAME}
+ + {form_field form=$form field='currency'} + + {/form_field} + + {/loop} +
+ {/form_field} + + {form_field form=$form field='tax_price'} +
+ + {loop type="currency" name="default-currency" default_only="1" backend_context="1"} + +
+
+
+ + {$SYMBOL} +
+
+
+ +
{intl l='Enter here the product tax price in the default currency (%title)' title=$NAME}
+ {/loop} +
+ {/form_field} + {form_field form=$form field='weight'}
@@ -611,7 +632,9 @@ {javascripts file='assets/js/bootstrap-editable/bootstrap-editable.js'} {/javascripts} - + {javascripts file='assets/js/jquery.typewatch.js'} + + {/javascripts} {/block} diff --git a/templates/frontOffice/default/I18n/en_US.php b/templates/frontOffice/default/I18n/en_US.php old mode 100755 new mode 100644 index c4ad5753a..32b34376e --- a/templates/frontOffice/default/I18n/en_US.php +++ b/templates/frontOffice/default/I18n/en_US.php @@ -7,6 +7,7 @@ return array( '+ View All' => '+ View All', '404' => '404', 'Sorry! We are not able to give you a delivery method for your order.' => 'Sorry! We are not able to give you a delivery method for your order.', + 'A problem occured' => 'A problem occured', 'A summary of your order email has been sent to the following address' => 'A summary of your order email has been sent to the following address', 'Account' => 'Account', 'Add a new address' => 'Add a new address', @@ -129,6 +130,7 @@ return array( 'Placeholder phone' => 'Phone number', 'Placeholder zipcode' => 'NY 10011', 'Please enter your email address below.' => 'Please enter your email address below.', + 'Please try again to order' => 'Please try again to order', 'Position' => 'Position', 'Previous' => 'Previous', 'Previous product' => 'Previous product', @@ -150,6 +152,7 @@ return array( 'Questions ? See our F.A.Q.' => 'Questions ? See our F.A.Q.', 'RSS' => 'RSS', 'Rating' => 'Rating', + 'Redirect to bank service' => 'Redirect to bank service', 'Ref.' => 'Ref.', 'Register' => 'Register', 'Register!' => 'Register!', diff --git a/templates/frontOffice/default/I18n/fr_FR.php b/templates/frontOffice/default/I18n/fr_FR.php old mode 100755 new mode 100644 index d5f65a7f0..9d319322c --- a/templates/frontOffice/default/I18n/fr_FR.php +++ b/templates/frontOffice/default/I18n/fr_FR.php @@ -7,6 +7,7 @@ return array( '+ View All' => '+ Voir tout', '404' => '404', 'Sorry! We are not able to give you a delivery method for your order.' => 'Désolé !Nous ne pouvons pas trouver de mode de livraison pour votre commande.', + 'A problem occured' => 'Un problème est survenu', 'A summary of your order email has been sent to the following address' => 'Un récapitulatif de commande vows a été envoyé par e-mail à l\'adresse suivante : ', 'Account' => 'Mon compte', 'Add a new address' => 'Ajouter une nouvelle adresse', @@ -129,6 +130,7 @@ return array( 'Placeholder phone' => 'Téléphone', 'Placeholder zipcode' => 'Code postal', 'Please enter your email address below.' => 'Veuillez saisir votre adresse e-mail ci-dessous.', + 'Please try again to order' => 'Merci de réessayer', 'Position' => 'Position', 'Previous' => 'Précédent', 'Previous product' => 'Produit précédent.', @@ -145,6 +147,7 @@ return array( 'Questions ? See our F.A.Q.' => 'Questions ? Voir notre FAQ', 'RSS' => 'RSS', 'Rating' => 'Avis', + 'Redirect to bank service' => 'Redirection vers le service bancaire', 'Ref.' => 'Ref.', 'Register' => 'S\'inscrire', 'Register!' => 'Enregistrez-vous !', From b0b0eac1cf441fc9f1d5123d82227a026b968693 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Thu, 13 Mar 2014 16:39:11 +0100 Subject: [PATCH 012/372] redirect user in install process if database connection settings are wrong --- web/install/bdd.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/web/install/bdd.php b/web/install/bdd.php index 8e9561876..50303f73a 100644 --- a/web/install/bdd.php +++ b/web/install/bdd.php @@ -32,8 +32,13 @@ if (isset($_POST['host']) && isset($_POST['username']) && isset($_POST['passwor $_SESSION['install']['port'] = $_POST['port']; $checkConnection = new \Thelia\Install\CheckDatabaseConnection($_POST['host'], $_POST['username'], $_POST['password'], $_POST['port']); + if(!$checkConnection->exec()) { + header('location: connection.php?err=1'); + exit; + } $databases = $checkConnection->getConnection()->query('SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA'); - if(! $checkConnection->exec() || $databases === false){ + + if(false === $databases){ header('location: connection.php?err=1'); exit; } From 613aac093e544f05b52e5f714855bd408c2f121c Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Thu, 13 Mar 2014 17:10:21 +0100 Subject: [PATCH 013/372] remove all callback in customer class before saving it --- core/lib/Thelia/Action/Customer.php | 5 +++++ core/lib/Thelia/Model/Tools/ModelEventDispatcherTrait.php | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/core/lib/Thelia/Action/Customer.php b/core/lib/Thelia/Action/Customer.php index 6220aefe5..30e6a573b 100644 --- a/core/lib/Thelia/Action/Customer.php +++ b/core/lib/Thelia/Action/Customer.php @@ -147,6 +147,11 @@ class Customer extends BaseAction implements EventSubscriberInterface public function login(CustomerLoginEvent $event) { + $customer = $event->getCustomer(); + + if (method_exists($customer, 'clearDispatcher')) { + $customer->clearDispatcher(); + } $this->securityContext->setCustomerUser($event->getCustomer()); } diff --git a/core/lib/Thelia/Model/Tools/ModelEventDispatcherTrait.php b/core/lib/Thelia/Model/Tools/ModelEventDispatcherTrait.php index 759d032d4..10aae9ab4 100644 --- a/core/lib/Thelia/Model/Tools/ModelEventDispatcherTrait.php +++ b/core/lib/Thelia/Model/Tools/ModelEventDispatcherTrait.php @@ -53,6 +53,11 @@ trait ModelEventDispatcherTrait return $this->dispatcher; } + public function clearDispatcher() + { + $this->dispatcher = null; + } + protected function dispatchEvent($eventName, ActionEvent $event) { if (!is_null($this->dispatcher)) { From 0e21cb7b826d055be3efbeacc51ea8874c5efcec Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Fri, 14 Mar 2014 11:19:23 +0100 Subject: [PATCH 014/372] weight is not mandatory anymore --- .../Thelia/Controller/Admin/AbstractSeoCrudController.php | 6 ++++-- .../Thelia/Form/ProductDefaultSaleElementUpdateForm.php | 3 +-- core/lib/Thelia/Form/ProductSaleElementUpdateForm.php | 7 ++----- .../backOffice/default/includes/product-prices-tab.html | 4 ++-- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/core/lib/Thelia/Controller/Admin/AbstractSeoCrudController.php b/core/lib/Thelia/Controller/Admin/AbstractSeoCrudController.php index 52c4bbda4..1103f74f7 100644 --- a/core/lib/Thelia/Controller/Admin/AbstractSeoCrudController.php +++ b/core/lib/Thelia/Controller/Admin/AbstractSeoCrudController.php @@ -157,13 +157,15 @@ abstract class AbstractSeoCrudController extends AbstractCrudController /** * Update SEO modification, and either go back to the object list, or stay on the edition page. * - * @return Thelia\Core\HttpFoundation\Response the response + * @return \Thelia\Core\HttpFoundation\Response the response */ public function processUpdateSeoAction() { // Check current user authorization - if (null !== $response = $this->checkAuth($this->resourceCode, array(), AccessManager::UPDATE)) + if (null !== $response = $this->checkAuth($this->resourceCode, array(), AccessManager::UPDATE)) { return $response; + } + // Error (Default: false) $error_msg = false; diff --git a/core/lib/Thelia/Form/ProductDefaultSaleElementUpdateForm.php b/core/lib/Thelia/Form/ProductDefaultSaleElementUpdateForm.php index 54fb2fdc1..9443ebb55 100644 --- a/core/lib/Thelia/Form/ProductDefaultSaleElementUpdateForm.php +++ b/core/lib/Thelia/Form/ProductDefaultSaleElementUpdateForm.php @@ -65,8 +65,7 @@ class ProductDefaultSaleElementUpdateForm extends ProductSaleElementUpdateForm "label_attr" => array("for" => "tax_rule_field") )) ->add("weight", "number", array( - "constraints" => array(new NotBlank()), - "label" => Translator::getInstance()->trans("Weight *"), + "label" => Translator::getInstance()->trans("Weight"), "label_attr" => array("for" => "weight_field") )) ->add("quantity", "number", array( diff --git a/core/lib/Thelia/Form/ProductSaleElementUpdateForm.php b/core/lib/Thelia/Form/ProductSaleElementUpdateForm.php index cda72cc72..1f6516775 100644 --- a/core/lib/Thelia/Form/ProductSaleElementUpdateForm.php +++ b/core/lib/Thelia/Form/ProductSaleElementUpdateForm.php @@ -91,13 +91,10 @@ class ProductSaleElementUpdateForm extends BaseForm )) ->add('weight', 'collection', array( 'type' => 'number', - 'label' => Translator::getInstance()->trans('Weight *'), + 'label' => Translator::getInstance()->trans('Weight'), 'label_attr' => array('for' => 'weight_field'), 'allow_add' => true, - 'allow_delete' => true, - 'options' => array( - 'constraints' => array(new NotBlank()), - ) + 'allow_delete' => true )) ->add('quantity', 'collection', array( 'type' => 'number', diff --git a/templates/backOffice/default/includes/product-prices-tab.html b/templates/backOffice/default/includes/product-prices-tab.html index 32aa42af6..3e93352d7 100644 --- a/templates/backOffice/default/includes/product-prices-tab.html +++ b/templates/backOffice/default/includes/product-prices-tab.html @@ -170,7 +170,7 @@
- + {intl l="Kg"}
@@ -411,7 +411,7 @@ {/form_field} {form_field form=$form field='weight' value_key=$idx} - + {/form_field} From 1d4b230417184dfbc5e21f106589b9538d42b026 Mon Sep 17 00:00:00 2001 From: Franck Allimant Date: Fri, 14 Mar 2014 15:03:04 +0100 Subject: [PATCH 015/372] Improves error messages in image and document loop --- core/lib/Thelia/Core/Template/Loop/Document.php | 2 +- core/lib/Thelia/Core/Template/Loop/Image.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/lib/Thelia/Core/Template/Loop/Document.php b/core/lib/Thelia/Core/Template/Loop/Document.php index 0353b8df6..e681c9c93 100644 --- a/core/lib/Thelia/Core/Template/Loop/Document.php +++ b/core/lib/Thelia/Core/Template/Loop/Document.php @@ -262,7 +262,7 @@ class Document extends BaseI18nLoop implements PropelSearchLoopInterface $loopResult->addRow($loopResultRow); } catch (\Exception $ex) { // Ignore the result and log an error - Tlog::getInstance()->addError(sprintf("Failed to process document in document loop: %s", $ex->getMessage()), $this->args); + Tlog::getInstance()->addError("Failed to process document in document loop: ", $ex->getMessage(), ", loop arguments: ", $this->args); } } diff --git a/core/lib/Thelia/Core/Template/Loop/Image.php b/core/lib/Thelia/Core/Template/Loop/Image.php index 157259f30..3c21627a7 100644 --- a/core/lib/Thelia/Core/Template/Loop/Image.php +++ b/core/lib/Thelia/Core/Template/Loop/Image.php @@ -316,7 +316,7 @@ class Image extends BaseI18nLoop implements PropelSearchLoopInterface $loopResult->addRow($loopResultRow); } catch (\Exception $ex) { // Ignore the result and log an error - Tlog::getInstance()->addError("Failed to process image in image loop: ", $this->args); + Tlog::getInstance()->addError("Failed to process image in image loop: ", $ex->getMessage(), ", loop arguments: ", $this->args); } } From ac4b92949b7dcb46a35bdfc848acd40da58f8ebe Mon Sep 17 00:00:00 2001 From: Franck Allimant Date: Fri, 14 Mar 2014 15:53:21 +0100 Subject: [PATCH 016/372] Improved (again) error messages --- core/lib/Thelia/Core/Template/Loop/Document.php | 2 +- core/lib/Thelia/Core/Template/Loop/Image.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/lib/Thelia/Core/Template/Loop/Document.php b/core/lib/Thelia/Core/Template/Loop/Document.php index e681c9c93..6f68c9aa0 100644 --- a/core/lib/Thelia/Core/Template/Loop/Document.php +++ b/core/lib/Thelia/Core/Template/Loop/Document.php @@ -262,7 +262,7 @@ class Document extends BaseI18nLoop implements PropelSearchLoopInterface $loopResult->addRow($loopResultRow); } catch (\Exception $ex) { // Ignore the result and log an error - Tlog::getInstance()->addError("Failed to process document in document loop: ", $ex->getMessage(), ", loop arguments: ", $this->args); + Tlog::getInstance()->addError(sprintf("Failed to process document in document loop: %s", $ex->getMessage())); } } diff --git a/core/lib/Thelia/Core/Template/Loop/Image.php b/core/lib/Thelia/Core/Template/Loop/Image.php index 3c21627a7..c015d2f44 100644 --- a/core/lib/Thelia/Core/Template/Loop/Image.php +++ b/core/lib/Thelia/Core/Template/Loop/Image.php @@ -316,7 +316,7 @@ class Image extends BaseI18nLoop implements PropelSearchLoopInterface $loopResult->addRow($loopResultRow); } catch (\Exception $ex) { // Ignore the result and log an error - Tlog::getInstance()->addError("Failed to process image in image loop: ", $ex->getMessage(), ", loop arguments: ", $this->args); + Tlog::getInstance()->addError(sprintf("Failed to process image in image loop: %s", $ex->getMessage())); } } From 0e7c46418371c035cc8a9c46e72616c508b2a788 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Mon, 17 Mar 2014 10:01:43 +0100 Subject: [PATCH 017/372] remove context in all security function. This Parameter is not used anymore. --- core/lib/Thelia/Core/Template/Loop/Auth.php | 3 +-- core/lib/Thelia/Core/Template/Smarty/Plugins/Security.php | 4 ++-- templates/frontOffice/default/account-password.html | 2 +- templates/frontOffice/default/account-update.html | 2 +- templates/frontOffice/default/account.html | 2 +- templates/frontOffice/default/address-update.html | 2 +- templates/frontOffice/default/address.html | 2 +- templates/frontOffice/default/badresponse.html | 2 +- templates/frontOffice/default/layout.tpl | 4 ++-- templates/frontOffice/default/order-delivery.html | 2 +- templates/frontOffice/default/order-invoice.html | 2 +- templates/frontOffice/default/order-placed.html | 2 +- 12 files changed, 14 insertions(+), 15 deletions(-) diff --git a/core/lib/Thelia/Core/Template/Loop/Auth.php b/core/lib/Thelia/Core/Template/Loop/Auth.php index 667d5dfd2..7a6dec7f9 100644 --- a/core/lib/Thelia/Core/Template/Loop/Auth.php +++ b/core/lib/Thelia/Core/Template/Loop/Auth.php @@ -71,8 +71,7 @@ class Auth extends BaseLoop implements ArraySearchLoopInterface new TypeCollection( new EnumListType(array(AccessManager::VIEW, AccessManager::CREATE, AccessManager::UPDATE, AccessManager::DELETE)) ) - ), - Argument::createAnyTypeArgument('context', 'front', false) + ) ); } diff --git a/core/lib/Thelia/Core/Template/Smarty/Plugins/Security.php b/core/lib/Thelia/Core/Template/Smarty/Plugins/Security.php index 9db8e90fe..26f412b2c 100644 --- a/core/lib/Thelia/Core/Template/Smarty/Plugins/Security.php +++ b/core/lib/Thelia/Core/Template/Smarty/Plugins/Security.php @@ -61,8 +61,8 @@ class Security extends AbstractSmartyPlugin if (! $this->securityContext->isGranted($roles, $resources, $modules, $accesses)) { $ex = new AuthenticationException( - sprintf("User not granted for roles '%s', to access resources '%s' with %s in context '%s'.", - implode(',', $roles), implode(',', $resources), implode(',', $accesses), $context + sprintf("User not granted for roles '%s', to access resources '%s' with %s.", + implode(',', $roles), implode(',', $resources), implode(',', $accesses) ) ); diff --git a/templates/frontOffice/default/account-password.html b/templates/frontOffice/default/account-password.html index 653ed9eef..9d0b592b7 100644 --- a/templates/frontOffice/default/account-password.html +++ b/templates/frontOffice/default/account-password.html @@ -2,7 +2,7 @@ {* Security *} {block name="no-return-functions" prepend} - {check_auth context="front" role="CUSTOMER" login_tpl="login"} + {check_auth role="CUSTOMER" login_tpl="login"} {/block} {* Body Class *} diff --git a/templates/frontOffice/default/account-update.html b/templates/frontOffice/default/account-update.html index 467d586f6..01c692094 100644 --- a/templates/frontOffice/default/account-update.html +++ b/templates/frontOffice/default/account-update.html @@ -2,7 +2,7 @@ {* Security *} {block name="no-return-functions" prepend} - {check_auth context="front" role="CUSTOMER" login_tpl="login"} + {check_auth role="CUSTOMER" login_tpl="login"} {/block} {* Body Class *} diff --git a/templates/frontOffice/default/account.html b/templates/frontOffice/default/account.html index a6fe50d84..55626509a 100644 --- a/templates/frontOffice/default/account.html +++ b/templates/frontOffice/default/account.html @@ -2,7 +2,7 @@ {* Security *} {block name="no-return-functions" prepend} - {check_auth context="front" role="CUSTOMER" login_tpl="login"} + {check_auth role="CUSTOMER" login_tpl="login"} {/block} {* Breadcrumb *} diff --git a/templates/frontOffice/default/address-update.html b/templates/frontOffice/default/address-update.html index 6add1d884..78ce6f1e7 100644 --- a/templates/frontOffice/default/address-update.html +++ b/templates/frontOffice/default/address-update.html @@ -2,7 +2,7 @@ {* Security *} {block name="no-return-functions" prepend} - {check_auth context="front" role="CUSTOMER" login_tpl="login"} + {check_auth role="CUSTOMER" login_tpl="login"} {/block} {* Body Class *} diff --git a/templates/frontOffice/default/address.html b/templates/frontOffice/default/address.html index 771d4aad5..9baf8c3e5 100644 --- a/templates/frontOffice/default/address.html +++ b/templates/frontOffice/default/address.html @@ -2,7 +2,7 @@ {* Security *} {block name="no-return-functions" prepend} - {check_auth context="front" role="CUSTOMER" login_tpl="login"} + {check_auth role="CUSTOMER" login_tpl="login"} {/block} {* Body Class *} diff --git a/templates/frontOffice/default/badresponse.html b/templates/frontOffice/default/badresponse.html index 47f5bb503..5dfd6b333 100755 --- a/templates/frontOffice/default/badresponse.html +++ b/templates/frontOffice/default/badresponse.html @@ -2,7 +2,7 @@ {* Security *} {block name="no-return-functions" prepend} -{check_auth context="front" role="CUSTOMER" login_tpl="login"} + {check_auth role="CUSTOMER" login_tpl="login"} {/block} {* Breadcrumb *} diff --git a/templates/frontOffice/default/layout.tpl b/templates/frontOffice/default/layout.tpl index a53d7ea2e..8aba0bb48 100644 --- a/templates/frontOffice/default/layout.tpl +++ b/templates/frontOffice/default/layout.tpl @@ -92,7 +92,7 @@ GNU General Public License : http://www.gnu.org/licenses/
@@ -289,14 +290,8 @@ {intl l="Back"} - {/form} - - - - - {/block} From 320565e96564b9a5a61c3a66781790c7bf808863 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Thu, 10 Apr 2014 12:02:03 +0200 Subject: [PATCH 067/372] change cart loop in mini cart --- local/modules/Klikandpay | 2 +- .../frontOffice/default/includes/mini-cart.html | 14 ++++++-------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/local/modules/Klikandpay b/local/modules/Klikandpay index 15cc539db..a72c066e7 160000 --- a/local/modules/Klikandpay +++ b/local/modules/Klikandpay @@ -1 +1 @@ -Subproject commit 15cc539db98eebd675538e6c35a92a3ca749195c +Subproject commit a72c066e7400d2350dca24016a302582cb7e7b62 diff --git a/templates/frontOffice/default/includes/mini-cart.html b/templates/frontOffice/default/includes/mini-cart.html index 5c075edf4..1dad142c3 100644 --- a/templates/frontOffice/default/includes/mini-cart.html +++ b/templates/frontOffice/default/includes/mini-cart.html @@ -16,16 +16,14 @@ {loop type="cart" name="cartloop"} - {ifloop rel="product-image"} - {loop type="image" name="product-image" product=$PRODUCT_ID limit="1" width="118" height="60"} - {$TITLE} - {/loop} - {/ifloop} + {loop type="image" name="product-image" product=$PRODUCT_ID limit="1" width="118" height="60"} + {$TITLE} + {/loop} -

- {$TITLE} -

+

+ {$TITLE} +

{intl l="Remove"} From 2532a3bb4b0efef23db1d3f5edd25a512c4f67d1 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Thu, 10 Apr 2014 12:05:45 +0200 Subject: [PATCH 068/372] fix cs --- core/lib/Thelia/Action/Currency.php | 1 - .../Command/Skeleton/Module/I18n/en_US.php | 8 +-- .../Command/Skeleton/Module/I18n/fr_FR.php | 8 +-- .../Command/Skeleton/Module/routing.xml | 62 +++++++++---------- .../Admin/AbstractSeoCrudController.php | 4 +- .../Event/Cart/CartItemDuplicationItem.php | 6 +- .../Thelia/Core/Event/Order/OrderEvent.php | 2 - .../Thelia/Core/Template/ParserInterface.php | 2 +- core/lib/Thelia/Model/OrderProduct.php | 2 - core/lib/Thelia/Module/BaseModule.php | 35 +++++------ 10 files changed, 61 insertions(+), 69 deletions(-) diff --git a/core/lib/Thelia/Action/Currency.php b/core/lib/Thelia/Action/Currency.php index 2a276cd9e..017e4a881 100644 --- a/core/lib/Thelia/Action/Currency.php +++ b/core/lib/Thelia/Action/Currency.php @@ -23,7 +23,6 @@ namespace Thelia\Action; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Thelia\Core\Event\ActionEvent; diff --git a/core/lib/Thelia/Command/Skeleton/Module/I18n/en_US.php b/core/lib/Thelia/Command/Skeleton/Module/I18n/en_US.php index f32e11983..0b4fa142b 100644 --- a/core/lib/Thelia/Command/Skeleton/Module/I18n/en_US.php +++ b/core/lib/Thelia/Command/Skeleton/Module/I18n/en_US.php @@ -1,4 +1,4 @@ - 'The displayed english string', -); \ No newline at end of file + 'The displayed english string', +); diff --git a/core/lib/Thelia/Command/Skeleton/Module/I18n/fr_FR.php b/core/lib/Thelia/Command/Skeleton/Module/I18n/fr_FR.php index fd88a21eb..370862450 100644 --- a/core/lib/Thelia/Command/Skeleton/Module/I18n/fr_FR.php +++ b/core/lib/Thelia/Command/Skeleton/Module/I18n/fr_FR.php @@ -1,4 +1,4 @@ - 'La traduction française de la chaine', -); \ No newline at end of file + 'La traduction française de la chaine', +); diff --git a/core/lib/Thelia/Command/Skeleton/Module/routing.xml b/core/lib/Thelia/Command/Skeleton/Module/routing.xml index 22d919792..12c942d0b 100644 --- a/core/lib/Thelia/Command/Skeleton/Module/routing.xml +++ b/core/lib/Thelia/Command/Skeleton/Module/routing.xml @@ -1,31 +1,31 @@ - - - - - - - + + + + + + + diff --git a/core/lib/Thelia/Controller/Admin/AbstractSeoCrudController.php b/core/lib/Thelia/Controller/Admin/AbstractSeoCrudController.php index 1d6cb06d5..0976696d8 100644 --- a/core/lib/Thelia/Controller/Admin/AbstractSeoCrudController.php +++ b/core/lib/Thelia/Controller/Admin/AbstractSeoCrudController.php @@ -221,7 +221,7 @@ abstract class AbstractSeoCrudController extends AbstractCrudController // Pass it to the parser $this->getParserContext()->addForm($changeForm); } - + if (false !== $error_msg) { $this->setupFormErrorContext( $this->getTranslator()->trans("%obj SEO modification", array('%obj' => $this->objectName)), @@ -229,7 +229,7 @@ abstract class AbstractSeoCrudController extends AbstractCrudController $updateSeoForm, $ex ); - + // At this point, the form has errors, and should be redisplayed. return $this->renderEditionTemplate(); } diff --git a/core/lib/Thelia/Core/Event/Cart/CartItemDuplicationItem.php b/core/lib/Thelia/Core/Event/Cart/CartItemDuplicationItem.php index 2ea8b04e6..fa6d297e1 100644 --- a/core/lib/Thelia/Core/Event/Cart/CartItemDuplicationItem.php +++ b/core/lib/Thelia/Core/Event/Cart/CartItemDuplicationItem.php @@ -26,7 +26,6 @@ namespace Thelia\Core\Event\Cart; use Thelia\Core\Event\ActionEvent; use Thelia\Model\CartItem; - /** * Class CartItemDuplicationItem * @package Thelia\Core\Event\Cart @@ -44,7 +43,7 @@ class CartItemDuplicationItem extends ActionEvent */ protected $newItem; - function __construct(CartItem $newItem, CartItem $oldItem) + public function __construct(CartItem $newItem, CartItem $oldItem) { $this->newItem = $newItem; $this->oldItem = $oldItem; @@ -66,5 +65,4 @@ class CartItemDuplicationItem extends ActionEvent return $this->oldItem; } - -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Core/Event/Order/OrderEvent.php b/core/lib/Thelia/Core/Event/Order/OrderEvent.php index c8ebeb033..503f6b4a8 100644 --- a/core/lib/Thelia/Core/Event/Order/OrderEvent.php +++ b/core/lib/Thelia/Core/Event/Order/OrderEvent.php @@ -81,8 +81,6 @@ class OrderEvent extends ActionEvent return $this->cartItemId; } - - /** * @param Order $order */ diff --git a/core/lib/Thelia/Core/Template/ParserInterface.php b/core/lib/Thelia/Core/Template/ParserInterface.php index 6156ca859..c9cf2eceb 100644 --- a/core/lib/Thelia/Core/Template/ParserInterface.php +++ b/core/lib/Thelia/Core/Template/ParserInterface.php @@ -63,7 +63,7 @@ interface ParserInterface * Create a variable that will be available in the templates * * @param string $variable the variable name - * @param mixed $value the value of the variable + * @param mixed $value the value of the variable */ public function assign($variable, $value); } diff --git a/core/lib/Thelia/Model/OrderProduct.php b/core/lib/Thelia/Model/OrderProduct.php index dfd23d00a..5f87cbc97 100644 --- a/core/lib/Thelia/Model/OrderProduct.php +++ b/core/lib/Thelia/Model/OrderProduct.php @@ -31,8 +31,6 @@ class OrderProduct extends BaseOrderProduct return $this->cartIemId; } - - /** * {@inheritDoc} */ diff --git a/core/lib/Thelia/Module/BaseModule.php b/core/lib/Thelia/Module/BaseModule.php index 1a3e54be9..7fc3a16f7 100644 --- a/core/lib/Thelia/Module/BaseModule.php +++ b/core/lib/Thelia/Module/BaseModule.php @@ -200,8 +200,8 @@ class BaseModule extends ContainerAware implements BaseModuleInterface * TODO : clarify the purpose of ModuleImage. How this table will be used elswhere in Thelia ? * TODO : this method doesn't take care of internationalization. This is a bug. * - * @param Module $module the module - * @param string $folderPath the image folder path + * @param Module $module the module + * @param string $folderPath the image folder path * @param ConnectionInterface $con * * @throws \Thelia\Exception\ModuleException @@ -300,10 +300,11 @@ class BaseModule extends ContainerAware implements BaseModuleInterface /** * Check if this module is the payment module for a given order * - * @param Order $order an order - * @return bool true if this module is the payment module for the given order. + * @param Order $order an order + * @return bool true if this module is the payment module for the given order. */ - public function isPaymentModuleFor(Order $order) { + public function isPaymentModuleFor(Order $order) + { $model = $this->getModuleModel(); return $order->getPaymentModuleId() == $model->getId(); @@ -312,10 +313,11 @@ class BaseModule extends ContainerAware implements BaseModuleInterface /** * Check if this module is the delivery module for a given order * - * @param Order $order an order - * @return bool true if this module is the delivery module for the given order. + * @param Order $order an order + * @return bool true if this module is the delivery module for the given order. */ - public function isDeliveryModuleFor(Order $order) { + public function isDeliveryModuleFor(Order $order) + { $model = $this->getModuleModel(); return $order->getDeliveryModuleId() == $model->getId(); @@ -327,14 +329,14 @@ class BaseModule extends ContainerAware implements BaseModuleInterface * get the total amount of an order already stored in the database. For such orders, use * Order::getTotalAmount() method. * - * @param bool $with_tax if true, to total price will include tax amount + * @param bool $with_tax if true, to total price will include tax amount * @param bool $with_discount if true, the total price will include discount, if any - * @param bool $with_postage if true, the total price will include the delivery costs, if any. + * @param bool $with_postage if true, the total price will include the delivery costs, if any. * * @return float|int the current order amount. */ - public function getCurrentOrderTotalAmount($with_tax = true, $with_discount = true, $with_postage = true) { - + public function getCurrentOrderTotalAmount($with_tax = true, $with_discount = true, $with_postage = true) + { /** @var Session $session */ $session = $this->getRequest()->getSession(); @@ -420,7 +422,6 @@ class BaseModule extends ContainerAware implements BaseModuleInterface public function preActivation(ConnectionInterface $con = null) { // Override this method to do something useful. - return true; } @@ -437,17 +438,15 @@ class BaseModule extends ContainerAware implements BaseModuleInterface /** * This method is called before the module de-activation, and may prevent it by returning false. * - * @param ConnectionInterface $con - * @return bool true to continue module de-activation, false to prevent it. + * @param ConnectionInterface $con + * @return bool true to continue module de-activation, false to prevent it. */ public function preDeactivation(ConnectionInterface $con = null) { // Override this method to do something useful. - return true; } - public function postDeactivation(ConnectionInterface $con = null) { // Override this method to do something useful. @@ -458,7 +457,7 @@ class BaseModule extends ContainerAware implements BaseModuleInterface * to delete its data. * * @param ConnectionInterface $con - * @param bool $deleteModuleData if true, the module should remove all its data from the system. + * @param bool $deleteModuleData if true, the module should remove all its data from the system. */ public function destroy(ConnectionInterface $con = null, $deleteModuleData = false) { From 7927d42ae1afe566890f8b70520d090f0fe4e2af Mon Sep 17 00:00:00 2001 From: driou Date: Thu, 10 Apr 2014 13:16:43 +0200 Subject: [PATCH 069/372] Update insert.sql --- install/insert.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install/insert.sql b/install/insert.sql index 2d53b3801..9ad551a47 100644 --- a/install/insert.sql +++ b/install/insert.sql @@ -1,7 +1,7 @@ INSERT INTO `lang`(`id`,`title`,`code`,`locale`,`url`,`date_format`,`time_format`,`datetime_format`,`decimal_separator`,`thousands_separator`,`decimals`,`by_default`,`created_at`,`updated_at`)VALUES (1, 'Français', 'fr', 'fr_FR', '', 'd/m/Y', 'H:i:s', 'd/m/y H:i:s', ',', ' ', '2', '0', NOW(), NOW()), (2, 'English', 'en', 'en_US', '', 'm-d-Y', 'h:i:s', 'm-d-Y h:i:s', '.', ' ', '2', '1', NOW(), NOW()), -(3, 'castellano', 'es', 'es_ES', '', 'm-d-Y', 'h:i:s', 'm-d-Y h:i:s', ',', '.', '2', '0', NOW(), NOW()), +(3, 'Castellano', 'es', 'es_ES', '', 'm-d-Y', 'h:i:s', 'm-d-Y h:i:s', ',', '.', '2', '0', NOW(), NOW()), (4, 'Italiano', 'it', 'it_IT', '', 'd/m/Y', 'H:i:s', 'd/m/y H:i:s', ',', ' ', '2', '0', NOW(), NOW()); INSERT INTO `config` (`name`, `value`, `secured`, `hidden`, `created_at`, `updated_at`) VALUES From 5e9070097dace6c17fba6731350ec0e8cbce86c6 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Thu, 10 Apr 2014 15:56:18 +0200 Subject: [PATCH 070/372] allow to possibility to flush the cache from admin panel, Fix #249 --- core/lib/Thelia/Config/Resources/form.xml | 2 + .../Thelia/Config/Resources/routing/admin.xml | 11 +++ .../Controller/Admin/CacheController.php | 73 +++++++++++++++++++ .../Core/Security/Resource/AdminResources.php | 2 + core/lib/Thelia/Form/Cache/CacheFlushForm.php | 69 ++++++++++++++++++ install/insert.sql | 3 +- templates/backOffice/default/cache.html | 31 ++++++++ .../backOffice/default/configuration.html | 6 ++ 8 files changed, 196 insertions(+), 1 deletion(-) create mode 100644 core/lib/Thelia/Controller/Admin/CacheController.php create mode 100644 core/lib/Thelia/Form/Cache/CacheFlushForm.php create mode 100644 templates/backOffice/default/cache.html diff --git a/core/lib/Thelia/Config/Resources/form.xml b/core/lib/Thelia/Config/Resources/form.xml index ec281266e..7cfd5ce34 100644 --- a/core/lib/Thelia/Config/Resources/form.xml +++ b/core/lib/Thelia/Config/Resources/form.xml @@ -122,6 +122,8 @@
+ + diff --git a/core/lib/Thelia/Config/Resources/routing/admin.xml b/core/lib/Thelia/Config/Resources/routing/admin.xml index 3e6ea5646..7173fa8ce 100644 --- a/core/lib/Thelia/Config/Resources/routing/admin.xml +++ b/core/lib/Thelia/Config/Resources/routing/admin.xml @@ -981,6 +981,17 @@ + + + Thelia\Controller\Admin\CacheController::defaultAction + + + + Thelia\Controller\Admin\CacheController::flushAction + + + + diff --git a/core/lib/Thelia/Controller/Admin/CacheController.php b/core/lib/Thelia/Controller/Admin/CacheController.php new file mode 100644 index 000000000..4f183cfd4 --- /dev/null +++ b/core/lib/Thelia/Controller/Admin/CacheController.php @@ -0,0 +1,73 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Controller\Admin; + +use Thelia\Core\Event\Cache\CacheEvent; +use Thelia\Core\Event\TheliaEvents; +use Thelia\Core\Security\AccessManager; +use Thelia\Core\Security\Resource\AdminResources; +use Thelia\Form\Cache\CacheFlushForm; +use Thelia\Form\Exception\FormValidationException; + + +/** + * Class CacheController + * @package Thelia\Controller\Admin + * @author Manuel Raynaud + */ +class CacheController extends BaseAdminController +{ + + public function defaultAction() + { + if (null !== $result = $this->checkAuth(AdminResources::CACHE, [], AccessManager::VIEW)) { + return $result; + } + + return $this->render('cache'); + } + + public function flushAction() + { + if (null !== $result = $this->checkAuth(AdminResources::CACHE, [], AccessManager::UPDATE)) { + return $result; + } + + $form = new CacheFlushForm($this->getRequest()); + try { + $this->validateForm($form); + + $event = new CacheEvent($this->container->getParameter("kernel.cache_dir")); + $this->dispatch(TheliaEvents::CACHE_CLEAR, $event); + + $event = new CacheEvent(THELIA_WEB_DIR . "assets"); + $this->dispatch(TheliaEvents::CACHE_CLEAR, $event); + + $this->redirectToRoute('admin.configuration.cache'); + } catch (FormValidationException $e) { + + } + } + +} \ No newline at end of file diff --git a/core/lib/Thelia/Core/Security/Resource/AdminResources.php b/core/lib/Thelia/Core/Security/Resource/AdminResources.php index 314038e67..4d8d8ad90 100644 --- a/core/lib/Thelia/Core/Security/Resource/AdminResources.php +++ b/core/lib/Thelia/Core/Security/Resource/AdminResources.php @@ -60,6 +60,8 @@ final class AdminResources const ATTRIBUTE = "admin.configuration.attribute"; + const CACHE = "admin.cache"; + const CATEGORY = "admin.category"; const CONFIG = "admin.configuration"; diff --git a/core/lib/Thelia/Form/Cache/CacheFlushForm.php b/core/lib/Thelia/Form/Cache/CacheFlushForm.php new file mode 100644 index 000000000..8410bd7c7 --- /dev/null +++ b/core/lib/Thelia/Form/Cache/CacheFlushForm.php @@ -0,0 +1,69 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Form\Cache; + +use Thelia\Form\BaseForm; + + +/** + * Class CacheFlushForm + * @package Thelia\Form\Cache + * @author Manuel Raynaud + */ +class CacheFlushForm extends BaseForm +{ + + /** + * + * in this function you add all the fields you need for your Form. + * Form this you have to call add method on $this->formBuilder attribute : + * + * $this->formBuilder->add("name", "text") + * ->add("email", "email", array( + * "attr" => array( + * "class" => "field" + * ), + * "label" => "email", + * "constraints" => array( + * new \Symfony\Component\Validator\Constraints\NotBlank() + * ) + * ) + * ) + * ->add('age', 'integer'); + * + * @return null + */ + protected function buildForm() + { + //Nothing, we just want CSRF protection + } + + /** + * @return string the name of you form. This name must be unique + */ + public function getName() + { + return "cache_flush"; + } +} \ No newline at end of file diff --git a/install/insert.sql b/install/insert.sql index 9ad551a47..a1a629f67 100644 --- a/install/insert.sql +++ b/install/insert.sql @@ -1269,7 +1269,8 @@ INSERT INTO resource (`id`, `code`, `created_at`, `updated_at`) VALUES (21, 'admin.configuration.shipping-zone', NOW(), NOW()), (22, 'admin.configuration.tax', NOW(), NOW()), (23, 'admin.configuration.template', NOW(), NOW()), -(24, 'admin.configuration.system-log', NOW(), NOW()); +(24, 'admin.configuration.system-log', NOW(), NOW()), +(25, 'admin.cache', NOW(), NOW()); /** generated with command : php Thelia thelia:generate-resources --output sql-i18n diff --git a/templates/backOffice/default/cache.html b/templates/backOffice/default/cache.html new file mode 100644 index 000000000..95c9b5178 --- /dev/null +++ b/templates/backOffice/default/cache.html @@ -0,0 +1,31 @@ +{extends file="admin-layout.tpl"} + +{block name="page-title"}{intl l='Cache'}{/block} + +{block name="check-resource"}admin.cache{/block} +{block name="check-access"}view{/block} + +{block name="main-content"} +
+ +
+ + + +
+
+ {form name="thelia.cache.flush"} + + {form_hidden_fields form=$form} + + + {/form} +
+
+
+
+{/block} diff --git a/templates/backOffice/default/configuration.html b/templates/backOffice/default/configuration.html index 1560cd332..4e57584ca 100644 --- a/templates/backOffice/default/configuration.html +++ b/templates/backOffice/default/configuration.html @@ -178,6 +178,12 @@ {/loop} + {loop type="auth" name="pcc9" role="ADMIN" resource="admin.configuration.cache" access="VIEW"} + + {intl l='Cache'} + + + {/loop} {module_include location='system_configuration_bottom'} From 4c6a519bd58eaf5a58796556acd2c8e711f16529 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Thu, 10 Apr 2014 16:02:33 +0200 Subject: [PATCH 071/372] update sql update file --- install/insert.sql | 4 +++- install/update/2.0.0.sql | 10 ++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/install/insert.sql b/install/insert.sql index a1a629f67..0dd73f6ad 100644 --- a/install/insert.sql +++ b/install/insert.sql @@ -1323,7 +1323,9 @@ INSERT INTO resource_i18n (`id`, `locale`, `title`) VALUES (23, 'en_US', 'Configuration / Template'), (23, 'fr_FR', 'Configuration / Template'), (24, 'en_US', 'Configuration / System Log'), -(24, 'fr_FR', 'Configuration / Logs système'); +(24, 'fr_FR', 'Configuration / Logs système'), +(25, 'en_US', 'Configuration / Cache'), +(25, 'fr_FR', 'Configuration / Cache'); INSERT INTO `message` (`id`, `name`, `secured`, `created_at`, `updated_at`, `version`, `version_created_at`, `version_created_by`) VALUES diff --git a/install/update/2.0.0.sql b/install/update/2.0.0.sql index d3c76ff94..aba2a4f0a 100644 --- a/install/update/2.0.0.sql +++ b/install/update/2.0.0.sql @@ -28,4 +28,14 @@ ALTER TABLE `feature_template` ADD INDEX `idx_feature_template_template_id_posit ALTER TABLE `currency` ADD INDEX `idx_currency_code` (`code`); +SELECT @max := MAX(`id`) FROM `resource`; +SET @max := @max+1; + +INSERT INTO `resource` (`id`, `code`, `created_at`, `updated_at`) VALUES +(@max, 'admin.cache', NOW(), NOW()); + +INSERT INTO resource_i18n (`id`, `locale`, `title`) VALUES +(@max, 'en_US', 'Configuration / Cache'), +(@max, 'fr_FR', 'Configuration / Cache'); + SET FOREIGN_KEY_CHECKS = 1; \ No newline at end of file From 4f6092f86ca7fb7a5d055099985318b656a192dc Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Thu, 10 Apr 2014 16:23:24 +0200 Subject: [PATCH 072/372] fix wrong translation --- templates/backOffice/default/I18n/fr_FR.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) mode change 100644 => 100755 templates/backOffice/default/I18n/fr_FR.php diff --git a/templates/backOffice/default/I18n/fr_FR.php b/templates/backOffice/default/I18n/fr_FR.php old mode 100644 new mode 100755 index 195acdb9c..359241e9a --- a/templates/backOffice/default/I18n/fr_FR.php +++ b/templates/backOffice/default/I18n/fr_FR.php @@ -684,8 +684,8 @@ return array( 'SEO' => 'SEO', 'Sale' => 'En promo', 'Sale price incl. taxes' => 'Prix promo TTC', - 'Sale price
w/ taxes (%currency)' => 'Prix promo
HT (%currency)', - 'Sale price
w/o taxes (%currency)' => 'Prix promo
TTC (%currency)', + 'Sale price
w/ taxes (%currency)' => 'Prix promo
TTC (%currency)', + 'Sale price
w/o taxes (%currency)' => 'Prix promo
HT (%currency)', 'Sales' => 'Ventes', 'Sales excluding shipping' => 'Ventes hors frais de port', 'Sales statistics' => 'Statistiques de vente', From f540941d3f3073f2200cf42d9f04a712cd025a24 Mon Sep 17 00:00:00 2001 From: Franck Allimant Date: Thu, 10 Apr 2014 18:35:43 +0200 Subject: [PATCH 073/372] Added getNewInstance() method --- core/lib/Thelia/Log/Tlog.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/core/lib/Thelia/Log/Tlog.php b/core/lib/Thelia/Log/Tlog.php index 1eaf64350..b8792bddb 100644 --- a/core/lib/Thelia/Log/Tlog.php +++ b/core/lib/Thelia/Log/Tlog.php @@ -124,6 +124,19 @@ class Tlog Implements LoggerInterface return self::$instance; } + /** + * Create a new Tlog instance, than t will not interfere with the "Main" instance + * + * @return Tlog a new Tlog instance + */ + public static function getNewInstance() { + $instance = new Tlog(); + + $instance->init(); + + return $instance; + } + /** * initialize default configuration */ From 381258ec739662197298023e4090edf884d05d00 Mon Sep 17 00:00:00 2001 From: Franck Allimant Date: Thu, 10 Apr 2014 18:36:46 +0200 Subject: [PATCH 074/372] Fixed comment --- core/lib/Thelia/Log/Tlog.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/lib/Thelia/Log/Tlog.php b/core/lib/Thelia/Log/Tlog.php index b8792bddb..f7863eb8d 100644 --- a/core/lib/Thelia/Log/Tlog.php +++ b/core/lib/Thelia/Log/Tlog.php @@ -125,9 +125,9 @@ class Tlog Implements LoggerInterface } /** - * Create a new Tlog instance, than t will not interfere with the "Main" instance - * - * @return Tlog a new Tlog instance + * Create a new Tlog instance, that could be configured without interfering with the "main" instance + * + * @return Tlog a new Tlog instance. */ public static function getNewInstance() { $instance = new Tlog(); From ea3ffbf3038dab7bf5520c01011f72764b1f7abb Mon Sep 17 00:00:00 2001 From: Franck Allimant Date: Fri, 11 Apr 2014 01:07:31 +0200 Subject: [PATCH 075/372] trim()'ed the search term --- templates/backOffice/default/search.html | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/templates/backOffice/default/search.html b/templates/backOffice/default/search.html index e2f1f9211..a3af85dac 100644 --- a/templates/backOffice/default/search.html +++ b/templates/backOffice/default/search.html @@ -13,7 +13,7 @@ @@ -54,7 +54,7 @@ - {loop name="customer_list" type="customer" current="false" visible="*" backend_context="1" search_term=$smarty.get.search_term search_in="ref,firstname,lastname,email"} + {loop name="customer_list" type="customer" current="false" visible="*" backend_context="1" search_term=trim($smarty.get.search_term) search_in="ref,firstname,lastname,email"} {assign "lastOrderDate" ''} {assign "lastOrderAmount" ''} {assign "lastOrderCurrency" ''} @@ -131,7 +131,7 @@ - {loop type="order" name="order-search" backend_context=1 customer="*" search_term=$smarty.get.search_term search_in="ref,customer_ref,customer_firstname,customer_lastname,customer_email"} + {loop type="order" name="order-search" backend_context=1 customer="*" search_term=trim($smarty.get.search_term) search_in="ref,customer_ref,customer_firstname,customer_lastname,customer_email"} {loop type="order_address" name="order-invoice-address" id=$INVOICE_ADDRESS} {assign "orderInvoiceFirstName" $FIRSTNAME} {assign "orderInvoiceLastName" $LASTNAME} @@ -187,7 +187,7 @@ - {loop type="product" name="product-search" visible="*" search_mode="sentence" search_term=$smarty.get.search_term search_in="ref,title"} + {loop type="product" name="product-search" visible="*" search_mode="sentence" search_term=trim($smarty.get.search_term) search_in="ref,title"} {$ID} From e7adfec2f10dc895a356f4a1df1822af32855ca7 Mon Sep 17 00:00:00 2001 From: Franck Allimant Date: Fri, 11 Apr 2014 02:14:34 +0200 Subject: [PATCH 076/372] Fixed page title ("My Cart" is not correct at this time) --- templates/frontOffice/default/order-delivery.html | 2 +- templates/frontOffice/default/order-invoice.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/frontOffice/default/order-delivery.html b/templates/frontOffice/default/order-delivery.html index c84d54592..49be8707d 100644 --- a/templates/frontOffice/default/order-delivery.html +++ b/templates/frontOffice/default/order-delivery.html @@ -23,7 +23,7 @@
-

{intl l="Your Cart"}

+

{intl l="Billing and delivery"}

{include file="misc/checkout-progress.tpl" step="delivery"} diff --git a/templates/frontOffice/default/order-invoice.html b/templates/frontOffice/default/order-invoice.html index 500b14f29..32d5408b8 100644 --- a/templates/frontOffice/default/order-invoice.html +++ b/templates/frontOffice/default/order-invoice.html @@ -23,7 +23,7 @@
-

{intl l="Your Cart"}

+

{intl l="Check my order"}

{include file="misc/checkout-progress.tpl" step="invoice"} From 112d2525b2207c9a0ee994d736f14ddcfff61a60 Mon Sep 17 00:00:00 2001 From: Franck Allimant Date: Fri, 11 Apr 2014 02:17:46 +0200 Subject: [PATCH 077/372] Added the order.failed route --- local/modules/Front/Config/front.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/local/modules/Front/Config/front.xml b/local/modules/Front/Config/front.xml index 74b42af5a..ed5e457fa 100644 --- a/local/modules/Front/Config/front.xml +++ b/local/modules/Front/Config/front.xml @@ -158,6 +158,11 @@ Front\Controller\OrderController::orderPlaced order-placed + + + Front\Controller\OrderController::orderFailed + order-failed + From 1c8b1f0e589b5a534a1f6a77714c09140a6aafd0 Mon Sep 17 00:00:00 2001 From: Franck Allimant Date: Fri, 11 Apr 2014 02:19:08 +0200 Subject: [PATCH 078/372] Added this abtract class for payment modules. --- .../Thelia/Module/AbstractPaymentModule.php | 132 ++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 core/lib/Thelia/Module/AbstractPaymentModule.php diff --git a/core/lib/Thelia/Module/AbstractPaymentModule.php b/core/lib/Thelia/Module/AbstractPaymentModule.php new file mode 100644 index 000000000..f80dd17f9 --- /dev/null +++ b/core/lib/Thelia/Module/AbstractPaymentModule.php @@ -0,0 +1,132 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Module; + +use Symfony\Component\Routing\Router; +use Thelia\Core\HttpFoundation\Response; +use Thelia\Core\Template\ParserInterface; +use Thelia\Core\Template\TemplateHelper; +use Thelia\Exception\TheliaProcessException; +use Thelia\Model\Order; +use Thelia\Tools\URL; + +abstract class AbstractPaymentModule extends BaseModule implements PaymentModuleInterface +{ + /** + * This method is called when the payement gateway needs to be invoked. + * + * If this method return a Response instance, this response is sent to the browser. Return null if you don't want to + * send a response and process the payment yourself. + * + * In many cases, it's necessary to send a form to the payment gateway. On your response you can return this form already + * completed, ready to be sent, instead of redirecting. The generateGatewayFormResponse() may help you in this case :) + * + * @param Order $order processed order + * @return null|Response + */ + abstract public function pay(Order $order); + + /** + * This method is called by the Payment loop, to check if the current module has to be displayed to the customer + * + * If you return true, the payment method will de displayed to the customed + * If you return false, the payment method will not be displayed + * + * @return boolean + */ + abstract public function isValidPayment(); + + + /** + * Render the payment gateway template. The module should provide the gateway URL and the form fields names and values. + * + * @param Order $order the order + * @param string $gateway_url the payment gateway URL + * @param array $form_data an associative array of form data, that will be rendered as hiddent fields + * + * @return Response the HTTP response. + */ + public function generateGatewayFormResponse($order, $gateway_url, $form_data) + { + /** @var ParserInterface $parser */ + $parser = $this->container->get("thelia.parser"); + + $parser->setTemplateDefinition(TemplateHelper::getInstance()->getActiveFrontTemplate()); + + $renderedTemplate = $parser->render( + "order-payment-gateway.html", + array( + "order_id" => $order->getId(), + "cart_count" => $this->getRequest()->getSession()->getCart()->getCartItems()->count(), + "gateway_url" => $gateway_url, + "payment_form_data" => $form_data + ) + ); + + return Response::create($renderedTemplate); + } + + /** + * Return the order payment success page URL + * + * @param int $order_id the order ID + * @return string the order payment success page URL + */ + public function getPayementSuccessPageUrl($order_id) + { + $frontOfficeRouter = $this->container->get('router.front'); + + return URL::getInstance()->absoluteUrl( + $frontOfficeRouter->generate( + "order.placed", + array("order_id" => $order_id), + Router::ABSOLUTE_URL + ) + ); + } + + /** + * Redirect the customer to the failure payment page. if $message is null, a generic message is displayed. + * + * @param int $order_id the order ID + * @param string|null $message an error message. + * + * @return string the order payment failure page URL + */ + public function getPayementFailurePageUrl($order_id, $message) + { + $frontOfficeRouter = $this->container->get('router.front'); + + return URL::getInstance()->absoluteUrl( + $frontOfficeRouter->generate( + "order.failed", + array( + "order_id" => $order_id, + "message" => $message + ), + Router::ABSOLUTE_URL + ) + ); + } +} From 93d5444b8b843294a44d891f664690ad7ff5b4b5 Mon Sep 17 00:00:00 2001 From: Franck Allimant Date: Fri, 11 Apr 2014 02:22:18 +0200 Subject: [PATCH 079/372] Fixed comments --- core/lib/Thelia/Controller/Front/BaseFrontController.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/lib/Thelia/Controller/Front/BaseFrontController.php b/core/lib/Thelia/Controller/Front/BaseFrontController.php index 00ac8143d..132d02215 100644 --- a/core/lib/Thelia/Controller/Front/BaseFrontController.php +++ b/core/lib/Thelia/Controller/Front/BaseFrontController.php @@ -48,9 +48,9 @@ class BaseFrontController extends BaseController /** * Redirect to à route ID related URL * - * @param unknown $routeId the route ID, as found in Config/Resources/routing/admin.xml - * @param array|\Thelia\Controller\Front\unknown $urlParameters the URL parametrs, as a var/value pair array - * @param bool $referenceType + * @param string $routeId the route ID, as found in Config/Resources/routing/admin.xml + * @param array $urlParameters the URL parametrs, as a var/value pair array + * @param bool $referenceType */ public function redirectToRoute($routeId, $urlParameters = array(), $referenceType = Router::ABSOLUTE_PATH) { @@ -104,7 +104,7 @@ class BaseFrontController extends BaseController /** * Render the given template, and returns the result as an Http Response. * - * @param $templateName the complete template name, with extension + * @param string $templateName the complete template name, with extension * @param array $args the template arguments * @param int $status http code status * @return \Thelia\Core\HttpFoundation\Response From d02b973945841a9f484048af79b4fb1c346c4186 Mon Sep 17 00:00:00 2001 From: Franck Allimant Date: Fri, 11 Apr 2014 02:22:40 +0200 Subject: [PATCH 080/372] Added setTemplateDefinition() method to the interface. --- core/lib/Thelia/Core/Template/ParserInterface.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/core/lib/Thelia/Core/Template/ParserInterface.php b/core/lib/Thelia/Core/Template/ParserInterface.php index c9cf2eceb..3e81f49f4 100644 --- a/core/lib/Thelia/Core/Template/ParserInterface.php +++ b/core/lib/Thelia/Core/Template/ParserInterface.php @@ -38,6 +38,13 @@ interface ParserInterface public function setStatus($status); + /** + * Setup the parser with a template definition, which provides a template description. + * + * @param TemplateDefinition $templateDefinition + */ + public function setTemplateDefinition(TemplateDefinition $templateDefinition); + /** * Add a template directory to the current template list * @@ -54,7 +61,7 @@ interface ParserInterface * Return the registeted template directories for a givent template type * * @param unknown $templateType - * @throws InvalidArgumentException if the tempmateType is not defined + * @throws \InvalidArgumentException if the templateType is not defined * @return array: an array of defined templates directories for the given template type */ public function getTemplateDirectories($templateType); From 26d45dd90b3fd6dc99c8e3a133f4e986d73f66c6 Mon Sep 17 00:00:00 2001 From: Franck Allimant Date: Fri, 11 Apr 2014 02:24:33 +0200 Subject: [PATCH 081/372] Added orderFailed() method --- .../Front/Controller/OrderController.php | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/local/modules/Front/Controller/OrderController.php b/local/modules/Front/Controller/OrderController.php index 5ac01d723..3b24a2ab4 100644 --- a/local/modules/Front/Controller/OrderController.php +++ b/local/modules/Front/Controller/OrderController.php @@ -234,6 +234,29 @@ class OrderController extends BaseFrontController $this->getParserContext()->set("placed_order_id", $placedOrder->getId()); } + public function orderFailed($order_id, $message) + { + /* check if the placed order matched the customer */ + $failedOrder = OrderQuery::create()->findPk( + $this->getRequest()->attributes->get('order_id') + ); + + if (null === $failedOrder) { + throw new TheliaProcessException("No failed order", TheliaProcessException::NO_PLACED_ORDER, $failedOrder); + } + + $customer = $this->getSecurityContext()->getCustomerUser(); + + if (null === $customer || $failedOrder->getCustomerId() !== $customer->getId()) { + throw new TheliaProcessException("Received failed order id does not belong to the current customer", TheliaProcessException::PLACED_ORDER_ID_BAD_CURRENT_CUSTOMER, $placedOrder); + } + + $this->getParserContext() + ->set("failed_order_id", $failedOrder->getId()) + ->set("failed_order_message", $message) + ; + } + protected function getOrderEvent() { $order = $this->getOrder($this->getRequest()); From a4bc3620ef40d25fcd7dab62a6002d727518ddb9 Mon Sep 17 00:00:00 2001 From: Franck Allimant Date: Fri, 11 Apr 2014 02:25:06 +0200 Subject: [PATCH 082/372] Fixed comments --- core/lib/Thelia/Core/Template/Smarty/SmartyParser.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php b/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php index d2450fb43..0e335c77e 100644 --- a/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php +++ b/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php @@ -92,11 +92,11 @@ class SmartyParser extends Smarty implements ParserInterface /** * Add a template directory to the current template list * - * @param unknown $templateType the template type (a TemplateDefinition type constant) + * @param int $templateType the template type (a TemplateDefinition type constant) * @param string $templateName the template name * @param string $templateDirectory path to the template dirtectory * @param unknown $key ??? - * @param string $unshift ??? Etienne ? + * @param boolean $unshift ??? Etienne ? */ public function addTemplateDirectory($templateType, $templateName, $templateDirectory, $key, $unshift = false) { @@ -116,9 +116,9 @@ class SmartyParser extends Smarty implements ParserInterface /** * Return the registeted template directories for a givent template type * - * @param unknown $templateType + * @param int $templateType * @throws InvalidArgumentException - * @return multitype: + * @return mixed: */ public function getTemplateDirectories($templateType) { From 8427cb10616373a07fcc20496a5921020e821c3c Mon Sep 17 00:00:00 2001 From: Franck Allimant Date: Fri, 11 Apr 2014 02:34:59 +0200 Subject: [PATCH 083/372] Fix comment. --- .../default/order-payment-gateway.html | 76 +++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 templates/frontOffice/default/order-payment-gateway.html diff --git a/templates/frontOffice/default/order-payment-gateway.html b/templates/frontOffice/default/order-payment-gateway.html new file mode 100644 index 000000000..1ac362384 --- /dev/null +++ b/templates/frontOffice/default/order-payment-gateway.html @@ -0,0 +1,76 @@ +{extends file="layout.tpl"} + +{* Security *} +{block name="no-return-functions" prepend} + {check_auth role="CUSTOMER" login_tpl="login"} +{/block} + +{* Body Class *} +{block name="body-class"}page-order-payment{/block} + +{* Breadcrumb *} +{block name='no-return-functions' append} + {$breadcrumbs = [ + ['title' => {intl l="Cart"}, 'url'=>{url path="/cart"}], + ['title' => {intl l="Secure Payment"}, 'url'=>{url path="/order/pay"}] + ]} +{/block} + + +{block name="main-content"} +
+
+ +

{intl l="Secure payment"}

+ + {include file="misc/checkout-progress.tpl" step="last"} + + {loop type="order" name="placed-order" id=$order_id} + +
+
+

{intl l="You choose to pay by"} : {loop name="payment-module" type="module" id=$PAYMENT_MODULE}{$TITLE}{/loop}

+
+ +
+ {if $cart_count > 0} +
+ {intl l="Connecting to the secure payment server, please wait a few seconds..."} +
+ +
+ +
+ {foreach from=$payment_form_data key='name' item='value'} + + {/foreach} + +

{intl l='If nothing happens within 10 seconds, please click here.'}

+
+
+ {else} + {intl l="Sorry, your cart is empty. There's nothing to pay."} + {/if} +
+
+ {/loop} +
+ +
+{/block} + +{block name="javascript-initialization"} + +{/block} + + From 8f988b3553108251e06533cb8f185a1cfc96c4ed Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Fri, 11 Apr 2014 08:52:22 +0200 Subject: [PATCH 084/372] set invoiceDate to current date when order status is changed to paid --- core/lib/Thelia/Model/Order.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/core/lib/Thelia/Model/Order.php b/core/lib/Thelia/Model/Order.php index 1835af62c..aa69cf6f8 100644 --- a/core/lib/Thelia/Model/Order.php +++ b/core/lib/Thelia/Model/Order.php @@ -38,6 +38,15 @@ class Order extends BaseOrder $this->dispatchEvent(TheliaEvents::ORDER_AFTER_CREATE, new OrderEvent($this)); } + public function postSave(ConnectionInterface $con = null) + { + if($this->isPaid() && null === $this->getInvoiceDate()) { + $this + ->setInvoiceDate(time()) + ->save($con); + } + } + public function generateRef() { /* order addresses are unique */ From 334ebf12f5a3af44e8fff944af76dadfcb7f7dd5 Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Fri, 11 Apr 2014 08:57:43 +0200 Subject: [PATCH 085/372] change string to array in OrderQuery method --- core/lib/Thelia/Model/OrderQuery.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/lib/Thelia/Model/OrderQuery.php b/core/lib/Thelia/Model/OrderQuery.php index d9b4ad8b4..459314b87 100644 --- a/core/lib/Thelia/Model/OrderQuery.php +++ b/core/lib/Thelia/Model/OrderQuery.php @@ -103,7 +103,7 @@ class OrderQuery extends BaseOrderQuery $query = self::create('o') ->filterByCreatedAt(sprintf("%s 00:00:00", $startDate->format('Y-m-d')), Criteria::GREATER_EQUAL) ->filterByCreatedAt(sprintf("%s 23:59:59", $endDate->format('Y-m-d')), Criteria::LESS_EQUAL) - ->filterByStatusId("2,3,4", Criteria::IN) + ->filterByStatusId([2,3,4], Criteria::IN) ->innerJoinOrderProduct() ->addJoinObject($orderTaxJoin) From b60abb206b5f62689a71ea05c731ec1fd5e0c1af Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Fri, 11 Apr 2014 09:36:43 +0200 Subject: [PATCH 086/372] fix cs --- .../Controller/Admin/CacheController.php | 3 +- .../Controller/Front/BaseFrontController.php | 10 +- .../Thelia/Core/Template/ParserInterface.php | 4 +- .../Core/Template/Smarty/SmartyParser.php | 2 +- core/lib/Thelia/Form/Cache/CacheFlushForm.php | 3 +- core/lib/Thelia/Log/Tlog.php | 3 +- core/lib/Thelia/Model/Order.php | 2 +- .../Thelia/Module/AbstractPaymentModule.php | 262 +++++++++--------- 8 files changed, 143 insertions(+), 146 deletions(-) diff --git a/core/lib/Thelia/Controller/Admin/CacheController.php b/core/lib/Thelia/Controller/Admin/CacheController.php index 4f183cfd4..d7790f3c8 100644 --- a/core/lib/Thelia/Controller/Admin/CacheController.php +++ b/core/lib/Thelia/Controller/Admin/CacheController.php @@ -30,7 +30,6 @@ use Thelia\Core\Security\Resource\AdminResources; use Thelia\Form\Cache\CacheFlushForm; use Thelia\Form\Exception\FormValidationException; - /** * Class CacheController * @package Thelia\Controller\Admin @@ -70,4 +69,4 @@ class CacheController extends BaseAdminController } } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Controller/Front/BaseFrontController.php b/core/lib/Thelia/Controller/Front/BaseFrontController.php index 132d02215..f065274f2 100644 --- a/core/lib/Thelia/Controller/Front/BaseFrontController.php +++ b/core/lib/Thelia/Controller/Front/BaseFrontController.php @@ -49,8 +49,8 @@ class BaseFrontController extends BaseController * Redirect to à route ID related URL * * @param string $routeId the route ID, as found in Config/Resources/routing/admin.xml - * @param array $urlParameters the URL parametrs, as a var/value pair array - * @param bool $referenceType + * @param array $urlParameters the URL parametrs, as a var/value pair array + * @param bool $referenceType */ public function redirectToRoute($routeId, $urlParameters = array(), $referenceType = Router::ABSOLUTE_PATH) { @@ -104,9 +104,9 @@ class BaseFrontController extends BaseController /** * Render the given template, and returns the result as an Http Response. * - * @param string $templateName the complete template name, with extension - * @param array $args the template arguments - * @param int $status http code status + * @param string $templateName the complete template name, with extension + * @param array $args the template arguments + * @param int $status http code status * @return \Thelia\Core\HttpFoundation\Response */ protected function render($templateName, $args = array(), $status = 200) diff --git a/core/lib/Thelia/Core/Template/ParserInterface.php b/core/lib/Thelia/Core/Template/ParserInterface.php index 3e81f49f4..2ee2f00f5 100644 --- a/core/lib/Thelia/Core/Template/ParserInterface.php +++ b/core/lib/Thelia/Core/Template/ParserInterface.php @@ -60,9 +60,9 @@ interface ParserInterface /** * Return the registeted template directories for a givent template type * - * @param unknown $templateType + * @param unknown $templateType * @throws \InvalidArgumentException if the templateType is not defined - * @return array: an array of defined templates directories for the given template type + * @return array: an array of defined templates directories for the given template type */ public function getTemplateDirectories($templateType); diff --git a/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php b/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php index 0e335c77e..9f70af987 100644 --- a/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php +++ b/core/lib/Thelia/Core/Template/Smarty/SmartyParser.php @@ -116,7 +116,7 @@ class SmartyParser extends Smarty implements ParserInterface /** * Return the registeted template directories for a givent template type * - * @param int $templateType + * @param int $templateType * @throws InvalidArgumentException * @return mixed: */ diff --git a/core/lib/Thelia/Form/Cache/CacheFlushForm.php b/core/lib/Thelia/Form/Cache/CacheFlushForm.php index 8410bd7c7..f921df455 100644 --- a/core/lib/Thelia/Form/Cache/CacheFlushForm.php +++ b/core/lib/Thelia/Form/Cache/CacheFlushForm.php @@ -25,7 +25,6 @@ namespace Thelia\Form\Cache; use Thelia\Form\BaseForm; - /** * Class CacheFlushForm * @package Thelia\Form\Cache @@ -66,4 +65,4 @@ class CacheFlushForm extends BaseForm { return "cache_flush"; } -} \ No newline at end of file +} diff --git a/core/lib/Thelia/Log/Tlog.php b/core/lib/Thelia/Log/Tlog.php index f7863eb8d..41ebbad0c 100644 --- a/core/lib/Thelia/Log/Tlog.php +++ b/core/lib/Thelia/Log/Tlog.php @@ -129,7 +129,8 @@ class Tlog Implements LoggerInterface * * @return Tlog a new Tlog instance. */ - public static function getNewInstance() { + public static function getNewInstance() + { $instance = new Tlog(); $instance->init(); diff --git a/core/lib/Thelia/Model/Order.php b/core/lib/Thelia/Model/Order.php index aa69cf6f8..d0fd7f43a 100644 --- a/core/lib/Thelia/Model/Order.php +++ b/core/lib/Thelia/Model/Order.php @@ -40,7 +40,7 @@ class Order extends BaseOrder public function postSave(ConnectionInterface $con = null) { - if($this->isPaid() && null === $this->getInvoiceDate()) { + if ($this->isPaid() && null === $this->getInvoiceDate()) { $this ->setInvoiceDate(time()) ->save($con); diff --git a/core/lib/Thelia/Module/AbstractPaymentModule.php b/core/lib/Thelia/Module/AbstractPaymentModule.php index f80dd17f9..7936dee16 100644 --- a/core/lib/Thelia/Module/AbstractPaymentModule.php +++ b/core/lib/Thelia/Module/AbstractPaymentModule.php @@ -1,132 +1,130 @@ -. */ -/* */ -/*************************************************************************************/ - -namespace Thelia\Module; - -use Symfony\Component\Routing\Router; -use Thelia\Core\HttpFoundation\Response; -use Thelia\Core\Template\ParserInterface; -use Thelia\Core\Template\TemplateHelper; -use Thelia\Exception\TheliaProcessException; -use Thelia\Model\Order; -use Thelia\Tools\URL; - -abstract class AbstractPaymentModule extends BaseModule implements PaymentModuleInterface -{ - /** - * This method is called when the payement gateway needs to be invoked. - * - * If this method return a Response instance, this response is sent to the browser. Return null if you don't want to - * send a response and process the payment yourself. - * - * In many cases, it's necessary to send a form to the payment gateway. On your response you can return this form already - * completed, ready to be sent, instead of redirecting. The generateGatewayFormResponse() may help you in this case :) - * - * @param Order $order processed order - * @return null|Response - */ - abstract public function pay(Order $order); - - /** - * This method is called by the Payment loop, to check if the current module has to be displayed to the customer - * - * If you return true, the payment method will de displayed to the customed - * If you return false, the payment method will not be displayed - * - * @return boolean - */ - abstract public function isValidPayment(); - - - /** - * Render the payment gateway template. The module should provide the gateway URL and the form fields names and values. - * - * @param Order $order the order - * @param string $gateway_url the payment gateway URL - * @param array $form_data an associative array of form data, that will be rendered as hiddent fields - * - * @return Response the HTTP response. - */ - public function generateGatewayFormResponse($order, $gateway_url, $form_data) - { - /** @var ParserInterface $parser */ - $parser = $this->container->get("thelia.parser"); - - $parser->setTemplateDefinition(TemplateHelper::getInstance()->getActiveFrontTemplate()); - - $renderedTemplate = $parser->render( - "order-payment-gateway.html", - array( - "order_id" => $order->getId(), - "cart_count" => $this->getRequest()->getSession()->getCart()->getCartItems()->count(), - "gateway_url" => $gateway_url, - "payment_form_data" => $form_data - ) - ); - - return Response::create($renderedTemplate); - } - - /** - * Return the order payment success page URL - * - * @param int $order_id the order ID - * @return string the order payment success page URL - */ - public function getPayementSuccessPageUrl($order_id) - { - $frontOfficeRouter = $this->container->get('router.front'); - - return URL::getInstance()->absoluteUrl( - $frontOfficeRouter->generate( - "order.placed", - array("order_id" => $order_id), - Router::ABSOLUTE_URL - ) - ); - } - - /** - * Redirect the customer to the failure payment page. if $message is null, a generic message is displayed. - * - * @param int $order_id the order ID - * @param string|null $message an error message. - * - * @return string the order payment failure page URL - */ - public function getPayementFailurePageUrl($order_id, $message) - { - $frontOfficeRouter = $this->container->get('router.front'); - - return URL::getInstance()->absoluteUrl( - $frontOfficeRouter->generate( - "order.failed", - array( - "order_id" => $order_id, - "message" => $message - ), - Router::ABSOLUTE_URL - ) - ); - } -} +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Module; + +use Symfony\Component\Routing\Router; +use Thelia\Core\HttpFoundation\Response; +use Thelia\Core\Template\ParserInterface; +use Thelia\Core\Template\TemplateHelper; +use Thelia\Model\Order; +use Thelia\Tools\URL; + +abstract class AbstractPaymentModule extends BaseModule implements PaymentModuleInterface +{ + /** + * This method is called when the payement gateway needs to be invoked. + * + * If this method return a Response instance, this response is sent to the browser. Return null if you don't want to + * send a response and process the payment yourself. + * + * In many cases, it's necessary to send a form to the payment gateway. On your response you can return this form already + * completed, ready to be sent, instead of redirecting. The generateGatewayFormResponse() may help you in this case :) + * + * @param Order $order processed order + * @return null|Response + */ + abstract public function pay(Order $order); + + /** + * This method is called by the Payment loop, to check if the current module has to be displayed to the customer + * + * If you return true, the payment method will de displayed to the customed + * If you return false, the payment method will not be displayed + * + * @return boolean + */ + abstract public function isValidPayment(); + + /** + * Render the payment gateway template. The module should provide the gateway URL and the form fields names and values. + * + * @param Order $order the order + * @param string $gateway_url the payment gateway URL + * @param array $form_data an associative array of form data, that will be rendered as hiddent fields + * + * @return Response the HTTP response. + */ + public function generateGatewayFormResponse($order, $gateway_url, $form_data) + { + /** @var ParserInterface $parser */ + $parser = $this->container->get("thelia.parser"); + + $parser->setTemplateDefinition(TemplateHelper::getInstance()->getActiveFrontTemplate()); + + $renderedTemplate = $parser->render( + "order-payment-gateway.html", + array( + "order_id" => $order->getId(), + "cart_count" => $this->getRequest()->getSession()->getCart()->getCartItems()->count(), + "gateway_url" => $gateway_url, + "payment_form_data" => $form_data + ) + ); + + return Response::create($renderedTemplate); + } + + /** + * Return the order payment success page URL + * + * @param int $order_id the order ID + * @return string the order payment success page URL + */ + public function getPayementSuccessPageUrl($order_id) + { + $frontOfficeRouter = $this->container->get('router.front'); + + return URL::getInstance()->absoluteUrl( + $frontOfficeRouter->generate( + "order.placed", + array("order_id" => $order_id), + Router::ABSOLUTE_URL + ) + ); + } + + /** + * Redirect the customer to the failure payment page. if $message is null, a generic message is displayed. + * + * @param int $order_id the order ID + * @param string|null $message an error message. + * + * @return string the order payment failure page URL + */ + public function getPayementFailurePageUrl($order_id, $message) + { + $frontOfficeRouter = $this->container->get('router.front'); + + return URL::getInstance()->absoluteUrl( + $frontOfficeRouter->generate( + "order.failed", + array( + "order_id" => $order_id, + "message" => $message + ), + Router::ABSOLUTE_URL + ) + ); + } +} From 1f16ea9fc30118a74a77f3a93b5ab7476bf6122d Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Fri, 11 Apr 2014 11:29:31 +0200 Subject: [PATCH 087/372] force saving cart id in session --- core/lib/Thelia/Cart/CartTrait.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/lib/Thelia/Cart/CartTrait.php b/core/lib/Thelia/Cart/CartTrait.php index f100d6ddc..26075dc75 100644 --- a/core/lib/Thelia/Cart/CartTrait.php +++ b/core/lib/Thelia/Cart/CartTrait.php @@ -86,7 +86,7 @@ trait CartTrait //le cookie de panier n'existe pas, il va falloir le créer et faire un enregistrement en base. $cart = $this->createCart($session); } - + $session->setCart($cart->getId()); return $cart; } From 3673208e02af7bc6d05ec563faf77c4c353fd62e Mon Sep 17 00:00:00 2001 From: Franck Allimant Date: Sat, 12 Apr 2014 02:14:55 +0200 Subject: [PATCH 088/372] Typed setStatus() argument method, to prevent confusion (code ? id ?) --- core/lib/Thelia/Core/Event/Order/OrderEvent.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/lib/Thelia/Core/Event/Order/OrderEvent.php b/core/lib/Thelia/Core/Event/Order/OrderEvent.php index 503f6b4a8..585663ac3 100644 --- a/core/lib/Thelia/Core/Event/Order/OrderEvent.php +++ b/core/lib/Thelia/Core/Event/Order/OrderEvent.php @@ -138,7 +138,7 @@ class OrderEvent extends ActionEvent } /** - * @param $status + * @param int $status */ public function setStatus($status) { From c134acf896ac8a17d9973448a7a7421a4e71a172 Mon Sep 17 00:00:00 2001 From: Franck Allimant Date: Sat, 12 Apr 2014 02:15:54 +0200 Subject: [PATCH 089/372] Fixed comments --- core/lib/Thelia/Controller/Admin/BaseAdminController.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/lib/Thelia/Controller/Admin/BaseAdminController.php b/core/lib/Thelia/Controller/Admin/BaseAdminController.php index 30ee37104..52458e13f 100644 --- a/core/lib/Thelia/Controller/Admin/BaseAdminController.php +++ b/core/lib/Thelia/Controller/Admin/BaseAdminController.php @@ -266,9 +266,9 @@ class BaseAdminController extends BaseController /** * Redirect to à route ID related URL * - * @param unknown $routeId the route ID, as found in Config/Resources/routing/admin.xml - * @param array|\Thelia\Controller\Admin\unknown $urlParameters the URL parametrs, as a var/value pair array - * @param array $routeParameters + * @param string $routeId the route ID, as found in Config/Resources/routing/admin.xml + * @param array $urlParameters the URL parameters, as a var/value pair array + * @param array $routeParameters */ public function redirectToRoute($routeId, array $urlParameters = array(), array $routeParameters = array()) { From 0884fae46dd8409039670c86ea38f9abde456327 Mon Sep 17 00:00:00 2001 From: Franck Allimant Date: Sat, 12 Apr 2014 02:16:54 +0200 Subject: [PATCH 090/372] Improved page text. --- .../frontOffice/default/order-failed.html | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 templates/frontOffice/default/order-failed.html diff --git a/templates/frontOffice/default/order-failed.html b/templates/frontOffice/default/order-failed.html new file mode 100644 index 000000000..bfb686ff9 --- /dev/null +++ b/templates/frontOffice/default/order-failed.html @@ -0,0 +1,51 @@ +{extends file="layout.tpl"} + +{* Security *} +{block name="no-return-functions" prepend} + {check_auth role="CUSTOMER" login_tpl="login"} +{/block} + +{* Body Class *} +{block name="body-class"}page-order-payment{/block} + +{* Breadcrumb *} +{block name='no-return-functions' append} + {$breadcrumbs = [ + ['title' => {intl l="Cart"}, 'url'=>{url path="/cart"}], + ['title' => {intl l="Secure Payment"}, 'url'=>{url path="/order/pay"}] + ]} +{/block} + + +{block name="main-content"} +
+
+ +

{intl l="Your Cart"}

+ + {include file="misc/checkout-progress.tpl" step="last"} + + {loop type="order" name="failed-order" id=$failed_order_id} + +
+
+

{intl l="You choose to pay by"} : {loop name="payment-module" type="module" id=$PAYMENT_MODULE}{$TITLE}{/loop}

+
+
+

{intl l="We're sorry, a problem occured and your payment was not successful."}

+ {if null !== $failed_order_message} +

{$failed_order_message}

+ {/if} + + {intl l="Try again"} +
+
+ + {/loop} + + {intl l="Go home"} + +
+ +
+{/block} From e86c4f44fc26c2f4d94f4486163904cc95ade737 Mon Sep 17 00:00:00 2001 From: Franck Allimant Date: Sat, 12 Apr 2014 02:30:03 +0200 Subject: [PATCH 091/372] Fixed duplication of subdir name when Thelia is installed in a subdir --- core/lib/Thelia/Tools/URL.php | 54 +++++++++++++++++++++++++---------- 1 file changed, 39 insertions(+), 15 deletions(-) diff --git a/core/lib/Thelia/Tools/URL.php b/core/lib/Thelia/Tools/URL.php index d2ac188c6..2c30fccda 100644 --- a/core/lib/Thelia/Tools/URL.php +++ b/core/lib/Thelia/Tools/URL.php @@ -23,6 +23,7 @@ namespace Thelia\Tools; +use Symfony\Component\Routing\RequestContext; use Thelia\Model\ConfigQuery; use Thelia\Rewriting\RewritingResolver; use Thelia\Rewriting\RewritingRetriever; @@ -32,9 +33,13 @@ use Symfony\Component\DependencyInjection\ContainerInterface; class URL { + /** @var RewritingResolver $resolver */ protected $resolver = null; + + /** @var RewritingRetriever $retriever */ protected $retriever = null; + /** @var RequestContext $requestContext */ protected $requestContext; const PATH_TO_FILE = true; @@ -42,10 +47,13 @@ class URL protected static $instance = null; + /** @var string $baseUrlScheme a cache for the base URL scheme */ + private $baseUrlScheme = null; + public function __construct(ContainerInterface $container = null) { - // Allow singleton style calls once intanciated. - // For this to work, the URL service has to be instanciated very early. This is done manually + // Allow singleton style calls once instantiated. + // For this to work, the URL service has to be instantiated very early. This is done manually // in TheliaHttpKernel, by calling $this->container->get('thelia.url.manager'); self::$instance = $this; @@ -72,26 +80,34 @@ class URL * Return the base URL, either the base_url defined in Config, or the URL * of the current language, if 'one_domain_foreach_lang' is enabled. * + * @param bool $scheme_only if true, only the scheme will be returned. If false, the complete base URL, including path, is returned. + * * @return string the base URL, with a trailing '/' */ - public function getBaseUrl() + public function getBaseUrl($scheme_only = false) { - if ($host = $this->requestContext->getHost()) { + if (null === $this->baseUrlScheme) { - $scheme = $this->requestContext->getScheme(); + $scheme = "http"; + $port = 80; - $port = ''; + if ($host = $this->requestContext->getHost()) { - if ('http' === $scheme && 80 != $this->requestContext->getHttpPort()) { - $port = ':'.$this->requestContext->getHttpPort(); - } elseif ('https' === $scheme && 443 != $this->requestContext->getHttpsPort()) { - $port = ':'.$this->requestContext->getHttpsPort(); + $scheme = $this->requestContext->getScheme(); + + $port = ''; + + if ('http' === $scheme && 80 != $this->requestContext->getHttpPort()) { + $port = ':'.$this->requestContext->getHttpPort(); + } elseif ('https' === $scheme && 443 != $this->requestContext->getHttpsPort()) { + $port = ':'.$this->requestContext->getHttpsPort(); + } } - $schemeAuthority = "$scheme://$host"."$port"; + $this->baseUrlScheme = "$scheme://$host"."$port"; } - return $schemeAuthority.$this->requestContext->getBaseUrl(); + return $scheme_only ? $this->baseUrlScheme : $this->baseUrlScheme . $this->requestContext->getBaseUrl(); } /** @@ -119,17 +135,25 @@ class URL // Already absolute ? if (substr($path, 0, 4) != 'http') { - $base_url = $this->getBaseUrl(); + // Prevent duplication of the subdirectory name when Thelia is installed in a subdirectory. + // This happens when $path was calculated with Router::generate(), which returns an absolute URL, + // starting at web server root. For example, if Thelia is installed in /thelia2, we got something like /thelia2/my/path + // As base URL also contains /thelia2 (e.g. http://some.server.com/thelia2), we end up with + // http://some.server.com/thelia2/thelia2/my/path, instead of http://some.server.com/thelia2/my/path + // We have to compensate for this. + $hasSubdirectory = 0 === strpos($path, $this->requestContext->getBaseUrl()); + + $base_url = $this->getBaseUrl($hasSubdirectory); // TODO fix this ugly patch + /* Seems no longer required if (strpos($path, "index_dev.php")) { $path = str_replace('index_dev.php', '', $path); } + */ // If only a path is requested, be sure to remove the script name (index.php or index_dev.php), if any. if ($path_only == self::PATH_TO_FILE) { - - // As the base_url always ends with '/', if we don't find / at the end, we have a script. if (substr($base_url, -3) == 'php') $base_url = dirname($base_url); } From 060df3ed619c228e2fc13f968173cccf5ba61513 Mon Sep 17 00:00:00 2001 From: Franck Allimant Date: Sat, 12 Apr 2014 02:36:17 +0200 Subject: [PATCH 092/372] Added heper methods to easyly get order status object --- core/lib/Thelia/Action/Order.php | 2 +- core/lib/Thelia/Model/OrderStatusQuery.php | 22 ++ .../Module/BasePaymentModuleController.php | 198 ++++++++++++++++++ 3 files changed, 221 insertions(+), 1 deletion(-) create mode 100644 core/lib/Thelia/Module/BasePaymentModuleController.php diff --git a/core/lib/Thelia/Action/Order.php b/core/lib/Thelia/Action/Order.php index cb32f1967..a8a8d5af9 100644 --- a/core/lib/Thelia/Action/Order.php +++ b/core/lib/Thelia/Action/Order.php @@ -206,7 +206,7 @@ class Order extends BaseAction implements EventSubscriberInterface $placedOrder->setInvoiceOrderAddressId($invoiceOrderAddress->getId()); $placedOrder->setStatusId( - OrderStatusQuery::create()->findOneByCode(OrderStatus::CODE_NOT_PAID)->getId() + OrderStatusQuery::getNotPaidStatus()->getId() ); /* memorize discount */ diff --git a/core/lib/Thelia/Model/OrderStatusQuery.php b/core/lib/Thelia/Model/OrderStatusQuery.php index c4ce4e325..9038699ec 100644 --- a/core/lib/Thelia/Model/OrderStatusQuery.php +++ b/core/lib/Thelia/Model/OrderStatusQuery.php @@ -16,4 +16,26 @@ use Thelia\Model\Base\OrderStatusQuery as BaseOrderStatusQuery; */ class OrderStatusQuery extends BaseOrderStatusQuery { + + public static function getNotPaidStatus() { + return OrderStatusQuery::create()->findOneByCode(OrderStatus::CODE_NOT_PAID); + } + + public static function getPaidStatus() { + return OrderStatusQuery::create()->findOneByCode(OrderStatus::CODE_PAID); + } + + public static function getProcessingStatus() { + return OrderStatusQuery::create()->findOneByCode(OrderStatus::CODE_PROCESSING); + } + + public static function getSentStatus() { + return OrderStatusQuery::create()->findOneByCode(OrderStatus::CODE_SENT); + } + + public static function getCancelledStatus() { + return OrderStatusQuery::create()->findOneByCode(OrderStatus::CODE_CANCELED); + } + + } // OrderStatusQuery diff --git a/core/lib/Thelia/Module/BasePaymentModuleController.php b/core/lib/Thelia/Module/BasePaymentModuleController.php new file mode 100644 index 000000000..417531fdd --- /dev/null +++ b/core/lib/Thelia/Module/BasePaymentModuleController.php @@ -0,0 +1,198 @@ +. */ +/* */ +/*************************************************************************************/ + +namespace Thelia\Module; + +use Symfony\Component\Routing\Router; +use Thelia\Controller\Front\BaseFrontController; +use Thelia\Core\Event\Order\OrderEvent; +use Thelia\Core\Event\TheliaEvents; +use Thelia\Core\HttpFoundation\Response; +use Thelia\Log\Tlog; +use Thelia\Model\OrderQuery; +use Thelia\Model\OrderStatus; +use Thelia\Model\OrderStatusQuery; + +/** + * This class implement the minimum + * + * @package Paypal\Controller + * @author Thelia + */ +abstract class BasePaymentModuleController extends BaseFrontController +{ + protected $log = null; + + /** + * Return a module identifier used to calculate the name of the log file, + * and in the log messages. + * + * @return string the module code + */ + protected abstract function getModuleCode(); + + /** + * Initialize a module-specific logger. + * + * @return Tlog a Tlog instance + */ + protected function getLog() { + + if ($this->log == null) { + $this->log = Tlog::getNewInstance(); + + $logFilePath = sprintf(THELIA_ROOT."log".DS."%s.log", strtolower($this->getModuleCode())); + + $this->log->setPrefix("#LEVEL: #DATE #HOUR: "); + $this->log->setDestinations("\\Thelia\\Log\\Destination\\TlogDestinationFile"); + $this->log->setConfig("\\Thelia\\Log\\Destination\\TlogDestinationFile", 0, $logFilePath); + } + + return $this->log; + } + + /** + * Process the confirmation of an order. This method should be called + * once the module has performed the required checks to confirm a valid payment. + * + * @param int $order_id the order ID + */ + public function confirmPayment($order_id) + { + try { + $order_id = intval($order_id); + + if (null !== $order = $this->getOrder($order_id)) { + + $this->getLog()->addInfo( + $this->getTranslator()->trans("Processing confirmation of order ref. %ref, ID %id", + array('%ref' => $order->getRef(), '%id' => $order->getId())) + ); + + $event = new OrderEvent($order); + + $event->setStatus(OrderStatusQuery::getPaidStatus()->getId()); + + $this->dispatch(TheliaEvents::ORDER_UPDATE_STATUS, $event); + + $this->getLog()->addInfo( + $this->getTranslator()->trans("Order ref. %ref, ID %id has been successfully paid.", + array('%ref' => $order->getRef(), '%id' => $order->getId())) + ); + } + } + catch (\Exception $ex) { + $this->getLog()->addError( + $this->getTranslator()->trans("Error occured while processing order ref. %ref, ID %id: %err", + array( + '%err' => $ex->getMessage(), + '%ref' => ! isset($order) ? "?" : $order->getRef(), + '%id' => ! isset($order) ? "?" : $order->getId() + ) + ) + ); + + throw $ex; + } + } + + /** + * Process the cancelation of a payment on the payment gateway. The order will go back to the + * "not paid" status. + * + * @param int $order_id the order ID + */ + public function cancelPayment($order_id) + { + $order_id = intval($order_id); + + if (null !== $order = $this->getOrder($order_id)) { + $this->getLog()->addInfo( + $this->getTranslator()->trans("Processing cancelation of payment for order ref. %ref", + array('%ref' => $order->getRef())) + ); + + $event = new OrderEvent($order); + + $event->setStatus(OrderStatus::CODE_NOT_PAID); + + $this->getLog()->addInfo( + $this->getTranslator()->trans("Order ref. %ref is now unpaid.", + array('%ref' => $order->getRef())) + ); + + $this->dispatch(TheliaEvents::ORDER_UPDATE_STATUS, $event); + } + } + + /** + * Get an order and issue a log message if not found. + * @param $order_id + * @return null|\Thelia\Model\Order + */ + protected function getOrder($order_id) + { + if (null == $order = OrderQuery::create()->findPk($order_id)) { + $this->getLog()->addError($this->getTranslator()->trans("Unknown order ID: %id", array('%id' => $order_id))); + } + + return $order; + } + /** + * Redirect the customer to the successful payment page. + * + * @param int $order_id the order ID + */ + public function redirectToSuccessPage($order_id) { + + $this->getLog()->addInfo("Redirecting customer to payment success page"); + + $this->redirectToRoute( + 'order.placed', + array( + 'order_id' => $order_id + ), + Router::ABSOLUTE_PATH + ); + } + + /** + * Redirect the customer to the failure payment page. if $message is null, a generic message is displayed. + * + * @param int $order_id the order ID + * @param string|null $message an error message. + */ + public function redirectToFailurePage($order_id, $message = null) { + + $this->getLog()->addInfo("Redirecting customer to payment failure page"); + + $this->redirectToRoute( + 'order.failed', + array( + 'order_id' => $order_id, + 'message' => $message + ), + Router::ABSOLUTE_PATH + ); + } +} \ No newline at end of file From 3419e9d94e925a2fd7fc63eaa634cc6258512025 Mon Sep 17 00:00:00 2001 From: Franck Allimant Date: Sat, 12 Apr 2014 02:37:36 +0200 Subject: [PATCH 093/372] Fixed comment --- core/lib/Thelia/Tools/URL.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/lib/Thelia/Tools/URL.php b/core/lib/Thelia/Tools/URL.php index 2c30fccda..c766d20e0 100644 --- a/core/lib/Thelia/Tools/URL.php +++ b/core/lib/Thelia/Tools/URL.php @@ -145,8 +145,8 @@ class URL $base_url = $this->getBaseUrl($hasSubdirectory); - // TODO fix this ugly patch /* Seems no longer required + // TODO fix this ugly patch if (strpos($path, "index_dev.php")) { $path = str_replace('index_dev.php', '', $path); } From b15729f116c3be994b9a9405724cee7583dc69a8 Mon Sep 17 00:00:00 2001 From: Franck Allimant Date: Sat, 12 Apr 2014 02:44:00 +0200 Subject: [PATCH 094/372] Completed some translations --- templates/frontOffice/default/I18n/en_US.php | 6 ++++++ templates/frontOffice/default/I18n/fr_FR.php | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/templates/frontOffice/default/I18n/en_US.php b/templates/frontOffice/default/I18n/en_US.php index 32b34376e..748ca5b3f 100644 --- a/templates/frontOffice/default/I18n/en_US.php +++ b/templates/frontOffice/default/I18n/en_US.php @@ -36,6 +36,7 @@ return array( 'Choose your delivery method' => 'Choose your delivery method', 'Choose your payment method' => 'Choose your payment method', 'Code :' => 'Code :', + 'Connecting to the secure payment server, please wait a few seconds...' => 'Connection au serveur depaiement sécurisé, merci de patienter.', 'Contact Us' => 'Contact Us', 'Continue Shopping' => 'Continue Shopping', 'Copyright' => 'Copyright', @@ -68,6 +69,7 @@ return array( 'Grid' => 'Grid', 'Home' => 'Home', 'I\'ve read and agreed on Terms & Conditions' => 'I\'ve read and agreed on Terms & Conditions', + 'If nothing happens within 10 seconds, please click here.' => 'Si rien ne se passe dans les 10 prochaines secondes, merci de cliquer ici. ', 'In Stock' => 'In Stock', 'Instagram' => 'Instagram', 'Language' => 'Language', @@ -113,6 +115,7 @@ return array( 'Pagination' => 'Pagination', 'Password' => 'Password', 'Password Forgotten' => 'Password Forgotten', + 'Pay with %module_title' => 'Payer avec %module_title', 'Personal Information' => 'Personal Information', 'Placeholder address label' => 'Home, Work office, other', 'Placeholder address1' => '76 Ninth Avenue', @@ -177,6 +180,7 @@ return array( 'Sign In' => 'Sign In', 'Sign up to receive our latest news.' => 'Sign up to receive our latest news.', 'Skip to content' => 'Skip to content', + 'Sorry, your cart is empty. There\'s nothing to pay.' => 'Désolé, mais votre panier est vide. Il n\'y a rien à payer.', 'Sort By' => 'Sort By', 'Special Price:' => 'Special Price:', 'Status' => 'Status', @@ -189,6 +193,7 @@ return array( 'Thelia V2' => 'Thelia V2', 'Toggle navigation' => 'Toggle navigation', 'Total' => 'Total', + 'Try again' => 'Merci de ré-essayer.', 'Twitter' => 'Twitter', 'Unit Price' => 'Unit Price', 'Update' => 'Update', @@ -204,6 +209,7 @@ return array( 'View order %ref as pdf document' => 'View order %ref as pdf document', 'View product' => 'View product', 'Warning' => 'Warning', + 'We\'re sorry, a problem occured during the payement process, and your payment has not been accepted.' => 'Nous sommes désolés, votre paiement n\'a opas été accepté.', 'Welcome to Thelia. This is a demo site built with Thelia V2 an E-Commerce solution based on Symfony 2.' => 'Welcome to Thelia. This is a demo site built with Thelia V2 an E-Commerce solution based on Symfony 2.', 'You are here:' => 'You are here:', 'You choose to pay by' => 'You choose to pay by', diff --git a/templates/frontOffice/default/I18n/fr_FR.php b/templates/frontOffice/default/I18n/fr_FR.php index 9d319322c..45920807a 100644 --- a/templates/frontOffice/default/I18n/fr_FR.php +++ b/templates/frontOffice/default/I18n/fr_FR.php @@ -36,6 +36,7 @@ return array( 'Choose your delivery method' => 'Choisissez votre moyen de livraison', 'Choose your payment method' => 'Choisissez voter moyen de paiement', 'Code :' => 'Code : ', + 'Connecting to the secure payment server, please wait a few seconds...' => 'Connexion au serveur sécurisé, merci de patienter quelques secondes.', 'Contact Us' => 'Contactez-nous', 'Continue Shopping' => 'Continuer mes achats', 'Copyright' => 'Copyright', @@ -68,6 +69,7 @@ return array( 'Grid' => 'Grille', 'Home' => 'Accueil', 'I\'ve read and agreed on Terms & Conditions' => 'J\'ai lu et j\'accepte les CGV', + 'If nothing happens within 10 seconds, please click here.' => 'Si rien ne se passe dans les 10 secondes, meri de cliquer ici. ', 'In Stock' => 'Disponible', 'Instagram' => 'Instagram', 'Language' => 'Langue', @@ -113,6 +115,7 @@ return array( 'Pagination' => 'Pagination', 'Password' => 'Mot de passe', 'Password Forgotten' => 'Mot de passe oublié', + 'Pay with %module_title' => 'Payer avec %module_title ', 'Personal Information' => 'Informations personnelles', 'Placeholder address label' => 'Maison, Domicile, Travail...', 'Placeholder address1' => 'Adresse', @@ -172,6 +175,7 @@ return array( 'Sign In' => 'Se connecter', 'Sign up to receive our latest news.' => 'Inscrivez-vous pour recevoir les dernières nouveautés.', 'Skip to content' => 'Aller au contenu', + 'Sorry, your cart is empty. There\'s nothing to pay.' => 'Désolé, votre panier est vide. Il n\'y a rien à payer.', 'Sort By' => 'Trier par', 'Special Price:' => 'Prix promo', 'Status' => 'Etat', @@ -184,6 +188,7 @@ return array( 'Thelia V2' => 'Thelia v2', 'Toggle navigation' => 'Basculer la navigation', 'Total' => 'Total', + 'Try again' => 'Ré-essayer le paiement', 'Twitter' => 'Twitter', 'Unit Price' => 'Prix unitaire', 'Update' => 'Mettre à jour', @@ -199,6 +204,7 @@ return array( 'View order %ref as pdf document' => 'Ouvrir la commande %ref dans un pdf', 'View product' => 'Voir le produit', 'Warning' => 'Attention', + 'We\'re sorry, a problem occured and your payment was not successful.' => 'Nous sommes désolés, un problème est survenu lors du paiement.', 'Welcome to Thelia. This is a demo site built with Thelia V2 an E-Commerce solution based on Symfony 2.' => 'Bienvenue sur ce site Thelia. ce site est un site de démonstration motorisé par la solution e-commerce libre Thelia v2 basée sur Symfony 2.', 'You are here:' => 'Vous êtes ici :', 'You choose to pay by' => 'Vous avez choisi de payer par', From 14f496f6a04d9b144755da98a6590a55f8fa14d2 Mon Sep 17 00:00:00 2001 From: Franck Allimant Date: Sat, 12 Apr 2014 15:36:14 +0200 Subject: [PATCH 095/372] Improved Database class --- core/lib/Thelia/Install/Database.php | 45 +++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/core/lib/Thelia/Install/Database.php b/core/lib/Thelia/Install/Database.php index cefd3ef65..b17f693ee 100644 --- a/core/lib/Thelia/Install/Database.php +++ b/core/lib/Thelia/Install/Database.php @@ -23,6 +23,10 @@ namespace Thelia\Install; +use Propel\Runtime\Connection\ConnectionWrapper; +use Propel\Runtime\Propel; +use Propel\Runtime\ServiceContainer\ServiceContainerInterface; + /** * Class Database * @package Thelia\Install @@ -30,10 +34,33 @@ namespace Thelia\Install; */ class Database { - public $connection; + /** + * @var \PDO + */ + protected $connection; - public function __construct(\PDO $connection) + /** + * Create a new instance, using the provided connection information, either none for + * automatically a connection, a ConnectionWrapper instance or a PDo connection. + * + * @param ConnectionWrapper|\PDO|null $connection the connection object + * @throws \InvalidArgumentException if $connection is not of the suitable type. + */ + public function __construct($connection = null) { + // Get a connection from Propel if we don't have one + if (null == $connection) { + $connection = Propel::getConnection(ServiceContainerInterface::CONNECTION_WRITE); + } + + // Get the PDO connection from an + if ($connection instanceof ConnectionWrapper) + $connection = $connection->getWrappedConnection(); + + if (! $connection instanceof \PDO) { + throw new \InvalidArgumentException("A PDO connextion shoud be provided"); + } + $this->connection = $connection; } @@ -69,11 +96,21 @@ class Database $size = count($sql); for ($i = 0; $i < $size; $i ++) { if (!empty($sql[$i])) { - $this->connection->query($sql[$i]); + $this->execute($sql[$i]); } } } + /** + * A simple wrapper around PDO::exec + * + * @param string $sql SQL query + * @param array $args SQL request parameters (PDO style) + */ + public function execute($sql, $args = array()) { + $this->connection->exec($sql, $args); + } + /** * Separate each sql instruction in an array * @@ -104,7 +141,7 @@ class Database */ public function createDatabase($dbName) { - $this->connection->exec( + $this->execute( sprintf( "CREATE DATABASE IF NOT EXISTS %s CHARACTER SET utf8", $dbName From 22df1be502072bf75cfa08f70e5f0daa5c6e730a Mon Sep 17 00:00:00 2001 From: Franck Allimant Date: Sat, 12 Apr 2014 15:42:29 +0200 Subject: [PATCH 096/372] Added a hint for installations in subdirectories --- web/.htaccess | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/web/.htaccess b/web/.htaccess index 3840d727a..33830b47c 100755 --- a/web/.htaccess +++ b/web/.htaccess @@ -1,10 +1,15 @@ -Options +FollowSymlinks -Indexes +#Options +FollowSymlinks -Indexes AddDefaultCharset UTF-8 RewriteEngine On + # If thelia is installed in a subdirectory (e.g., thelia2) + # define the RewriteBase below to get a proper URL rewriting + # + # RewriteBase /thelia2 + RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d From 604a80e5e174dab1696dafc8660d296218acc7ed Mon Sep 17 00:00:00 2001 From: Franck Allimant Date: Sat, 12 Apr 2014 15:57:58 +0200 Subject: [PATCH 097/372] Fixed typos --- core/lib/Thelia/Install/Database.php | 2 +- web/.htaccess | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/core/lib/Thelia/Install/Database.php b/core/lib/Thelia/Install/Database.php index b17f693ee..4e9497bc1 100644 --- a/core/lib/Thelia/Install/Database.php +++ b/core/lib/Thelia/Install/Database.php @@ -41,7 +41,7 @@ class Database /** * Create a new instance, using the provided connection information, either none for - * automatically a connection, a ConnectionWrapper instance or a PDo connection. + * automatically a connection, a ConnectionWrapper instance or a PDO connection. * * @param ConnectionWrapper|\PDO|null $connection the connection object * @throws \InvalidArgumentException if $connection is not of the suitable type. diff --git a/web/.htaccess b/web/.htaccess index 33830b47c..dfe03bf51 100755 --- a/web/.htaccess +++ b/web/.htaccess @@ -7,7 +7,6 @@ AddDefaultCharset UTF-8 # If thelia is installed in a subdirectory (e.g., thelia2) # define the RewriteBase below to get a proper URL rewriting - # # RewriteBase /thelia2 RewriteCond %{REQUEST_FILENAME} !-f From f6524e1d472bdf82244f0c72beac5294620e0551 Mon Sep 17 00:00:00 2001 From: Franck Allimant Date: Mon, 14 Apr 2014 10:45:50 +0200 Subject: [PATCH 098/372] Dummy commit --- templates/frontOffice/default/order-failed.html | 1 - 1 file changed, 1 deletion(-) diff --git a/templates/frontOffice/default/order-failed.html b/templates/frontOffice/default/order-failed.html index bfb686ff9..a15eb0515 100644 --- a/templates/frontOffice/default/order-failed.html +++ b/templates/frontOffice/default/order-failed.html @@ -46,6 +46,5 @@ {intl l="Go home"}
-
{/block} From a3f6d749f2dd241f0ffd8207bb77bfc40d23b2bf Mon Sep 17 00:00:00 2001 From: Franck Allimant Date: Mon, 14 Apr 2014 10:48:04 +0200 Subject: [PATCH 099/372] Fixed execute() method --- core/lib/Thelia/Install/Database.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/core/lib/Thelia/Install/Database.php b/core/lib/Thelia/Install/Database.php index 4e9497bc1..6682a15df 100644 --- a/core/lib/Thelia/Install/Database.php +++ b/core/lib/Thelia/Install/Database.php @@ -23,6 +23,7 @@ namespace Thelia\Install; +use Propel\Runtime\Connection\ConnectionInterface; use Propel\Runtime\Connection\ConnectionWrapper; use Propel\Runtime\Propel; use Propel\Runtime\ServiceContainer\ServiceContainerInterface; @@ -41,9 +42,9 @@ class Database /** * Create a new instance, using the provided connection information, either none for - * automatically a connection, a ConnectionWrapper instance or a PDO connection. + * automatically a connection, a ConnectionWrapper instance (through ConnectionInterface) or a PDO connection. * - * @param ConnectionWrapper|\PDO|null $connection the connection object + * @param ConnectionInterface|\PDO|null $connection the connection object * @throws \InvalidArgumentException if $connection is not of the suitable type. */ public function __construct($connection = null) @@ -58,7 +59,7 @@ class Database $connection = $connection->getWrappedConnection(); if (! $connection instanceof \PDO) { - throw new \InvalidArgumentException("A PDO connextion shoud be provided"); + throw new \InvalidArgumentException("A PDO connection shoud be provided"); } $this->connection = $connection; @@ -108,7 +109,7 @@ class Database * @param array $args SQL request parameters (PDO style) */ public function execute($sql, $args = array()) { - $this->connection->exec($sql, $args); + $this->connection->query($sql, $args); } /** From 08b2d6dfd69aaf82616baa8d84ea0f02eba8ab16 Mon Sep 17 00:00:00 2001 From: Franck Allimant Date: Mon, 14 Apr 2014 10:48:46 +0200 Subject: [PATCH 100/372] Code formatting --- core/lib/Thelia/Install/Database.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/core/lib/Thelia/Install/Database.php b/core/lib/Thelia/Install/Database.php index 6682a15df..826e392a0 100644 --- a/core/lib/Thelia/Install/Database.php +++ b/core/lib/Thelia/Install/Database.php @@ -55,10 +55,11 @@ class Database } // Get the PDO connection from an - if ($connection instanceof ConnectionWrapper) + if ($connection instanceof ConnectionWrapper) { $connection = $connection->getWrappedConnection(); + } - if (! $connection instanceof \PDO) { + if (!$connection instanceof \PDO) { throw new \InvalidArgumentException("A PDO connection shoud be provided"); } @@ -69,8 +70,8 @@ class Database * Insert all sql needed in database * Default insert /install/thelia.sql and /install/insert.sql * - * @param string $dbName Database name - * @param array $extraSqlFiles SQL Files uri to insert + * @param string $dbName Database name + * @param array $extraSqlFiles SQL Files uri to insert */ public function insertSql($dbName = null, array $extraSqlFiles = null) { @@ -95,7 +96,7 @@ class Database } } $size = count($sql); - for ($i = 0; $i < $size; $i ++) { + for ($i = 0; $i < $size; $i++) { if (!empty($sql[$i])) { $this->execute($sql[$i]); } @@ -108,7 +109,8 @@ class Database * @param string $sql SQL query * @param array $args SQL request parameters (PDO style) */ - public function execute($sql, $args = array()) { + public function execute($sql, $args = array()) + { $this->connection->query($sql, $args); } @@ -126,7 +128,7 @@ class Database $tab = explode(";\n", $sql); $size = count($tab); - for ($i=0; $i<$size; $i++) { + for ($i = 0; $i < $size; $i++) { $queryTemp = str_replace("-CODE-", ";',", $tab[$i]); $queryTemp = str_replace("|", ";", $queryTemp); $query[] = $queryTemp; From 2e9d5b91b5a7d2d33cd209455c1e7f09017c7418 Mon Sep 17 00:00:00 2001 From: Franck Allimant Date: Mon, 14 Apr 2014 10:50:08 +0200 Subject: [PATCH 101/372] Fixed comment --- core/lib/Thelia/Controller/Admin/BaseAdminController.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/lib/Thelia/Controller/Admin/BaseAdminController.php b/core/lib/Thelia/Controller/Admin/BaseAdminController.php index 52458e13f..3c0bcd7fe 100644 --- a/core/lib/Thelia/Controller/Admin/BaseAdminController.php +++ b/core/lib/Thelia/Controller/Admin/BaseAdminController.php @@ -405,9 +405,9 @@ class BaseAdminController extends BaseController /** * Render the given template, and returns the result as an Http Response. * - * @param $templateName the complete template name, with extension - * @param array $args the template arguments - * @param int $status http code status + * @param string $templateName the complete template name, with extension + * @param array $args the template arguments + * @param int $status http code status * @return \Thelia\Core\HttpFoundation\Response */ protected function render($templateName, $args = array(), $status = 200) From bb30a69932a26ef3418801bd70ad75592e7e2e23 Mon Sep 17 00:00:00 2001 From: Franck Allimant Date: Mon, 14 Apr 2014 11:05:37 +0200 Subject: [PATCH 102/372] Fixed (again !) execute --- core/lib/Thelia/Install/Database.php | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/core/lib/Thelia/Install/Database.php b/core/lib/Thelia/Install/Database.php index 826e392a0..e09ea3b4b 100644 --- a/core/lib/Thelia/Install/Database.php +++ b/core/lib/Thelia/Install/Database.php @@ -108,10 +108,21 @@ class Database * * @param string $sql SQL query * @param array $args SQL request parameters (PDO style) + * @throws \RuntimeException|\PDOException if something goes wrong. */ public function execute($sql, $args = array()) { - $this->connection->query($sql, $args); + $stmt = $this->connection->prepare($sql); + + if ($stmt === false) { + throw new \RuntimeException("Failed to prepare statement for $sql: " . print_r($this->connection->errorInfo(), 1)); + } + + $success = $stmt->execute($args); + + if ($success === false || $stmt->errorCode() != 0) { + throw new \RuntimeException("Failed to execute SQL '$sql', arguments:" . print_r($args,1).", error:".print_r($stmt->errorInfo(), 1)); + } } /** From 0765da1bcffa2e2baac2b7f92c535ac29298b79c Mon Sep 17 00:00:00 2001 From: Emmanuel Nurit Date: Mon, 14 Apr 2014 16:19:58 +0200 Subject: [PATCH 103/372] [Front Office] adding nofilter to $DESCRIPTION --- templates/frontOffice/default/includes/single-product.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/frontOffice/default/includes/single-product.html b/templates/frontOffice/default/includes/single-product.html index 941742ca1..4d8828741 100644 --- a/templates/frontOffice/default/includes/single-product.html +++ b/templates/frontOffice/default/includes/single-product.html @@ -31,7 +31,7 @@

{$productTitle}

{if $hasDescription}
-

{$DESCRIPTION}

+

{$DESCRIPTION nofilter}

{/if}
From 8434b14d79b9fd11e8e97c702f54891127c5fddb Mon Sep 17 00:00:00 2001 From: Manuel Raynaud Date: Mon, 14 Apr 2014 16:31:42 +0200 Subject: [PATCH 104/372] create export for expeditor --- .../AdminIncludes/module_configuration.html | 301 ++++++++++++------ local/modules/Colissimo/Config/config.xml | 2 + local/modules/Colissimo/Config/routing.xml | 4 + 3 files changed, 203 insertions(+), 104 deletions(-) diff --git a/local/modules/Colissimo/AdminIncludes/module_configuration.html b/local/modules/Colissimo/AdminIncludes/module_configuration.html index d45792dcd..1917e7208 100755 --- a/local/modules/Colissimo/AdminIncludes/module_configuration.html +++ b/local/modules/Colissimo/AdminIncludes/module_configuration.html @@ -9,6 +9,10 @@ {elseloop rel="checkrights.colissimo"} +
+

{intl l="Colissimo Module allows to send your products all around the world with La Poste."}

+
+