This commit is contained in:
Manuel Raynaud
2013-09-11 08:27:40 +02:00
parent 990ab0e094
commit 70d93d1daa
155 changed files with 541 additions and 809 deletions

View File

@@ -27,7 +27,6 @@ use Thelia\Core\Event\AddressCreateOrUpdateEvent;
use Thelia\Core\Event\TheliaEvents; use Thelia\Core\Event\TheliaEvents;
use Thelia\Model\Address as AddressModel; use Thelia\Model\Address as AddressModel;
/** /**
* Class Address * Class Address
* @package Thelia\Action * @package Thelia\Action
@@ -50,7 +49,6 @@ class Address extends BaseAction implements EventSubscriberInterface
$this->createOrUpdate($addressModel, $event); $this->createOrUpdate($addressModel, $event);
} }
protected function createOrUpdate(AddressModel $addressModel, AddressCreateOrUpdateEvent $event) protected function createOrUpdate(AddressModel $addressModel, AddressCreateOrUpdateEvent $event)
{ {
$addressModel->setDispatcher($this->getDispatcher()); $addressModel->setDispatcher($this->getDispatcher());
@@ -105,4 +103,4 @@ class Address extends BaseAction implements EventSubscriberInterface
TheliaEvents::ADDRESS_UPDATE => array("update", 128) TheliaEvents::ADDRESS_UPDATE => array("update", 128)
); );
} }
} }

View File

@@ -22,10 +22,6 @@
/*************************************************************************************/ /*************************************************************************************/
namespace Thelia\Action; namespace Thelia\Action;
use Thelia\Form\BaseForm;
use Thelia\Action\Exception\FormValidationException;
use Thelia\Core\Event\ActionEvent;
use Symfony\Component\Form\Form;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
class BaseAction class BaseAction
@@ -49,4 +45,4 @@ class BaseAction
{ {
return $this->container->get('event_dispatcher'); return $this->container->get('event_dispatcher');
} }
} }

View File

@@ -23,12 +23,9 @@
namespace Thelia\Action; namespace Thelia\Action;
use Propel\Runtime\Exception\PropelException;
use Symfony\Component\Config\Definition\Exception\Exception;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Thelia\Core\Event\CartEvent; use Thelia\Core\Event\CartEvent;
use Thelia\Form\CartAdd;
use Thelia\Model\ProductPrice; use Thelia\Model\ProductPrice;
use Thelia\Model\ProductPriceQuery; use Thelia\Model\ProductPriceQuery;
use Thelia\Model\CartItem; use Thelia\Model\CartItem;

View File

@@ -31,7 +31,6 @@ use Thelia\Model\CategoryQuery;
use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\Propel; use Propel\Runtime\Propel;
use Thelia\Model\Map\CategoryTableMap; use Thelia\Model\Map\CategoryTableMap;
use Propel\Runtime\Exception\PropelException;
use Thelia\Core\Event\CategoryCreateEvent; use Thelia\Core\Event\CategoryCreateEvent;
use Thelia\Core\Event\CategoryDeleteEvent; use Thelia\Core\Event\CategoryDeleteEvent;

View File

@@ -23,7 +23,6 @@
namespace Thelia\Action; namespace Thelia\Action;
use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Thelia\Model\ConfigQuery; use Thelia\Model\ConfigQuery;

View File

@@ -27,9 +27,6 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Thelia\Core\Event\Coupon\CouponCreateOrUpdateEvent; use Thelia\Core\Event\Coupon\CouponCreateOrUpdateEvent;
use Thelia\Core\Event\TheliaEvents; use Thelia\Core\Event\TheliaEvents;
use Thelia\Model\Coupon as CouponModel; use Thelia\Model\Coupon as CouponModel;
use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\Propel;
use Thelia\Model\Map\CategoryTableMap;
/** /**
* Created by JetBrains PhpStorm. * Created by JetBrains PhpStorm.

View File

@@ -23,7 +23,6 @@
namespace Thelia\Action; namespace Thelia\Action;
use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Thelia\Model\CurrencyQuery; use Thelia\Model\CurrencyQuery;
@@ -60,7 +59,6 @@ class Currency extends BaseAction implements EventSubscriberInterface
->save() ->save()
; ;
$event->setCurrency($currency); $event->setCurrency($currency);
} }
@@ -136,16 +134,15 @@ class Currency extends BaseAction implements EventSubscriberInterface
} }
} }
public function updateRates() { public function updateRates()
{
$rates_url = ConfigQuery::read('currency_rate_update_url', 'http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml'); $rates_url = ConfigQuery::read('currency_rate_update_url', 'http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml');
$rate_data = @file_get_contents($rates_url); $rate_data = @file_get_contents($rates_url);
if ($rate_data && $sxe = new \SimpleXMLElement($rate_data)) { if ($rate_data && $sxe = new \SimpleXMLElement($rate_data)) {
foreach ($sxe->Cube[0]->Cube[0]->Cube as $last) foreach ($sxe->Cube[0]->Cube[0]->Cube as $last) {
{
$code = strtoupper($last["currency"]); $code = strtoupper($last["currency"]);
$rate = floatval($last['rate']); $rate = floatval($last['rate']);
@@ -157,8 +154,7 @@ class Currency extends BaseAction implements EventSubscriberInterface
; ;
} }
} }
} } else {
else {
throw new \RuntimeException(sprintf("Failed to get currency rates data from URL %s", $rates_url)); throw new \RuntimeException(sprintf("Failed to get currency rates data from URL %s", $rates_url));
} }
} }

View File

@@ -27,17 +27,7 @@ use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Thelia\Core\Event\ActionEvent; use Thelia\Core\Event\ActionEvent;
use Thelia\Core\Event\CustomerCreateOrUpdateEvent; use Thelia\Core\Event\CustomerCreateOrUpdateEvent;
use Thelia\Core\Event\TheliaEvents; use Thelia\Core\Event\TheliaEvents;
use Thelia\Form\CustomerCreation;
use Thelia\Form\CustomerModification;
use Thelia\Model\Customer as CustomerModel; use Thelia\Model\Customer as CustomerModel;
use Thelia\Log\Tlog;
use Thelia\Model\CustomerQuery;
use Thelia\Form\CustomerLogin;
use Thelia\Core\Security\Authentication\CustomerUsernamePasswordFormAuthenticator;
use Symfony\Component\Validator\Exception\ValidatorException;
use Thelia\Core\Security\Exception\AuthenticationException;
use Thelia\Core\Security\Exception\UsernameNotFoundException;
use Propel\Runtime\Exception\PropelException;
use Thelia\Core\Event\CustomerLoginEvent; use Thelia\Core\Event\CustomerLoginEvent;
/** /**
@@ -96,7 +86,6 @@ class Customer extends BaseAction implements EventSubscriberInterface
$event->setCustomer($customer); $event->setCustomer($customer);
} }
public function login(CustomerLoginEvent $event) public function login(CustomerLoginEvent $event)
{ {
$this->getSecurityContext()->setCustomerUser($event->getCustomer()); $this->getSecurityContext()->setCustomerUser($event->getCustomer());

View File

@@ -25,7 +25,6 @@ namespace Thelia\Action;
use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Thelia\Core\Event\ActionEvent;
use Thelia\Core\Event\ImageEvent; use Thelia\Core\Event\ImageEvent;
use Thelia\Model\ConfigQuery; use Thelia\Model\ConfigQuery;
use Thelia\Tools\URL; use Thelia\Tools\URL;
@@ -86,8 +85,8 @@ class Image extends BaseAction implements EventSubscriberInterface
* *
* @param ImageEvent $event * @param ImageEvent $event
*/ */
public function clearCache(ImageEvent $event) { public function clearCache(ImageEvent $event)
{
$path = $this->getCachePath($event->getCacheSubdirectory(), false); $path = $this->getCachePath($event->getCacheSubdirectory(), false);
$this->clearDirectory($path); $this->clearDirectory($path);
@@ -98,8 +97,8 @@ class Image extends BaseAction implements EventSubscriberInterface
* *
* @param string $path the directory path * @param string $path the directory path
*/ */
protected function clearDirectory($path) { protected function clearDirectory($path)
{
$iterator = new \DirectoryIterator($path); $iterator = new \DirectoryIterator($path);
foreach ($iterator as $fileinfo) { foreach ($iterator as $fileinfo) {
@@ -108,8 +107,7 @@ class Image extends BaseAction implements EventSubscriberInterface
if ($fileinfo->isFile() || $fileinfo->isLink()) { if ($fileinfo->isFile() || $fileinfo->isLink()) {
@unlink($fileinfo->getPathname()); @unlink($fileinfo->getPathname());
} } elseif ($fileinfo->isDir()) {
else if ($fileinfo->isDir()) {
$this->clearDirectory($fileinfo->getPathname()); $this->clearDirectory($fileinfo->getPathname());
} }
} }
@@ -124,7 +122,7 @@ class Image extends BaseAction implements EventSubscriberInterface
* *
* This method updates the cache_file_path and file_url attributes of the event * This method updates the cache_file_path and file_url attributes of the event
* *
* @param ImageEvent $event * @param ImageEvent $event
* @throws \InvalidArgumentException, ImageException * @throws \InvalidArgumentException, ImageException
*/ */
public function processImage(ImageEvent $event) public function processImage(ImageEvent $event)
@@ -160,8 +158,7 @@ class Image extends BaseAction implements EventSubscriberInterface
if (false == symlink($source_file, $originalImagePathInCache)) { if (false == symlink($source_file, $originalImagePathInCache)) {
throw new ImageException(sprintf("Failed to create symbolic link for %s in %s image cache directory", basename($source_file), $subdir)); throw new ImageException(sprintf("Failed to create symbolic link for %s in %s image cache directory", basename($source_file), $subdir));
} }
} } else {// mode = 'copy'
else {// mode = 'copy'
if (false == @copy($source_file, $originalImagePathInCache)) { if (false == @copy($source_file, $originalImagePathInCache)) {
throw new ImageException(sprintf("Failed to copy %s in %s image cache directory", basename($source_file), $subdir)); throw new ImageException(sprintf("Failed to copy %s in %s image cache directory", basename($source_file), $subdir));
} }
@@ -182,8 +179,7 @@ class Image extends BaseAction implements EventSubscriberInterface
if ($background_color != null) { if ($background_color != null) {
$bg_color = new Color($background_color); $bg_color = new Color($background_color);
} } else
else
$bg_color = null; $bg_color = null;
// Apply resize // Apply resize
@@ -252,8 +248,7 @@ class Image extends BaseAction implements EventSubscriberInterface
$cacheFilePath, $cacheFilePath,
array('quality' => $quality) array('quality' => $quality)
); );
} } else {
else {
throw new ImageException(sprintf("Source file %s cannot be opened.", basename($source_file))); throw new ImageException(sprintf("Source file %s cannot be opened.", basename($source_file)));
} }
} }
@@ -277,13 +272,13 @@ class Image extends BaseAction implements EventSubscriberInterface
* Process image resizing, with borders or cropping. If $dest_width and $dest_height * Process image resizing, with borders or cropping. If $dest_width and $dest_height
* are both null, no resize is performed. * are both null, no resize is performed.
* *
* @param ImagineInterface $imagine the Imagine instance * @param ImagineInterface $imagine the Imagine instance
* @param ImageInterface $image the image to process * @param ImageInterface $image the image to process
* @param int $dest_width the required width * @param int $dest_width the required width
* @param int $dest_height the required height * @param int $dest_height the required height
* @param int $resize_mode the resize mode (crop / bands / keep image ratio)p * @param int $resize_mode the resize mode (crop / bands / keep image ratio)p
* @param string $bg_color the bg_color used for bands * @param string $bg_color the bg_color used for bands
* @return ImageInterface the resized image. * @return ImageInterface the resized image.
*/ */
protected function applyResize(ImagineInterface $imagine, ImageInterface $image, $dest_width, $dest_height, $resize_mode, $bg_color) protected function applyResize(ImagineInterface $imagine, ImageInterface $image, $dest_width, $dest_height, $resize_mode, $bg_color)
{ {
@@ -313,8 +308,7 @@ class Image extends BaseAction implements EventSubscriberInterface
$dest_width = ($resize_mode == self::EXACT_RATIO_WITH_BORDERS ? $dest_width : $next_width); $dest_width = ($resize_mode == self::EXACT_RATIO_WITH_BORDERS ? $dest_width : $next_width);
$dest_height = ($resize_mode == self::EXACT_RATIO_WITH_BORDERS ? $dest_height : $next_height); $dest_height = ($resize_mode == self::EXACT_RATIO_WITH_BORDERS ? $dest_height : $next_height);
} } elseif ($width_diff > $height_diff) {
else if ($width_diff > $height_diff) {
// Image height > image width // Image height > image width
$next_height = $dest_height; $next_height = $dest_height;
@@ -324,12 +318,10 @@ class Image extends BaseAction implements EventSubscriberInterface
$next_width = $dest_width; $next_width = $dest_width;
$next_height = intval($height_orig * $dest_width / $width_orig); $next_height = intval($height_orig * $dest_width / $width_orig);
$delta_y = ($next_height - $dest_height) / 2; $delta_y = ($next_height - $dest_height) / 2;
} } elseif ($resize_mode != self::EXACT_RATIO_WITH_BORDERS) {
else if ($resize_mode != self::EXACT_RATIO_WITH_BORDERS) {
$dest_width = $next_width; $dest_width = $next_width;
} }
} } else {
else {
// Image width > image height // Image width > image height
$next_width = $dest_width; $next_width = $dest_width;
$next_height = intval($height_orig * $dest_width / $width_orig); $next_height = intval($height_orig * $dest_width / $width_orig);
@@ -338,8 +330,7 @@ class Image extends BaseAction implements EventSubscriberInterface
$next_height = $dest_height; $next_height = $dest_height;
$next_width = intval(($width_orig * $next_height) / $height_orig); $next_width = intval(($width_orig * $next_height) / $height_orig);
$delta_x = ($next_width - $dest_width) / 2; $delta_x = ($next_width - $dest_width) / 2;
} } elseif ($resize_mode != self::EXACT_RATIO_WITH_BORDERS) {
else if ($resize_mode != self::EXACT_RATIO_WITH_BORDERS) {
$dest_height = $next_height; $dest_height = $next_height;
} }
} }
@@ -357,9 +348,7 @@ class Image extends BaseAction implements EventSubscriberInterface
return $imagine->create($canvas, $bg_color) return $imagine->create($canvas, $bg_color)
->paste($image, new Point($border_width, $border_height)); ->paste($image, new Point($border_width, $border_height));
} } elseif ($resize_mode == self::EXACT_RATIO_WITH_CROP) {
else if ($resize_mode == self::EXACT_RATIO_WITH_CROP) {
$image->crop( $image->crop(
new Point($delta_x, $delta_y), new Point($delta_x, $delta_y),
new Box($dest_width, $dest_height) new Box($dest_width, $dest_height)
@@ -370,12 +359,11 @@ class Image extends BaseAction implements EventSubscriberInterface
return $image; return $image;
} }
/** /**
* Return the absolute URL to the cached image * Return the absolute URL to the cached image
* *
* @param string $subdir the subdirectory related to cache base * @param string $subdir the subdirectory related to cache base
* @param string $filename the safe filename, as returned by getCacheFilePath() * @param string $filename the safe filename, as returned by getCacheFilePath()
* @return string the absolute URL to the cached image * @return string the absolute URL to the cached image
*/ */
protected function getCacheFileURL($subdir, $safe_filename) protected function getCacheFileURL($subdir, $safe_filename)
@@ -388,10 +376,10 @@ class Image extends BaseAction implements EventSubscriberInterface
/** /**
* Return the full path of the cached file * Return the full path of the cached file
* *
* @param string $subdir the subdirectory related to cache base * @param string $subdir the subdirectory related to cache base
* @param string $filename the filename * @param string $filename the filename
* @param boolean $forceOriginalImage if true, the origiunal image path in the cache dir is returned. * @param boolean $forceOriginalImage if true, the origiunal image path in the cache dir is returned.
* @return string the cache directory path relative to Web Root * @return string the cache directory path relative to Web Root
*/ */
protected function getCacheFilePath($subdir, $filename, ImageEvent $event, $forceOriginalImage = false) protected function getCacheFilePath($subdir, $filename, ImageEvent $event, $forceOriginalImage = false)
{ {
@@ -409,7 +397,7 @@ class Image extends BaseAction implements EventSubscriberInterface
/** /**
* Return the cache directory path relative to Web Root * Return the cache directory path relative to Web Root
* *
* @param string $subdir the subdirectory related to cache base, or null to get the cache directory only. * @param string $subdir the subdirectory related to cache base, or null to get the cache directory only.
* @return string the cache directory path relative to Web Root * @return string the cache directory path relative to Web Root
*/ */
protected function getCachePathFromWebRoot($subdir = null) protected function getCachePathFromWebRoot($subdir = null)
@@ -420,21 +408,19 @@ class Image extends BaseAction implements EventSubscriberInterface
$safe_subdir = basename($subdir); $safe_subdir = basename($subdir);
$path = sprintf("%s/%s", $cache_dir_from_web_root, $safe_subdir); $path = sprintf("%s/%s", $cache_dir_from_web_root, $safe_subdir);
} } else
else
$path = $cache_dir_from_web_root; $path = $cache_dir_from_web_root;
// Check if path is valid, e.g. in the cache dir // Check if path is valid, e.g. in the cache dir
return $path; return $path;
} }
/** /**
* Return the absolute cache directory path * Return the absolute cache directory path
* *
* @param string $subdir the subdirectory related to cache base, or null to get the cache base directory. * @param string $subdir the subdirectory related to cache base, or null to get the cache base directory.
* @throws \RuntimeException if cache directory cannot be created * @throws \RuntimeException if cache directory cannot be created
* @return string the absolute cache directory path * @return string the absolute cache directory path
*/ */
protected function getCachePath($subdir = null, $create_if_not_exists = true) protected function getCachePath($subdir = null, $create_if_not_exists = true)
{ {
@@ -494,4 +480,4 @@ class Image extends BaseAction implements EventSubscriberInterface
TheliaEvents::IMAGE_CLEAR_CACHE => array("clearCache", 128), TheliaEvents::IMAGE_CLEAR_CACHE => array("clearCache", 128),
); );
} }
} }

View File

@@ -23,7 +23,6 @@
namespace Thelia\Action; namespace Thelia\Action;
use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Thelia\Model\MessageQuery; use Thelia\Model\MessageQuery;

View File

@@ -23,7 +23,6 @@
namespace Thelia\Action; namespace Thelia\Action;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent; use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
@@ -41,7 +40,7 @@ class PageNotFound extends BaseAction implements EventSubscriberInterface
{ {
public function display404(GetResponseForExceptionEvent $event) public function display404(GetResponseForExceptionEvent $event)
{ {
if($event->getException() instanceof NotFoundHttpException) { if ($event->getException() instanceof NotFoundHttpException) {
$parser = $this->container->get("thelia.parser"); $parser = $this->container->get("thelia.parser");

View File

@@ -25,8 +25,8 @@ namespace Thelia\Action;
use Thelia\Core\Event\BaseChangePositionEvent; use Thelia\Core\Event\BaseChangePositionEvent;
trait PositionManagementTrait { trait PositionManagementTrait
{
const POSITION_UP const POSITION_UP
/** /**
* Changes object position, selecting absolute ou relative change. * Changes object position, selecting absolute ou relative change.
@@ -154,4 +154,4 @@ trait PositionManagementTrait {
} }
} }
} }
} }

View File

@@ -139,4 +139,4 @@ trait CartTrait
return $id; return $id;
} }
} }

View File

@@ -61,7 +61,7 @@ class CacheClear extends ContainerAwareCommand
$cacheDir = $this->getContainer()->getParameter("kernel.cache_dir"); $cacheDir = $this->getContainer()->getParameter("kernel.cache_dir");
$this->clearCache($cacheDir, $output); $this->clearCache($cacheDir, $output);
if(!$input->getOption("without-assets")) { if (!$input->getOption("without-assets")) {
$this->clearCache(THELIA_WEB_DIR . "/assets", $output); $this->clearCache(THELIA_WEB_DIR . "/assets", $output);
} }

View File

@@ -32,7 +32,6 @@ use Thelia\Core\HttpFoundation\Request;
use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputArgument;
use Thelia\Core\Event\TheliaEvents; use Thelia\Core\Event\TheliaEvents;
class ClearImageCache extends ContainerAwareCommand class ClearImageCache extends ContainerAwareCommand
{ {
protected function configure() protected function configure()
@@ -60,9 +59,8 @@ class ClearImageCache extends ContainerAwareCommand
$dispatcher->dispatch(TheliaEvents::IMAGE_CLEAR_CACHE, $event); $dispatcher->dispatch(TheliaEvents::IMAGE_CLEAR_CACHE, $event);
$output->writeln(sprintf('%s image cache successfully cleared.', is_null($subdir) ? 'Entire' : ucfirst($subdir))); $output->writeln(sprintf('%s image cache successfully cleared.', is_null($subdir) ? 'Entire' : ucfirst($subdir)));
} } catch (\Exception $ex) {
catch(\Exception $ex) {
$output->writeln(sprintf("Failed to clear image cache: %s", $ex->getMessage())); $output->writeln(sprintf("Failed to clear image cache: %s", $ex->getMessage()));
} }
} }
} }

View File

@@ -133,8 +133,7 @@ class CreateAdminUser extends ContainerAwareCommand
} }
$output->writeln("Passwords are different, please try again."); $output->writeln("Passwords are different, please try again.");
} } while (true);
while (true);
return $admin; return $admin;
} }
@@ -144,4 +143,4 @@ class CreateAdminUser extends ContainerAwareCommand
return sprintf("<info>%s</info>", $text); return sprintf("<info>%s</info>", $text);
} }
} }

View File

@@ -28,7 +28,6 @@ use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Output\OutputInterface;
use Thelia\Install\Database; use Thelia\Install\Database;
/** /**
* Class ReloadDatabasesCommand * Class ReloadDatabasesCommand
* @package Thelia\Command * @package Thelia\Command
@@ -67,4 +66,4 @@ class ReloadDatabaseCommand extends BaseModuleGenerate
'' ''
)); ));
} }
} }

View File

@@ -25,7 +25,7 @@ namespace %%NAMESPACE%%;
use Thelia\Module\BaseModule; use Thelia\Module\BaseModule;
class %%CLASSNAME%% extends BaseModule class Class extends BaseModule
{ {
/** /**
* YOU HAVE TO IMPLEMENT HERE ABSTRACT METHODD FROM BaseModule Class * YOU HAVE TO IMPLEMENT HERE ABSTRACT METHODD FROM BaseModule Class

View File

@@ -23,18 +23,6 @@
namespace Thelia\Controller\Admin; namespace Thelia\Controller\Admin;
use Thelia\Core\Event\MessageDeleteEvent;
use Thelia\Core\Event\TheliaEvents;
use Thelia\Tools\URL;
use Thelia\Core\Event\MessageUpdateEvent;
use Thelia\Core\Event\MessageCreateEvent;
use Thelia\Log\Tlog;
use Thelia\Form\Exception\FormValidationException;
use Thelia\Core\Security\Exception\AuthorizationException;
use Thelia\Model\MessageQuery;
use Thelia\Form\MessageModificationForm;
use Thelia\Form\MessageCreationForm;
/** /**
* Manages messages sent by mail * Manages messages sent by mail
* *
@@ -47,17 +35,15 @@ class AttributeController extends BaseAdminController
* *
* @return Symfony\Component\HttpFoundation\Response the response * @return Symfony\Component\HttpFoundation\Response the response
*/ */
public function defaultAction() { public function defaultAction()
{
if (null !== $response = $this->checkAuth("admin.configuration.attributes.view")) return $response; if (null !== $response = $this->checkAuth("admin.configuration.attributes.view")) return $response;
return $this->render('product-attributes'); return $this->render('product-attributes');
} }
public function updateAction() { public function updateAction()
{
if (null !== $response = $this->checkAuth("admin.configuration.attributes.update")) return $response; if (null !== $response = $this->checkAuth("admin.configuration.attributes.update")) return $response;
return $this->render('product-attributes-edit'); return $this->render('product-attributes-edit');
} }
} }

View File

@@ -33,7 +33,6 @@ use Symfony\Component\HttpKernel\HttpKernelInterface;
use Thelia\Core\Security\Exception\AuthenticationException; use Thelia\Core\Security\Exception\AuthenticationException;
use Thelia\Tools\URL; use Thelia\Tools\URL;
use Thelia\Tools\Redirect; use Thelia\Tools\Redirect;
use Thelia\Core\Security\SecurityContext;
use Thelia\Model\AdminLog; use Thelia\Model\AdminLog;
use Thelia\Model\Lang; use Thelia\Model\Lang;
use Thelia\Model\LangQuery; use Thelia\Model\LangQuery;
@@ -50,14 +49,15 @@ class BaseAdminController extends BaseController
* *
* @param unknown $message * @param unknown $message
*/ */
public function adminLogAppend($message) { public function adminLogAppend($message)
{
AdminLog::append($message, $this->getRequest(), $this->getSecurityContext()->getAdminUser()); AdminLog::append($message, $this->getRequest(), $this->getSecurityContext()->getAdminUser());
} }
/** /**
* This method process the rendering of view called from an admin page * This method process the rendering of view called from an admin page
* *
* @param unknown $template * @param unknown $template
* @return Response the reponse which contains the rendered view * @return Response the reponse which contains the rendered view
*/ */
public function processTemplateAction($template) public function processTemplateAction($template)
@@ -66,12 +66,10 @@ class BaseAdminController extends BaseController
if (! empty($template)) { if (! empty($template)) {
// If we have a view in the URL, render this view // If we have a view in the URL, render this view
return $this->render($template); return $this->render($template);
} } elseif (null != $view = $this->getRequest()->get('view')) {
elseif (null != $view = $this->getRequest()->get('view')) {
return $this->render($view); return $this->render($view);
} }
} } catch (\Exception $ex) {
catch (\Exception $ex) {
return $this->errorPage($ex->getMessage()); return $this->errorPage($ex->getMessage());
} }
@@ -135,7 +133,8 @@ class BaseAdminController extends BaseController
/* /*
* Create the standard message displayed to the user when the form cannot be validated. * Create the standard message displayed to the user when the form cannot be validated.
*/ */
protected function createStandardFormValidationErrorMessage(FormValidationException $exception) { protected function createStandardFormValidationErrorMessage(FormValidationException $exception)
{
return $this->getTranslator()->trans( return $this->getTranslator()->trans(
"Please check your input: %error", "Please check your input: %error",
array( array(
@@ -147,13 +146,13 @@ class BaseAdminController extends BaseController
/** /**
* Setup the error context when an error occurs in a action method. * Setup the error context when an error occurs in a action method.
* *
* @param string $action the action that caused the error (category modification, variable creation, currency update, etc.) * @param string $action the action that caused the error (category modification, variable creation, currency update, etc.)
* @param BaseForm $form the form where the error occured, or null if no form was involved * @param BaseForm $form the form where the error occured, or null if no form was involved
* @param string $error_message the error message * @param string $error_message the error message
* @param Exception $exception the exception or null if no exception * @param Exception $exception the exception or null if no exception
*/ */
protected function setupFormErrorContext($action, $error_message, BaseForm $form = null, \Exception $exception = null) { protected function setupFormErrorContext($action, $error_message, BaseForm $form = null, \Exception $exception = null)
{
if ($error_message !== false) { if ($error_message !== false) {
// Log the error message // Log the error message
@@ -214,7 +213,7 @@ class BaseAdminController extends BaseController
/** /**
* Return the route path defined for the givent route ID * Return the route path defined for the givent route ID
* *
* @param string $routeId a route ID, as defines in Config/Resources/routing/admin.xml * @param string $routeId a route ID, as defines in Config/Resources/routing/admin.xml
* @param mixed $parameters An array of parameters * @param mixed $parameters An array of parameters
* @param Boolean|string $referenceType The type of reference to be generated (one of the constants) * @param Boolean|string $referenceType The type of reference to be generated (one of the constants)
* *
@@ -222,12 +221,13 @@ class BaseAdminController extends BaseController
* @throws MissingMandatoryParametersException When some parameters are missing that are mandatory for the route * @throws MissingMandatoryParametersException When some parameters are missing that are mandatory for the route
* @throws InvalidParameterException When a parameter value for a placeholder is not correct because * @throws InvalidParameterException When a parameter value for a placeholder is not correct because
* it does not match the requirement * it does not match the requirement
* @throws \InvalidArgumentException When the router doesn't exist * @throws \InvalidArgumentException When the router doesn't exist
* @return string The generated URL * @return string The generated URL
* *
* @see \Thelia\Controller\BaseController::getRouteFromRouter() * @see \Thelia\Controller\BaseController::getRouteFromRouter()
*/ */
protected function getRoute($routeId, $parameters = array(), $referenceType = Router::ABSOLUTE_PATH) { protected function getRoute($routeId, $parameters = array(), $referenceType = Router::ABSOLUTE_PATH)
{
return $this->getRouteFromRouter( return $this->getRouteFromRouter(
'router.admin', 'router.admin',
$routeId, $routeId,
@@ -239,18 +239,19 @@ class BaseAdminController extends BaseController
/** /**
* Redirect to à route ID related URL * Redirect to à route ID related URL
* *
* @param unknown $routeId the route ID, as found in Config/Resources/routing/admin.xml * @param unknown $routeId the route ID, as found in Config/Resources/routing/admin.xml
* @param unknown $urlParameters the URL parametrs, as a var/value pair array * @param unknown $urlParameters the URL parametrs, as a var/value pair array
*/ */
public function redirectToRoute($routeId, $urlParameters = array()) { public function redirectToRoute($routeId, $urlParameters = array())
{
$this->redirect(URL::getInstance()->absoluteUrl($this->getRoute($routeId), $urlParameters)); $this->redirect(URL::getInstance()->absoluteUrl($this->getRoute($routeId), $urlParameters));
} }
/** /**
* Get the current edition lang ID, checking if a change was requested in the current request. * Get the current edition lang ID, checking if a change was requested in the current request.
*/ */
protected function getCurrentEditionLang() { protected function getCurrentEditionLang()
{
// Return the new language if a change is required. // Return the new language if a change is required.
if (null !== $edit_language_id = $this->getRequest()->get('edit_language_id', null)) { if (null !== $edit_language_id = $this->getRequest()->get('edit_language_id', null)) {
@@ -266,7 +267,8 @@ class BaseAdminController extends BaseController
/** /**
* A simple helper to get the current edition locale. * A simple helper to get the current edition locale.
*/ */
protected function getCurrentEditionLocale() { protected function getCurrentEditionLocale()
{
return $this->getCurrentEditionLang()->getLocale(); return $this->getCurrentEditionLang()->getLocale();
} }
@@ -322,13 +324,11 @@ class BaseAdminController extends BaseController
$data = $this->getParser()->render($templateName, $args); $data = $this->getParser()->render($templateName, $args);
return $data; return $data;
} } catch (AuthenticationException $ex) {
catch (AuthenticationException $ex) {
// User is not authenticated, and templates requires authentication -> redirect to login page // User is not authenticated, and templates requires authentication -> redirect to login page
// We user login_tpl as a path, not a template. // We user login_tpl as a path, not a template.
Redirect::exec(URL::getInstance()->absoluteUrl($ex->getLoginTemplate())); Redirect::exec(URL::getInstance()->absoluteUrl($ex->getLoginTemplate()));
} } catch (AuthorizationException $ex) {
catch (AuthorizationException $ex) {
// User is not allowed to perform the required action. Return the error page instead of the requested page. // User is not allowed to perform the required action. Return the error page instead of the requested page.
return $this->errorPage($this->getTranslator()->trans("Sorry, you are not allowed to perform this action.")); return $this->errorPage($this->getTranslator()->trans("Sorry, you are not allowed to perform this action."));
} }

View File

@@ -23,18 +23,10 @@
namespace Thelia\Controller\Admin; namespace Thelia\Controller\Admin;
use Thelia\Core\Security\Exception\AuthenticationException;
use Thelia\Core\Security\Exception\AuthorizationException;
use Thelia\Log\Tlog;
use Thelia\Core\Event\TheliaEvents; use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Event\CategoryCreateEvent; use Thelia\Core\Event\CategoryCreateEvent;
use Thelia\Form\CategoryCreationForm; use Thelia\Form\CategoryCreationForm;
use Thelia\Core\Event\CategoryDeleteEvent; use Thelia\Core\Event\CategoryDeleteEvent;
use Thelia\Core\Event\CategoryToggleVisibilityEvent;
use Thelia\Core\Event\CategoryChangePositionEvent;
use Thelia\Form\CategoryDeletionForm;
use Thelia\Model\Lang;
use Thelia\Core\Translation\Translator;
use Thelia\Core\Event\CategoryUpdatePositionEvent; use Thelia\Core\Event\CategoryUpdatePositionEvent;
use Thelia\Model\CategoryQuery; use Thelia\Model\CategoryQuery;
use Thelia\Form\CategoryModificationForm; use Thelia\Form\CategoryModificationForm;
@@ -46,12 +38,13 @@ class CategoryController extends BaseAdminController
* *
* @return Symfony\Component\HttpFoundation\Response the response * @return Symfony\Component\HttpFoundation\Response the response
*/ */
protected function renderList() { protected function renderList()
{
return $this->render('categories', $this->getTemplateArgs()); return $this->render('categories', $this->getTemplateArgs());
} }
protected function getTemplateArgs() { protected function getTemplateArgs()
{
// Get the category ID // Get the category ID
$category_id = $this->getRequest()->get('category_id', 0); $category_id = $this->getRequest()->get('category_id', 0);
@@ -77,10 +70,9 @@ class CategoryController extends BaseAdminController
* *
* @return Symfony\Component\HttpFoundation\Response the response * @return Symfony\Component\HttpFoundation\Response the response
*/ */
public function defaultAction() { public function defaultAction()
{
if (null !== $response = $this->checkAuth("admin.categories.view")) return $response; if (null !== $response = $this->checkAuth("admin.categories.view")) return $response;
return $this->renderList(); return $this->renderList();
} }
@@ -89,8 +81,8 @@ class CategoryController extends BaseAdminController
* *
* @return Symfony\Component\HttpFoundation\Response the response * @return Symfony\Component\HttpFoundation\Response the response
*/ */
public function createAction() { public function createAction()
{
// Check current user authorization // Check current user authorization
if (null !== $response = $this->checkAuth("admin.categories.create")) return $response; if (null !== $response = $this->checkAuth("admin.categories.create")) return $response;
@@ -126,12 +118,10 @@ class CategoryController extends BaseAdminController
// Redirect to the success URL // Redirect to the success URL
$this->redirect($successUrl); $this->redirect($successUrl);
} } catch (FormValidationException $ex) {
catch (FormValidationException $ex) {
// Form cannot be validated // Form cannot be validated
$error_msg = $this->createStandardFormValidationErrorMessage($ex); $error_msg = $this->createStandardFormValidationErrorMessage($ex);
} } catch (\Exception $ex) {
catch (\Exception $ex) {
// Any other error // Any other error
$error_msg = $ex->getMessage(); $error_msg = $ex->getMessage();
} }
@@ -147,8 +137,8 @@ class CategoryController extends BaseAdminController
* *
* @return Symfony\Component\HttpFoundation\Response the response * @return Symfony\Component\HttpFoundation\Response the response
*/ */
public function changeAction() { public function changeAction()
{
// Check current user authorization // Check current user authorization
if (null !== $response = $this->checkAuth("admin.categories.update")) return $response; if (null !== $response = $this->checkAuth("admin.categories.update")) return $response;
@@ -189,8 +179,8 @@ class CategoryController extends BaseAdminController
* *
* @return Symfony\Component\HttpFoundation\Response the response * @return Symfony\Component\HttpFoundation\Response the response
*/ */
public function saveChangeAction() { public function saveChangeAction()
{
// Check current user authorization // Check current user authorization
if (null !== $response = $this->checkAuth("admin.categories.update")) return $response; if (null !== $response = $this->checkAuth("admin.categories.update")) return $response;
@@ -241,12 +231,10 @@ class CategoryController extends BaseAdminController
// Redirect to the success URL // Redirect to the success URL
$this->redirect($changeForm->getSuccessUrl()); $this->redirect($changeForm->getSuccessUrl());
} } catch (FormValidationException $ex) {
catch (FormValidationException $ex) {
// Form cannot be validated // Form cannot be validated
$error_msg = $this->createStandardFormValidationErrorMessage($ex); $error_msg = $this->createStandardFormValidationErrorMessage($ex);
} } catch (\Exception $ex) {
catch (\Exception $ex) {
// Any other error // Any other error
$error_msg = $ex->getMessage(); $error_msg = $ex->getMessage();
} }
@@ -260,7 +248,8 @@ class CategoryController extends BaseAdminController
/** /**
* Online status toggle category * Online status toggle category
*/ */
public function setToggleVisibilityAction() { public function setToggleVisibilityAction()
{
// Check current user authorization // Check current user authorization
if (null !== $response = $this->checkAuth("admin.categories.update")) return $response; if (null !== $response = $this->checkAuth("admin.categories.update")) return $response;
@@ -271,8 +260,7 @@ class CategoryController extends BaseAdminController
try { try {
$this->dispatch(TheliaEvents::CATEGORY_SET_DEFAULT, $changeEvent); $this->dispatch(TheliaEvents::CATEGORY_SET_DEFAULT, $changeEvent);
} } catch (\Exception $ex) {
catch (\Exception $ex) {
// Any error // Any error
return $this->errorPage($ex); return $this->errorPage($ex);
} }
@@ -283,7 +271,8 @@ class CategoryController extends BaseAdminController
/** /**
* Update categoryposition * Update categoryposition
*/ */
public function updatePositionAction() { public function updatePositionAction()
{
// Check current user authorization // Check current user authorization
if (null !== $response = $this->checkAuth("admin.categories.update")) return $response; if (null !== $response = $this->checkAuth("admin.categories.update")) return $response;
@@ -306,8 +295,7 @@ class CategoryController extends BaseAdminController
); );
$this->dispatch(TheliaEvents::CATEGORY_UPDATE_POSITION, $event); $this->dispatch(TheliaEvents::CATEGORY_UPDATE_POSITION, $event);
} } catch (\Exception $ex) {
catch (\Exception $ex) {
// Any error // Any error
return $this->errorPage($ex); return $this->errorPage($ex);
} }
@@ -320,8 +308,8 @@ class CategoryController extends BaseAdminController
* *
* @return Symfony\Component\HttpFoundation\Response the response * @return Symfony\Component\HttpFoundation\Response the response
*/ */
public function deleteAction() { public function deleteAction()
{
// Check current user authorization // Check current user authorization
if (null !== $response = $this->checkAuth("admin.categories.delete")) return $response; if (null !== $response = $this->checkAuth("admin.categories.delete")) return $response;
@@ -335,4 +323,4 @@ class CategoryController extends BaseAdminController
$this->redirectToRoute('admin.categories.default'); $this->redirectToRoute('admin.categories.default');
} }
} }

View File

@@ -28,9 +28,7 @@ use Thelia\Core\Event\TheliaEvents;
use Thelia\Tools\URL; use Thelia\Tools\URL;
use Thelia\Core\Event\ConfigUpdateEvent; use Thelia\Core\Event\ConfigUpdateEvent;
use Thelia\Core\Event\ConfigCreateEvent; use Thelia\Core\Event\ConfigCreateEvent;
use Thelia\Log\Tlog;
use Thelia\Form\Exception\FormValidationException; use Thelia\Form\Exception\FormValidationException;
use Thelia\Core\Security\Exception\AuthorizationException;
use Thelia\Model\ConfigQuery; use Thelia\Model\ConfigQuery;
use Thelia\Form\ConfigModificationForm; use Thelia\Form\ConfigModificationForm;
use Thelia\Form\ConfigCreationForm; use Thelia\Form\ConfigCreationForm;
@@ -47,8 +45,8 @@ class ConfigController extends BaseAdminController
* *
* @return Symfony\Component\HttpFoundation\Response the response * @return Symfony\Component\HttpFoundation\Response the response
*/ */
protected function renderList() { protected function renderList()
{
// Find the current order // Find the current order
$order = $this->getRequest()->get( $order = $this->getRequest()->get(
'order', 'order',
@@ -66,10 +64,9 @@ class ConfigController extends BaseAdminController
* *
* @return Symfony\Component\HttpFoundation\Response the response * @return Symfony\Component\HttpFoundation\Response the response
*/ */
public function defaultAction() { public function defaultAction()
{
if (null !== $response = $this->checkAuth("admin.configuration.variables.view")) return $response; if (null !== $response = $this->checkAuth("admin.configuration.variables.view")) return $response;
return $this->renderList(); return $this->renderList();
} }
@@ -78,8 +75,8 @@ class ConfigController extends BaseAdminController
* *
* @return Symfony\Component\HttpFoundation\Response the response * @return Symfony\Component\HttpFoundation\Response the response
*/ */
public function createAction() { public function createAction()
{
// Check current user authorization // Check current user authorization
if (null !== $response = $this->checkAuth("admin.configuration.variables.create")) return $response; if (null !== $response = $this->checkAuth("admin.configuration.variables.create")) return $response;
@@ -120,12 +117,10 @@ class ConfigController extends BaseAdminController
// Redirect to the success URL // Redirect to the success URL
$this->redirect($successUrl); $this->redirect($successUrl);
} } catch (FormValidationException $ex) {
catch (FormValidationException $ex) {
// Form cannot be validated // Form cannot be validated
$message = $this->createStandardFormValidationErrorMessage($ex); $message = $this->createStandardFormValidationErrorMessage($ex);
} } catch (\Exception $ex) {
catch (\Exception $ex) {
// Any other error // Any other error
$message = $ex->getMessage(); $message = $ex->getMessage();
} }
@@ -141,8 +136,8 @@ class ConfigController extends BaseAdminController
* *
* @return Symfony\Component\HttpFoundation\Response the response * @return Symfony\Component\HttpFoundation\Response the response
*/ */
public function changeAction() { public function changeAction()
{
// Check current user authorization // Check current user authorization
if (null !== $response = $this->checkAuth("admin.configuration.variables.update")) return $response; if (null !== $response = $this->checkAuth("admin.configuration.variables.update")) return $response;
@@ -183,8 +178,8 @@ class ConfigController extends BaseAdminController
* *
* @return Symfony\Component\HttpFoundation\Response the response * @return Symfony\Component\HttpFoundation\Response the response
*/ */
public function saveChangeAction() { public function saveChangeAction()
{
// Check current user authorization // Check current user authorization
if (null !== $response = $this->checkAuth("admin.configuration.variables.update")) return $response; if (null !== $response = $this->checkAuth("admin.configuration.variables.update")) return $response;
@@ -240,12 +235,10 @@ class ConfigController extends BaseAdminController
// Redirect to the success URL // Redirect to the success URL
$this->redirect($changeForm->getSuccessUrl()); $this->redirect($changeForm->getSuccessUrl());
} } catch (FormValidationException $ex) {
catch (FormValidationException $ex) {
// Form cannot be validated // Form cannot be validated
$message = $this->createStandardFormValidationErrorMessage($ex); $message = $this->createStandardFormValidationErrorMessage($ex);
} } catch (\Exception $ex) {
catch (\Exception $ex) {
// Any other error // Any other error
$message = $ex->getMessage(); $message = $ex->getMessage();
} }
@@ -261,15 +254,15 @@ class ConfigController extends BaseAdminController
* *
* @return Symfony\Component\HttpFoundation\Response the response * @return Symfony\Component\HttpFoundation\Response the response
*/ */
public function changeValuesAction() { public function changeValuesAction()
{
// Check current user authorization // Check current user authorization
if (null !== $response = $this->checkAuth("admin.configuration.variables.update")) return $response; if (null !== $response = $this->checkAuth("admin.configuration.variables.update")) return $response;
$variables = $this->getRequest()->get('variable', array()); $variables = $this->getRequest()->get('variable', array());
// Process all changed variables // Process all changed variables
foreach($variables as $id => $value) { foreach ($variables as $id => $value) {
$event = new ConfigUpdateEvent($id); $event = new ConfigUpdateEvent($id);
$event->setValue($value); $event->setValue($value);
@@ -284,8 +277,8 @@ class ConfigController extends BaseAdminController
* *
* @return Symfony\Component\HttpFoundation\Response the response * @return Symfony\Component\HttpFoundation\Response the response
*/ */
public function deleteAction() { public function deleteAction()
{
// Check current user authorization // Check current user authorization
if (null !== $response = $this->checkAuth("admin.configuration.variables.delete")) return $response; if (null !== $response = $this->checkAuth("admin.configuration.variables.delete")) return $response;
@@ -299,4 +292,4 @@ class ConfigController extends BaseAdminController
$this->redirectToRoute('admin.configuration.variables.default'); $this->redirectToRoute('admin.configuration.variables.default');
} }
} }

View File

@@ -26,17 +26,12 @@ namespace Thelia\Controller\Admin;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Router; use Symfony\Component\Routing\Router;
use Thelia\Constraint\ConstraintFactory; use Thelia\Constraint\ConstraintFactory;
use Thelia\Constraint\ConstraintFactoryTest;
use Thelia\Constraint\Rule\AvailableForTotalAmount; use Thelia\Constraint\Rule\AvailableForTotalAmount;
use Thelia\Constraint\Rule\CouponRuleInterface; use Thelia\Constraint\Rule\CouponRuleInterface;
use Thelia\Constraint\Validator\PriceParam; use Thelia\Constraint\Validator\PriceParam;
use Thelia\Core\Event\Coupon\CouponCreateEvent;
use Thelia\Core\Event\Coupon\CouponCreateOrUpdateEvent; use Thelia\Core\Event\Coupon\CouponCreateOrUpdateEvent;
use Thelia\Core\Event\Coupon\CouponEvent; use Thelia\Core\Event\Coupon\CouponEvent;
use Thelia\Core\Event\TheliaEvents; use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\HttpFoundation\Session\Session;
use Thelia\Core\Security\Exception\AuthenticationException;
use Thelia\Core\Security\Exception\AuthorizationException;
use Thelia\Core\Translation\Translator; use Thelia\Core\Translation\Translator;
use Thelia\Coupon\CouponAdapterInterface; use Thelia\Coupon\CouponAdapterInterface;
use Thelia\Coupon\CouponManager; use Thelia\Coupon\CouponManager;
@@ -222,7 +217,6 @@ class CouponController extends BaseAdminController
); );
} }
/** /**
* Manage Coupons Rule creation display * Manage Coupons Rule creation display
* *
@@ -311,8 +305,6 @@ class CouponController extends BaseAdminController
); );
} }
/** /**
* Manage Coupons read display * Manage Coupons read display
* *
@@ -375,7 +367,6 @@ class CouponController extends BaseAdminController
); );
} }
/** /**
* Manage Coupons read display * Manage Coupons read display
* *
@@ -697,6 +688,4 @@ class CouponController extends BaseAdminController
// } // }
// } // }
} }

View File

@@ -28,9 +28,7 @@ use Thelia\Core\Event\TheliaEvents;
use Thelia\Tools\URL; use Thelia\Tools\URL;
use Thelia\Core\Event\CurrencyUpdateEvent; use Thelia\Core\Event\CurrencyUpdateEvent;
use Thelia\Core\Event\CurrencyCreateEvent; use Thelia\Core\Event\CurrencyCreateEvent;
use Thelia\Log\Tlog;
use Thelia\Form\Exception\FormValidationException; use Thelia\Form\Exception\FormValidationException;
use Thelia\Core\Security\Exception\AuthorizationException;
use Thelia\Model\CurrencyQuery; use Thelia\Model\CurrencyQuery;
use Thelia\Form\CurrencyModificationForm; use Thelia\Form\CurrencyModificationForm;
use Thelia\Form\CurrencyCreationForm; use Thelia\Form\CurrencyCreationForm;
@@ -48,8 +46,8 @@ class CurrencyController extends BaseAdminController
* *
* @return Symfony\Component\HttpFoundation\Response the response * @return Symfony\Component\HttpFoundation\Response the response
*/ */
protected function renderList() { protected function renderList()
{
// Find the current order // Find the current order
$order = $this->getRequest()->get( $order = $this->getRequest()->get(
'order', 'order',
@@ -67,10 +65,9 @@ class CurrencyController extends BaseAdminController
* *
* @return Symfony\Component\HttpFoundation\Response the response * @return Symfony\Component\HttpFoundation\Response the response
*/ */
public function defaultAction() { public function defaultAction()
{
if (null !== $response = $this->checkAuth("admin.configuration.currencies.view")) return $response; if (null !== $response = $this->checkAuth("admin.configuration.currencies.view")) return $response;
return $this->renderList(); return $this->renderList();
} }
@@ -79,8 +76,8 @@ class CurrencyController extends BaseAdminController
* *
* @return Symfony\Component\HttpFoundation\Response the response * @return Symfony\Component\HttpFoundation\Response the response
*/ */
public function createAction() { public function createAction()
{
// Check current user authorization // Check current user authorization
if (null !== $response = $this->checkAuth("admin.configuration.currencies.create")) return $response; if (null !== $response = $this->checkAuth("admin.configuration.currencies.create")) return $response;
@@ -120,12 +117,10 @@ class CurrencyController extends BaseAdminController
// Redirect to the success URL // Redirect to the success URL
$this->redirect($successUrl); $this->redirect($successUrl);
} } catch (FormValidationException $ex) {
catch (FormValidationException $ex) {
// Form cannot be validated // Form cannot be validated
$error_msg = $this->createStandardFormValidationErrorMessage($ex); $error_msg = $this->createStandardFormValidationErrorMessage($ex);
} } catch (\Exception $ex) {
catch (\Exception $ex) {
// Any other error // Any other error
$error_msg = $ex->getMessage(); $error_msg = $ex->getMessage();
} }
@@ -141,8 +136,8 @@ class CurrencyController extends BaseAdminController
* *
* @return Symfony\Component\HttpFoundation\Response the response * @return Symfony\Component\HttpFoundation\Response the response
*/ */
public function changeAction() { public function changeAction()
{
// Check current user authorization // Check current user authorization
if (null !== $response = $this->checkAuth("admin.configuration.currencies.update")) return $response; if (null !== $response = $this->checkAuth("admin.configuration.currencies.update")) return $response;
@@ -179,8 +174,8 @@ class CurrencyController extends BaseAdminController
* *
* @return Symfony\Component\HttpFoundation\Response the response * @return Symfony\Component\HttpFoundation\Response the response
*/ */
public function saveChangeAction() { public function saveChangeAction()
{
// Check current user authorization // Check current user authorization
if (null !== $response = $this->checkAuth("admin.configuration.currencies.update")) return $response; if (null !== $response = $this->checkAuth("admin.configuration.currencies.update")) return $response;
@@ -231,12 +226,10 @@ class CurrencyController extends BaseAdminController
// Redirect to the success URL // Redirect to the success URL
$this->redirect($changeForm->getSuccessUrl()); $this->redirect($changeForm->getSuccessUrl());
} } catch (FormValidationException $ex) {
catch (FormValidationException $ex) {
// Form cannot be validated // Form cannot be validated
$error_msg = $this->createStandardFormValidationErrorMessage($ex); $error_msg = $this->createStandardFormValidationErrorMessage($ex);
} } catch (\Exception $ex) {
catch (\Exception $ex) {
// Any other error // Any other error
$error_msg = $ex->getMessage(); $error_msg = $ex->getMessage();
} }
@@ -250,7 +243,8 @@ class CurrencyController extends BaseAdminController
/** /**
* Sets the default currency * Sets the default currency
*/ */
public function setDefaultAction() { public function setDefaultAction()
{
// Check current user authorization // Check current user authorization
if (null !== $response = $this->checkAuth("admin.configuration.currencies.update")) return $response; if (null !== $response = $this->checkAuth("admin.configuration.currencies.update")) return $response;
@@ -261,8 +255,7 @@ class CurrencyController extends BaseAdminController
try { try {
$this->dispatch(TheliaEvents::CURRENCY_SET_DEFAULT, $changeEvent); $this->dispatch(TheliaEvents::CURRENCY_SET_DEFAULT, $changeEvent);
} } catch (\Exception $ex) {
catch (\Exception $ex) {
// Any error // Any error
return $this->errorPage($ex); return $this->errorPage($ex);
} }
@@ -273,14 +266,14 @@ class CurrencyController extends BaseAdminController
/** /**
* Update currencies rates * Update currencies rates
*/ */
public function updateRatesAction() { public function updateRatesAction()
{
// Check current user authorization // Check current user authorization
if (null !== $response = $this->checkAuth("admin.configuration.currencies.update")) return $response; if (null !== $response = $this->checkAuth("admin.configuration.currencies.update")) return $response;
try { try {
$this->dispatch(TheliaEvents::CURRENCY_UPDATE_RATES); $this->dispatch(TheliaEvents::CURRENCY_UPDATE_RATES);
} } catch (\Exception $ex) {
catch (\Exception $ex) {
// Any error // Any error
return $this->errorPage($ex); return $this->errorPage($ex);
} }
@@ -291,7 +284,8 @@ class CurrencyController extends BaseAdminController
/** /**
* Update currencyposition * Update currencyposition
*/ */
public function updatePositionAction() { public function updatePositionAction()
{
// Check current user authorization // Check current user authorization
if (null !== $response = $this->checkAuth("admin.configuration.currencies.update")) return $response; if (null !== $response = $this->checkAuth("admin.configuration.currencies.update")) return $response;
@@ -314,8 +308,7 @@ class CurrencyController extends BaseAdminController
); );
$this->dispatch(TheliaEvents::CURRENCY_UPDATE_POSITION, $event); $this->dispatch(TheliaEvents::CURRENCY_UPDATE_POSITION, $event);
} } catch (\Exception $ex) {
catch (\Exception $ex) {
// Any error // Any error
return $this->errorPage($ex); return $this->errorPage($ex);
} }
@@ -323,14 +316,13 @@ class CurrencyController extends BaseAdminController
$this->redirectToRoute('admin.configuration.currencies.default'); $this->redirectToRoute('admin.configuration.currencies.default');
} }
/** /**
* Delete a currency object * Delete a currency object
* *
* @return Symfony\Component\HttpFoundation\Response the response * @return Symfony\Component\HttpFoundation\Response the response
*/ */
public function deleteAction() { public function deleteAction()
{
// Check current user authorization // Check current user authorization
if (null !== $response = $this->checkAuth("admin.configuration.currencies.delete")) return $response; if (null !== $response = $this->checkAuth("admin.configuration.currencies.delete")) return $response;
@@ -344,4 +336,4 @@ class CurrencyController extends BaseAdminController
$this->redirectToRoute('admin.configuration.currencies.default'); $this->redirectToRoute('admin.configuration.currencies.default');
} }
} }

View File

@@ -23,7 +23,6 @@
namespace Thelia\Controller\Admin; namespace Thelia\Controller\Admin;
/** /**
* Class CustomerController * Class CustomerController
* @package Thelia\Controller\Admin * @package Thelia\Controller\Admin
@@ -34,7 +33,6 @@ class CustomerController extends BaseAdminController
public function indexAction() public function indexAction()
{ {
if (null !== $response = $this->checkAuth("admin.customers.view")) return $response; if (null !== $response = $this->checkAuth("admin.customers.view")) return $response;
return $this->render("customers", array("display_customer" => 20)); return $this->render("customers", array("display_customer" => 20));
} }
} }

View File

@@ -28,9 +28,7 @@ use Thelia\Core\Event\TheliaEvents;
use Thelia\Tools\URL; use Thelia\Tools\URL;
use Thelia\Core\Event\MessageUpdateEvent; use Thelia\Core\Event\MessageUpdateEvent;
use Thelia\Core\Event\MessageCreateEvent; use Thelia\Core\Event\MessageCreateEvent;
use Thelia\Log\Tlog;
use Thelia\Form\Exception\FormValidationException; use Thelia\Form\Exception\FormValidationException;
use Thelia\Core\Security\Exception\AuthorizationException;
use Thelia\Model\MessageQuery; use Thelia\Model\MessageQuery;
use Thelia\Form\MessageModificationForm; use Thelia\Form\MessageModificationForm;
use Thelia\Form\MessageCreationForm; use Thelia\Form\MessageCreationForm;
@@ -47,7 +45,8 @@ class MessageController extends BaseAdminController
* *
* @return Symfony\Component\HttpFoundation\Response the response * @return Symfony\Component\HttpFoundation\Response the response
*/ */
protected function renderList() { protected function renderList()
{
return $this->render('messages'); return $this->render('messages');
} }
@@ -56,10 +55,9 @@ class MessageController extends BaseAdminController
* *
* @return Symfony\Component\HttpFoundation\Response the response * @return Symfony\Component\HttpFoundation\Response the response
*/ */
public function defaultAction() { public function defaultAction()
{
if (null !== $response = $this->checkAuth("admin.configuration.messages.view")) return $response; if (null !== $response = $this->checkAuth("admin.configuration.messages.view")) return $response;
return $this->renderList(); return $this->renderList();
} }
@@ -68,8 +66,8 @@ class MessageController extends BaseAdminController
* *
* @return Symfony\Component\HttpFoundation\Response the response * @return Symfony\Component\HttpFoundation\Response the response
*/ */
public function createAction() { public function createAction()
{
// Check current user authorization // Check current user authorization
if (null !== $response = $this->checkAuth("admin.configuration.messages.create")) return $response; if (null !== $response = $this->checkAuth("admin.configuration.messages.create")) return $response;
@@ -107,12 +105,10 @@ class MessageController extends BaseAdminController
// Redirect to the success URL // Redirect to the success URL
$this->redirect($successUrl); $this->redirect($successUrl);
} } catch (FormValidationException $ex) {
catch (FormValidationException $ex) {
// Form cannot be validated // Form cannot be validated
$message = $this->createStandardFormValidationErrorMessage($ex); $message = $this->createStandardFormValidationErrorMessage($ex);
} } catch (\Exception $ex) {
catch (\Exception $ex) {
// Any other error // Any other error
$message = $ex->getMessage(); $message = $ex->getMessage();
} }
@@ -128,8 +124,8 @@ class MessageController extends BaseAdminController
* *
* @return Symfony\Component\HttpFoundation\Response the response * @return Symfony\Component\HttpFoundation\Response the response
*/ */
public function changeAction() { public function changeAction()
{
// Check current user authorization // Check current user authorization
if (null !== $response = $this->checkAuth("admin.configuration.messages.update")) return $response; if (null !== $response = $this->checkAuth("admin.configuration.messages.update")) return $response;
@@ -168,8 +164,8 @@ class MessageController extends BaseAdminController
* *
* @return Symfony\Component\HttpFoundation\Response the response * @return Symfony\Component\HttpFoundation\Response the response
*/ */
public function saveChangeAction() { public function saveChangeAction()
{
// Check current user authorization // Check current user authorization
if (null !== $response = $this->checkAuth("admin.configuration.messages.update")) return $response; if (null !== $response = $this->checkAuth("admin.configuration.messages.update")) return $response;
@@ -221,12 +217,10 @@ class MessageController extends BaseAdminController
// Redirect to the success URL // Redirect to the success URL
$this->redirect($changeForm->getSuccessUrl()); $this->redirect($changeForm->getSuccessUrl());
} } catch (FormValidationException $ex) {
catch (FormValidationException $ex) {
// Form cannot be validated // Form cannot be validated
$message = $this->createStandardFormValidationErrorMessage($ex); $message = $this->createStandardFormValidationErrorMessage($ex);
} } catch (\Exception $ex) {
catch (\Exception $ex) {
// Any other error // Any other error
$message = $ex->getMessage(); $message = $ex->getMessage();
} }
@@ -242,8 +236,8 @@ class MessageController extends BaseAdminController
* *
* @return Symfony\Component\HttpFoundation\Response the response * @return Symfony\Component\HttpFoundation\Response the response
*/ */
public function deleteAction() { public function deleteAction()
{
// Check current user authorization // Check current user authorization
if (null !== $response = $this->checkAuth("admin.configuration.messages.delete")) return $response; if (null !== $response = $this->checkAuth("admin.configuration.messages.delete")) return $response;
@@ -257,4 +251,4 @@ class MessageController extends BaseAdminController
$this->redirectToRoute('admin.configuration.messages.default'); $this->redirectToRoute('admin.configuration.messages.default');
} }
} }

View File

@@ -27,7 +27,6 @@ use Thelia\Form\AdminLogin;
use Thelia\Core\Security\Authentication\AdminUsernamePasswordFormAuthenticator; use Thelia\Core\Security\Authentication\AdminUsernamePasswordFormAuthenticator;
use Thelia\Model\AdminLog; use Thelia\Model\AdminLog;
use Thelia\Core\Security\Exception\AuthenticationException; use Thelia\Core\Security\Exception\AuthenticationException;
use Symfony\Component\Validator\Exception\ValidatorException;
use Thelia\Tools\URL; use Thelia\Tools\URL;
use Thelia\Tools\Redirect; use Thelia\Tools\Redirect;
use Thelia\Core\Event\TheliaEvents; use Thelia\Core\Event\TheliaEvents;
@@ -74,20 +73,17 @@ class SessionController extends BaseAdminController
// Redirect to the success URL // Redirect to the success URL
return Redirect::exec($adminLoginForm->getSuccessUrl()); return Redirect::exec($adminLoginForm->getSuccessUrl());
} } catch (FormValidationException $ex) {
catch (FormValidationException $ex) {
// Validation problem // Validation problem
$message = $this->createStandardFormValidationErrorMessage($ex); $message = $this->createStandardFormValidationErrorMessage($ex);
} } catch (AuthenticationException $ex) {
catch (AuthenticationException $ex) {
// Log authentication failure // Log authentication failure
AdminLog::append(sprintf("Authentication failure for username '%s'", $authenticator->getUsername()), $request); AdminLog::append(sprintf("Authentication failure for username '%s'", $authenticator->getUsername()), $request);
$message = $this->getTranslator()->trans("Login failed. Please check your username and password."); $message = $this->getTranslator()->trans("Login failed. Please check your username and password.");
} } catch (\Exception $ex) {
catch (\Exception $ex) {
// Log authentication failure // Log authentication failure
AdminLog::append(sprintf("Undefined error: %s", $ex->getMessage()), $request); AdminLog::append(sprintf("Undefined error: %s", $ex->getMessage()), $request);
@@ -103,4 +99,4 @@ class SessionController extends BaseAdminController
// Display the login form again // Display the login form again
return $this->render("login"); return $this->render("login");
} }
} }

View File

@@ -39,7 +39,6 @@ use Thelia\Form\BaseForm;
use Thelia\Form\Exception\FormValidationException; use Thelia\Form\Exception\FormValidationException;
use Symfony\Component\EventDispatcher\Event; use Symfony\Component\EventDispatcher\Event;
use Thelia\Core\Event\DefaultActionEvent; use Thelia\Core\Event\DefaultActionEvent;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
/** /**
@@ -65,8 +64,8 @@ class BaseController extends ContainerAware
/** /**
* Dispatch a Thelia event * Dispatch a Thelia event
* *
* @param string $eventName a TheliaEvent name, as defined in TheliaEvents class * @param string $eventName a TheliaEvent name, as defined in TheliaEvents class
* @param Event $event the action event, or null (a DefaultActionEvent will be dispatched) * @param Event $event the action event, or null (a DefaultActionEvent will be dispatched)
*/ */
protected function dispatch($eventName, ActionEvent $event = null) protected function dispatch($eventName, ActionEvent $event = null)
{ {
@@ -139,11 +138,11 @@ class BaseController extends ContainerAware
/** /**
* Get all errors that occured in a form * Get all errors that occured in a form
* *
* @param \Symfony\Component\Form\Form $form * @param \Symfony\Component\Form\Form $form
* @return string the error string * @return string the error string
*/ */
private function getErrorMessages(\Symfony\Component\Form\Form $form) { private function getErrorMessages(\Symfony\Component\Form\Form $form)
{
$errors = ''; $errors = '';
foreach ($form->getErrors() as $key => $error) { foreach ($form->getErrors() as $key => $error) {
@@ -177,8 +176,7 @@ class BaseController extends ContainerAware
if ($form->isValid()) { if ($form->isValid()) {
return $form; return $form;
} } else {
else {
$errorMessage = null; $errorMessage = null;
if ($form->get("error_message")->getData() != null) { if ($form->get("error_message")->getData() != null) {
$errorMessage = $form->get("error_message")->getData(); $errorMessage = $form->get("error_message")->getData();
@@ -188,8 +186,7 @@ class BaseController extends ContainerAware
throw new FormValidationException($errorMessage); throw new FormValidationException($errorMessage);
} }
} } else {
else {
throw new FormValidationException(sprintf("Wrong form method, %s expected.", $expectedMethod)); throw new FormValidationException(sprintf("Wrong form method, %s expected.", $expectedMethod));
} }
} }
@@ -214,8 +211,7 @@ class BaseController extends ContainerAware
{ {
if ($form != null) { if ($form != null) {
$url = $form->getSuccessUrl(); $url = $form->getSuccessUrl();
} } else {
else {
$url = $this->getRequest()->get("success_url"); $url = $this->getRequest()->get("success_url");
} }
@@ -236,10 +232,11 @@ class BaseController extends ContainerAware
* @throws MissingMandatoryParametersException When some parameters are missing that are mandatory for the route * @throws MissingMandatoryParametersException When some parameters are missing that are mandatory for the route
* @throws InvalidParameterException When a parameter value for a placeholder is not correct because * @throws InvalidParameterException When a parameter value for a placeholder is not correct because
* it does not match the requirement * it does not match the requirement
* @throws \InvalidArgumentException When the router doesn't exist * @throws \InvalidArgumentException When the router doesn't exist
* @return string The generated URL * @return string The generated URL
*/ */
protected function getRouteFromRouter($routerName, $routeId, $parameters = array(), $referenceType = Router::ABSOLUTE_PATH) { protected function getRouteFromRouter($routerName, $routeId, $parameters = array(), $referenceType = Router::ABSOLUTE_PATH)
{
/** @var Router $router */ /** @var Router $router */
$router = $this->container->get($routerName); $router = $this->container->get($routerName);
@@ -268,4 +265,4 @@ class BaseController extends ContainerAware
{ {
return $this->container->getParameter('kernel.debug'); return $this->container->getParameter('kernel.debug');
} }
} }

View File

@@ -31,7 +31,6 @@ use Thelia\Model\Base\AddressQuery;
use Thelia\Model\Customer; use Thelia\Model\Customer;
use Thelia\Tools\URL; use Thelia\Tools\URL;
/** /**
* Class AddressController * Class AddressController
* @package Thelia\Controller\Front * @package Thelia\Controller\Front
@@ -64,10 +63,9 @@ class AddressController extends BaseFrontController
$this->dispatch(TheliaEvents::ADDRESS_CREATE, $event); $this->dispatch(TheliaEvents::ADDRESS_CREATE, $event);
$this->redirectSuccess($addressCreate); $this->redirectSuccess($addressCreate);
}catch (FormValidationException $e) { } catch (FormValidationException $e) {
$message = sprintf("Please check your input: %s", $e->getMessage()); $message = sprintf("Please check your input: %s", $e->getMessage());
} } catch (\Exception $e) {
catch (\Exception $e) {
$message = sprintf("Sorry, an error occured: %s", $e->getMessage()); $message = sprintf("Sorry, an error occured: %s", $e->getMessage());
} }
@@ -91,7 +89,7 @@ class AddressController extends BaseFrontController
$this->redirectToRoute("home"); $this->redirectToRoute("home");
} }
if(null === $address_id = $request->get("address_id")) { if (null === $address_id = $request->get("address_id")) {
$this->redirectToRoute("home"); $this->redirectToRoute("home");
} }
@@ -108,7 +106,7 @@ class AddressController extends BaseFrontController
$this->redirectToRoute("home"); $this->redirectToRoute("home");
} }
if($address->getCustomer()->getId() != $customer->getId()) { if ($address->getCustomer()->getId() != $customer->getId()) {
$this->redirectToRoute("home"); $this->redirectToRoute("home");
} }
@@ -118,10 +116,9 @@ class AddressController extends BaseFrontController
$this->dispatch(TheliaEvents::ADDRESS_UPDATE, $event); $this->dispatch(TheliaEvents::ADDRESS_UPDATE, $event);
$this->redirectSuccess($addressUpdate); $this->redirectSuccess($addressUpdate);
}catch (FormValidationException $e) { } catch (FormValidationException $e) {
$message = sprintf("Please check your input: %s", $e->getMessage()); $message = sprintf("Please check your input: %s", $e->getMessage());
} } catch (\Exception $e) {
catch (\Exception $e) {
$message = sprintf("Sorry, an error occured: %s", $e->getMessage()); $message = sprintf("Sorry, an error occured: %s", $e->getMessage());
} }
@@ -155,4 +152,4 @@ class AddressController extends BaseFrontController
$form->get("company")->getData() $form->get("company")->getData()
); );
} }
} }

View File

@@ -35,17 +35,19 @@ class BaseFrontController extends BaseController
* *
* @see \Thelia\Controller\BaseController::getRouteFromRouter() * @see \Thelia\Controller\BaseController::getRouteFromRouter()
*/ */
protected function getRoute($routeId, $parameters = array(), $referenceType = Router::ABSOLUTE_PATH) { protected function getRoute($routeId, $parameters = array(), $referenceType = Router::ABSOLUTE_PATH)
{
return $this->getRouteFromRouter('router.front', $routeId, $parameters, $referenceType); return $this->getRouteFromRouter('router.front', $routeId, $parameters, $referenceType);
} }
/** /**
* Redirect to à route ID related URL * Redirect to à route ID related URL
* *
* @param unknown $routeId the route ID, as found in Config/Resources/routing/admin.xml * @param unknown $routeId the route ID, as found in Config/Resources/routing/admin.xml
* @param unknown $urlParameters the URL parametrs, as a var/value pair array * @param unknown $urlParameters the URL parametrs, as a var/value pair array
*/ */
public function redirectToRoute($routeId, $urlParameters = array(), $referenceType = Router::ABSOLUTE_PATH) { public function redirectToRoute($routeId, $urlParameters = array(), $referenceType = Router::ABSOLUTE_PATH)
{
$this->redirect(URL::getInstance()->absoluteUrl($this->getRoute($routeId, array(), $referenceType), $urlParameters)); $this->redirect(URL::getInstance()->absoluteUrl($this->getRoute($routeId, array(), $referenceType), $urlParameters));
} }
} }

View File

@@ -77,7 +77,7 @@ class CartController extends BaseFrontController
$this->getDispatcher()->dispatch(TheliaEvents::CART_UPDATEITEM, $cartEvent); $this->getDispatcher()->dispatch(TheliaEvents::CART_UPDATEITEM, $cartEvent);
$this->redirectSuccess(); $this->redirectSuccess();
} catch(PropelException $e) { } catch (PropelException $e) {
$this->getParserContext()->setGeneralError($e->getMessage()); $this->getParserContext()->setGeneralError($e->getMessage());
} }
@@ -97,7 +97,6 @@ class CartController extends BaseFrontController
$this->getParserContext()->setGeneralError($e->getMessage()); $this->getParserContext()->setGeneralError($e->getMessage());
} }
} }
/** /**

View File

@@ -27,19 +27,15 @@ use Thelia\Core\Event\CustomerLoginEvent;
use Thelia\Core\Security\Authentication\CustomerUsernamePasswordFormAuthenticator; use Thelia\Core\Security\Authentication\CustomerUsernamePasswordFormAuthenticator;
use Thelia\Core\Security\Exception\AuthenticationException; use Thelia\Core\Security\Exception\AuthenticationException;
use Thelia\Core\Security\Exception\UsernameNotFoundException; use Thelia\Core\Security\Exception\UsernameNotFoundException;
use Thelia\Core\Security\SecurityContext;
use Thelia\Form\CustomerCreation; use Thelia\Form\CustomerCreation;
use Thelia\Form\CustomerLogin; use Thelia\Form\CustomerLogin;
use Thelia\Form\CustomerModification; use Thelia\Form\CustomerModification;
use Thelia\Form\Exception\FormValidationException; use Thelia\Form\Exception\FormValidationException;
use Thelia\Model\Customer; use Thelia\Model\Customer;
use Thelia\Core\Event\TheliaEvents; use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Event\CustomerEvent;
use Thelia\Core\Factory\ActionEventFactory;
use Thelia\Tools\URL; use Thelia\Tools\URL;
use Thelia\Log\Tlog; use Thelia\Log\Tlog;
use Thelia\Core\Security\Exception\WrongPasswordException; use Thelia\Core\Security\Exception\WrongPasswordException;
use Symfony\Component\Routing\Router;
/** /**
* Class CustomerController * Class CustomerController
@@ -70,11 +66,9 @@ class CustomerController extends BaseFrontController
$this->processLogin($customerCreateEvent->getCustomer()); $this->processLogin($customerCreateEvent->getCustomer());
$this->redirectSuccess($customerCreation); $this->redirectSuccess($customerCreation);
} } catch (FormValidationException $e) {
catch (FormValidationException $e) {
$message = sprintf("Please check your input: %s", $e->getMessage()); $message = sprintf("Please check your input: %s", $e->getMessage());
} } catch (\Exception $e) {
catch (\Exception $e) {
$message = sprintf("Sorry, an error occured: %s", $e->getMessage()); $message = sprintf("Sorry, an error occured: %s", $e->getMessage());
} }
@@ -118,11 +112,9 @@ class CustomerController extends BaseFrontController
$this->redirectSuccess($customerModification); $this->redirectSuccess($customerModification);
} } catch (FormValidationException $e) {
catch (FormValidationException $e) {
$message = sprintf("Please check your input: %s", $e->getMessage()); $message = sprintf("Please check your input: %s", $e->getMessage());
} } catch (\Exception $e) {
catch (\Exception $e) {
$message = sprintf("Sorry, an error occured: %s", $e->getMessage()); $message = sprintf("Sorry, an error occured: %s", $e->getMessage());
} }
@@ -166,29 +158,24 @@ class CustomerController extends BaseFrontController
$this->redirectSuccess($customerLoginForm); $this->redirectSuccess($customerLoginForm);
} } catch (FormValidationException $e) {
catch (FormValidationException $e) {
if ($request->request->has("account")) { if ($request->request->has("account")) {
$account = $request->request->get("account"); $account = $request->request->get("account");
$form = $customerLoginForm->getForm(); $form = $customerLoginForm->getForm();
if($account == 0 && $form->get("email")->getData() !== null) { if ($account == 0 && $form->get("email")->getData() !== null) {
$this->redirectToRoute("customer.create.view", array("email" => $form->get("email")->getData())); $this->redirectToRoute("customer.create.view", array("email" => $form->get("email")->getData()));
} }
} }
$message = sprintf("Please check your input: %s", $e->getMessage()); $message = sprintf("Please check your input: %s", $e->getMessage());
} } catch (UsernameNotFoundException $e) {
catch(UsernameNotFoundException $e) {
$message = "Wrong email or password. Please try again"; $message = "Wrong email or password. Please try again";
} } catch (WrongPasswordException $e) {
catch (WrongPasswordException $e) {
$message = "Wrong email or password. Please try again"; $message = "Wrong email or password. Please try again";
} } catch (AuthenticationException $e) {
catch(AuthenticationException $e) {
$message = "Wrong email or password. Please try again"; $message = "Wrong email or password. Please try again";
} } catch (\Exception $e) {
catch (\Exception $e) {
$message = sprintf("Sorry, an error occured: %s", $e->getMessage()); $message = sprintf("Sorry, an error occured: %s", $e->getMessage());
} }

View File

@@ -53,7 +53,7 @@ class DefaultController extends BaseFrontController
$view = $request->request->get('view'); $view = $request->request->get('view');
} }
} }
if(null !== $view) { if (null !== $view) {
$request->attributes->set('_view', $view); $request->attributes->set('_view', $view);
} }
@@ -61,11 +61,11 @@ class DefaultController extends BaseFrontController
$request->attributes->set("_view", "index"); $request->attributes->set("_view", "index");
} }
if(ConfigQuery::isRewritingEnable()) { if (ConfigQuery::isRewritingEnable()) {
if($request->attributes->get('_rewritten', false) === false) { if ($request->attributes->get('_rewritten', false) === false) {
/* Does the query GET parameters match a rewritten URL ? */ /* Does the query GET parameters match a rewritten URL ? */
$rewrittenUrl = URL::getInstance()->retrieveCurrent($request); $rewrittenUrl = URL::getInstance()->retrieveCurrent($request);
if($rewrittenUrl->rewrittenUrl !== null) { if ($rewrittenUrl->rewrittenUrl !== null) {
/* 301 redirection to rewritten URL */ /* 301 redirection to rewritten URL */
$this->redirect($rewrittenUrl->rewrittenUrl, 301); $this->redirect($rewrittenUrl->rewrittenUrl, 301);
} }

View File

@@ -25,7 +25,6 @@ namespace Thelia\Controller\Front;
use Thelia\Model\ModuleQuery; use Thelia\Model\ModuleQuery;
use Thelia\Tools\URL; use Thelia\Tools\URL;
/** /**
* Class DeliveryController * Class DeliveryController
* @package Thelia\Controller\Front * @package Thelia\Controller\Front
@@ -53,4 +52,4 @@ class DeliveryController extends BaseFrontController
$this->pageNotFound(); $this->pageNotFound();
} }
} }
} }

View File

@@ -25,7 +25,6 @@ namespace Thelia\Controller\Install;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Thelia\Controller\BaseController; use Thelia\Controller\BaseController;
/** /**
* Class BaseInstallController * Class BaseInstallController
* @package Thelia\Controller\Install * @package Thelia\Controller\Install
@@ -57,4 +56,4 @@ class BaseInstallController extends BaseController
return $data; return $data;
} }
} }

View File

@@ -22,7 +22,6 @@
/*************************************************************************************/ /*************************************************************************************/
namespace Thelia\Controller\Install; namespace Thelia\Controller\Install;
use Thelia\Install\BaseInstall;
use Thelia\Install\CheckPermission; use Thelia\Install\CheckPermission;
/** /**
@@ -30,8 +29,8 @@ use Thelia\Install\CheckPermission;
* @package Thelia\Controller\Install * @package Thelia\Controller\Install
* @author Manuel Raynaud <mraynaud@openstudio.fr> * @author Manuel Raynaud <mraynaud@openstudio.fr>
*/ */
class InstallController extends BaseInstallController { class InstallController extends BaseInstallController
{
public function index() public function index()
{ {
$this->verifyStep(1); $this->verifyStep(1);
@@ -58,7 +57,7 @@ class InstallController extends BaseInstallController {
return true; return true;
} }
switch($step) { switch ($step) {
case "1" : case "1" :
if ($sessionStep > 1) { if ($sessionStep > 1) {
$this->redirect("/install/step/2"); $this->redirect("/install/step/2");
@@ -66,4 +65,4 @@ class InstallController extends BaseInstallController {
break; break;
} }
} }
} }

View File

@@ -24,8 +24,6 @@
namespace Thelia\Core\Event; namespace Thelia\Core\Event;
use Symfony\Component\EventDispatcher\Event; use Symfony\Component\EventDispatcher\Event;
use Thelia\Core\HttpFoundation\Request;
use Thelia\Form\BaseForm;
/** /**
* *
* Class thrown on Thelia.action event * Class thrown on Thelia.action event
@@ -50,4 +48,4 @@ abstract class ActionEvent extends Event
return null; return null;
} }
} }

View File

@@ -26,7 +26,6 @@ use Symfony\Component\EventDispatcher\Event;
use Thelia\Model\Address; use Thelia\Model\Address;
use Thelia\Model\Customer; use Thelia\Model\Customer;
/** /**
* Class AddressCreateOrUpdateEvent * Class AddressCreateOrUpdateEvent
* @package Thelia\Core\Event * @package Thelia\Core\Event
@@ -109,7 +108,7 @@ class AddressCreateOrUpdateEvent extends ActionEvent
*/ */
protected $address; protected $address;
function __construct($label, $title, $firstname, $lastname, $address1, $address2, $address3, $zipcode, $city, $country, $cellphone, $phone, $company) public function __construct($label, $title, $firstname, $lastname, $address1, $address2, $address3, $zipcode, $city, $country, $cellphone, $phone, $company)
{ {
$this->address1 = $address1; $this->address1 = $address1;
$this->address2 = $address2; $this->address2 = $address2;
@@ -263,5 +262,4 @@ class AddressCreateOrUpdateEvent extends ActionEvent
return $this->address; return $this->address;
} }
}
}

View File

@@ -25,7 +25,6 @@ namespace Thelia\Core\Event;
use Symfony\Component\EventDispatcher\Event; use Symfony\Component\EventDispatcher\Event;
use Thelia\Model\Address; use Thelia\Model\Address;
/** /**
* Class AddressEvent * Class AddressEvent
* @package Thelia\Core\Event * @package Thelia\Core\Event
@@ -38,12 +37,11 @@ class AddressEvent extends ActionEvent
*/ */
protected $address; protected $address;
function __construct(Address $address) public function __construct(Address $address)
{ {
$this->address = $address; $this->address = $address;
} }
/** /**
* @return \Thelia\Model\Address * @return \Thelia\Model\Address
*/ */
@@ -51,4 +49,4 @@ class AddressEvent extends ActionEvent
{ {
return $this->address; return $this->address;
} }
} }

View File

@@ -23,7 +23,6 @@
namespace Thelia\Core\Event; namespace Thelia\Core\Event;
class BaseToggleVisibilityEvent extends ActionEvent class BaseToggleVisibilityEvent extends ActionEvent
{ {
protected $object_id; protected $object_id;
@@ -43,6 +42,7 @@ class BaseToggleVisibilityEvent extends ActionEvent
public function setObjectId($object_id) public function setObjectId($object_id)
{ {
$this->object_id = $object_id; $this->object_id = $object_id;
return $this; return $this;
} }
} }

View File

@@ -50,6 +50,7 @@ class BaseUpdatePositionEvent extends ActionEvent
public function setMode($mode) public function setMode($mode)
{ {
$this->mode = $mode; $this->mode = $mode;
return $this; return $this;
} }
@@ -61,6 +62,7 @@ class BaseUpdatePositionEvent extends ActionEvent
public function setPosition($position) public function setPosition($position)
{ {
$this->position = $position; $this->position = $position;
return $this; return $this;
} }
@@ -72,6 +74,7 @@ class BaseUpdatePositionEvent extends ActionEvent
public function setObjectId($object_id) public function setObjectId($object_id)
{ {
$this->object_id = $object_id; $this->object_id = $object_id;
return $this; return $this;
} }
} }

View File

@@ -145,5 +145,4 @@ class CartEvent extends ActionEvent
return $this->cart; return $this->cart;
} }
} }

View File

@@ -23,8 +23,6 @@
namespace Thelia\Core\Event; namespace Thelia\Core\Event;
use Thelia\Model\Category;
class CategoryCreateEvent extends CategoryEvent class CategoryCreateEvent extends CategoryEvent
{ {
protected $title; protected $title;
@@ -46,6 +44,7 @@ class CategoryCreateEvent extends CategoryEvent
public function setTitle($title) public function setTitle($title)
{ {
$this->title = $title; $this->title = $title;
return $this; return $this;
} }
@@ -57,6 +56,7 @@ class CategoryCreateEvent extends CategoryEvent
public function setParent($parent) public function setParent($parent)
{ {
$this->parent = $parent; $this->parent = $parent;
return $this; return $this;
} }
@@ -68,6 +68,7 @@ class CategoryCreateEvent extends CategoryEvent
public function setLocale($locale) public function setLocale($locale)
{ {
$this->locale = $locale; $this->locale = $locale;
return $this; return $this;
} }
} }

View File

@@ -23,8 +23,6 @@
namespace Thelia\Core\Event; namespace Thelia\Core\Event;
use Thelia\Model\Category;
class CategoryDeleteEvent extends CategoryEvent class CategoryDeleteEvent extends CategoryEvent
{ {
public function __construct($category_id) public function __construct($category_id)
@@ -40,6 +38,7 @@ class CategoryDeleteEvent extends CategoryEvent
public function setCategoryId($category_id) public function setCategoryId($category_id)
{ {
$this->category_id = $category_id; $this->category_id = $category_id;
return $this; return $this;
} }
} }

View File

@@ -35,7 +35,8 @@ class CategoryEvent extends ActionEvent
$this->category = $category; $this->category = $category;
} }
public function hasCategory() { public function hasCategory()
{
return ! is_null($this->category); return ! is_null($this->category);
} }

View File

@@ -25,4 +25,4 @@ namespace Thelia\Core\Event;
class CategoryToggleVisibilityEvent extends BaseToggleVisibilityEvent class CategoryToggleVisibilityEvent extends BaseToggleVisibilityEvent
{ {
} }

View File

@@ -22,7 +22,6 @@
/*************************************************************************************/ /*************************************************************************************/
namespace Thelia\Core\Event; namespace Thelia\Core\Event;
use Thelia\Model\Category;
class CategoryUpdateEvent extends CategoryCreateEvent class CategoryUpdateEvent extends CategoryCreateEvent
{ {
@@ -49,6 +48,7 @@ class CategoryUpdateEvent extends CategoryCreateEvent
public function setCategoryId($category_id) public function setCategoryId($category_id)
{ {
$this->category_id = $category_id; $this->category_id = $category_id;
return $this; return $this;
} }
@@ -60,6 +60,7 @@ class CategoryUpdateEvent extends CategoryCreateEvent
public function setChapo($chapo) public function setChapo($chapo)
{ {
$this->chapo = $chapo; $this->chapo = $chapo;
return $this; return $this;
} }
@@ -71,6 +72,7 @@ class CategoryUpdateEvent extends CategoryCreateEvent
public function setDescription($description) public function setDescription($description)
{ {
$this->description = $description; $this->description = $description;
return $this; return $this;
} }
@@ -82,6 +84,7 @@ class CategoryUpdateEvent extends CategoryCreateEvent
public function setPostscriptum($postscriptum) public function setPostscriptum($postscriptum)
{ {
$this->postscriptum = $postscriptum; $this->postscriptum = $postscriptum;
return $this; return $this;
} }
@@ -93,6 +96,7 @@ class CategoryUpdateEvent extends CategoryCreateEvent
public function setUrl($url) public function setUrl($url)
{ {
$this->url = $url; $this->url = $url;
return $this; return $this;
} }
@@ -104,6 +108,7 @@ class CategoryUpdateEvent extends CategoryCreateEvent
public function setVisibility($visibility) public function setVisibility($visibility)
{ {
$this->visibility = $visibility; $this->visibility = $visibility;
return $this; return $this;
} }
@@ -115,6 +120,7 @@ class CategoryUpdateEvent extends CategoryCreateEvent
public function setParent($parent) public function setParent($parent)
{ {
$this->parent = $parent; $this->parent = $parent;
return $this; return $this;
} }
} }

View File

@@ -25,4 +25,4 @@ namespace Thelia\Core\Event;
class CategoryUpdatePositionEvent extends BaseUpdatePositionEvent class CategoryUpdatePositionEvent extends BaseUpdatePositionEvent
{ {
} }

View File

@@ -22,7 +22,6 @@
/*************************************************************************************/ /*************************************************************************************/
namespace Thelia\Core\Event; namespace Thelia\Core\Event;
use Thelia\Model\Config;
class ConfigCreateEvent extends ConfigEvent class ConfigCreateEvent extends ConfigEvent
{ {

View File

@@ -23,8 +23,6 @@
namespace Thelia\Core\Event; namespace Thelia\Core\Event;
use Thelia\Model\Config;
class ConfigDeleteEvent extends ConfigEvent class ConfigDeleteEvent extends ConfigEvent
{ {
protected $config_id; protected $config_id;

View File

@@ -33,7 +33,8 @@ class ConfigEvent extends ActionEvent
$this->config = $config; $this->config = $config;
} }
public function hasConfig() { public function hasConfig()
{
return ! is_null($this->config); return ! is_null($this->config);
} }

View File

@@ -23,8 +23,6 @@
namespace Thelia\Core\Event; namespace Thelia\Core\Event;
use Thelia\Model\Config;
class ConfigUpdateEvent extends ConfigCreateEvent class ConfigUpdateEvent extends ConfigCreateEvent
{ {
protected $config_id; protected $config_id;
@@ -85,4 +83,4 @@ class ConfigUpdateEvent extends ConfigCreateEvent
return $this; return $this;
} }
} }

View File

@@ -102,7 +102,7 @@ class CouponCreateOrUpdateEvent extends ActionEvent
* @param CouponRuleCollection $rules CouponRuleInterface to add * @param CouponRuleCollection $rules CouponRuleInterface to add
* @param string $locale Coupon Language code ISO (ex: fr_FR) * @param string $locale Coupon Language code ISO (ex: fr_FR)
*/ */
function __construct( public function __construct(
$code, $code,
$title, $title,
$amount, $amount,
@@ -307,6 +307,4 @@ class CouponCreateOrUpdateEvent extends ActionEvent
return $this->coupon; return $this->coupon;
} }
} }

View File

@@ -22,7 +22,6 @@
/*************************************************************************************/ /*************************************************************************************/
namespace Thelia\Core\Event; namespace Thelia\Core\Event;
use Thelia\Model\Currency;
class CurrencyCreateEvent extends CurrencyEvent class CurrencyCreateEvent extends CurrencyEvent
{ {
@@ -92,4 +91,4 @@ class CurrencyCreateEvent extends CurrencyEvent
return $this; return $this;
} }
} }

View File

@@ -23,8 +23,6 @@
namespace Thelia\Core\Event; namespace Thelia\Core\Event;
use Thelia\Model\Currency;
class CurrencyDeleteEvent extends CurrencyEvent class CurrencyDeleteEvent extends CurrencyEvent
{ {
protected $currency_id; protected $currency_id;
@@ -45,4 +43,4 @@ class CurrencyDeleteEvent extends CurrencyEvent
return $this; return $this;
} }
} }

View File

@@ -33,7 +33,8 @@ class CurrencyEvent extends ActionEvent
$this->currency = $currency; $this->currency = $currency;
} }
public function hasCurrency() { public function hasCurrency()
{
return ! is_null($this->currency); return ! is_null($this->currency);
} }

View File

@@ -22,7 +22,6 @@
/*************************************************************************************/ /*************************************************************************************/
namespace Thelia\Core\Event; namespace Thelia\Core\Event;
use Thelia\Model\Currency;
class CurrencyUpdateEvent extends CurrencyCreateEvent class CurrencyUpdateEvent extends CurrencyCreateEvent
{ {

View File

@@ -25,4 +25,4 @@ namespace Thelia\Core\Event;
class CurrencyUpdatePositionEvent extends BaseUpdatePositionEvent class CurrencyUpdatePositionEvent extends BaseUpdatePositionEvent
{ {
} }

View File

@@ -9,12 +9,11 @@
namespace Thelia\Core\Event; namespace Thelia\Core\Event;
use Symfony\Component\EventDispatcher\Event; use Symfony\Component\EventDispatcher\Event;
use Thelia\Model\Customer; use Thelia\Model\Customer;
class CustomerCreateOrUpdateEvent extends ActionEvent { class CustomerCreateOrUpdateEvent extends ActionEvent
{
//base parameters for creating new customer //base parameters for creating new customer
protected $title; protected $title;
protected $firstname; protected $firstname;
@@ -39,9 +38,8 @@ class CustomerCreateOrUpdateEvent extends ActionEvent {
*/ */
protected $customer; protected $customer;
/** /**
* @param int $title the title customer id * @param int $title the title customer id
* @param string $firstname * @param string $firstname
* @param string $lastname * @param string $lastname
* @param string $address1 * @param string $address1
@@ -51,15 +49,15 @@ class CustomerCreateOrUpdateEvent extends ActionEvent {
* @param string $cellphone * @param string $cellphone
* @param string $zipcode * @param string $zipcode
* @param string $city * @param string $city
* @param int $country the country id * @param int $country the country id
* @param string $email * @param string $email
* @param string $password plain password, don't put hash password, it will hashes again * @param string $password plain password, don't put hash password, it will hashes again
* @param $lang * @param $lang
* @param int $reseller if customer is a reseller * @param int $reseller if customer is a reseller
* @param int $sponsor customer's id sponsor * @param int $sponsor customer's id sponsor
* @param float $discount * @param float $discount
*/ */
function __construct($title, $firstname, $lastname, $address1, $address2, $address3, $phone, $cellphone, $zipcode, $city, $country, $email, $password, $lang, $reseller, $sponsor, $discount) public function __construct($title, $firstname, $lastname, $address1, $address2, $address3, $phone, $cellphone, $zipcode, $city, $country, $email, $password, $lang, $reseller, $sponsor, $discount)
{ {
$this->address1 = $address1; $this->address1 = $address1;
$this->address2 = $address2; $this->address2 = $address2;
@@ -231,7 +229,4 @@ class CustomerCreateOrUpdateEvent extends ActionEvent {
return $this->customer; return $this->customer;
} }
}
}

View File

@@ -43,5 +43,4 @@ class CustomerEvent extends ActionEvent
return $this->customer; return $this->customer;
} }
} }

View File

@@ -23,11 +23,10 @@
namespace Thelia\Core\Event; namespace Thelia\Core\Event;
use Thelia\Model\Customer; use Thelia\Model\Customer;
class CustomerLoginEvent extends ActionEvent { class CustomerLoginEvent extends ActionEvent
{
protected $customer; protected $customer;
public function __construct(Customer $customer) public function __construct(Customer $customer)
@@ -39,4 +38,4 @@ class CustomerLoginEvent extends ActionEvent {
{ {
return $this->customer; return $this->customer;
} }
} }

View File

@@ -22,8 +22,6 @@
/*************************************************************************************/ /*************************************************************************************/
namespace Thelia\Core\Event; namespace Thelia\Core\Event;
use Thelia\Core\HttpFoundation\Request;
use Thelia\Model\Cart;
class ImageEvent extends ActionEvent class ImageEvent extends ActionEvent
{ {

View File

@@ -22,7 +22,6 @@
/*************************************************************************************/ /*************************************************************************************/
namespace Thelia\Core\Event; namespace Thelia\Core\Event;
use Thelia\Model\Message;
class MessageCreateEvent extends MessageEvent class MessageCreateEvent extends MessageEvent
{ {
@@ -79,4 +78,4 @@ class MessageCreateEvent extends MessageEvent
return $this; return $this;
} }
} }

View File

@@ -23,8 +23,6 @@
namespace Thelia\Core\Event; namespace Thelia\Core\Event;
use Thelia\Model\Message;
class MessageDeleteEvent extends MessageEvent class MessageDeleteEvent extends MessageEvent
{ {
protected $message_id; protected $message_id;
@@ -45,4 +43,4 @@ class MessageDeleteEvent extends MessageEvent
return $this; return $this;
} }
} }

View File

@@ -33,7 +33,8 @@ class MessageEvent extends ActionEvent
$this->message = $message; $this->message = $message;
} }
public function hasMessage() { public function hasMessage()
{
return ! is_null($this->message); return ! is_null($this->message);
} }

View File

@@ -23,8 +23,6 @@
namespace Thelia\Core\Event; namespace Thelia\Core\Event;
use Thelia\Model\Message;
class MessageUpdateEvent extends MessageCreateEvent class MessageUpdateEvent extends MessageCreateEvent
{ {
protected $message_id; protected $message_id;

View File

@@ -204,8 +204,6 @@ final class TheliaEvents
*/ */
const IMAGE_CLEAR_CACHE = "action.clearImageCache"; const IMAGE_CLEAR_CACHE = "action.clearImageCache";
/** /**
* Sent when creating a Coupon * Sent when creating a Coupon
*/ */
@@ -311,7 +309,6 @@ final class TheliaEvents
*/ */
const AFTER_COUPON_RULE_DELETE = "action.after_delete_coupon_rule"; const AFTER_COUPON_RULE_DELETE = "action.after_delete_coupon_rule";
// -- Configuration management --------------------------------------------- // -- Configuration management ---------------------------------------------
const CONFIG_CREATE = "action.createConfig"; const CONFIG_CREATE = "action.createConfig";
@@ -361,5 +358,4 @@ final class TheliaEvents
const BEFORE_DELETECURRENCY = "action.before_deleteCurrency"; const BEFORE_DELETECURRENCY = "action.before_deleteCurrency";
const AFTER_DELETECURRENCY = "action.after_deleteCurrency"; const AFTER_DELETECURRENCY = "action.after_deleteCurrency";
} }

View File

@@ -84,6 +84,7 @@ class Session extends BaseSession
public function setCustomerUser(UserInterface $user) public function setCustomerUser(UserInterface $user)
{ {
$this->set('thelia.customer_user', $user); $this->set('thelia.customer_user', $user);
return $this; return $this;
} }
@@ -102,6 +103,7 @@ class Session extends BaseSession
public function setAdminUser(UserInterface $user) public function setAdminUser(UserInterface $user)
{ {
$this->set('thelia.admin_user', $user); $this->set('thelia.admin_user', $user);
return $this; return $this;
} }
@@ -120,6 +122,7 @@ class Session extends BaseSession
public function setReturnToUrl($url) public function setReturnToUrl($url)
{ {
$this->set('thelia.return_to_url', $url); $this->set('thelia.return_to_url', $url);
return $this; return $this;
} }
@@ -180,6 +183,7 @@ class Session extends BaseSession
public function setCart($cart_id) public function setCart($cart_id)
{ {
$this->set("thelia.cart_id", $cart_id); $this->set("thelia.cart_id", $cart_id);
return $this; return $this;
} }
@@ -192,6 +196,7 @@ class Session extends BaseSession
public function setDelivery($delivery_id) public function setDelivery($delivery_id)
{ {
$this->set("thelia.delivery_id", $delivery_id); $this->set("thelia.delivery_id", $delivery_id);
return $this; return $this;
} }
@@ -199,4 +204,4 @@ class Session extends BaseSession
{ {
return $this->get("thelia.delivery_id"); return $this->get("thelia.delivery_id");
} }
} }

View File

@@ -38,7 +38,6 @@ use Thelia\Model\ConfigQuery;
use Thelia\Tools\Redirect; use Thelia\Tools\Redirect;
use Thelia\Tools\URL; use Thelia\Tools\URL;
/** /**
* Class RewritingRouter * Class RewritingRouter
* @package Thelia\Core\Routing * @package Thelia\Core\Routing
@@ -114,8 +113,8 @@ class RewritingRouter implements RouterInterface, RequestMatcherInterface
* *
* If there is no route with the given name, the generator must throw the RouteNotFoundException. * If there is no route with the given name, the generator must throw the RouteNotFoundException.
* *
* @param string $name The name of the route * @param string $name The name of the route
* @param mixed $parameters An array of parameters * @param mixed $parameters An array of parameters
* @param Boolean|string $referenceType The type of reference to be generated (one of the constants) * @param Boolean|string $referenceType The type of reference to be generated (one of the constants)
* *
* @return string The generated URL * @return string The generated URL
@@ -163,16 +162,16 @@ class RewritingRouter implements RouterInterface, RequestMatcherInterface
* @throws \Exception|\Thelia\Exception\UrlRewritingException * @throws \Exception|\Thelia\Exception\UrlRewritingException
* @throws \Symfony\Component\Routing\Exception\ResourceNotFoundException * @throws \Symfony\Component\Routing\Exception\ResourceNotFoundException
* @throws \Thelia\Exception\RedirectException * @throws \Thelia\Exception\RedirectException
* @return array An array of parameters * @return array An array of parameters
* *
*/ */
public function matchRequest(Request $request) public function matchRequest(Request $request)
{ {
if(ConfigQuery::isRewritingEnable()) { if (ConfigQuery::isRewritingEnable()) {
try { try {
$rewrittenUrlData = URL::getInstance()->resolve($request->getPathInfo()); $rewrittenUrlData = URL::getInstance()->resolve($request->getPathInfo());
} catch(UrlRewritingException $e) { } catch (UrlRewritingException $e) {
switch($e->getCode()) { switch ($e->getCode()) {
case UrlRewritingException::URL_NOT_FOUND : case UrlRewritingException::URL_NOT_FOUND :
throw new ResourceNotFoundException(); throw new ResourceNotFoundException();
break; break;
@@ -183,23 +182,23 @@ class RewritingRouter implements RouterInterface, RequestMatcherInterface
/* is the URL redirected ? */ /* is the URL redirected ? */
if(null !== $rewrittenUrlData->redirectedToUrl) { if (null !== $rewrittenUrlData->redirectedToUrl) {
$this->redirect($rewrittenUrlData->redirectedToUrl, 301); $this->redirect($rewrittenUrlData->redirectedToUrl, 301);
} }
/* define GET arguments in request */ /* define GET arguments in request */
if(null !== $rewrittenUrlData->view) { if (null !== $rewrittenUrlData->view) {
$request->attributes->set('_view', $rewrittenUrlData->view); $request->attributes->set('_view', $rewrittenUrlData->view);
if(null !== $rewrittenUrlData->viewId) { if (null !== $rewrittenUrlData->viewId) {
$request->query->set($rewrittenUrlData->view . '_id', $rewrittenUrlData->viewId); $request->query->set($rewrittenUrlData->view . '_id', $rewrittenUrlData->viewId);
} }
} }
if(null !== $rewrittenUrlData->locale) { if (null !== $rewrittenUrlData->locale) {
$request->query->set('locale', $rewrittenUrlData->locale); $request->query->set('locale', $rewrittenUrlData->locale);
} }
foreach($rewrittenUrlData->otherParameters as $parameter => $value) { foreach ($rewrittenUrlData->otherParameters as $parameter => $value) {
$request->query->set($parameter, $value); $request->query->set($parameter, $value);
} }
@@ -216,4 +215,4 @@ class RewritingRouter implements RouterInterface, RequestMatcherInterface
{ {
Redirect::exec($url, $status); Redirect::exec($url, $status);
} }
} }

View File

@@ -93,12 +93,12 @@ class SecurityContext
/** /**
* Check if a user has at least one of the required roles * Check if a user has at least one of the required roles
* *
* @param UserInterface $user the user * @param UserInterface $user the user
* @param array $roles the roles * @param array $roles the roles
* @return boolean true if the user has the required role, false otherwise * @return boolean true if the user has the required role, false otherwise
*/ */
final public function hasRequiredRole($user, array $roles) { final public function hasRequiredRole($user, array $roles)
{
if ($user != null) { if ($user != null) {
// Check if user's roles matches required roles // Check if user's roles matches required roles
$userRoles = $user->getRoles(); $userRoles = $user->getRoles();
@@ -208,4 +208,4 @@ class SecurityContext
{ {
$this->getSession()->clearAdminUser(); $this->getSession()->clearAdminUser();
} }
} }

View File

@@ -29,8 +29,6 @@ use Assetic\Filter;
use Assetic\Factory\AssetFactory; use Assetic\Factory\AssetFactory;
use Assetic\Factory\Worker\CacheBustingWorker; use Assetic\Factory\Worker\CacheBustingWorker;
use Assetic\AssetWriter; use Assetic\AssetWriter;
use Assetic\Asset\AssetCache;
use Assetic\Cache\FilesystemCache;
/** /**
* This class is a simple helper for generating assets using Assetic. * This class is a simple helper for generating assets using Assetic.
@@ -139,8 +137,7 @@ class AsseticHelper
foreach ($filter_list as $filter) { foreach ($filter_list as $filter) {
if ('?' != $filter[0]) { if ('?' != $filter[0]) {
$asset->ensureFilter($fm->get($filter)); $asset->ensureFilter($fm->get($filter));
} } elseif (!$debug) {
elseif (!$debug) {
$asset->ensureFilter($fm->get(substr($filter, 1))); $asset->ensureFilter($fm->get(substr($filter, 1)));
} }
} }

View File

@@ -24,10 +24,8 @@
namespace Thelia\Core\Template\Element; namespace Thelia\Core\Template\Element;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Core\Template\Loop\Argument\Argument;
use Propel\Runtime\ActiveQuery\ModelCriteria; use Propel\Runtime\ActiveQuery\ModelCriteria;
use Thelia\Core\Security\SecurityContext;
use Thelia\Model\Tools\ModelCriteriaTools; use Thelia\Model\Tools\ModelCriteriaTools;
/** /**
@@ -55,10 +53,10 @@ abstract class BaseI18nLoop extends BaseLoop
/** /**
* Setup ModelCriteria for proper i18n processing * Setup ModelCriteria for proper i18n processing
* *
* @param ModelCriteria $search the Propel Criteria to configure * @param ModelCriteria $search the Propel Criteria to configure
* @param array $columns the i18n columns * @param array $columns the i18n columns
* @param string $foreignTable the specified table (default to criteria table) * @param string $foreignTable the specified table (default to criteria table)
* @param string $foreignKey the foreign key in this table (default to criteria table) * @param string $foreignKey the foreign key in this table (default to criteria table)
* @param bool $forceReturn * @param bool $forceReturn
* *
* @return mixed the locale * @return mixed the locale
@@ -66,6 +64,7 @@ abstract class BaseI18nLoop extends BaseLoop
protected function configureI18nProcessing(ModelCriteria $search, $columns = array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'), $foreignTable = null, $foreignKey = 'ID', $forceReturn = false) protected function configureI18nProcessing(ModelCriteria $search, $columns = array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'), $foreignTable = null, $foreignKey = 'ID', $forceReturn = false)
{ {
/* manage translations */ /* manage translations */
return ModelCriteriaTools::getI18n( return ModelCriteriaTools::getI18n(
$this->getBackend_context(), $this->getBackend_context(),
$this->getLang(), $this->getLang(),
@@ -77,4 +76,4 @@ abstract class BaseI18nLoop extends BaseLoop
$forceReturn $forceReturn
); );
} }
} }

View File

@@ -29,7 +29,6 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Core\Template\Loop\Argument\Argument;
use Propel\Runtime\ActiveQuery\ModelCriteria; use Propel\Runtime\ActiveQuery\ModelCriteria;
use Thelia\Core\Security\SecurityContext; use Thelia\Core\Security\SecurityContext;
use Thelia\Model\Tools\ModelCriteriaTools;
/** /**
* *

View File

@@ -37,7 +37,7 @@ class LoopResult implements \Iterator
public function __construct($modelCollection = null) public function __construct($modelCollection = null)
{ {
$this->position = 0; $this->position = 0;
if($modelCollection instanceof ObjectCollection || $modelCollection instanceof PropelModelPager) { if ($modelCollection instanceof ObjectCollection || $modelCollection instanceof PropelModelPager) {
$this->modelCollection = $modelCollection; $this->modelCollection = $modelCollection;
} }
} }

View File

@@ -38,14 +38,14 @@ class LoopResultRow
public function __construct($loopResult = null, $model = null, $versionable = false, $timestampable = false, $countable = true) public function __construct($loopResult = null, $model = null, $versionable = false, $timestampable = false, $countable = true)
{ {
if($model instanceof ActiveRecordInterface) { if ($model instanceof ActiveRecordInterface) {
$this->model = $model; $this->model = $model;
$this->versionable = $versionable; $this->versionable = $versionable;
$this->timestampable = $timestampable; $this->timestampable = $timestampable;
} }
if($loopResult instanceof LoopResult) { if ($loopResult instanceof LoopResult) {
$this->loopResult = $loopResult; $this->loopResult = $loopResult;
$this->countable = $countable; $this->countable = $countable;
@@ -95,17 +95,17 @@ class LoopResultRow
protected function assignDefaultOutputs() protected function assignDefaultOutputs()
{ {
if(true === $this->versionable) { if (true === $this->versionable) {
foreach($this->getVersionOutputs() as $output) { foreach ($this->getVersionOutputs() as $output) {
$this->set($output[0], $this->model->$output[1]()); $this->set($output[0], $this->model->$output[1]());
} }
} }
if(true === $this->timestampable) { if (true === $this->timestampable) {
foreach($this->getTimestampOutputs() as $output) { foreach ($this->getTimestampOutputs() as $output) {
$this->set($output[0], $this->model->$output[1]()); $this->set($output[0], $this->model->$output[1]());
} }
} }
if(true === $this->countable) { if (true === $this->countable) {
$this->set('LOOP_COUNT', 1 + $this->loopResult->getCount()); $this->set('LOOP_COUNT', 1 + $this->loopResult->getCount());
$this->set('LOOP_TOTAL', $this->loopResult->modelCollection->count()); $this->set('LOOP_TOTAL', $this->loopResult->modelCollection->count());
} }

View File

@@ -24,7 +24,6 @@
namespace Thelia\Core\Template\Loop; namespace Thelia\Core\Template\Loop;
use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\Collection\ObjectCollection;
use Thelia\Core\Template\Element\BaseLoop; use Thelia\Core\Template\Element\BaseLoop;
use Thelia\Core\Template\Element\LoopResult; use Thelia\Core\Template\Element\LoopResult;
use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Element\LoopResultRow;
@@ -48,7 +47,7 @@ use Thelia\Type;
class Address extends BaseLoop class Address extends BaseLoop
{ {
public $timestampable = true; public $timestampable = true;
/** /**
* @return ArgumentCollection * @return ArgumentCollection
*/ */
@@ -99,7 +98,6 @@ class Address extends BaseLoop
$default = $this->getDefault(); $default = $this->getDefault();
if ($default === true) { if ($default === true) {
$search->filterByIsDefault(1, Criteria::EQUAL); $search->filterByIsDefault(1, Criteria::EQUAL);
} }

View File

@@ -77,15 +77,15 @@ class AssociatedContent extends Content
$product = $this->getProduct(); $product = $this->getProduct();
$category = $this->getCategory(); $category = $this->getCategory();
if($product === null && $category === null) { if ($product === null && $category === null) {
throw new \InvalidArgumentException('You have to provide either `product` or `category` argument in associated_content loop'); throw new \InvalidArgumentException('You have to provide either `product` or `category` argument in associated_content loop');
} }
if($product !== null) { if ($product !== null) {
$search = ProductAssociatedContentQuery::create(); $search = ProductAssociatedContentQuery::create();
$search->filterByProductId($product, Criteria::EQUAL); $search->filterByProductId($product, Criteria::EQUAL);
} elseif($category !== null) { } elseif ($category !== null) {
$search = CategoryAssociatedContentQuery::create(); $search = CategoryAssociatedContentQuery::create();
$search->filterByCategoryId($category, Criteria::EQUAL); $search->filterByCategoryId($category, Criteria::EQUAL);

View File

@@ -24,21 +24,16 @@
namespace Thelia\Core\Template\Loop; namespace Thelia\Core\Template\Loop;
use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\ActiveQuery\Join;
use Thelia\Core\Template\Element\BaseI18nLoop; use Thelia\Core\Template\Element\BaseI18nLoop;
use Thelia\Core\Template\Element\LoopResult; use Thelia\Core\Template\Element\LoopResult;
use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Log\Tlog;
use Thelia\Model\Base\LangQuery;
use Thelia\Model\Base\CategoryQuery; use Thelia\Model\Base\CategoryQuery;
use Thelia\Model\Base\ProductCategoryQuery; use Thelia\Model\Base\ProductCategoryQuery;
use Thelia\Model\Base\AttributeQuery; use Thelia\Model\Base\AttributeQuery;
use Thelia\Model\ConfigQuery;
use Thelia\Model\Map\ProductCategoryTableMap; use Thelia\Model\Map\ProductCategoryTableMap;
use Thelia\Type\TypeCollection; use Thelia\Type\TypeCollection;
use Thelia\Type; use Thelia\Type;
@@ -113,17 +108,17 @@ class Attribute extends BaseI18nLoop
$product = $this->getProduct(); $product = $this->getProduct();
$category = $this->getCategory(); $category = $this->getCategory();
if(null !== $product) { if (null !== $product) {
$productCategories = ProductCategoryQuery::create()->select(array(ProductCategoryTableMap::CATEGORY_ID))->filterByProductId($product, Criteria::IN)->find()->getData(); $productCategories = ProductCategoryQuery::create()->select(array(ProductCategoryTableMap::CATEGORY_ID))->filterByProductId($product, Criteria::IN)->find()->getData();
if(null === $category) { if (null === $category) {
$category = $productCategories; $category = $productCategories;
} else { } else {
$category = array_merge($category, $productCategories); $category = array_merge($category, $productCategories);
} }
} }
if(null !== $category) { if (null !== $category) {
$search->filterByCategory( $search->filterByCategory(
CategoryQuery::create()->filterById($category)->find(), CategoryQuery::create()->filterById($category)->find(),
Criteria::IN Criteria::IN
@@ -132,7 +127,7 @@ class Attribute extends BaseI18nLoop
$orders = $this->getOrder(); $orders = $this->getOrder();
foreach($orders as $order) { foreach ($orders as $order) {
switch ($order) { switch ($order) {
case "alpha": case "alpha":
$search->addAscendingOrderByColumn('i18n_TITLE'); $search->addAscendingOrderByColumn('i18n_TITLE');
@@ -170,4 +165,4 @@ class Attribute extends BaseI18nLoop
return $loopResult; return $loopResult;
} }
} }

View File

@@ -24,17 +24,14 @@
namespace Thelia\Core\Template\Loop; namespace Thelia\Core\Template\Loop;
use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\ActiveQuery\Join;
use Thelia\Core\Template\Element\BaseI18nLoop; use Thelia\Core\Template\Element\BaseI18nLoop;
use Thelia\Core\Template\Element\LoopResult; use Thelia\Core\Template\Element\LoopResult;
use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Log\Tlog;
use Thelia\Model\Base\AttributeAvQuery; use Thelia\Model\Base\AttributeAvQuery;
use Thelia\Model\ConfigQuery;
use Thelia\Type\TypeCollection; use Thelia\Type\TypeCollection;
use Thelia\Type; use Thelia\Type;
@@ -95,13 +92,13 @@ class AttributeAvailability extends BaseI18nLoop
$attribute = $this->getAttribute(); $attribute = $this->getAttribute();
if(null !== $attribute) { if (null !== $attribute) {
$search->filterByAttributeId($attribute, Criteria::IN); $search->filterByAttributeId($attribute, Criteria::IN);
} }
$orders = $this->getOrder(); $orders = $this->getOrder();
foreach($orders as $order) { foreach ($orders as $order) {
switch ($order) { switch ($order) {
case "alpha": case "alpha":
$search->addAscendingOrderByColumn('i18n_TITLE'); $search->addAscendingOrderByColumn('i18n_TITLE');
@@ -139,4 +136,4 @@ class AttributeAvailability extends BaseI18nLoop
return $loopResult; return $loopResult;
} }
} }

View File

@@ -24,19 +24,16 @@
namespace Thelia\Core\Template\Loop; namespace Thelia\Core\Template\Loop;
use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\ActiveQuery\Join;
use Thelia\Core\Template\Element\BaseI18nLoop; use Thelia\Core\Template\Element\BaseI18nLoop;
use Thelia\Core\Template\Element\LoopResult; use Thelia\Core\Template\Element\LoopResult;
use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Log\Tlog;
use Thelia\Model\Base\AttributeCombinationQuery; use Thelia\Model\Base\AttributeCombinationQuery;
use Thelia\Model\Map\AttributeAvTableMap; use Thelia\Model\Map\AttributeAvTableMap;
use Thelia\Model\Map\AttributeTableMap; use Thelia\Model\Map\AttributeTableMap;
use Thelia\Model\ConfigQuery;
use Thelia\Type\TypeCollection; use Thelia\Type\TypeCollection;
use Thelia\Type; use Thelia\Type;
@@ -100,7 +97,7 @@ class AttributeCombination extends BaseI18nLoop
$orders = $this->getOrder(); $orders = $this->getOrder();
foreach($orders as $order) { foreach ($orders as $order) {
switch ($order) { switch ($order) {
case "alpha": case "alpha":
$search->addAscendingOrderByColumn(AttributeTableMap::TABLE_NAME . '_i18n_TITLE'); $search->addAscendingOrderByColumn(AttributeTableMap::TABLE_NAME . '_i18n_TITLE');
@@ -134,4 +131,4 @@ class AttributeCombination extends BaseI18nLoop
return $loopResult; return $loopResult;
} }
} }

View File

@@ -28,13 +28,13 @@ use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Model\ModuleQuery; use Thelia\Model\ModuleQuery;
/** /**
* Class Delivery * Class Delivery
* @package Thelia\Core\Template\Loop * @package Thelia\Core\Template\Loop
* @author Manuel Raynaud <mraynaud@openstudio.fr> * @author Manuel Raynaud <mraynaud@openstudio.fr>
*/ */
class BaseSpecificModule extends BaseI18nLoop { class BaseSpecificModule extends BaseI18nLoop
{
public $timestampable = true; public $timestampable = true;
/** /**
@@ -93,12 +93,10 @@ class BaseSpecificModule extends BaseI18nLoop {
{ {
$search = ModuleQuery::create(); $search = ModuleQuery::create();
if(null !== $id = $this->getId()) if (null !== $id = $this->getId()) {
{
$search->filterById($id); $search->filterById($id);
} }
if (null !== $exclude = $this->getExclude()) { if (null !== $exclude = $this->getExclude()) {
$search->filterById($exclude, Criteria::NOT_IN); $search->filterById($exclude, Criteria::NOT_IN);
} }
@@ -106,4 +104,4 @@ class BaseSpecificModule extends BaseI18nLoop {
return $search; return $search;
} }
} }

View File

@@ -72,8 +72,6 @@ class Cart extends BaseLoop
public function exec(&$pagination) public function exec(&$pagination)
{ {
$cart = $this->getCart($this->request); $cart = $this->getCart($this->request);
$cartItems = $cart->getCartItems(); $cartItems = $cart->getCartItems();
$result = new LoopResult($cartItems); $result = new LoopResult($cartItems);

View File

@@ -30,10 +30,8 @@ use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Log\Tlog;
use Thelia\Model\CategoryQuery; use Thelia\Model\CategoryQuery;
use Thelia\Model\ConfigQuery;
use Thelia\Type\TypeCollection; use Thelia\Type\TypeCollection;
use Thelia\Type; use Thelia\Type;
use Thelia\Type\BooleanOrBothType; use Thelia\Type\BooleanOrBothType;
@@ -101,7 +99,7 @@ class Category extends BaseI18nLoop
/* manage translations */ /* manage translations */
$locale = $this->configureI18nProcessing($search); $locale = $this->configureI18nProcessing($search);
$id = $this->getId(); $id = $this->getId();
if (!is_null($id)) { if (!is_null($id)) {
$search->filterById($id, Criteria::IN); $search->filterById($id, Criteria::IN);
@@ -113,8 +111,7 @@ class Category extends BaseI18nLoop
$search->filterByParent($parent); $search->filterByParent($parent);
} }
$current = $this->getCurrent();
$current = $this->getCurrent();
if ($current === true) { if ($current === true) {
$search->filterById($this->request->get("category_id")); $search->filterById($this->request->get("category_id"));
@@ -122,7 +119,6 @@ class Category extends BaseI18nLoop
$search->filterById($this->request->get("category_id"), Criteria::NOT_IN); $search->filterById($this->request->get("category_id"), Criteria::NOT_IN);
} }
$exclude = $this->getExclude(); $exclude = $this->getExclude();
if (!is_null($exclude)) { if (!is_null($exclude)) {
@@ -130,11 +126,11 @@ class Category extends BaseI18nLoop
} }
if ($this->getVisible() != BooleanOrBothType::ANY) if ($this->getVisible() != BooleanOrBothType::ANY)
$search->filterByVisible($this->getVisible() ? 1 : 0); $search->filterByVisible($this->getVisible() ? 1 : 0);
$orders = $this->getOrder(); $orders = $this->getOrder();
foreach($orders as $order) { foreach ($orders as $order) {
switch ($order) { switch ($order) {
case "alpha": case "alpha":
$search->addAscendingOrderByColumn('i18n_TITLE'); $search->addAscendingOrderByColumn('i18n_TITLE');
@@ -179,23 +175,23 @@ class Category extends BaseI18nLoop
$loopResultRow = new LoopResultRow($loopResult, $category, $this->versionable, $this->timestampable, $this->countable); $loopResultRow = new LoopResultRow($loopResult, $category, $this->versionable, $this->timestampable, $this->countable);
$loopResultRow $loopResultRow
->set("ID", $category->getId()) ->set("ID", $category->getId())
->set("IS_TRANSLATED",$category->getVirtualColumn('IS_TRANSLATED')) ->set("IS_TRANSLATED",$category->getVirtualColumn('IS_TRANSLATED'))
->set("LOCALE",$locale) ->set("LOCALE",$locale)
->set("TITLE", $category->getVirtualColumn('i18n_TITLE')) ->set("TITLE", $category->getVirtualColumn('i18n_TITLE'))
->set("CHAPO", $category->getVirtualColumn('i18n_CHAPO')) ->set("CHAPO", $category->getVirtualColumn('i18n_CHAPO'))
->set("DESCRIPTION", $category->getVirtualColumn('i18n_DESCRIPTION')) ->set("DESCRIPTION", $category->getVirtualColumn('i18n_DESCRIPTION'))
->set("POSTSCRIPTUM", $category->getVirtualColumn('i18n_POSTSCRIPTUM')) ->set("POSTSCRIPTUM", $category->getVirtualColumn('i18n_POSTSCRIPTUM'))
->set("PARENT", $category->getParent()) ->set("PARENT", $category->getParent())
->set("URL", $category->getUrl($locale)) ->set("URL", $category->getUrl($locale))
->set("PRODUCT_COUNT", $category->countChild()) ->set("PRODUCT_COUNT", $category->countChild())
->set("VISIBLE", $category->getVisible() ? "1" : "0") ->set("VISIBLE", $category->getVisible() ? "1" : "0")
->set("POSITION", $category->getPosition()) ->set("POSITION", $category->getPosition())
; ;
$loopResult->addRow($loopResultRow); $loopResult->addRow($loopResultRow);
} }
return $loopResult; return $loopResult;
} }
} }

View File

@@ -30,7 +30,6 @@ use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Model\LangQuery;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Model\ConfigQuery; use Thelia\Model\ConfigQuery;
use Thelia\Type\BooleanOrBothType; use Thelia\Type\BooleanOrBothType;
@@ -114,7 +113,7 @@ class Config extends BaseI18nLoop
$orders = $this->getOrder(); $orders = $this->getOrder();
foreach($orders as $order) { foreach ($orders as $order) {
switch ($order) { switch ($order) {
case 'id': case 'id':
$search->orderById(Criteria::ASC); $search->orderById(Criteria::ASC);

View File

@@ -35,7 +35,6 @@ use Thelia\Model\FolderQuery;
use Thelia\Model\Map\ContentTableMap; use Thelia\Model\Map\ContentTableMap;
use Thelia\Model\ContentFolderQuery; use Thelia\Model\ContentFolderQuery;
use Thelia\Model\ContentQuery; use Thelia\Model\ContentQuery;
use Thelia\Model\ConfigQuery;
use Thelia\Type\TypeCollection; use Thelia\Type\TypeCollection;
use Thelia\Type; use Thelia\Type;
use Thelia\Type\BooleanOrBothType; use Thelia\Type\BooleanOrBothType;

View File

@@ -32,7 +32,6 @@ use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Model\CountryQuery; use Thelia\Model\CountryQuery;
use Thelia\Model\ConfigQuery;
/** /**
* *

View File

@@ -34,13 +34,9 @@ use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Model\Base\CategoryQuery;
use Thelia\Model\ConfigQuery;
use Thelia\Model\CouponQuery; use Thelia\Model\CouponQuery;
use Thelia\Model\Coupon as MCoupon; use Thelia\Model\Coupon as MCoupon;
use Thelia\Model\Map\ProductCategoryTableMap;
use Thelia\Type; use Thelia\Type;
use Thelia\Type\BooleanOrBothType;
/** /**
* Created by JetBrains PhpStorm. * Created by JetBrains PhpStorm.
@@ -95,7 +91,6 @@ class Coupon extends BaseI18nLoop
/** @var Lang $lang */ /** @var Lang $lang */
$lang = $request->getSession()->getLang(); $lang = $request->getSession()->getLang();
/** @var MCoupon $coupon */ /** @var MCoupon $coupon */
foreach ($coupons as $coupon) { foreach ($coupons as $coupon) {
$loopResultRow = new LoopResultRow(); $loopResultRow = new LoopResultRow();

View File

@@ -32,7 +32,6 @@ use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Model\CurrencyQuery; use Thelia\Model\CurrencyQuery;
use Thelia\Model\ConfigQuery;
use Thelia\Type\TypeCollection; use Thelia\Type\TypeCollection;
use Thelia\Type\EnumListType; use Thelia\Type\EnumListType;
@@ -109,7 +108,7 @@ class Currency extends BaseI18nLoop
$orders = $this->getOrder(); $orders = $this->getOrder();
foreach($orders as $order) { foreach ($orders as $order) {
switch ($order) { switch ($order) {
case 'id': case 'id':
$search->orderById(Criteria::ASC); $search->orderById(Criteria::ASC);

View File

@@ -24,7 +24,6 @@
namespace Thelia\Core\Template\Loop; namespace Thelia\Core\Template\Loop;
use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\Collection\ObjectCollection;
use Thelia\Core\Template\Element\BaseLoop; use Thelia\Core\Template\Element\BaseLoop;
use Thelia\Core\Template\Element\LoopResult; use Thelia\Core\Template\Element\LoopResult;
use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Element\LoopResultRow;
@@ -48,7 +47,7 @@ use Thelia\Type;
class Customer extends BaseLoop class Customer extends BaseLoop
{ {
public $timestampable = true; public $timestampable = true;
/** /**
* @return ArgumentCollection * @return ArgumentCollection
*/ */

View File

@@ -26,7 +26,6 @@ use Thelia\Core\Template\Element\LoopResult;
use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Core\Template\Loop\Argument\Argument;
/** /**
* Class Delivery * Class Delivery
* @package Thelia\Core\Template\Loop * @package Thelia\Core\Template\Loop
@@ -60,7 +59,7 @@ class Delivery extends BaseSpecificModule
$loopResultRow = new LoopResultRow($loopResult, $deliveryModule, $this->versionable, $this->timestampable, $this->countable); $loopResultRow = new LoopResultRow($loopResult, $deliveryModule, $this->versionable, $this->timestampable, $this->countable);
$moduleReflection = new \ReflectionClass($deliveryModule->getFullNamespace()); $moduleReflection = new \ReflectionClass($deliveryModule->getFullNamespace());
if($moduleReflection->isSubclassOf("Thelia\Module\DeliveryModuleInterface") === false) { if ($moduleReflection->isSubclassOf("Thelia\Module\DeliveryModuleInterface") === false) {
throw new \RuntimeException(sprintf("delivery module %s is not a Thelia\Module\DeliveryModuleInterface", $deliveryModule->getCode())); throw new \RuntimeException(sprintf("delivery module %s is not a Thelia\Module\DeliveryModuleInterface", $deliveryModule->getCode()));
} }
$moduleInstance = $moduleReflection->newInstance(); $moduleInstance = $moduleReflection->newInstance();
@@ -82,4 +81,4 @@ class Delivery extends BaseSpecificModule
return $loopResult; return $loopResult;
} }
} }

View File

@@ -34,7 +34,6 @@ use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Model\Base\CategoryQuery; use Thelia\Model\Base\CategoryQuery;
use Thelia\Model\Base\ProductCategoryQuery; use Thelia\Model\Base\ProductCategoryQuery;
use Thelia\Model\Base\FeatureQuery; use Thelia\Model\Base\FeatureQuery;
use Thelia\Model\ConfigQuery;
use Thelia\Model\Map\ProductCategoryTableMap; use Thelia\Model\Map\ProductCategoryTableMap;
use Thelia\Type\TypeCollection; use Thelia\Type\TypeCollection;
use Thelia\Type; use Thelia\Type;

View File

@@ -32,7 +32,6 @@ use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Model\Base\FeatureAvQuery; use Thelia\Model\Base\FeatureAvQuery;
use Thelia\Model\ConfigQuery;
use Thelia\Type\TypeCollection; use Thelia\Type\TypeCollection;
use Thelia\Type; use Thelia\Type;

View File

@@ -24,19 +24,15 @@
namespace Thelia\Core\Template\Loop; namespace Thelia\Core\Template\Loop;
use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\ActiveQuery\Join;
use Thelia\Core\Template\Element\BaseI18nLoop; use Thelia\Core\Template\Element\BaseI18nLoop;
use Thelia\Core\Template\Element\LoopResult; use Thelia\Core\Template\Element\LoopResult;
use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Log\Tlog;
use Thelia\Model\Base\FeatureProductQuery; use Thelia\Model\Base\FeatureProductQuery;
use Thelia\Model\ConfigQuery;
use Thelia\Model\Map\FeatureAvTableMap; use Thelia\Model\Map\FeatureAvTableMap;
use Thelia\Model\Map\FeatureProductTableMap;
use Thelia\Type\TypeCollection; use Thelia\Type\TypeCollection;
use Thelia\Type; use Thelia\Type;
@@ -107,18 +103,18 @@ class FeatureValue extends BaseI18nLoop
} }
$excludeFeatureAvailability = $this->getExclude_feature_availability(); $excludeFeatureAvailability = $this->getExclude_feature_availability();
if($excludeFeatureAvailability == true) { if ($excludeFeatureAvailability == true) {
$search->filterByFeatureAvId(null, Criteria::NULL); $search->filterByFeatureAvId(null, Criteria::NULL);
} }
$excludeDefaultValues = $this->getExclude_personal_values(); $excludeDefaultValues = $this->getExclude_personal_values();
if($excludeDefaultValues == true) { if ($excludeDefaultValues == true) {
$search->filterByByDefault(null, Criteria::NULL); $search->filterByByDefault(null, Criteria::NULL);
} }
$orders = $this->getOrder(); $orders = $this->getOrder();
foreach($orders as $order) { foreach ($orders as $order) {
switch ($order) { switch ($order) {
case "alpha": case "alpha":
$search->addAscendingOrderByColumn(FeatureAvTableMap::TABLE_NAME . '_i18n_TITLE'); $search->addAscendingOrderByColumn(FeatureAvTableMap::TABLE_NAME . '_i18n_TITLE');
@@ -157,4 +153,4 @@ class FeatureValue extends BaseI18nLoop
return $loopResult; return $loopResult;
} }
} }

View File

@@ -30,10 +30,8 @@ use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Log\Tlog;
use Thelia\Model\FolderQuery; use Thelia\Model\FolderQuery;
use Thelia\Model\ConfigQuery;
use Thelia\Type\TypeCollection; use Thelia\Type\TypeCollection;
use Thelia\Type; use Thelia\Type;
use Thelia\Type\BooleanOrBothType; use Thelia\Type\BooleanOrBothType;
@@ -83,7 +81,7 @@ class Folder extends BaseI18nLoop
/* manage translations */ /* manage translations */
$locale = $this->configureI18nProcessing($search); $locale = $this->configureI18nProcessing($search);
$id = $this->getId(); $id = $this->getId();
if (!is_null($id)) { if (!is_null($id)) {
$search->filterById($id, Criteria::IN); $search->filterById($id, Criteria::IN);
@@ -95,8 +93,7 @@ class Folder extends BaseI18nLoop
$search->filterByParent($parent); $search->filterByParent($parent);
} }
$current = $this->getCurrent();
$current = $this->getCurrent();
if ($current === true) { if ($current === true) {
$search->filterById($this->request->get("folder_id")); $search->filterById($this->request->get("folder_id"));
@@ -104,7 +101,6 @@ class Folder extends BaseI18nLoop
$search->filterById($this->request->get("folder_id"), Criteria::NOT_IN); $search->filterById($this->request->get("folder_id"), Criteria::NOT_IN);
} }
$exclude = $this->getExclude(); $exclude = $this->getExclude();
if (!is_null($exclude)) { if (!is_null($exclude)) {
@@ -117,7 +113,7 @@ class Folder extends BaseI18nLoop
$orders = $this->getOrder(); $orders = $this->getOrder();
foreach($orders as $order) { foreach ($orders as $order) {
switch ($order) { switch ($order) {
case "alpha": case "alpha":
$search->addAscendingOrderByColumn('i18n_TITLE'); $search->addAscendingOrderByColumn('i18n_TITLE');
@@ -157,23 +153,23 @@ class Folder extends BaseI18nLoop
$loopResultRow = new LoopResultRow($loopResult, $folder, $this->versionable, $this->timestampable, $this->countable); $loopResultRow = new LoopResultRow($loopResult, $folder, $this->versionable, $this->timestampable, $this->countable);
$loopResultRow $loopResultRow
->set("ID", $folder->getId()) ->set("ID", $folder->getId())
->set("IS_TRANSLATED",$folder->getVirtualColumn('IS_TRANSLATED')) ->set("IS_TRANSLATED",$folder->getVirtualColumn('IS_TRANSLATED'))
->set("LOCALE",$locale) ->set("LOCALE",$locale)
->set("TITLE",$folder->getVirtualColumn('i18n_TITLE')) ->set("TITLE",$folder->getVirtualColumn('i18n_TITLE'))
->set("CHAPO", $folder->getVirtualColumn('i18n_CHAPO')) ->set("CHAPO", $folder->getVirtualColumn('i18n_CHAPO'))
->set("DESCRIPTION", $folder->getVirtualColumn('i18n_DESCRIPTION')) ->set("DESCRIPTION", $folder->getVirtualColumn('i18n_DESCRIPTION'))
->set("POSTSCRIPTUM", $folder->getVirtualColumn('i18n_POSTSCRIPTUM')) ->set("POSTSCRIPTUM", $folder->getVirtualColumn('i18n_POSTSCRIPTUM'))
->set("PARENT", $folder->getParent()) ->set("PARENT", $folder->getParent())
->set("URL", $folder->getUrl($locale)) ->set("URL", $folder->getUrl($locale))
->set("CONTENT_COUNT", $folder->countChild()) ->set("CONTENT_COUNT", $folder->countChild())
->set("VISIBLE", $folder->getVisible() ? "1" : "0") ->set("VISIBLE", $folder->getVisible() ? "1" : "0")
->set("POSITION", $folder->getPosition()) ->set("POSITION", $folder->getPosition())
; ;
$loopResult->addRow($loopResultRow); $loopResult->addRow($loopResultRow);
} }
return $loopResult; return $loopResult;
} }
} }

View File

@@ -25,8 +25,6 @@ namespace Thelia\Core\Template\Loop;
use Thelia\Core\Template\Element\BaseI18nLoop; use Thelia\Core\Template\Element\BaseI18nLoop;
use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Core\Event\ImageEvent; use Thelia\Core\Event\ImageEvent;
use Thelia\Model\CategoryImageQuery;
use Thelia\Model\ProductImageQuery;
use Thelia\Core\Event\TheliaEvents; use Thelia\Core\Event\TheliaEvents;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Type\TypeCollection; use Thelia\Type\TypeCollection;
@@ -99,7 +97,7 @@ class Image extends BaseI18nLoop
); );
// Add possible image sources // Add possible image sources
foreach($this->possible_sources as $source) { foreach ($this->possible_sources as $source) {
$collection->addArgument(Argument::createIntTypeArgument($source)); $collection->addArgument(Argument::createIntTypeArgument($source));
} }
@@ -109,12 +107,12 @@ class Image extends BaseI18nLoop
/** /**
* Dynamically create the search query, and set the proper filter and order * Dynamically create the search query, and set the proper filter and order
* *
* @param string $source a valid source identifier (@see $possible_sources) * @param string $source a valid source identifier (@see $possible_sources)
* @param int $object_id the source object ID * @param int $object_id the source object ID
* @return ModelCriteria the propel Query object * @return ModelCriteria the propel Query object
*/ */
protected function createSearchQuery($source, $object_id) { protected function createSearchQuery($source, $object_id)
{
$object = ucfirst($source); $object = ucfirst($source);
$queryClass = sprintf("\Thelia\Model\%sImageQuery", $object); $queryClass = sprintf("\Thelia\Model\%sImageQuery", $object);
@@ -159,12 +157,12 @@ class Image extends BaseI18nLoop
/** /**
* Dynamically create the search query, and set the proper filter and order * Dynamically create the search query, and set the proper filter and order
* *
* @param string $object_type (returned) the a valid source identifier (@see $possible_sources) * @param string $object_type (returned) the a valid source identifier (@see $possible_sources)
* @param string $object_id (returned) the ID of the source object * @param string $object_id (returned) the ID of the source object
* @return ModelCriteria the propel Query object * @return ModelCriteria the propel Query object
*/ */
protected function getSearchQuery(&$object_type, &$object_id) { protected function getSearchQuery(&$object_type, &$object_id)
{
$search = null; $search = null;
// Check form source="product" source_id="123" style arguments // Check form source="product" source_id="123" style arguments
@@ -184,10 +182,9 @@ class Image extends BaseI18nLoop
$object_type = $source; $object_type = $source;
$object_id = $source_id; $object_id = $source_id;
} } else {
else {
// Check for product="id" folder="id", etc. style arguments // Check for product="id" folder="id", etc. style arguments
foreach($this->possible_sources as $source) { foreach ($this->possible_sources as $source) {
$argValue = intval($this->getArgValue($source)); $argValue = intval($this->getArgValue($source));
@@ -247,7 +244,7 @@ class Image extends BaseI18nLoop
$effects = explode(',', $effects); $effects = explode(',', $effects);
} }
switch($this->getResizeMode()) { switch ($this->getResizeMode()) {
case 'crop' : case 'crop' :
$resize_mode = \Thelia\Action\Image::EXACT_RATIO_WITH_CROP; $resize_mode = \Thelia\Action\Image::EXACT_RATIO_WITH_CROP;
break; break;
@@ -316,8 +313,7 @@ class Image extends BaseI18nLoop
; ;
$loopResult->addRow($loopResultRow); $loopResult->addRow($loopResultRow);
} } catch (\Exception $ex) {
catch (\Exception $ex) {
// Ignore the result and log an error // 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: ", $this->args);
} }
@@ -325,4 +321,4 @@ class Image extends BaseI18nLoop
return $loopResult; return $loopResult;
} }
} }

View File

@@ -30,7 +30,6 @@ use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Model\LangQuery;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Model\MessageQuery; use Thelia\Model\MessageQuery;
use Thelia\Type\BooleanOrBothType; use Thelia\Type\BooleanOrBothType;

View File

@@ -31,12 +31,10 @@ use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Log\Tlog;
use Thelia\Model\CategoryQuery; use Thelia\Model\CategoryQuery;
use Thelia\Model\CountryQuery; use Thelia\Model\CountryQuery;
use Thelia\Model\CurrencyQuery; use Thelia\Model\CurrencyQuery;
use Thelia\Model\Map\FeatureProductTableMap;
use Thelia\Model\Map\ProductPriceTableMap; use Thelia\Model\Map\ProductPriceTableMap;
use Thelia\Model\Map\ProductSaleElementsTableMap; use Thelia\Model\Map\ProductSaleElementsTableMap;
use Thelia\Model\Map\ProductTableMap; use Thelia\Model\Map\ProductTableMap;
@@ -168,8 +166,8 @@ class Product extends BaseI18nLoop
$depth = $this->getDepth(); $depth = $this->getDepth();
if(null !== $depth) { if (null !== $depth) {
foreach(CategoryQuery::findAllChild($category, $depth) as $subCategory) { foreach (CategoryQuery::findAllChild($category, $depth) as $subCategory) {
$categories->prepend($subCategory); $categories->prepend($subCategory);
} }
} }
@@ -187,7 +185,7 @@ class Product extends BaseI18nLoop
$search->joinProductSaleElements('is_new', Criteria::LEFT_JOIN) $search->joinProductSaleElements('is_new', Criteria::LEFT_JOIN)
->where('`is_new`.NEWNESS' . Criteria::EQUAL . '1') ->where('`is_new`.NEWNESS' . Criteria::EQUAL . '1')
->where('NOT ISNULL(`is_new`.ID)'); ->where('NOT ISNULL(`is_new`.ID)');
} else if($new === false) { } elseif ($new === false) {
$isPSELeftJoinList[] = 'is_new'; $isPSELeftJoinList[] = 'is_new';
$search->joinProductSaleElements('is_new', Criteria::LEFT_JOIN) $search->joinProductSaleElements('is_new', Criteria::LEFT_JOIN)
->where('`is_new`.NEWNESS' . Criteria::EQUAL . '0') ->where('`is_new`.NEWNESS' . Criteria::EQUAL . '0')
@@ -201,7 +199,7 @@ class Product extends BaseI18nLoop
$search->joinProductSaleElements('is_promo', Criteria::LEFT_JOIN) $search->joinProductSaleElements('is_promo', Criteria::LEFT_JOIN)
->where('`is_promo`.PROMO' . Criteria::EQUAL . '1') ->where('`is_promo`.PROMO' . Criteria::EQUAL . '1')
->where('NOT ISNULL(`is_promo`.ID)'); ->where('NOT ISNULL(`is_promo`.ID)');
} else if($promo === false) { } elseif ($promo === false) {
$isPSELeftJoinList[] = 'is_promo'; $isPSELeftJoinList[] = 'is_promo';
$search->joinProductSaleElements('is_promo', Criteria::LEFT_JOIN) $search->joinProductSaleElements('is_promo', Criteria::LEFT_JOIN)
->where('`is_promo`.PROMO' . Criteria::EQUAL . '0') ->where('`is_promo`.PROMO' . Criteria::EQUAL . '0')
@@ -235,14 +233,14 @@ class Product extends BaseI18nLoop
->where('NOT ISNULL(`is_max_weight`.ID)'); ->where('NOT ISNULL(`is_max_weight`.ID)');
} }
if( $attributeNonStrictMatch != '*' ) { if ($attributeNonStrictMatch != '*') {
if($attributeNonStrictMatch == 'none') { if ($attributeNonStrictMatch == 'none') {
$actuallyUsedAttributeNonStrictMatchList = $isPSELeftJoinList; $actuallyUsedAttributeNonStrictMatchList = $isPSELeftJoinList;
} else { } else {
$actuallyUsedAttributeNonStrictMatchList = array_values(array_intersect($isPSELeftJoinList, $attributeNonStrictMatch)); $actuallyUsedAttributeNonStrictMatchList = array_values(array_intersect($isPSELeftJoinList, $attributeNonStrictMatch));
} }
foreach($actuallyUsedAttributeNonStrictMatchList as $key => $actuallyUsedAttributeNonStrictMatch) { foreach ($actuallyUsedAttributeNonStrictMatchList as $key => $actuallyUsedAttributeNonStrictMatch) {
if($key == 0) if($key == 0)
continue; continue;
$search->where('`' . $actuallyUsedAttributeNonStrictMatch . '`.ID=' . '`' . $actuallyUsedAttributeNonStrictMatchList[$key-1] . '`.ID'); $search->where('`' . $actuallyUsedAttributeNonStrictMatch . '`.ID=' . '`' . $actuallyUsedAttributeNonStrictMatchList[$key-1] . '`.ID');
@@ -251,9 +249,9 @@ class Product extends BaseI18nLoop
$min_price = $this->getMin_price(); $min_price = $this->getMin_price();
if(null !== $min_price) { if (null !== $min_price) {
if(false === ConfigQuery::useTaxFreeAmounts()) { if (false === ConfigQuery::useTaxFreeAmounts()) {
// @todo // @todo
} }
@@ -268,7 +266,7 @@ class Product extends BaseI18nLoop
->addJoinObject($minPriceJoin, 'is_min_price_join') ->addJoinObject($minPriceJoin, 'is_min_price_join')
->addJoinCondition('is_min_price_join', '`min_price_data`.`currency_id` = ?', $currency->getId(), null, \PDO::PARAM_INT); ->addJoinCondition('is_min_price_join', '`min_price_data`.`currency_id` = ?', $currency->getId(), null, \PDO::PARAM_INT);
if($defaultCurrency->getId() != $currency->getId()) { if ($defaultCurrency->getId() != $currency->getId()) {
$minPriceJoinDefaultCurrency = new Join(); $minPriceJoinDefaultCurrency = new Join();
$minPriceJoinDefaultCurrency->addExplicitCondition(ProductSaleElementsTableMap::TABLE_NAME, 'ID', 'is_min_price', ProductPriceTableMap::TABLE_NAME, 'PRODUCT_SALE_ELEMENTS_ID', 'min_price_data' . $defaultCurrencySuffix); $minPriceJoinDefaultCurrency->addExplicitCondition(ProductSaleElementsTableMap::TABLE_NAME, 'ID', 'is_min_price', ProductPriceTableMap::TABLE_NAME, 'PRODUCT_SALE_ELEMENTS_ID', 'min_price_data' . $defaultCurrencySuffix);
$minPriceJoinDefaultCurrency->setJoinType(Criteria::LEFT_JOIN); $minPriceJoinDefaultCurrency->setJoinType(Criteria::LEFT_JOIN);
@@ -294,7 +292,7 @@ class Product extends BaseI18nLoop
$max_price = $this->getMax_price(); $max_price = $this->getMax_price();
if(null !== $max_price) { if (null !== $max_price) {
$isPSELeftJoinList[] = 'is_max_price'; $isPSELeftJoinList[] = 'is_max_price';
$isProductPriceFirstLeftJoin = array('is_max_price', 'max_price_data'); $isProductPriceFirstLeftJoin = array('is_max_price', 'max_price_data');
@@ -306,7 +304,7 @@ class Product extends BaseI18nLoop
->addJoinObject($maxPriceJoin, 'is_max_price_join') ->addJoinObject($maxPriceJoin, 'is_max_price_join')
->addJoinCondition('is_max_price_join', '`max_price_data`.`currency_id` = ?', $currency->getId(), null, \PDO::PARAM_INT); ->addJoinCondition('is_max_price_join', '`max_price_data`.`currency_id` = ?', $currency->getId(), null, \PDO::PARAM_INT);
if($defaultCurrency->getId() != $currency->getId()) { if ($defaultCurrency->getId() != $currency->getId()) {
$maxPriceJoinDefaultCurrency = new Join(); $maxPriceJoinDefaultCurrency = new Join();
$maxPriceJoinDefaultCurrency->addExplicitCondition(ProductSaleElementsTableMap::TABLE_NAME, 'ID', 'is_max_price', ProductPriceTableMap::TABLE_NAME, 'PRODUCT_SALE_ELEMENTS_ID', 'max_price_data' . $defaultCurrencySuffix); $maxPriceJoinDefaultCurrency->addExplicitCondition(ProductSaleElementsTableMap::TABLE_NAME, 'ID', 'is_max_price', ProductPriceTableMap::TABLE_NAME, 'PRODUCT_SALE_ELEMENTS_ID', 'max_price_data' . $defaultCurrencySuffix);
$maxPriceJoinDefaultCurrency->setJoinType(Criteria::LEFT_JOIN); $maxPriceJoinDefaultCurrency->setJoinType(Criteria::LEFT_JOIN);
@@ -338,8 +336,8 @@ class Product extends BaseI18nLoop
*/ */
/* if we don't have any join yet, let's make a global one */ /* if we don't have any join yet, let's make a global one */
if(empty($isProductPriceFirstLeftJoin)) { if (empty($isProductPriceFirstLeftJoin)) {
if(count($isPSELeftJoinList) == 0) { if (count($isPSELeftJoinList) == 0) {
$joiningTable = "global"; $joiningTable = "global";
$isPSELeftJoinList[] = $joiningTable; $isPSELeftJoinList[] = $joiningTable;
$search->joinProductSaleElements('global', Criteria::LEFT_JOIN); $search->joinProductSaleElements('global', Criteria::LEFT_JOIN);
@@ -356,7 +354,7 @@ class Product extends BaseI18nLoop
$search->addJoinObject($globalPriceJoin, 'global_price_join') $search->addJoinObject($globalPriceJoin, 'global_price_join')
->addJoinCondition('global_price_join', '`global_price_data`.`currency_id` = ?', $currency->getId(), null, \PDO::PARAM_INT); ->addJoinCondition('global_price_join', '`global_price_data`.`currency_id` = ?', $currency->getId(), null, \PDO::PARAM_INT);
if($defaultCurrency->getId() != $currency->getId()) { if ($defaultCurrency->getId() != $currency->getId()) {
$globalPriceJoinDefaultCurrency = new Join(); $globalPriceJoinDefaultCurrency = new Join();
$globalPriceJoinDefaultCurrency->addExplicitCondition(ProductSaleElementsTableMap::TABLE_NAME, 'ID', $joiningTable, ProductPriceTableMap::TABLE_NAME, 'PRODUCT_SALE_ELEMENTS_ID', 'global_price_data' . $defaultCurrencySuffix); $globalPriceJoinDefaultCurrency->addExplicitCondition(ProductSaleElementsTableMap::TABLE_NAME, 'ID', $joiningTable, ProductPriceTableMap::TABLE_NAME, 'PRODUCT_SALE_ELEMENTS_ID', 'global_price_data' . $defaultCurrencySuffix);
$globalPriceJoinDefaultCurrency->setJoinType(Criteria::LEFT_JOIN); $globalPriceJoinDefaultCurrency->setJoinType(Criteria::LEFT_JOIN);
@@ -381,7 +379,7 @@ class Product extends BaseI18nLoop
*/ */
$booleanMatchedPromoList = array(); $booleanMatchedPromoList = array();
$booleanMatchedNewnessList = array(); $booleanMatchedNewnessList = array();
foreach($isPSELeftJoinList as $isPSELeftJoin) { foreach ($isPSELeftJoinList as $isPSELeftJoin) {
$booleanMatchedPromoList[] = '`' . $isPSELeftJoin . '`.PROMO'; $booleanMatchedPromoList[] = '`' . $isPSELeftJoin . '`.PROMO';
$booleanMatchedNewnessList[] = '`' . $isPSELeftJoin . '`.NEWNESS'; $booleanMatchedNewnessList[] = '`' . $isPSELeftJoin . '`.NEWNESS';
} }
@@ -391,7 +389,7 @@ class Product extends BaseI18nLoop
$booleanMatchedPrice = 'CASE WHEN `' . $isProductPriceFirstLeftJoin[0] . '`.PROMO=1 THEN `' . $isProductPriceFirstLeftJoin[1] . '`.PROMO_PRICE ELSE `' . $isProductPriceFirstLeftJoin[1] . '`.PRICE END'; $booleanMatchedPrice = 'CASE WHEN `' . $isProductPriceFirstLeftJoin[0] . '`.PROMO=1 THEN `' . $isProductPriceFirstLeftJoin[1] . '`.PROMO_PRICE ELSE `' . $isProductPriceFirstLeftJoin[1] . '`.PRICE END';
$booleanMatchedPriceDefaultCurrency = 'CASE WHEN `' . $isProductPriceFirstLeftJoin[0] . '`.PROMO=1 THEN `' . $isProductPriceFirstLeftJoin[1] . $defaultCurrencySuffix . '`.PROMO_PRICE ELSE `' . $isProductPriceFirstLeftJoin[1] . $defaultCurrencySuffix . '`.PRICE END'; $booleanMatchedPriceDefaultCurrency = 'CASE WHEN `' . $isProductPriceFirstLeftJoin[0] . '`.PROMO=1 THEN `' . $isProductPriceFirstLeftJoin[1] . $defaultCurrencySuffix . '`.PROMO_PRICE ELSE `' . $isProductPriceFirstLeftJoin[1] . $defaultCurrencySuffix . '`.PRICE END';
if($defaultCurrency->getId() != $currency->getId()) { if ($defaultCurrency->getId() != $currency->getId()) {
/** /**
* In propel we trust : $currency->getRate() always returns a float. * In propel we trust : $currency->getRate() always returns a float.
* Or maybe not : rate value is checked as a float in overloaded getRate method. * Or maybe not : rate value is checked as a float in overloaded getRate method.
@@ -408,7 +406,7 @@ class Product extends BaseI18nLoop
if ($current === true) { if ($current === true) {
$search->filterById($this->request->get("product_id")); $search->filterById($this->request->get("product_id"));
} elseif($current === false) { } elseif ($current === false) {
$search->filterById($this->request->get("product_id"), Criteria::NOT_IN); $search->filterById($this->request->get("product_id"), Criteria::NOT_IN);
} }
@@ -425,7 +423,7 @@ class Product extends BaseI18nLoop
)->find(), )->find(),
Criteria::IN Criteria::IN
); );
} elseif($current_category === false) { } elseif ($current_category === false) {
$search->filterByCategory( $search->filterByCategory(
CategoryQuery::create()->filterByProduct( CategoryQuery::create()->filterByProduct(
ProductCategoryQuery::create()->filterByProductId( ProductCategoryQuery::create()->filterByProductId(
@@ -459,9 +457,9 @@ class Product extends BaseI18nLoop
$feature_availability = $this->getFeature_availability(); $feature_availability = $this->getFeature_availability();
if(null !== $feature_availability) { if (null !== $feature_availability) {
foreach($feature_availability as $feature => $feature_choice) { foreach ($feature_availability as $feature => $feature_choice) {
foreach($feature_choice['values'] as $feature_av) { foreach ($feature_choice['values'] as $feature_av) {
$featureAlias = 'fa_' . $feature; $featureAlias = 'fa_' . $feature;
if($feature_av != '*') if($feature_av != '*')
$featureAlias .= '_' . $feature_av; $featureAlias .= '_' . $feature_av;
@@ -473,7 +471,7 @@ class Product extends BaseI18nLoop
/* format for mysql */ /* format for mysql */
$sqlWhereString = $feature_choice['expression']; $sqlWhereString = $feature_choice['expression'];
if($sqlWhereString == '*') { if ($sqlWhereString == '*') {
$sqlWhereString = 'NOT ISNULL(`fa_' . $feature . '`.ID)'; $sqlWhereString = 'NOT ISNULL(`fa_' . $feature . '`.ID)';
} else { } else {
$sqlWhereString = preg_replace('#([0-9]+)#', 'NOT ISNULL(`fa_' . $feature . '_' . '\1`.ID)', $sqlWhereString); $sqlWhereString = preg_replace('#([0-9]+)#', 'NOT ISNULL(`fa_' . $feature . '_' . '\1`.ID)', $sqlWhereString);
@@ -487,9 +485,9 @@ class Product extends BaseI18nLoop
$feature_values = $this->getFeature_values(); $feature_values = $this->getFeature_values();
if(null !== $feature_values) { if (null !== $feature_values) {
foreach($feature_values as $feature => $feature_choice) { foreach ($feature_values as $feature => $feature_choice) {
foreach($feature_choice['values'] as $feature_value) { foreach ($feature_choice['values'] as $feature_value) {
$featureAlias = 'fv_' . $feature; $featureAlias = 'fv_' . $feature;
if($feature_value != '*') if($feature_value != '*')
$featureAlias .= '_' . $feature_value; $featureAlias .= '_' . $feature_value;
@@ -501,7 +499,7 @@ class Product extends BaseI18nLoop
/* format for mysql */ /* format for mysql */
$sqlWhereString = $feature_choice['expression']; $sqlWhereString = $feature_choice['expression'];
if($sqlWhereString == '*') { if ($sqlWhereString == '*') {
$sqlWhereString = 'NOT ISNULL(`fv_' . $feature . '`.ID)'; $sqlWhereString = 'NOT ISNULL(`fv_' . $feature . '`.ID)';
} else { } else {
$sqlWhereString = preg_replace('#([a-zA-Z0-9_\-]+)#', 'NOT ISNULL(`fv_' . $feature . '_' . '\1`.ID)', $sqlWhereString); $sqlWhereString = preg_replace('#([a-zA-Z0-9_\-]+)#', 'NOT ISNULL(`fv_' . $feature . '_' . '\1`.ID)', $sqlWhereString);
@@ -517,7 +515,7 @@ class Product extends BaseI18nLoop
$orders = $this->getOrder(); $orders = $this->getOrder();
foreach($orders as $order) { foreach ($orders as $order) {
switch ($order) { switch ($order) {
case "alpha": case "alpha":
$search->addAscendingOrderByColumn('i18n_TITLE'); $search->addAscendingOrderByColumn('i18n_TITLE');
@@ -553,7 +551,7 @@ class Product extends BaseI18nLoop
case "given_id": case "given_id":
if(null === $id) if(null === $id)
throw new \InvalidArgumentException('Given_id order cannot be set without `id` argument'); throw new \InvalidArgumentException('Given_id order cannot be set without `id` argument');
foreach($id as $singleId) { foreach ($id as $singleId) {
$givenIdMatched = 'given_id_matched_' . $singleId; $givenIdMatched = 'given_id_matched_' . $singleId;
$search->withColumn(ProductTableMap::ID . "='$singleId'", $givenIdMatched); $search->withColumn(ProductTableMap::ID . "='$singleId'", $givenIdMatched);
$search->orderBy($givenIdMatched, Criteria::DESC); $search->orderBy($givenIdMatched, Criteria::DESC);

View File

@@ -24,17 +24,14 @@
namespace Thelia\Core\Template\Loop; namespace Thelia\Core\Template\Loop;
use Propel\Runtime\ActiveQuery\Criteria; use Propel\Runtime\ActiveQuery\Criteria;
use Propel\Runtime\ActiveQuery\Join;
use Thelia\Core\Template\Element\BaseLoop; use Thelia\Core\Template\Element\BaseLoop;
use Thelia\Core\Template\Element\LoopResult; use Thelia\Core\Template\Element\LoopResult;
use Thelia\Core\Template\Element\LoopResultRow; use Thelia\Core\Template\Element\LoopResultRow;
use Thelia\Core\Template\Loop\Argument\ArgumentCollection; use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Log\Tlog;
use Thelia\Model\Base\ProductSaleElementsQuery; use Thelia\Model\Base\ProductSaleElementsQuery;
use Thelia\Model\ConfigQuery;
use Thelia\Model\CountryQuery; use Thelia\Model\CountryQuery;
use Thelia\Model\CurrencyQuery; use Thelia\Model\CurrencyQuery;
use Thelia\Type\TypeCollection; use Thelia\Type\TypeCollection;
@@ -53,7 +50,7 @@ use Thelia\Type;
class ProductSaleElements extends BaseLoop class ProductSaleElements extends BaseLoop
{ {
public $timestampable = true; public $timestampable = true;
/** /**
* @return ArgumentCollection * @return ArgumentCollection
*/ */
@@ -93,7 +90,7 @@ class ProductSaleElements extends BaseLoop
$orders = $this->getOrder(); $orders = $this->getOrder();
foreach($orders as $order) { foreach ($orders as $order) {
switch ($order) { switch ($order) {
case "min_price": case "min_price":
$search->addAscendingOrderByColumn('real_lowest_price', Criteria::ASC); $search->addAscendingOrderByColumn('real_lowest_price', Criteria::ASC);
@@ -115,9 +112,9 @@ class ProductSaleElements extends BaseLoop
} }
$currencyId = $this->getCurrency(); $currencyId = $this->getCurrency();
if(null !== $currency) { if (null !== $currency) {
$currency = CurrencyQuery::create()->findOneById($currencyId); $currency = CurrencyQuery::create()->findOneById($currencyId);
if(null === $currency) { if (null === $currency) {
throw new \InvalidArgumentException('Cannot found currency id: `' . $currency . '` in product_sale_elements loop'); throw new \InvalidArgumentException('Cannot found currency id: `' . $currency . '` in product_sale_elements loop');
} }
} else { } else {
@@ -169,4 +166,4 @@ class ProductSaleElements extends BaseLoop
return $loopResult; return $loopResult;
} }
} }

View File

@@ -32,7 +32,6 @@ use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
use Thelia\Core\Template\Loop\Argument\Argument; use Thelia\Core\Template\Loop\Argument\Argument;
use Thelia\Model\CustomerTitleQuery; use Thelia\Model\CustomerTitleQuery;
use Thelia\Model\ConfigQuery;
/** /**
* *

View File

@@ -25,7 +25,6 @@ namespace Thelia\Core\Template;
use Thelia\Model\ConfigQuery; use Thelia\Model\ConfigQuery;
use Thelia\Core\HttpFoundation\Request; use Thelia\Core\HttpFoundation\Request;
use Thelia\Tools\URL;
use Thelia\Form\BaseForm; use Thelia\Form\BaseForm;
/** /**
* The parser context is an application-wide context, which stores var-value pairs. * The parser context is an application-wide context, which stores var-value pairs.

Some files were not shown because too many files have changed in this diff Show More