Merge branch 'master' of https://github.com/thelia/thelia into coupon
# By Manuel Raynaud (19) and others # Via Manuel Raynaud (8) and others * 'master' of https://github.com/thelia/thelia: (47 commits) tax engine tax engine - Add orders view route - Add view & action for orders index Removed a redondant "use" Add tooltip - Add creation address form - Add addresses list - Add update address form Added process_assets config variable Change breadcrumb separator color Add breadcrumb to customers view - Change boolean type to integer type for update_logged_in_user field - Create view for customer modification syntax use ROUTER::ABSOLUTE_URL by default PSE loop todo currency management in PSE loop Add customer view finish Add modal for create/delete customer Update body background fixed typo searching route return relative path pse loop currency ... Conflicts: core/lib/Thelia/Controller/Admin/CouponController.php core/lib/Thelia/Core/Event/TheliaEvents.php web/index_dev.php
This commit is contained in:
@@ -24,8 +24,6 @@
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
use Symfony\Component\EventDispatcher\Event;
|
||||
use Thelia\Core\HttpFoundation\Request;
|
||||
use Thelia\Form\BaseForm;
|
||||
/**
|
||||
*
|
||||
* Class thrown on Thelia.action event
|
||||
@@ -50,4 +48,4 @@ abstract class ActionEvent extends Event
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ use Symfony\Component\EventDispatcher\Event;
|
||||
use Thelia\Model\Address;
|
||||
use Thelia\Model\Customer;
|
||||
|
||||
|
||||
/**
|
||||
* Class AddressCreateOrUpdateEvent
|
||||
* @package Thelia\Core\Event
|
||||
@@ -109,7 +108,7 @@ class AddressCreateOrUpdateEvent extends ActionEvent
|
||||
*/
|
||||
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->address2 = $address2;
|
||||
@@ -263,5 +262,4 @@ class AddressCreateOrUpdateEvent extends ActionEvent
|
||||
return $this->address;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ namespace Thelia\Core\Event;
|
||||
use Symfony\Component\EventDispatcher\Event;
|
||||
use Thelia\Model\Address;
|
||||
|
||||
|
||||
/**
|
||||
* Class AddressEvent
|
||||
* @package Thelia\Core\Event
|
||||
@@ -38,12 +37,11 @@ class AddressEvent extends ActionEvent
|
||||
*/
|
||||
protected $address;
|
||||
|
||||
function __construct(Address $address)
|
||||
public function __construct(Address $address)
|
||||
{
|
||||
$this->address = $address;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return \Thelia\Model\Address
|
||||
*/
|
||||
@@ -51,4 +49,4 @@ class AddressEvent extends ActionEvent
|
||||
{
|
||||
return $this->address;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
|
||||
class BaseToggleVisibilityEvent extends ActionEvent
|
||||
{
|
||||
protected $object_id;
|
||||
@@ -43,6 +42,7 @@ class BaseToggleVisibilityEvent extends ActionEvent
|
||||
public function setObjectId($object_id)
|
||||
{
|
||||
$this->object_id = $object_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ class BaseUpdatePositionEvent extends ActionEvent
|
||||
public function setMode($mode)
|
||||
{
|
||||
$this->mode = $mode;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -61,6 +62,7 @@ class BaseUpdatePositionEvent extends ActionEvent
|
||||
public function setPosition($position)
|
||||
{
|
||||
$this->position = $position;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -72,6 +74,7 @@ class BaseUpdatePositionEvent extends ActionEvent
|
||||
public function setObjectId($object_id)
|
||||
{
|
||||
$this->object_id = $object_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,5 +145,4 @@ class CartEvent extends ActionEvent
|
||||
return $this->cart;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -23,8 +23,6 @@
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
use Thelia\Model\Category;
|
||||
|
||||
class CategoryCreateEvent extends CategoryEvent
|
||||
{
|
||||
protected $title;
|
||||
@@ -46,6 +44,7 @@ class CategoryCreateEvent extends CategoryEvent
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->title = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -57,6 +56,7 @@ class CategoryCreateEvent extends CategoryEvent
|
||||
public function setParent($parent)
|
||||
{
|
||||
$this->parent = $parent;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -68,6 +68,7 @@ class CategoryCreateEvent extends CategoryEvent
|
||||
public function setLocale($locale)
|
||||
{
|
||||
$this->locale = $locale;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,8 +23,6 @@
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
use Thelia\Model\Category;
|
||||
|
||||
class CategoryDeleteEvent extends CategoryEvent
|
||||
{
|
||||
public function __construct($category_id)
|
||||
@@ -40,6 +38,7 @@ class CategoryDeleteEvent extends CategoryEvent
|
||||
public function setCategoryId($category_id)
|
||||
{
|
||||
$this->category_id = $category_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,8 @@ class CategoryEvent extends ActionEvent
|
||||
$this->category = $category;
|
||||
}
|
||||
|
||||
public function hasCategory() {
|
||||
public function hasCategory()
|
||||
{
|
||||
return ! is_null($this->category);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,4 +25,4 @@ namespace Thelia\Core\Event;
|
||||
|
||||
class CategoryToggleVisibilityEvent extends BaseToggleVisibilityEvent
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
use Thelia\Model\Category;
|
||||
|
||||
class CategoryUpdateEvent extends CategoryCreateEvent
|
||||
{
|
||||
@@ -49,6 +48,7 @@ class CategoryUpdateEvent extends CategoryCreateEvent
|
||||
public function setCategoryId($category_id)
|
||||
{
|
||||
$this->category_id = $category_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -60,6 +60,7 @@ class CategoryUpdateEvent extends CategoryCreateEvent
|
||||
public function setChapo($chapo)
|
||||
{
|
||||
$this->chapo = $chapo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -71,6 +72,7 @@ class CategoryUpdateEvent extends CategoryCreateEvent
|
||||
public function setDescription($description)
|
||||
{
|
||||
$this->description = $description;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -82,6 +84,7 @@ class CategoryUpdateEvent extends CategoryCreateEvent
|
||||
public function setPostscriptum($postscriptum)
|
||||
{
|
||||
$this->postscriptum = $postscriptum;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -93,6 +96,7 @@ class CategoryUpdateEvent extends CategoryCreateEvent
|
||||
public function setUrl($url)
|
||||
{
|
||||
$this->url = $url;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -104,6 +108,7 @@ class CategoryUpdateEvent extends CategoryCreateEvent
|
||||
public function setVisibility($visibility)
|
||||
{
|
||||
$this->visibility = $visibility;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -115,6 +120,7 @@ class CategoryUpdateEvent extends CategoryCreateEvent
|
||||
public function setParent($parent)
|
||||
{
|
||||
$this->parent = $parent;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,4 +25,4 @@ namespace Thelia\Core\Event;
|
||||
|
||||
class CategoryUpdatePositionEvent extends BaseUpdatePositionEvent
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
use Thelia\Model\Config;
|
||||
|
||||
class ConfigCreateEvent extends ConfigEvent
|
||||
{
|
||||
|
||||
@@ -23,8 +23,6 @@
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
use Thelia\Model\Config;
|
||||
|
||||
class ConfigDeleteEvent extends ConfigEvent
|
||||
{
|
||||
protected $config_id;
|
||||
|
||||
@@ -33,7 +33,8 @@ class ConfigEvent extends ActionEvent
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
public function hasConfig() {
|
||||
public function hasConfig()
|
||||
{
|
||||
return ! is_null($this->config);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,8 +23,6 @@
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
use Thelia\Model\Config;
|
||||
|
||||
class ConfigUpdateEvent extends ConfigCreateEvent
|
||||
{
|
||||
protected $config_id;
|
||||
@@ -85,4 +83,4 @@ class ConfigUpdateEvent extends ConfigCreateEvent
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ class CouponCreateOrUpdateEvent extends ActionEvent
|
||||
* @param CouponRuleCollection $rules CouponRuleInterface to add
|
||||
* @param string $locale Coupon Language code ISO (ex: fr_FR)
|
||||
*/
|
||||
function __construct(
|
||||
public function __construct(
|
||||
$code,
|
||||
$title,
|
||||
$amount,
|
||||
@@ -307,6 +307,4 @@ class CouponCreateOrUpdateEvent extends ActionEvent
|
||||
return $this->coupon;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
use Thelia\Model\Currency;
|
||||
|
||||
class CurrencyCreateEvent extends CurrencyEvent
|
||||
{
|
||||
@@ -92,4 +91,4 @@ class CurrencyCreateEvent extends CurrencyEvent
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,8 +23,6 @@
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
use Thelia\Model\Currency;
|
||||
|
||||
class CurrencyDeleteEvent extends CurrencyEvent
|
||||
{
|
||||
protected $currency_id;
|
||||
@@ -45,4 +43,4 @@ class CurrencyDeleteEvent extends CurrencyEvent
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,8 @@ class CurrencyEvent extends ActionEvent
|
||||
$this->currency = $currency;
|
||||
}
|
||||
|
||||
public function hasCurrency() {
|
||||
public function hasCurrency()
|
||||
{
|
||||
return ! is_null($this->currency);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
use Thelia\Model\Currency;
|
||||
|
||||
class CurrencyUpdateEvent extends CurrencyCreateEvent
|
||||
{
|
||||
|
||||
@@ -25,4 +25,4 @@ namespace Thelia\Core\Event;
|
||||
|
||||
class CurrencyUpdatePositionEvent extends BaseUpdatePositionEvent
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,12 +9,11 @@
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
|
||||
use Symfony\Component\EventDispatcher\Event;
|
||||
use Thelia\Model\Customer;
|
||||
|
||||
class CustomerCreateOrUpdateEvent extends ActionEvent {
|
||||
|
||||
class CustomerCreateOrUpdateEvent extends ActionEvent
|
||||
{
|
||||
//base parameters for creating new customer
|
||||
protected $title;
|
||||
protected $firstname;
|
||||
@@ -39,9 +38,8 @@ class CustomerCreateOrUpdateEvent extends ActionEvent {
|
||||
*/
|
||||
protected $customer;
|
||||
|
||||
|
||||
/**
|
||||
* @param int $title the title customer id
|
||||
* @param int $title the title customer id
|
||||
* @param string $firstname
|
||||
* @param string $lastname
|
||||
* @param string $address1
|
||||
@@ -51,15 +49,15 @@ class CustomerCreateOrUpdateEvent extends ActionEvent {
|
||||
* @param string $cellphone
|
||||
* @param string $zipcode
|
||||
* @param string $city
|
||||
* @param int $country the country id
|
||||
* @param int $country the country id
|
||||
* @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 int $reseller if customer is a reseller
|
||||
* @param int $sponsor customer's id sponsor
|
||||
* @param int $reseller if customer is a reseller
|
||||
* @param int $sponsor customer's id sponsor
|
||||
* @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->address2 = $address2;
|
||||
@@ -231,7 +229,4 @@ class CustomerCreateOrUpdateEvent extends ActionEvent {
|
||||
return $this->customer;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,5 +43,4 @@ class CustomerEvent extends ActionEvent
|
||||
return $this->customer;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -23,11 +23,10 @@
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
|
||||
use Thelia\Model\Customer;
|
||||
|
||||
class CustomerLoginEvent extends ActionEvent {
|
||||
|
||||
class CustomerLoginEvent extends ActionEvent
|
||||
{
|
||||
protected $customer;
|
||||
|
||||
public function __construct(Customer $customer)
|
||||
@@ -39,4 +38,4 @@ class CustomerLoginEvent extends ActionEvent {
|
||||
{
|
||||
return $this->customer;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,8 +22,6 @@
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
use Thelia\Core\HttpFoundation\Request;
|
||||
use Thelia\Model\Cart;
|
||||
|
||||
class ImageEvent extends ActionEvent
|
||||
{
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
use Thelia\Model\Message;
|
||||
|
||||
class MessageCreateEvent extends MessageEvent
|
||||
{
|
||||
@@ -79,4 +78,4 @@ class MessageCreateEvent extends MessageEvent
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,8 +23,6 @@
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
use Thelia\Model\Message;
|
||||
|
||||
class MessageDeleteEvent extends MessageEvent
|
||||
{
|
||||
protected $message_id;
|
||||
@@ -45,4 +43,4 @@ class MessageDeleteEvent extends MessageEvent
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,8 @@ class MessageEvent extends ActionEvent
|
||||
$this->message = $message;
|
||||
}
|
||||
|
||||
public function hasMessage() {
|
||||
public function hasMessage()
|
||||
{
|
||||
return ! is_null($this->message);
|
||||
}
|
||||
|
||||
|
||||
@@ -23,8 +23,6 @@
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
use Thelia\Model\Message;
|
||||
|
||||
class MessageUpdateEvent extends MessageCreateEvent
|
||||
{
|
||||
protected $message_id;
|
||||
|
||||
@@ -204,8 +204,6 @@ final class TheliaEvents
|
||||
*/
|
||||
const IMAGE_CLEAR_CACHE = "action.clearImageCache";
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Sent when creating a Coupon
|
||||
*/
|
||||
|
||||
@@ -47,7 +47,12 @@ class Session extends BaseSession
|
||||
*/
|
||||
public function getLang($forceDefault = true)
|
||||
{
|
||||
return $this->get("thelia.current.lang", $forceDefault ? Lang::getDefaultLanguage():null);
|
||||
$lang = $this->get("thelia.current.lang");
|
||||
if(null === $lang && $forceDefault)
|
||||
{
|
||||
$lang = Lang::getDefaultLanguage();
|
||||
}
|
||||
return $lang;
|
||||
}
|
||||
|
||||
public function setLang(Lang $lang)
|
||||
@@ -59,7 +64,12 @@ class Session extends BaseSession
|
||||
|
||||
public function getAdminEditionLang()
|
||||
{
|
||||
return $this->get('thelia.admin.edition.lang', Lang::getDefaultLanguage());
|
||||
$lang = $this->get('thelia.admin.edition.lang');
|
||||
|
||||
if (null === $lang) {
|
||||
$lang = Lang::getDefaultLanguage();
|
||||
}
|
||||
return $lang;
|
||||
}
|
||||
|
||||
public function setAdminEditionLang($langId)
|
||||
@@ -76,7 +86,13 @@ class Session extends BaseSession
|
||||
|
||||
public function getCurrency($forceDefault = true)
|
||||
{
|
||||
return $this->get("thelia.current.currency", $forceDefault ? Currency::getDefaultCurrency():null);
|
||||
$currency = $this->get("thelia.current.currency");
|
||||
|
||||
if(null === $currency && $forceDefault)
|
||||
{
|
||||
$currency = Currency::getDefaultCurrency();
|
||||
}
|
||||
return $currency;
|
||||
}
|
||||
|
||||
// -- Customer user --------------------------------------------------------
|
||||
@@ -84,6 +100,7 @@ class Session extends BaseSession
|
||||
public function setCustomerUser(UserInterface $user)
|
||||
{
|
||||
$this->set('thelia.customer_user', $user);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -102,6 +119,7 @@ class Session extends BaseSession
|
||||
public function setAdminUser(UserInterface $user)
|
||||
{
|
||||
$this->set('thelia.admin_user', $user);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -120,6 +138,7 @@ class Session extends BaseSession
|
||||
public function setReturnToUrl($url)
|
||||
{
|
||||
$this->set('thelia.return_to_url', $url);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -180,6 +199,7 @@ class Session extends BaseSession
|
||||
public function setCart($cart_id)
|
||||
{
|
||||
$this->set("thelia.cart_id", $cart_id);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -192,6 +212,7 @@ class Session extends BaseSession
|
||||
public function setDelivery($delivery_id)
|
||||
{
|
||||
$this->set("thelia.delivery_id", $delivery_id);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -199,4 +220,4 @@ class Session extends BaseSession
|
||||
{
|
||||
return $this->get("thelia.delivery_id");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,6 @@ use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Tools\Redirect;
|
||||
use Thelia\Tools\URL;
|
||||
|
||||
|
||||
/**
|
||||
* Class RewritingRouter
|
||||
* @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.
|
||||
*
|
||||
* @param string $name The name of the route
|
||||
* @param mixed $parameters An array of parameters
|
||||
* @param string $name The name of the route
|
||||
* @param mixed $parameters An array of parameters
|
||||
* @param Boolean|string $referenceType The type of reference to be generated (one of the constants)
|
||||
*
|
||||
* @return string The generated URL
|
||||
@@ -163,16 +162,16 @@ class RewritingRouter implements RouterInterface, RequestMatcherInterface
|
||||
* @throws \Exception|\Thelia\Exception\UrlRewritingException
|
||||
* @throws \Symfony\Component\Routing\Exception\ResourceNotFoundException
|
||||
* @throws \Thelia\Exception\RedirectException
|
||||
* @return array An array of parameters
|
||||
* @return array An array of parameters
|
||||
*
|
||||
*/
|
||||
public function matchRequest(Request $request)
|
||||
{
|
||||
if(ConfigQuery::isRewritingEnable()) {
|
||||
if (ConfigQuery::isRewritingEnable()) {
|
||||
try {
|
||||
$rewrittenUrlData = URL::getInstance()->resolve($request->getPathInfo());
|
||||
} catch(UrlRewritingException $e) {
|
||||
switch($e->getCode()) {
|
||||
} catch (UrlRewritingException $e) {
|
||||
switch ($e->getCode()) {
|
||||
case UrlRewritingException::URL_NOT_FOUND :
|
||||
throw new ResourceNotFoundException();
|
||||
break;
|
||||
@@ -183,23 +182,23 @@ class RewritingRouter implements RouterInterface, RequestMatcherInterface
|
||||
|
||||
/* is the URL redirected ? */
|
||||
|
||||
if(null !== $rewrittenUrlData->redirectedToUrl) {
|
||||
if (null !== $rewrittenUrlData->redirectedToUrl) {
|
||||
$this->redirect($rewrittenUrlData->redirectedToUrl, 301);
|
||||
}
|
||||
|
||||
/* define GET arguments in request */
|
||||
|
||||
if(null !== $rewrittenUrlData->view) {
|
||||
if (null !== $rewrittenUrlData->view) {
|
||||
$request->attributes->set('_view', $rewrittenUrlData->view);
|
||||
if(null !== $rewrittenUrlData->viewId) {
|
||||
if (null !== $rewrittenUrlData->viewId) {
|
||||
$request->query->set($rewrittenUrlData->view . '_id', $rewrittenUrlData->viewId);
|
||||
}
|
||||
}
|
||||
if(null !== $rewrittenUrlData->locale) {
|
||||
if (null !== $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);
|
||||
}
|
||||
|
||||
@@ -216,4 +215,4 @@ class RewritingRouter implements RouterInterface, RequestMatcherInterface
|
||||
{
|
||||
Redirect::exec($url, $status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,12 +93,12 @@ class SecurityContext
|
||||
/**
|
||||
* Check if a user has at least one of the required roles
|
||||
*
|
||||
* @param UserInterface $user the user
|
||||
* @param array $roles the roles
|
||||
* @return boolean true if the user has the required role, false otherwise
|
||||
* @param UserInterface $user the user
|
||||
* @param array $roles the roles
|
||||
* @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) {
|
||||
// Check if user's roles matches required roles
|
||||
$userRoles = $user->getRoles();
|
||||
@@ -208,4 +208,4 @@ class SecurityContext
|
||||
{
|
||||
$this->getSession()->clearAdminUser();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,8 +29,7 @@ use Assetic\Filter;
|
||||
use Assetic\Factory\AssetFactory;
|
||||
use Assetic\Factory\Worker\CacheBustingWorker;
|
||||
use Assetic\AssetWriter;
|
||||
use Assetic\Asset\AssetCache;
|
||||
use Assetic\Cache\FilesystemCache;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
|
||||
/**
|
||||
* This class is a simple helper for generating assets using Assetic.
|
||||
@@ -128,26 +127,28 @@ class AsseticHelper
|
||||
//
|
||||
if ($dev_mode == true || ! file_exists($target_file)) {
|
||||
|
||||
// Delete previous version of the file
|
||||
list($commonPart, $dummy) = explode('-', $asset_target_path);
|
||||
if (ConfigQuery::read('process_assets', true)) {
|
||||
|
||||
foreach (glob("$output_path/$commonPart-*") as $filename) {
|
||||
@unlink($filename);
|
||||
}
|
||||
// Delete previous version of the file
|
||||
list($commonPart, $dummy) = explode('-', $asset_target_path);
|
||||
|
||||
// Apply filters now
|
||||
foreach ($filter_list as $filter) {
|
||||
if ('?' != $filter[0]) {
|
||||
$asset->ensureFilter($fm->get($filter));
|
||||
foreach (glob("$output_path/$commonPart-*") as $filename) {
|
||||
@unlink($filename);
|
||||
}
|
||||
elseif (!$debug) {
|
||||
$asset->ensureFilter($fm->get(substr($filter, 1)));
|
||||
|
||||
// Apply filters now
|
||||
foreach ($filter_list as $filter) {
|
||||
if ('?' != $filter[0]) {
|
||||
$asset->ensureFilter($fm->get($filter));
|
||||
} elseif (!$debug) {
|
||||
$asset->ensureFilter($fm->get(substr($filter, 1)));
|
||||
}
|
||||
}
|
||||
|
||||
$writer = new AssetWriter($output_path);
|
||||
|
||||
$writer->writeAsset($asset);
|
||||
}
|
||||
|
||||
$writer = new AssetWriter($output_path);
|
||||
|
||||
$writer->writeAsset($asset);
|
||||
}
|
||||
|
||||
return rtrim($output_url, '/').'/'.$asset_target_path;
|
||||
|
||||
@@ -24,10 +24,8 @@
|
||||
namespace Thelia\Core\Template\Element;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Propel\Runtime\ActiveQuery\ModelCriteria;
|
||||
use Thelia\Core\Security\SecurityContext;
|
||||
use Thelia\Model\Tools\ModelCriteriaTools;
|
||||
|
||||
/**
|
||||
@@ -55,10 +53,10 @@ abstract class BaseI18nLoop extends BaseLoop
|
||||
/**
|
||||
* Setup ModelCriteria for proper i18n processing
|
||||
*
|
||||
* @param ModelCriteria $search the Propel Criteria to configure
|
||||
* @param array $columns the i18n columns
|
||||
* @param string $foreignTable the specified table (default to criteria table)
|
||||
* @param string $foreignKey the foreign key in this table (default to criteria table)
|
||||
* @param ModelCriteria $search the Propel Criteria to configure
|
||||
* @param array $columns the i18n columns
|
||||
* @param string $foreignTable the specified table (default to criteria table)
|
||||
* @param string $foreignKey the foreign key in this table (default to criteria table)
|
||||
* @param bool $forceReturn
|
||||
*
|
||||
* @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)
|
||||
{
|
||||
/* manage translations */
|
||||
|
||||
return ModelCriteriaTools::getI18n(
|
||||
$this->getBackend_context(),
|
||||
$this->getLang(),
|
||||
@@ -77,4 +76,4 @@ abstract class BaseI18nLoop extends BaseLoop
|
||||
$forceReturn
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,6 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Propel\Runtime\ActiveQuery\ModelCriteria;
|
||||
use Thelia\Core\Security\SecurityContext;
|
||||
use Thelia\Model\Tools\ModelCriteriaTools;
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@@ -37,7 +37,7 @@ class LoopResult implements \Iterator
|
||||
public function __construct($modelCollection = null)
|
||||
{
|
||||
$this->position = 0;
|
||||
if($modelCollection instanceof ObjectCollection || $modelCollection instanceof PropelModelPager) {
|
||||
if ($modelCollection instanceof ObjectCollection || $modelCollection instanceof PropelModelPager) {
|
||||
$this->modelCollection = $modelCollection;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,14 +38,14 @@ class LoopResultRow
|
||||
|
||||
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->versionable = $versionable;
|
||||
$this->timestampable = $timestampable;
|
||||
}
|
||||
|
||||
if($loopResult instanceof LoopResult) {
|
||||
if ($loopResult instanceof LoopResult) {
|
||||
$this->loopResult = $loopResult;
|
||||
|
||||
$this->countable = $countable;
|
||||
@@ -95,17 +95,17 @@ class LoopResultRow
|
||||
|
||||
protected function assignDefaultOutputs()
|
||||
{
|
||||
if(true === $this->versionable) {
|
||||
foreach($this->getVersionOutputs() as $output) {
|
||||
if (true === $this->versionable) {
|
||||
foreach ($this->getVersionOutputs() as $output) {
|
||||
$this->set($output[0], $this->model->$output[1]());
|
||||
}
|
||||
}
|
||||
if(true === $this->timestampable) {
|
||||
foreach($this->getTimestampOutputs() as $output) {
|
||||
if (true === $this->timestampable) {
|
||||
foreach ($this->getTimestampOutputs() as $output) {
|
||||
$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_TOTAL', $this->loopResult->modelCollection->count());
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
namespace Thelia\Core\Template\Loop;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Propel\Runtime\Collection\ObjectCollection;
|
||||
use Thelia\Core\Template\Element\BaseLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
@@ -48,7 +47,7 @@ use Thelia\Type;
|
||||
class Address extends BaseLoop
|
||||
{
|
||||
public $timestampable = true;
|
||||
|
||||
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
*/
|
||||
@@ -99,7 +98,6 @@ class Address extends BaseLoop
|
||||
|
||||
$default = $this->getDefault();
|
||||
|
||||
|
||||
if ($default === true) {
|
||||
$search->filterByIsDefault(1, Criteria::EQUAL);
|
||||
}
|
||||
|
||||
@@ -77,15 +77,15 @@ class AssociatedContent extends Content
|
||||
$product = $this->getProduct();
|
||||
$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');
|
||||
}
|
||||
|
||||
if($product !== null) {
|
||||
if ($product !== null) {
|
||||
$search = ProductAssociatedContentQuery::create();
|
||||
|
||||
$search->filterByProductId($product, Criteria::EQUAL);
|
||||
} elseif($category !== null) {
|
||||
} elseif ($category !== null) {
|
||||
$search = CategoryAssociatedContentQuery::create();
|
||||
|
||||
$search->filterByCategoryId($category, Criteria::EQUAL);
|
||||
|
||||
@@ -24,21 +24,16 @@
|
||||
namespace Thelia\Core\Template\Loop;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Propel\Runtime\ActiveQuery\Join;
|
||||
use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
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\ProductCategoryQuery;
|
||||
use Thelia\Model\Base\AttributeQuery;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Model\Map\ProductCategoryTableMap;
|
||||
use Thelia\Type\TypeCollection;
|
||||
use Thelia\Type;
|
||||
@@ -113,17 +108,17 @@ class Attribute extends BaseI18nLoop
|
||||
$product = $this->getProduct();
|
||||
$category = $this->getCategory();
|
||||
|
||||
if(null !== $product) {
|
||||
if (null !== $product) {
|
||||
$productCategories = ProductCategoryQuery::create()->select(array(ProductCategoryTableMap::CATEGORY_ID))->filterByProductId($product, Criteria::IN)->find()->getData();
|
||||
|
||||
if(null === $category) {
|
||||
if (null === $category) {
|
||||
$category = $productCategories;
|
||||
} else {
|
||||
$category = array_merge($category, $productCategories);
|
||||
}
|
||||
}
|
||||
|
||||
if(null !== $category) {
|
||||
if (null !== $category) {
|
||||
$search->filterByCategory(
|
||||
CategoryQuery::create()->filterById($category)->find(),
|
||||
Criteria::IN
|
||||
@@ -132,7 +127,7 @@ class Attribute extends BaseI18nLoop
|
||||
|
||||
$orders = $this->getOrder();
|
||||
|
||||
foreach($orders as $order) {
|
||||
foreach ($orders as $order) {
|
||||
switch ($order) {
|
||||
case "alpha":
|
||||
$search->addAscendingOrderByColumn('i18n_TITLE');
|
||||
@@ -170,4 +165,4 @@ class Attribute extends BaseI18nLoop
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,17 +24,14 @@
|
||||
namespace Thelia\Core\Template\Loop;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Propel\Runtime\ActiveQuery\Join;
|
||||
use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Log\Tlog;
|
||||
|
||||
use Thelia\Model\Base\AttributeAvQuery;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Type\TypeCollection;
|
||||
use Thelia\Type;
|
||||
|
||||
@@ -95,13 +92,13 @@ class AttributeAvailability extends BaseI18nLoop
|
||||
|
||||
$attribute = $this->getAttribute();
|
||||
|
||||
if(null !== $attribute) {
|
||||
if (null !== $attribute) {
|
||||
$search->filterByAttributeId($attribute, Criteria::IN);
|
||||
}
|
||||
|
||||
$orders = $this->getOrder();
|
||||
|
||||
foreach($orders as $order) {
|
||||
foreach ($orders as $order) {
|
||||
switch ($order) {
|
||||
case "alpha":
|
||||
$search->addAscendingOrderByColumn('i18n_TITLE');
|
||||
@@ -139,4 +136,4 @@ class AttributeAvailability extends BaseI18nLoop
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,19 +24,16 @@
|
||||
namespace Thelia\Core\Template\Loop;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Propel\Runtime\ActiveQuery\Join;
|
||||
use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Log\Tlog;
|
||||
|
||||
use Thelia\Model\Base\AttributeCombinationQuery;
|
||||
use Thelia\Model\Map\AttributeAvTableMap;
|
||||
use Thelia\Model\Map\AttributeTableMap;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Type\TypeCollection;
|
||||
use Thelia\Type;
|
||||
|
||||
@@ -100,7 +97,7 @@ class AttributeCombination extends BaseI18nLoop
|
||||
|
||||
$orders = $this->getOrder();
|
||||
|
||||
foreach($orders as $order) {
|
||||
foreach ($orders as $order) {
|
||||
switch ($order) {
|
||||
case "alpha":
|
||||
$search->addAscendingOrderByColumn(AttributeTableMap::TABLE_NAME . '_i18n_TITLE');
|
||||
@@ -134,4 +131,4 @@ class AttributeCombination extends BaseI18nLoop
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,13 +28,13 @@ use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Model\ModuleQuery;
|
||||
|
||||
|
||||
/**
|
||||
* Class Delivery
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class BaseSpecificModule extends BaseI18nLoop {
|
||||
class BaseSpecificModule extends BaseI18nLoop
|
||||
{
|
||||
public $timestampable = true;
|
||||
|
||||
/**
|
||||
@@ -93,12 +93,10 @@ class BaseSpecificModule extends BaseI18nLoop {
|
||||
{
|
||||
$search = ModuleQuery::create();
|
||||
|
||||
if(null !== $id = $this->getId())
|
||||
{
|
||||
if (null !== $id = $this->getId()) {
|
||||
$search->filterById($id);
|
||||
}
|
||||
|
||||
|
||||
if (null !== $exclude = $this->getExclude()) {
|
||||
$search->filterById($exclude, Criteria::NOT_IN);
|
||||
}
|
||||
@@ -106,4 +104,4 @@ class BaseSpecificModule extends BaseI18nLoop {
|
||||
return $search;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,8 +72,6 @@ class Cart extends BaseLoop
|
||||
public function exec(&$pagination)
|
||||
{
|
||||
|
||||
|
||||
|
||||
$cart = $this->getCart($this->request);
|
||||
$cartItems = $cart->getCartItems();
|
||||
$result = new LoopResult($cartItems);
|
||||
|
||||
@@ -30,10 +30,8 @@ use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Log\Tlog;
|
||||
|
||||
use Thelia\Model\CategoryQuery;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Type\TypeCollection;
|
||||
use Thelia\Type;
|
||||
use Thelia\Type\BooleanOrBothType;
|
||||
@@ -101,7 +99,7 @@ class Category extends BaseI18nLoop
|
||||
/* manage translations */
|
||||
$locale = $this->configureI18nProcessing($search);
|
||||
|
||||
$id = $this->getId();
|
||||
$id = $this->getId();
|
||||
|
||||
if (!is_null($id)) {
|
||||
$search->filterById($id, Criteria::IN);
|
||||
@@ -113,8 +111,7 @@ class Category extends BaseI18nLoop
|
||||
$search->filterByParent($parent);
|
||||
}
|
||||
|
||||
|
||||
$current = $this->getCurrent();
|
||||
$current = $this->getCurrent();
|
||||
|
||||
if ($current === true) {
|
||||
$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);
|
||||
}
|
||||
|
||||
|
||||
$exclude = $this->getExclude();
|
||||
|
||||
if (!is_null($exclude)) {
|
||||
@@ -130,11 +126,11 @@ class Category extends BaseI18nLoop
|
||||
}
|
||||
|
||||
if ($this->getVisible() != BooleanOrBothType::ANY)
|
||||
$search->filterByVisible($this->getVisible() ? 1 : 0);
|
||||
$search->filterByVisible($this->getVisible() ? 1 : 0);
|
||||
|
||||
$orders = $this->getOrder();
|
||||
|
||||
foreach($orders as $order) {
|
||||
foreach ($orders as $order) {
|
||||
switch ($order) {
|
||||
case "alpha":
|
||||
$search->addAscendingOrderByColumn('i18n_TITLE');
|
||||
@@ -179,23 +175,23 @@ class Category extends BaseI18nLoop
|
||||
$loopResultRow = new LoopResultRow($loopResult, $category, $this->versionable, $this->timestampable, $this->countable);
|
||||
|
||||
$loopResultRow
|
||||
->set("ID", $category->getId())
|
||||
->set("ID", $category->getId())
|
||||
->set("IS_TRANSLATED",$category->getVirtualColumn('IS_TRANSLATED'))
|
||||
->set("LOCALE",$locale)
|
||||
->set("TITLE", $category->getVirtualColumn('i18n_TITLE'))
|
||||
->set("CHAPO", $category->getVirtualColumn('i18n_CHAPO'))
|
||||
->set("DESCRIPTION", $category->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set("POSTSCRIPTUM", $category->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||
->set("PARENT", $category->getParent())
|
||||
->set("URL", $category->getUrl($locale))
|
||||
->set("PRODUCT_COUNT", $category->countChild())
|
||||
->set("VISIBLE", $category->getVisible() ? "1" : "0")
|
||||
->set("POSITION", $category->getPosition())
|
||||
;
|
||||
->set("TITLE", $category->getVirtualColumn('i18n_TITLE'))
|
||||
->set("CHAPO", $category->getVirtualColumn('i18n_CHAPO'))
|
||||
->set("DESCRIPTION", $category->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set("POSTSCRIPTUM", $category->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||
->set("PARENT", $category->getParent())
|
||||
->set("URL", $category->getUrl($locale))
|
||||
->set("PRODUCT_COUNT", $category->countChild())
|
||||
->set("VISIBLE", $category->getVisible() ? "1" : "0")
|
||||
->set("POSITION", $category->getPosition())
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,6 @@ use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
use Thelia\Model\LangQuery;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Type\BooleanOrBothType;
|
||||
@@ -114,7 +113,7 @@ class Config extends BaseI18nLoop
|
||||
|
||||
$orders = $this->getOrder();
|
||||
|
||||
foreach($orders as $order) {
|
||||
foreach ($orders as $order) {
|
||||
switch ($order) {
|
||||
case 'id':
|
||||
$search->orderById(Criteria::ASC);
|
||||
|
||||
@@ -35,7 +35,6 @@ use Thelia\Model\FolderQuery;
|
||||
use Thelia\Model\Map\ContentTableMap;
|
||||
use Thelia\Model\ContentFolderQuery;
|
||||
use Thelia\Model\ContentQuery;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Type\TypeCollection;
|
||||
use Thelia\Type;
|
||||
use Thelia\Type\BooleanOrBothType;
|
||||
|
||||
@@ -32,7 +32,6 @@ use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
use Thelia\Model\CountryQuery;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@@ -34,13 +34,9 @@ use Thelia\Core\Template\Element\LoopResultRow;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
use Thelia\Model\Base\CategoryQuery;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Model\CouponQuery;
|
||||
use Thelia\Model\Coupon as MCoupon;
|
||||
use Thelia\Model\Map\ProductCategoryTableMap;
|
||||
use Thelia\Type;
|
||||
use Thelia\Type\BooleanOrBothType;
|
||||
|
||||
/**
|
||||
* Created by JetBrains PhpStorm.
|
||||
@@ -95,7 +91,6 @@ class Coupon extends BaseI18nLoop
|
||||
/** @var Lang $lang */
|
||||
$lang = $request->getSession()->getLang();
|
||||
|
||||
|
||||
/** @var MCoupon $coupon */
|
||||
foreach ($coupons as $coupon) {
|
||||
$loopResultRow = new LoopResultRow();
|
||||
|
||||
@@ -32,7 +32,6 @@ use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
use Thelia\Model\CurrencyQuery;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Type\TypeCollection;
|
||||
use Thelia\Type\EnumListType;
|
||||
|
||||
@@ -109,7 +108,7 @@ class Currency extends BaseI18nLoop
|
||||
|
||||
$orders = $this->getOrder();
|
||||
|
||||
foreach($orders as $order) {
|
||||
foreach ($orders as $order) {
|
||||
switch ($order) {
|
||||
case 'id':
|
||||
$search->orderById(Criteria::ASC);
|
||||
|
||||
@@ -24,7 +24,6 @@
|
||||
namespace Thelia\Core\Template\Loop;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Propel\Runtime\Collection\ObjectCollection;
|
||||
use Thelia\Core\Template\Element\BaseLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
@@ -48,7 +47,7 @@ use Thelia\Type;
|
||||
class Customer extends BaseLoop
|
||||
{
|
||||
public $timestampable = true;
|
||||
|
||||
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
*/
|
||||
|
||||
@@ -26,7 +26,6 @@ use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
|
||||
/**
|
||||
* Class Delivery
|
||||
* @package Thelia\Core\Template\Loop
|
||||
@@ -60,7 +59,7 @@ class Delivery extends BaseSpecificModule
|
||||
$loopResultRow = new LoopResultRow($loopResult, $deliveryModule, $this->versionable, $this->timestampable, $this->countable);
|
||||
|
||||
$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()));
|
||||
}
|
||||
$moduleInstance = $moduleReflection->newInstance();
|
||||
@@ -82,4 +81,4 @@ class Delivery extends BaseSpecificModule
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@ use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Model\Base\CategoryQuery;
|
||||
use Thelia\Model\Base\ProductCategoryQuery;
|
||||
use Thelia\Model\Base\FeatureQuery;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Model\Map\ProductCategoryTableMap;
|
||||
use Thelia\Type\TypeCollection;
|
||||
use Thelia\Type;
|
||||
|
||||
@@ -32,7 +32,6 @@ use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
use Thelia\Model\Base\FeatureAvQuery;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Type\TypeCollection;
|
||||
use Thelia\Type;
|
||||
|
||||
|
||||
@@ -24,19 +24,15 @@
|
||||
namespace Thelia\Core\Template\Loop;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Propel\Runtime\ActiveQuery\Join;
|
||||
use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Log\Tlog;
|
||||
|
||||
use Thelia\Model\Base\FeatureProductQuery;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Model\Map\FeatureAvTableMap;
|
||||
use Thelia\Model\Map\FeatureProductTableMap;
|
||||
use Thelia\Type\TypeCollection;
|
||||
use Thelia\Type;
|
||||
|
||||
@@ -107,18 +103,18 @@ class FeatureValue extends BaseI18nLoop
|
||||
}
|
||||
|
||||
$excludeFeatureAvailability = $this->getExclude_feature_availability();
|
||||
if($excludeFeatureAvailability == true) {
|
||||
if ($excludeFeatureAvailability == true) {
|
||||
$search->filterByFeatureAvId(null, Criteria::NULL);
|
||||
}
|
||||
|
||||
$excludeDefaultValues = $this->getExclude_personal_values();
|
||||
if($excludeDefaultValues == true) {
|
||||
if ($excludeDefaultValues == true) {
|
||||
$search->filterByByDefault(null, Criteria::NULL);
|
||||
}
|
||||
|
||||
$orders = $this->getOrder();
|
||||
|
||||
foreach($orders as $order) {
|
||||
foreach ($orders as $order) {
|
||||
switch ($order) {
|
||||
case "alpha":
|
||||
$search->addAscendingOrderByColumn(FeatureAvTableMap::TABLE_NAME . '_i18n_TITLE');
|
||||
@@ -157,4 +153,4 @@ class FeatureValue extends BaseI18nLoop
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,10 +30,8 @@ use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Log\Tlog;
|
||||
|
||||
use Thelia\Model\FolderQuery;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Type\TypeCollection;
|
||||
use Thelia\Type;
|
||||
use Thelia\Type\BooleanOrBothType;
|
||||
@@ -83,7 +81,7 @@ class Folder extends BaseI18nLoop
|
||||
/* manage translations */
|
||||
$locale = $this->configureI18nProcessing($search);
|
||||
|
||||
$id = $this->getId();
|
||||
$id = $this->getId();
|
||||
|
||||
if (!is_null($id)) {
|
||||
$search->filterById($id, Criteria::IN);
|
||||
@@ -95,8 +93,7 @@ class Folder extends BaseI18nLoop
|
||||
$search->filterByParent($parent);
|
||||
}
|
||||
|
||||
|
||||
$current = $this->getCurrent();
|
||||
$current = $this->getCurrent();
|
||||
|
||||
if ($current === true) {
|
||||
$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);
|
||||
}
|
||||
|
||||
|
||||
$exclude = $this->getExclude();
|
||||
|
||||
if (!is_null($exclude)) {
|
||||
@@ -117,7 +113,7 @@ class Folder extends BaseI18nLoop
|
||||
|
||||
$orders = $this->getOrder();
|
||||
|
||||
foreach($orders as $order) {
|
||||
foreach ($orders as $order) {
|
||||
switch ($order) {
|
||||
case "alpha":
|
||||
$search->addAscendingOrderByColumn('i18n_TITLE');
|
||||
@@ -157,23 +153,23 @@ class Folder extends BaseI18nLoop
|
||||
$loopResultRow = new LoopResultRow($loopResult, $folder, $this->versionable, $this->timestampable, $this->countable);
|
||||
|
||||
$loopResultRow
|
||||
->set("ID", $folder->getId())
|
||||
->set("ID", $folder->getId())
|
||||
->set("IS_TRANSLATED",$folder->getVirtualColumn('IS_TRANSLATED'))
|
||||
->set("LOCALE",$locale)
|
||||
->set("TITLE",$folder->getVirtualColumn('i18n_TITLE'))
|
||||
->set("CHAPO", $folder->getVirtualColumn('i18n_CHAPO'))
|
||||
->set("DESCRIPTION", $folder->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set("POSTSCRIPTUM", $folder->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||
->set("PARENT", $folder->getParent())
|
||||
->set("PARENT", $folder->getParent())
|
||||
->set("URL", $folder->getUrl($locale))
|
||||
->set("CONTENT_COUNT", $folder->countChild())
|
||||
->set("VISIBLE", $folder->getVisible() ? "1" : "0")
|
||||
->set("POSITION", $folder->getPosition())
|
||||
;
|
||||
->set("CONTENT_COUNT", $folder->countChild())
|
||||
->set("VISIBLE", $folder->getVisible() ? "1" : "0")
|
||||
->set("POSITION", $folder->getPosition())
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,8 +25,6 @@ namespace Thelia\Core\Template\Loop;
|
||||
use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Core\Event\ImageEvent;
|
||||
use Thelia\Model\CategoryImageQuery;
|
||||
use Thelia\Model\ProductImageQuery;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Type\TypeCollection;
|
||||
@@ -99,7 +97,7 @@ class Image extends BaseI18nLoop
|
||||
);
|
||||
|
||||
// Add possible image sources
|
||||
foreach($this->possible_sources as $source) {
|
||||
foreach ($this->possible_sources as $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
|
||||
*
|
||||
* @param string $source a valid source identifier (@see $possible_sources)
|
||||
* @param int $object_id the source object ID
|
||||
* @param string $source a valid source identifier (@see $possible_sources)
|
||||
* @param int $object_id the source object ID
|
||||
* @return ModelCriteria the propel Query object
|
||||
*/
|
||||
protected function createSearchQuery($source, $object_id) {
|
||||
|
||||
protected function createSearchQuery($source, $object_id)
|
||||
{
|
||||
$object = ucfirst($source);
|
||||
|
||||
$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
|
||||
*
|
||||
* @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_type (returned) the a valid source identifier (@see $possible_sources)
|
||||
* @param string $object_id (returned) the ID of the source object
|
||||
* @return ModelCriteria the propel Query object
|
||||
*/
|
||||
protected function getSearchQuery(&$object_type, &$object_id) {
|
||||
|
||||
protected function getSearchQuery(&$object_type, &$object_id)
|
||||
{
|
||||
$search = null;
|
||||
|
||||
// Check form source="product" source_id="123" style arguments
|
||||
@@ -184,10 +182,9 @@ class Image extends BaseI18nLoop
|
||||
|
||||
$object_type = $source;
|
||||
$object_id = $source_id;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// 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));
|
||||
|
||||
@@ -247,7 +244,7 @@ class Image extends BaseI18nLoop
|
||||
$effects = explode(',', $effects);
|
||||
}
|
||||
|
||||
switch($this->getResizeMode()) {
|
||||
switch ($this->getResizeMode()) {
|
||||
case 'crop' :
|
||||
$resize_mode = \Thelia\Action\Image::EXACT_RATIO_WITH_CROP;
|
||||
break;
|
||||
@@ -316,8 +313,7 @@ class Image extends BaseI18nLoop
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
catch (\Exception $ex) {
|
||||
} catch (\Exception $ex) {
|
||||
// Ignore the result and log an error
|
||||
Tlog::getInstance()->addError("Failed to process image in image loop: ", $this->args);
|
||||
}
|
||||
@@ -325,4 +321,4 @@ class Image extends BaseI18nLoop
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,7 +30,6 @@ use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
use Thelia\Model\LangQuery;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Model\MessageQuery;
|
||||
use Thelia\Type\BooleanOrBothType;
|
||||
|
||||
@@ -31,11 +31,10 @@ use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Log\Tlog;
|
||||
|
||||
use Thelia\Model\CategoryQuery;
|
||||
use Thelia\Model\CountryQuery;
|
||||
use Thelia\Model\Map\FeatureProductTableMap;
|
||||
use Thelia\Model\CurrencyQuery;
|
||||
use Thelia\Model\Map\ProductPriceTableMap;
|
||||
use Thelia\Model\Map\ProductSaleElementsTableMap;
|
||||
use Thelia\Model\Map\ProductTableMap;
|
||||
@@ -54,8 +53,6 @@ use Thelia\Type\BooleanOrBothType;
|
||||
* Class Product
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*
|
||||
* @todo : manage currency in price filter
|
||||
*/
|
||||
class Product extends BaseI18nLoop
|
||||
{
|
||||
@@ -87,6 +84,7 @@ class Product extends BaseI18nLoop
|
||||
Argument::createBooleanTypeArgument('current_category'),
|
||||
Argument::createIntTypeArgument('depth', 1),
|
||||
Argument::createBooleanOrBothTypeArgument('visible', 1),
|
||||
Argument::createIntTypeArgument('currency'),
|
||||
new Argument(
|
||||
'order',
|
||||
new TypeCollection(
|
||||
@@ -137,6 +135,19 @@ class Product extends BaseI18nLoop
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
{
|
||||
$currencyId = $this->getCurrency();
|
||||
if(null !== $currencyId) {
|
||||
$currency = CurrencyQuery::create()->findOneById($currencyId);
|
||||
if(null === $currency) {
|
||||
throw new \InvalidArgumentException('Cannot found currency id: `' . $currency . '` in product_sale_elements loop');
|
||||
}
|
||||
} else {
|
||||
$currency = $this->request->getSession()->getCurrency();
|
||||
}
|
||||
|
||||
$defaultCurrency = CurrencyQuery::create()->findOneByByDefault(1);
|
||||
$defaultCurrencySuffix = '_default_currency';
|
||||
|
||||
$search = ProductQuery::create();
|
||||
|
||||
/* manage translations */
|
||||
@@ -144,7 +155,7 @@ class Product extends BaseI18nLoop
|
||||
|
||||
$attributeNonStrictMatch = $this->getAttribute_non_strict_match();
|
||||
$isPSELeftJoinList = array();
|
||||
$isProductPriceLeftJoinList = array();
|
||||
$isProductPriceFirstLeftJoin = array();
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
@@ -165,8 +176,8 @@ class Product extends BaseI18nLoop
|
||||
|
||||
$depth = $this->getDepth();
|
||||
|
||||
if(null !== $depth) {
|
||||
foreach(CategoryQuery::findAllChild($category, $depth) as $subCategory) {
|
||||
if (null !== $depth) {
|
||||
foreach (CategoryQuery::findAllChild($category, $depth) as $subCategory) {
|
||||
$categories->prepend($subCategory);
|
||||
}
|
||||
}
|
||||
@@ -184,7 +195,7 @@ class Product extends BaseI18nLoop
|
||||
$search->joinProductSaleElements('is_new', Criteria::LEFT_JOIN)
|
||||
->where('`is_new`.NEWNESS' . Criteria::EQUAL . '1')
|
||||
->where('NOT ISNULL(`is_new`.ID)');
|
||||
} else if($new === false) {
|
||||
} elseif ($new === false) {
|
||||
$isPSELeftJoinList[] = 'is_new';
|
||||
$search->joinProductSaleElements('is_new', Criteria::LEFT_JOIN)
|
||||
->where('`is_new`.NEWNESS' . Criteria::EQUAL . '0')
|
||||
@@ -198,7 +209,7 @@ class Product extends BaseI18nLoop
|
||||
$search->joinProductSaleElements('is_promo', Criteria::LEFT_JOIN)
|
||||
->where('`is_promo`.PROMO' . Criteria::EQUAL . '1')
|
||||
->where('NOT ISNULL(`is_promo`.ID)');
|
||||
} else if($promo === false) {
|
||||
} elseif ($promo === false) {
|
||||
$isPSELeftJoinList[] = 'is_promo';
|
||||
$search->joinProductSaleElements('is_promo', Criteria::LEFT_JOIN)
|
||||
->where('`is_promo`.PROMO' . Criteria::EQUAL . '0')
|
||||
@@ -232,68 +243,111 @@ class Product extends BaseI18nLoop
|
||||
->where('NOT ISNULL(`is_max_weight`.ID)');
|
||||
}
|
||||
|
||||
$min_price = $this->getMin_price();
|
||||
|
||||
if(null !== $min_price) {
|
||||
$isPSELeftJoinList[] = 'is_min_price';
|
||||
$isProductPriceLeftJoinList['is_min_price'] = 'min_price_data';
|
||||
$minPriceJoin = new Join();
|
||||
$minPriceJoin->addExplicitCondition(ProductSaleElementsTableMap::TABLE_NAME, 'ID', 'is_min_price', ProductPriceTableMap::TABLE_NAME, 'PRODUCT_SALE_ELEMENTS_ID', 'min_price_data');
|
||||
$minPriceJoin->setJoinType(Criteria::LEFT_JOIN);
|
||||
|
||||
$search->joinProductSaleElements('is_min_price', Criteria::LEFT_JOIN)
|
||||
->addJoinObject($minPriceJoin)
|
||||
->condition('in_promo', '`is_min_price`.promo'. Criteria::EQUAL .'1')
|
||||
->condition('not_in_promo', '`is_min_price`.promo'. Criteria::NOT_EQUAL .'1')
|
||||
->condition('min_promo_price', '`min_price_data`.promo_price' . Criteria::GREATER_EQUAL . '?', $min_price, \PDO::PARAM_STR)
|
||||
->condition('min_price', '`min_price_data`.price' . Criteria::GREATER_EQUAL . '?', $min_price, \PDO::PARAM_STR)
|
||||
->combine(array('in_promo', 'min_promo_price'), Criteria::LOGICAL_AND, 'in_promo_min_price')
|
||||
->combine(array('not_in_promo', 'min_price'), Criteria::LOGICAL_AND, 'not_in_promo_min_price')
|
||||
->where(array('not_in_promo_min_price', 'in_promo_min_price'), Criteria::LOGICAL_OR);
|
||||
}
|
||||
|
||||
$max_price = $this->getMax_price();
|
||||
|
||||
if(null !== $max_price) {
|
||||
$isPSELeftJoinList[] = 'is_max_price';
|
||||
$isProductPriceLeftJoinList['is_max_price'] = 'max_price_data';
|
||||
$minPriceJoin = new Join();
|
||||
$minPriceJoin->addExplicitCondition(ProductSaleElementsTableMap::TABLE_NAME, 'ID', 'is_max_price', ProductPriceTableMap::TABLE_NAME, 'PRODUCT_SALE_ELEMENTS_ID', 'max_price_data');
|
||||
$minPriceJoin->setJoinType(Criteria::LEFT_JOIN);
|
||||
|
||||
$search->joinProductSaleElements('is_max_price', Criteria::LEFT_JOIN)
|
||||
->addJoinObject($minPriceJoin)
|
||||
->condition('in_promo', '`is_max_price`.promo'. Criteria::EQUAL .'1')
|
||||
->condition('not_in_promo', '`is_max_price`.promo'. Criteria::NOT_EQUAL .'1')
|
||||
->condition('min_promo_price', '`max_price_data`.promo_price' . Criteria::LESS_EQUAL . '?', $max_price, \PDO::PARAM_STR)
|
||||
->condition('max_price', '`max_price_data`.price' . Criteria::LESS_EQUAL . '?', $max_price, \PDO::PARAM_STR)
|
||||
->combine(array('in_promo', 'min_promo_price'), Criteria::LOGICAL_AND, 'in_promo_max_price')
|
||||
->combine(array('not_in_promo', 'max_price'), Criteria::LOGICAL_AND, 'not_in_promo_max_price')
|
||||
->where(array('not_in_promo_max_price', 'in_promo_max_price'), Criteria::LOGICAL_OR);
|
||||
}
|
||||
|
||||
if( $attributeNonStrictMatch != '*' ) {
|
||||
if($attributeNonStrictMatch == 'none') {
|
||||
if ($attributeNonStrictMatch != '*') {
|
||||
if ($attributeNonStrictMatch == 'none') {
|
||||
$actuallyUsedAttributeNonStrictMatchList = $isPSELeftJoinList;
|
||||
} else {
|
||||
$actuallyUsedAttributeNonStrictMatchList = array_values(array_intersect($isPSELeftJoinList, $attributeNonStrictMatch));
|
||||
}
|
||||
|
||||
foreach($actuallyUsedAttributeNonStrictMatchList as $key => $actuallyUsedAttributeNonStrictMatch) {
|
||||
foreach ($actuallyUsedAttributeNonStrictMatchList as $key => $actuallyUsedAttributeNonStrictMatch) {
|
||||
if($key == 0)
|
||||
continue;
|
||||
$search->where('`' . $actuallyUsedAttributeNonStrictMatch . '`.ID=' . '`' . $actuallyUsedAttributeNonStrictMatchList[$key-1] . '`.ID');
|
||||
}
|
||||
}
|
||||
|
||||
$min_price = $this->getMin_price();
|
||||
|
||||
if (null !== $min_price) {
|
||||
|
||||
if (false === ConfigQuery::useTaxFreeAmounts()) {
|
||||
// @todo
|
||||
}
|
||||
|
||||
$isPSELeftJoinList[] = 'is_min_price';
|
||||
$isProductPriceFirstLeftJoin = array('is_min_price', 'min_price_data');
|
||||
|
||||
$minPriceJoin = new Join();
|
||||
$minPriceJoin->addExplicitCondition(ProductSaleElementsTableMap::TABLE_NAME, 'ID', 'is_min_price', ProductPriceTableMap::TABLE_NAME, 'PRODUCT_SALE_ELEMENTS_ID', 'min_price_data');
|
||||
$minPriceJoin->setJoinType(Criteria::LEFT_JOIN);
|
||||
|
||||
$search->joinProductSaleElements('is_min_price', Criteria::LEFT_JOIN)
|
||||
->addJoinObject($minPriceJoin, 'is_min_price_join')
|
||||
->addJoinCondition('is_min_price_join', '`min_price_data`.`currency_id` = ?', $currency->getId(), null, \PDO::PARAM_INT);
|
||||
|
||||
if ($defaultCurrency->getId() != $currency->getId()) {
|
||||
$minPriceJoinDefaultCurrency = new Join();
|
||||
$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);
|
||||
|
||||
$search->addJoinObject($minPriceJoinDefaultCurrency, 'is_min_price_join' . $defaultCurrencySuffix)
|
||||
->addJoinCondition('is_min_price_join' . $defaultCurrencySuffix, '`min_price_data' . $defaultCurrencySuffix . '`.`currency_id` = ?', $defaultCurrency->getId(), null, \PDO::PARAM_INT);
|
||||
|
||||
/**
|
||||
* In propel we trust : $currency->getRate() always returns a float.
|
||||
* Or maybe not : rate value is checked as a float in overloaded getRate method.
|
||||
*/
|
||||
$MinPriceToCompareAsSQL = 'CASE WHEN ISNULL(CASE WHEN `is_min_price`.PROMO=1 THEN `min_price_data`.PROMO_PRICE ELSE `min_price_data`.PRICE END) THEN
|
||||
CASE WHEN `is_min_price`.PROMO=1 THEN `min_price_data' . $defaultCurrencySuffix . '`.PROMO_PRICE ELSE `min_price_data' . $defaultCurrencySuffix . '`.PRICE END * ' . $currency->getRate() . '
|
||||
ELSE
|
||||
CASE WHEN `is_min_price`.PROMO=1 THEN `min_price_data`.PROMO_PRICE ELSE `min_price_data`.PRICE END
|
||||
END';
|
||||
} else {
|
||||
$MinPriceToCompareAsSQL = 'CASE WHEN `is_min_price`.PROMO=1 THEN `min_price_data`.PROMO_PRICE ELSE `min_price_data`.PRICE END';
|
||||
}
|
||||
|
||||
$search->where('ROUND(' . $MinPriceToCompareAsSQL . ', 2)>=?', $min_price, \PDO::PARAM_STR);
|
||||
}
|
||||
|
||||
$max_price = $this->getMax_price();
|
||||
|
||||
if (null !== $max_price) {
|
||||
$isPSELeftJoinList[] = 'is_max_price';
|
||||
$isProductPriceFirstLeftJoin = array('is_max_price', 'max_price_data');
|
||||
|
||||
$maxPriceJoin = new Join();
|
||||
$maxPriceJoin->addExplicitCondition(ProductSaleElementsTableMap::TABLE_NAME, 'ID', 'is_max_price', ProductPriceTableMap::TABLE_NAME, 'PRODUCT_SALE_ELEMENTS_ID', 'max_price_data');
|
||||
$maxPriceJoin->setJoinType(Criteria::LEFT_JOIN);
|
||||
|
||||
$search->joinProductSaleElements('is_max_price', Criteria::LEFT_JOIN)
|
||||
->addJoinObject($maxPriceJoin, 'is_max_price_join')
|
||||
->addJoinCondition('is_max_price_join', '`max_price_data`.`currency_id` = ?', $currency->getId(), null, \PDO::PARAM_INT);
|
||||
|
||||
if ($defaultCurrency->getId() != $currency->getId()) {
|
||||
$maxPriceJoinDefaultCurrency = new Join();
|
||||
$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);
|
||||
|
||||
$search->addJoinObject($maxPriceJoinDefaultCurrency, 'is_max_price_join' . $defaultCurrencySuffix)
|
||||
->addJoinCondition('is_max_price_join' . $defaultCurrencySuffix, '`max_price_data' . $defaultCurrencySuffix . '`.`currency_id` = ?', $defaultCurrency->getId(), null, \PDO::PARAM_INT);
|
||||
|
||||
/**
|
||||
* In propel we trust : $currency->getRate() always returns a float.
|
||||
* Or maybe not : rate value is checked as a float in overloaded getRate method.
|
||||
*/
|
||||
$MaxPriceToCompareAsSQL = 'CASE WHEN ISNULL(CASE WHEN `is_max_price`.PROMO=1 THEN `max_price_data`.PROMO_PRICE ELSE `max_price_data`.PRICE END) THEN
|
||||
CASE WHEN `is_max_price`.PROMO=1 THEN `max_price_data' . $defaultCurrencySuffix . '`.PROMO_PRICE ELSE `max_price_data' . $defaultCurrencySuffix . '`.PRICE END * ' . $currency->getRate() . '
|
||||
ELSE
|
||||
CASE WHEN `is_max_price`.PROMO=1 THEN `max_price_data`.PROMO_PRICE ELSE `max_price_data`.PRICE END
|
||||
END';
|
||||
|
||||
} else {
|
||||
$MaxPriceToCompareAsSQL = 'CASE WHEN `is_max_price`.PROMO=1 THEN `max_price_data`.PROMO_PRICE ELSE `max_price_data`.PRICE END';
|
||||
}
|
||||
|
||||
$search->where('ROUND(' . $MaxPriceToCompareAsSQL . ', 2)<=?', $max_price, \PDO::PARAM_STR);
|
||||
}
|
||||
|
||||
/*
|
||||
* for ordering and outputs, the product will be :
|
||||
* - new if at least one the criteria matching PSE is new
|
||||
* - in promo if at least one the criteria matching PSE is in promo
|
||||
*/
|
||||
|
||||
if(count($isProductPriceLeftJoinList) == 0) {
|
||||
if(count($isPSELeftJoinList) == 0) {
|
||||
/* if we don't have any join yet, let's make a global one */
|
||||
if (empty($isProductPriceFirstLeftJoin)) {
|
||||
if (count($isPSELeftJoinList) == 0) {
|
||||
$joiningTable = "global";
|
||||
$isPSELeftJoinList[] = $joiningTable;
|
||||
$search->joinProductSaleElements('global', Criteria::LEFT_JOIN);
|
||||
@@ -301,13 +355,22 @@ class Product extends BaseI18nLoop
|
||||
$joiningTable = $isPSELeftJoinList[0];
|
||||
}
|
||||
|
||||
$isProductPriceLeftJoinList[$joiningTable] = 'global_price_data';
|
||||
$isProductPriceFirstLeftJoin = array($joiningTable, 'global_price_data');
|
||||
|
||||
$minPriceJoin = new Join();
|
||||
$minPriceJoin->addExplicitCondition(ProductSaleElementsTableMap::TABLE_NAME, 'ID', $joiningTable, ProductPriceTableMap::TABLE_NAME, 'PRODUCT_SALE_ELEMENTS_ID', 'global_price_data');
|
||||
$minPriceJoin->setJoinType(Criteria::LEFT_JOIN);
|
||||
$globalPriceJoin = new Join();
|
||||
$globalPriceJoin->addExplicitCondition(ProductSaleElementsTableMap::TABLE_NAME, 'ID', $joiningTable, ProductPriceTableMap::TABLE_NAME, 'PRODUCT_SALE_ELEMENTS_ID', 'global_price_data');
|
||||
$globalPriceJoin->setJoinType(Criteria::LEFT_JOIN);
|
||||
|
||||
$search->addJoinObject($minPriceJoin);
|
||||
$search->addJoinObject($globalPriceJoin, 'global_price_join')
|
||||
->addJoinCondition('global_price_join', '`global_price_data`.`currency_id` = ?', $currency->getId(), null, \PDO::PARAM_INT);
|
||||
|
||||
if ($defaultCurrency->getId() != $currency->getId()) {
|
||||
$globalPriceJoinDefaultCurrency = new Join();
|
||||
$globalPriceJoinDefaultCurrency->addExplicitCondition(ProductSaleElementsTableMap::TABLE_NAME, 'ID', $joiningTable, ProductPriceTableMap::TABLE_NAME, 'PRODUCT_SALE_ELEMENTS_ID', 'global_price_data' . $defaultCurrencySuffix);
|
||||
$globalPriceJoinDefaultCurrency->setJoinType(Criteria::LEFT_JOIN);
|
||||
$search->addJoinObject($globalPriceJoinDefaultCurrency, 'global_price_join' . $defaultCurrencySuffix)
|
||||
->addJoinCondition('global_price_join' . $defaultCurrencySuffix, '`global_price_data' . $defaultCurrencySuffix . '`.`currency_id` = ?', $defaultCurrency->getId(), null, \PDO::PARAM_INT);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -326,25 +389,34 @@ class Product extends BaseI18nLoop
|
||||
*/
|
||||
$booleanMatchedPromoList = array();
|
||||
$booleanMatchedNewnessList = array();
|
||||
foreach($isPSELeftJoinList as $isPSELeftJoin) {
|
||||
foreach ($isPSELeftJoinList as $isPSELeftJoin) {
|
||||
$booleanMatchedPromoList[] = '`' . $isPSELeftJoin . '`.PROMO';
|
||||
$booleanMatchedNewnessList[] = '`' . $isPSELeftJoin . '`.NEWNESS';
|
||||
}
|
||||
$booleanMatchedPriceList = array();
|
||||
foreach($isProductPriceLeftJoinList as $pSE => $isProductPriceLeftJoin) {
|
||||
$booleanMatchedPriceList[] = 'CASE WHEN `' . $pSE . '`.PROMO=1 THEN `' . $isProductPriceLeftJoin . '`.PROMO_PRICE ELSE `' . $isProductPriceLeftJoin . '`.PRICE END';
|
||||
}
|
||||
$search->withColumn('ROUND(MAX(' . implode(' OR ', $booleanMatchedPromoList) . '), 2)', 'main_product_is_promo');
|
||||
$search->withColumn('ROUND(MAX(' . implode(' OR ', $booleanMatchedNewnessList) . '), 2)', 'main_product_is_new');
|
||||
$search->withColumn('ROUND(MAX(' . implode(' OR ', $booleanMatchedPriceList) . '), 2)', 'real_highest_price');
|
||||
$search->withColumn('ROUND(MIN(' . implode(' OR ', $booleanMatchedPriceList) . '), 2)', 'real_lowest_price');
|
||||
|
||||
$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';
|
||||
|
||||
if ($defaultCurrency->getId() != $currency->getId()) {
|
||||
/**
|
||||
* In propel we trust : $currency->getRate() always returns a float.
|
||||
* Or maybe not : rate value is checked as a float in overloaded getRate method.
|
||||
*/
|
||||
$priceToCompareAsSQL = 'CASE WHEN ISNULL(' . $booleanMatchedPrice .') THEN ' . $booleanMatchedPriceDefaultCurrency . ' * ' . $currency->getRate() . ' ELSE ' . $booleanMatchedPrice . ' END';
|
||||
} else {
|
||||
$priceToCompareAsSQL = $booleanMatchedPrice;
|
||||
}
|
||||
|
||||
$search->withColumn('ROUND(MAX(' . $priceToCompareAsSQL . '), 2)', 'real_highest_price');
|
||||
$search->withColumn('ROUND(MIN(' . $priceToCompareAsSQL . '), 2)', 'real_lowest_price');
|
||||
|
||||
$current = $this->getCurrent();
|
||||
|
||||
if ($current === true) {
|
||||
$search->filterById($this->request->get("product_id"));
|
||||
} elseif($current === false) {
|
||||
} elseif ($current === false) {
|
||||
$search->filterById($this->request->get("product_id"), Criteria::NOT_IN);
|
||||
}
|
||||
|
||||
@@ -361,7 +433,7 @@ class Product extends BaseI18nLoop
|
||||
)->find(),
|
||||
Criteria::IN
|
||||
);
|
||||
} elseif($current_category === false) {
|
||||
} elseif ($current_category === false) {
|
||||
$search->filterByCategory(
|
||||
CategoryQuery::create()->filterByProduct(
|
||||
ProductCategoryQuery::create()->filterByProductId(
|
||||
@@ -395,9 +467,9 @@ class Product extends BaseI18nLoop
|
||||
|
||||
$feature_availability = $this->getFeature_availability();
|
||||
|
||||
if(null !== $feature_availability) {
|
||||
foreach($feature_availability as $feature => $feature_choice) {
|
||||
foreach($feature_choice['values'] as $feature_av) {
|
||||
if (null !== $feature_availability) {
|
||||
foreach ($feature_availability as $feature => $feature_choice) {
|
||||
foreach ($feature_choice['values'] as $feature_av) {
|
||||
$featureAlias = 'fa_' . $feature;
|
||||
if($feature_av != '*')
|
||||
$featureAlias .= '_' . $feature_av;
|
||||
@@ -409,7 +481,7 @@ class Product extends BaseI18nLoop
|
||||
|
||||
/* format for mysql */
|
||||
$sqlWhereString = $feature_choice['expression'];
|
||||
if($sqlWhereString == '*') {
|
||||
if ($sqlWhereString == '*') {
|
||||
$sqlWhereString = 'NOT ISNULL(`fa_' . $feature . '`.ID)';
|
||||
} else {
|
||||
$sqlWhereString = preg_replace('#([0-9]+)#', 'NOT ISNULL(`fa_' . $feature . '_' . '\1`.ID)', $sqlWhereString);
|
||||
@@ -423,9 +495,9 @@ class Product extends BaseI18nLoop
|
||||
|
||||
$feature_values = $this->getFeature_values();
|
||||
|
||||
if(null !== $feature_values) {
|
||||
foreach($feature_values as $feature => $feature_choice) {
|
||||
foreach($feature_choice['values'] as $feature_value) {
|
||||
if (null !== $feature_values) {
|
||||
foreach ($feature_values as $feature => $feature_choice) {
|
||||
foreach ($feature_choice['values'] as $feature_value) {
|
||||
$featureAlias = 'fv_' . $feature;
|
||||
if($feature_value != '*')
|
||||
$featureAlias .= '_' . $feature_value;
|
||||
@@ -437,7 +509,7 @@ class Product extends BaseI18nLoop
|
||||
|
||||
/* format for mysql */
|
||||
$sqlWhereString = $feature_choice['expression'];
|
||||
if($sqlWhereString == '*') {
|
||||
if ($sqlWhereString == '*') {
|
||||
$sqlWhereString = 'NOT ISNULL(`fv_' . $feature . '`.ID)';
|
||||
} else {
|
||||
$sqlWhereString = preg_replace('#([a-zA-Z0-9_\-]+)#', 'NOT ISNULL(`fv_' . $feature . '_' . '\1`.ID)', $sqlWhereString);
|
||||
@@ -453,7 +525,7 @@ class Product extends BaseI18nLoop
|
||||
|
||||
$orders = $this->getOrder();
|
||||
|
||||
foreach($orders as $order) {
|
||||
foreach ($orders as $order) {
|
||||
switch ($order) {
|
||||
case "alpha":
|
||||
$search->addAscendingOrderByColumn('i18n_TITLE');
|
||||
@@ -489,7 +561,7 @@ class Product extends BaseI18nLoop
|
||||
case "given_id":
|
||||
if(null === $id)
|
||||
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;
|
||||
$search->withColumn(ProductTableMap::ID . "='$singleId'", $givenIdMatched);
|
||||
$search->orderBy($givenIdMatched, Criteria::DESC);
|
||||
|
||||
@@ -24,18 +24,17 @@
|
||||
namespace Thelia\Core\Template\Loop;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Propel\Runtime\ActiveQuery\Join;
|
||||
use Thelia\Core\Template\Element\BaseLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Log\Tlog;
|
||||
|
||||
use Thelia\Model\Base\ProductSaleElementsQuery;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Model\CountryQuery;
|
||||
use Thelia\Model\CurrencyQuery;
|
||||
use Thelia\Model\Map\ProductSaleElementsTableMap;
|
||||
use Thelia\Type\TypeCollection;
|
||||
use Thelia\Type;
|
||||
|
||||
@@ -43,7 +42,7 @@ use Thelia\Type;
|
||||
*
|
||||
* Product Sale Elements loop
|
||||
*
|
||||
* @todo : manage currency and attribute_availability
|
||||
* @todo : manage attribute_availability ?
|
||||
*
|
||||
* Class ProductSaleElements
|
||||
* @package Thelia\Core\Template\Loop
|
||||
@@ -52,7 +51,7 @@ use Thelia\Type;
|
||||
class ProductSaleElements extends BaseLoop
|
||||
{
|
||||
public $timestampable = true;
|
||||
|
||||
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
*/
|
||||
@@ -70,9 +69,9 @@ class ProductSaleElements extends BaseLoop
|
||||
new Argument(
|
||||
'order',
|
||||
new TypeCollection(
|
||||
new Type\EnumListType(array('alpha', 'alpha_reverse', 'attribute', 'attribute_reverse'))
|
||||
new Type\EnumListType(array('min_price', 'max_price', 'promo', 'new', 'random'))
|
||||
),
|
||||
'attribute'
|
||||
'random'
|
||||
)
|
||||
);
|
||||
}
|
||||
@@ -81,6 +80,7 @@ class ProductSaleElements extends BaseLoop
|
||||
* @param $pagination
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
{
|
||||
@@ -92,31 +92,56 @@ class ProductSaleElements extends BaseLoop
|
||||
|
||||
$orders = $this->getOrder();
|
||||
|
||||
foreach($orders as $order) {
|
||||
foreach ($orders as $order) {
|
||||
switch ($order) {
|
||||
case "alpha":
|
||||
//$search->addAscendingOrderByColumn(\Thelia\Model\Map\AttributeI18nTableMap::TITLE);
|
||||
case "min_price":
|
||||
$search->addAscendingOrderByColumn('price_FINAL_PRICE', Criteria::ASC);
|
||||
break;
|
||||
case "alpha_reverse":
|
||||
//$search->addDescendingOrderByColumn(\Thelia\Model\Map\AttributeI18nTableMap::TITLE);
|
||||
case "max_price":
|
||||
$search->addDescendingOrderByColumn('price_FINAL_PRICE');
|
||||
break;
|
||||
case "attribute":
|
||||
//$search->orderByPosition(Criteria::ASC);
|
||||
case "promo":
|
||||
$search->orderByPromo(Criteria::DESC);
|
||||
break;
|
||||
case "attribute_reverse":
|
||||
//$search->orderByPosition(Criteria::DESC);
|
||||
case "new":
|
||||
$search->orderByNewness(Criteria::DESC);
|
||||
break;
|
||||
case "random":
|
||||
$search->clearOrderByColumns();
|
||||
$search->addAscendingOrderByColumn('RAND()');
|
||||
break(2);
|
||||
}
|
||||
}
|
||||
|
||||
$currency = $this->getCurrency();
|
||||
$currencyId = $this->getCurrency();
|
||||
if (null !== $currencyId) {
|
||||
$currency = CurrencyQuery::create()->findOneById($currencyId);
|
||||
if (null === $currency) {
|
||||
throw new \InvalidArgumentException('Cannot found currency id: `' . $currency . '` in product_sale_elements loop');
|
||||
}
|
||||
} else {
|
||||
$currency = $this->request->getSession()->getCurrency();
|
||||
}
|
||||
|
||||
$search->joinProductPrice('price', Criteria::INNER_JOIN);
|
||||
//->addJoinCondition('price', '');
|
||||
$defaultCurrency = CurrencyQuery::create()->findOneByByDefault(1);
|
||||
$defaultCurrencySuffix = '_default_currency';
|
||||
|
||||
$search->withColumn('`price`.CURRENCY_ID', 'price_CURRENCY_ID')
|
||||
->withColumn('`price`.PRICE', 'price_PRICE')
|
||||
->withColumn('`price`.PROMO_PRICE', 'price_PROMO_PRICE');
|
||||
$search->joinProductPrice('price', Criteria::LEFT_JOIN)
|
||||
->addJoinCondition('price', '`price`.`currency_id` = ?', $currency->getId(), null, \PDO::PARAM_INT);
|
||||
|
||||
$search->joinProductPrice('price' . $defaultCurrencySuffix, Criteria::LEFT_JOIN)
|
||||
->addJoinCondition('price_default_currency', '`price' . $defaultCurrencySuffix . '`.`currency_id` = ?', $defaultCurrency->getId(), null, \PDO::PARAM_INT);
|
||||
|
||||
/**
|
||||
* rate value is checked as a float in overloaded getRate method.
|
||||
*/
|
||||
$priceSelectorAsSQL = 'ROUND(CASE WHEN ISNULL(`price`.PRICE) THEN `price_default_currency`.PRICE * ' . $currency->getRate() . ' ELSE `price`.PRICE END, 2)';
|
||||
$promoPriceSelectorAsSQL = 'ROUND(CASE WHEN ISNULL(`price`.PRICE) THEN `price_default_currency`.PROMO_PRICE * ' . $currency->getRate() . ' ELSE `price`.PROMO_PRICE END, 2)';
|
||||
$search->withColumn($priceSelectorAsSQL, 'price_PRICE')
|
||||
->withColumn($promoPriceSelectorAsSQL, 'price_PROMO_PRICE')
|
||||
->withColumn('CASE WHEN ' . ProductSaleElementsTableMap::PROMO . ' = 1 THEN ' . $promoPriceSelectorAsSQL . ' ELSE ' . $priceSelectorAsSQL . ' END', 'price_FINAL_PRICE');
|
||||
|
||||
$search->groupById();
|
||||
|
||||
$PSEValues = $this->search($search, $pagination);
|
||||
|
||||
@@ -139,8 +164,6 @@ class ProductSaleElements extends BaseLoop
|
||||
->set("IS_PROMO", $PSEValue->getPromo() === 1 ? 1 : 0)
|
||||
->set("IS_NEW", $PSEValue->getNewness() === 1 ? 1 : 0)
|
||||
->set("WEIGHT", $PSEValue->getWeight())
|
||||
|
||||
->set("CURRENCY", $PSEValue->getVirtualColumn('price_CURRENCY_ID'))
|
||||
->set("PRICE", $price)
|
||||
->set("PRICE_TAX", $taxedPrice - $price)
|
||||
->set("TAXED_PRICE", $taxedPrice)
|
||||
@@ -153,4 +176,4 @@ class ProductSaleElements extends BaseLoop
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,6 @@ use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
use Thelia\Model\CustomerTitleQuery;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
|
||||
/**
|
||||
*
|
||||
|
||||
@@ -25,7 +25,6 @@ namespace Thelia\Core\Template;
|
||||
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Core\HttpFoundation\Request;
|
||||
use Thelia\Tools\URL;
|
||||
use Thelia\Form\BaseForm;
|
||||
/**
|
||||
* The parser context is an application-wide context, which stores var-value pairs.
|
||||
|
||||
@@ -39,9 +39,9 @@ class SmartyAssetsManager
|
||||
/**
|
||||
* Creates a new SmartyAssetsManager instance
|
||||
*
|
||||
* @param string $web_root the disk path to the web root
|
||||
* @param string $path_relative_to_web_root the path (relative to web root) where the assets will be generated
|
||||
* @param boolean $developmentMode true / false. If true, assets are not cached, and always generated.
|
||||
* @param string $web_root the disk path to the web root
|
||||
* @param string $path_relative_to_web_root the path (relative to web root) where the assets will be generated
|
||||
* @param boolean $developmentMode true / false. If true, assets are not cached, and always generated.
|
||||
*/
|
||||
public function __construct($web_root, $path_relative_to_web_root, $developmentMode)
|
||||
{
|
||||
|
||||
@@ -23,11 +23,10 @@
|
||||
|
||||
namespace Thelia\Core\Template\Smarty\Exception;
|
||||
|
||||
|
||||
/**
|
||||
* Class SmartyPluginException
|
||||
* @package Thelia\Core\Template\Smarty\Exception
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class SmartyPluginException extends \SmartyException
|
||||
{}
|
||||
{}
|
||||
|
||||
@@ -26,7 +26,6 @@ namespace Thelia\Core\Template\Smarty\Plugins;
|
||||
use Thelia\Core\Template\Smarty\SmartyPluginDescriptor;
|
||||
use Thelia\Core\Template\Smarty\AbstractSmartyPlugin;
|
||||
use Thelia\Tools\URL;
|
||||
use Thelia\Core\HttpFoundation\Request;
|
||||
use Thelia\Core\Security\SecurityContext;
|
||||
|
||||
/**
|
||||
@@ -43,7 +42,8 @@ class AdminUtilities extends AbstractSmartyPlugin
|
||||
$this->securityContext = $securityContext;
|
||||
}
|
||||
|
||||
public function generatePositionChangeBlock($params, &$smarty) {
|
||||
public function generatePositionChangeBlock($params, &$smarty)
|
||||
{
|
||||
// The required permissions
|
||||
$permission = $this->getParam($params, 'permission');
|
||||
|
||||
@@ -77,13 +77,11 @@ class AdminUtilities extends AbstractSmartyPlugin
|
||||
$position,
|
||||
URL::getInstance()->absoluteUrl($path, array('mode' => 'down', $url_parameter => $id))
|
||||
);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return $position;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Generates the link of a sortable column header
|
||||
*
|
||||
@@ -111,12 +109,10 @@ class AdminUtilities extends AbstractSmartyPlugin
|
||||
if ($current_order == $order) {
|
||||
$icon = 'up';
|
||||
$order_change = $reverse_order;
|
||||
}
|
||||
else if ($current_order == $reverse_order) {
|
||||
} elseif ($current_order == $reverse_order) {
|
||||
$icon = 'down';
|
||||
$order_change = $order;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$order_change = $order;
|
||||
}
|
||||
|
||||
@@ -128,7 +124,6 @@ class AdminUtilities extends AbstractSmartyPlugin
|
||||
return sprintf('%s<a href="%s">%s</a>', $output, URL::getInstance()->absoluteUrl($path, array('order' => $order_change)), $label);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Define the various smarty plugins handled by this class
|
||||
*
|
||||
@@ -141,4 +136,4 @@ class AdminUtilities extends AbstractSmartyPlugin
|
||||
new SmartyPluginDescriptor('function', 'admin_position_block' , $this, 'generatePositionChangeBlock'),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ class DataAccessFunctions extends AbstractSmartyPlugin
|
||||
{
|
||||
$productId = $this->request->get('product_id');
|
||||
|
||||
if($productId !== null) {
|
||||
if ($productId !== null) {
|
||||
|
||||
$search = ProductQuery::create()
|
||||
->filterById($productId);
|
||||
@@ -98,7 +98,7 @@ class DataAccessFunctions extends AbstractSmartyPlugin
|
||||
{
|
||||
$categoryId = $this->request->get('category_id');
|
||||
|
||||
if($categoryId !== null) {
|
||||
if ($categoryId !== null) {
|
||||
|
||||
$search = CategoryQuery::create()
|
||||
->filterById($categoryId);
|
||||
@@ -111,7 +111,7 @@ class DataAccessFunctions extends AbstractSmartyPlugin
|
||||
{
|
||||
$contentId = $this->request->get('content_id');
|
||||
|
||||
if($contentId !== null) {
|
||||
if ($contentId !== null) {
|
||||
|
||||
$search = ContentQuery::create()
|
||||
->filterById($contentId);
|
||||
@@ -124,7 +124,7 @@ class DataAccessFunctions extends AbstractSmartyPlugin
|
||||
{
|
||||
$folderId = $this->request->get('folder_id');
|
||||
|
||||
if($folderId !== null) {
|
||||
if ($folderId !== null) {
|
||||
|
||||
$search = FolderQuery::create()
|
||||
->filterById($folderId);
|
||||
@@ -175,7 +175,7 @@ class DataAccessFunctions extends AbstractSmartyPlugin
|
||||
protected function dataAccessWithI18n($objectLabel, $params, ModelCriteria $search, $columns = array('TITLE', 'CHAPO', 'DESCRIPTION', 'POSTSCRIPTUM'), $foreignTable = null, $foreignKey = 'ID')
|
||||
{
|
||||
$lang = $this->getNormalizedParam($params, array('lang'));
|
||||
if($lang === null) {
|
||||
if ($lang === null) {
|
||||
$lang = $this->request->getSession()->getLang()->getId();
|
||||
}
|
||||
|
||||
@@ -193,7 +193,7 @@ class DataAccessFunctions extends AbstractSmartyPlugin
|
||||
$data = $search->findOne();
|
||||
|
||||
$noGetterData = array();
|
||||
foreach($columns as $column) {
|
||||
foreach ($columns as $column) {
|
||||
$noGetterData[$column] = $data->getVirtualColumn('i18n_' . $column);
|
||||
}
|
||||
|
||||
@@ -218,7 +218,7 @@ class DataAccessFunctions extends AbstractSmartyPlugin
|
||||
if (null != $data) {
|
||||
|
||||
$keyAttribute = strtoupper($attribute);
|
||||
if(array_key_exists($keyAttribute, $noGetterData)) {
|
||||
if (array_key_exists($keyAttribute, $noGetterData)) {
|
||||
return $noGetterData[$keyAttribute];
|
||||
}
|
||||
|
||||
@@ -226,7 +226,7 @@ class DataAccessFunctions extends AbstractSmartyPlugin
|
||||
if (method_exists($data, $getter)) {
|
||||
$return = $data->$getter();
|
||||
|
||||
if($return instanceof \DateTime) {
|
||||
if ($return instanceof \DateTime) {
|
||||
if (array_key_exists("format", $params)) {
|
||||
$format = $params["format"];
|
||||
} else {
|
||||
|
||||
@@ -107,8 +107,7 @@ class Form extends AbstractSmartyPlugin
|
||||
|
||||
$template->assign("form_error", $instance->hasError() ? true : false);
|
||||
$template->assign("form_error_message", $instance->getErrorMessage());
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
@@ -201,7 +200,6 @@ class Form extends AbstractSmartyPlugin
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected function assignFieldErrorVars(\Smarty_Internal_Template $template, array $errors)
|
||||
{
|
||||
$template->assign("message", $errors[0]->getMessage());
|
||||
@@ -223,7 +221,6 @@ class Form extends AbstractSmartyPlugin
|
||||
if (null == $fieldName)
|
||||
throw new \InvalidArgumentException("'field' parameter is missing");
|
||||
|
||||
|
||||
if (empty($instance->getView()[$fieldName]))
|
||||
throw new \InvalidArgumentException(sprintf("Field name '%s' not found in form %s", $fieldName, $instance->getName()));
|
||||
|
||||
|
||||
@@ -62,8 +62,8 @@ class Format extends AbstractSmartyPlugin
|
||||
* {format_date date=$dateTimeObject output="date"} will output the date using the default date system format
|
||||
* {format_date date=$dateTimeObject} will output with the default datetime system format
|
||||
*
|
||||
* @param array $params
|
||||
* @param null $template
|
||||
* @param array $params
|
||||
* @param null $template
|
||||
* @throws \Thelia\Core\Template\Smarty\Exception\SmartyPluginException
|
||||
* @return string
|
||||
*/
|
||||
@@ -76,7 +76,7 @@ class Format extends AbstractSmartyPlugin
|
||||
|
||||
$date = $params["date"];
|
||||
|
||||
if(!$date instanceof \DateTime) {
|
||||
if (!$date instanceof \DateTime) {
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -103,9 +103,9 @@ class Format extends AbstractSmartyPlugin
|
||||
* ex : {format_number number="1246.12" decimals="1" dec_point="," thousands_sep=" "} will output "1 246,1"
|
||||
*
|
||||
* @param $params
|
||||
* @param null $template
|
||||
* @param null $template
|
||||
* @throws \Thelia\Core\Template\Smarty\Exception\SmartyPluginException
|
||||
* @return string the expected number formatted
|
||||
* @return string the expected number formatted
|
||||
*/
|
||||
public function formatNumber($params, $template = null)
|
||||
{
|
||||
@@ -115,13 +115,12 @@ class Format extends AbstractSmartyPlugin
|
||||
|
||||
$number = $params["number"];
|
||||
|
||||
if(empty($number)) {
|
||||
if (empty($number)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
$lang = $this->request->getSession()->getLang();
|
||||
|
||||
|
||||
$decimals = array_key_exists("decimals", $params) ? $params["decimals"] : $lang->getDecimals();
|
||||
$decPoint = array_key_exists("dec_point", $params) ? $params["dec_point"] : $lang->getDecimalSeparator();
|
||||
$thousandsSep = array_key_exists("thousands_sep", $params) ? $params["thousands_sep"] : $lang->getThousandsSeparator();
|
||||
@@ -139,4 +138,4 @@ class Format extends AbstractSmartyPlugin
|
||||
new SmartyPluginDescriptor("function", "format_number", $this, "formatNumber")
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -32,7 +32,6 @@ use Thelia\Core\Template\Element\Exception\ElementNotFoundException;
|
||||
use Thelia\Core\Template\Element\Exception\InvalidElementException;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Thelia\Core\Security\SecurityContext;
|
||||
|
||||
class TheliaLoop extends AbstractSmartyPlugin
|
||||
@@ -70,7 +69,7 @@ class TheliaLoop extends AbstractSmartyPlugin
|
||||
*/
|
||||
public static function getPagination($loopId)
|
||||
{
|
||||
if(!empty(self::$pagination[$loopId])) {
|
||||
if (!empty(self::$pagination[$loopId])) {
|
||||
return self::$pagination[$loopId];
|
||||
} else {
|
||||
return null;
|
||||
@@ -84,7 +83,7 @@ class TheliaLoop extends AbstractSmartyPlugin
|
||||
{
|
||||
$type = $this->getParam($params, 'type');
|
||||
|
||||
if (null == $type) {
|
||||
if (null == $type) {
|
||||
throw new \InvalidArgumentException("Missing 'type' parameter in count arguments");
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,6 @@ class UrlGenerator extends AbstractSmartyPlugin
|
||||
$url = URL::getInstance()->absoluteUrl($path, $this->getArgsFromParam($params, array('path', 'target')));
|
||||
|
||||
if ($target != null) $url .= '#'.$target;
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
@@ -154,13 +153,13 @@ class UrlGenerator extends AbstractSmartyPlugin
|
||||
|
||||
protected function getNavigateToMethod($to)
|
||||
{
|
||||
if($to === null) {
|
||||
if ($to === null) {
|
||||
throw new \InvalidArgumentException("Missing 'to' parameter in `navigate` substitution.");
|
||||
}
|
||||
|
||||
$navigateToValues = $this->getNavigateToValues();
|
||||
|
||||
if(!array_key_exists($to, $navigateToValues)) {
|
||||
if (!array_key_exists($to, $navigateToValues)) {
|
||||
throw new \InvalidArgumentException("Incorrect value for parameter `to` in `navigate` substitution.");
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ class SmartyParser extends Smarty implements ParserInterface
|
||||
$this->setTemplate($template ?: ConfigQuery::read('active-template', 'default'));
|
||||
|
||||
$this->debugging = $debug;
|
||||
|
||||
|
||||
// Prevent smarty ErrorException: Notice: Undefined index bla bla bla...
|
||||
$this->error_reporting = E_ALL ^ E_NOTICE;
|
||||
|
||||
@@ -82,19 +82,10 @@ class SmartyParser extends Smarty implements ParserInterface
|
||||
// The default HTTP status
|
||||
$this->status = 200;
|
||||
|
||||
$this->registerFilter('pre', array($this, "preThelia"));
|
||||
$this->registerFilter('output', array($this, "removeBlankLines"));
|
||||
$this->registerFilter('variable', array(__CLASS__, "theliaEscape"));
|
||||
}
|
||||
|
||||
public function preThelia($tpl_source, \Smarty_Internal_Template $template)
|
||||
{
|
||||
$new_source = preg_replace('`{#([a-zA-Z][a-zA-Z0-9_]*)(.*)}`', '{\$$1$2}', $tpl_source);
|
||||
$new_source = preg_replace('`#([a-zA-Z][a-zA-Z0-9_]*)`', '{\$$1|dieseCanceller:\'#$1\'}', $new_source);
|
||||
|
||||
return $new_source;
|
||||
}
|
||||
|
||||
public function removeBlankLines($tpl_source, \Smarty_Internal_Template $template)
|
||||
{
|
||||
return preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $tpl_source);
|
||||
@@ -102,7 +93,7 @@ class SmartyParser extends Smarty implements ParserInterface
|
||||
|
||||
public static function theliaEscape($content, $smarty)
|
||||
{
|
||||
if(is_scalar($content)) {
|
||||
if (is_scalar($content)) {
|
||||
return htmlspecialchars($content ,ENT_QUOTES, Smarty::$_CHARSET);
|
||||
} else {
|
||||
return $content;
|
||||
|
||||
@@ -32,17 +32,16 @@ namespace Thelia\Core;
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
|
||||
use Propel\Runtime\Connection\ConnectionWrapper;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Definition;
|
||||
use Symfony\Component\HttpKernel\Kernel;
|
||||
use Symfony\Component\Config\Loader\LoaderInterface;
|
||||
use Symfony\Component\Validator\Tests\Fixtures\Reference;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
|
||||
|
||||
use Thelia\Core\Bundle;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Log\Tlog;
|
||||
use Thelia\Config\DatabaseConfiguration;
|
||||
use Thelia\Config\DefinePropel;
|
||||
use Thelia\Core\TheliaContainerBuilder;
|
||||
@@ -81,9 +80,10 @@ class Thelia extends Kernel
|
||||
$manager = new ConnectionManagerSingle();
|
||||
$manager->setConfiguration($definePropel->getConfig());
|
||||
$serviceContainer->setConnectionManager('thelia', $manager);
|
||||
|
||||
$con = Propel::getConnection(\Thelia\Model\Map\ProductTableMap::DATABASE_NAME);
|
||||
$con->setAttribute(ConnectionWrapper::PROPEL_ATTR_CACHE_PREPARES, true);
|
||||
if ($this->isDebug()) {
|
||||
$con = Propel::getConnection(\Thelia\Model\Map\ProductTableMap::DATABASE_NAME);
|
||||
$serviceContainer->setLogger('defaultLogger', \Thelia\Log\Tlog::getInstance());
|
||||
$con->useDebug(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ class TheliaHttpKernel extends HttpKernel
|
||||
$currency = $request->getSession()->getCurrency(false);
|
||||
}
|
||||
|
||||
if(null === $currency) {
|
||||
if (null === $currency) {
|
||||
$currency = Model\Currency::getDefaultCurrency();
|
||||
}
|
||||
|
||||
|
||||
@@ -19,12 +19,12 @@ class Translator extends BaseTranslator
|
||||
/**
|
||||
* Return this class instance, only once instanciated.
|
||||
*
|
||||
* @throws \RuntimeException if the class has not been instanciated.
|
||||
* @throws \RuntimeException if the class has not been instanciated.
|
||||
* @return \Thelia\Core\Translation\Translator the instance.
|
||||
*/
|
||||
public static function getInstance() {
|
||||
public static function getInstance()
|
||||
{
|
||||
if (self::$instance == null) throw new \RuntimeException("Translator instance is not initialized.");
|
||||
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user