Merge branch 'master' of https://github.com/thelia/thelia into upload_management
# By Manuel Raynaud (60) and others # Via Manuel Raynaud (16) and others * 'master' of https://github.com/thelia/thelia: (113 commits) implement process for changing folder position allow possibility to change folder visibility allow to create folder add dispatcher before/after for folder crud management icreate folder delete event process folder update action create folder events display info in folders edition template push model re-add home link in menu comment dev menu in layout translate some missing string fixes order integration order process change some informations in layou fix query in Thelia\Model\Folder::countAllContents allow to order products on category page Add default language & editing language default field Vertical align middle tables Fixed translations ... Conflicts: core/lib/Thelia/Tools/I18n.php templates/admin/default/category-edit.html
This commit is contained in:
54
core/lib/Thelia/Core/Event/AccessoryEvent.php
Normal file
54
core/lib/Thelia/Core/Event/AccessoryEvent.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
use Thelia\Model\Accessory;
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
|
||||
class AccessoryEvent extends ActionEvent
|
||||
{
|
||||
public $accessory = null;
|
||||
|
||||
public function __construct(Accessory $accessory = null)
|
||||
{
|
||||
$this->accessory = $accessory;
|
||||
}
|
||||
|
||||
public function hasAccessory()
|
||||
{
|
||||
return ! is_null($this->accessory);
|
||||
}
|
||||
|
||||
public function getAccessory()
|
||||
{
|
||||
return $this->accessory;
|
||||
}
|
||||
|
||||
public function setAccessory(Accessory $accessory)
|
||||
{
|
||||
$this->accessory = $accessory;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
use Thelia\Model\CategoryAssociatedContent;
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
|
||||
class CategoryAssociatedContentEvent extends ActionEvent
|
||||
{
|
||||
public $content = null;
|
||||
|
||||
public function __construct(CategoryAssociatedContent $content = null)
|
||||
{
|
||||
$this->content = $content;
|
||||
}
|
||||
|
||||
public function hasCategoryAssociatedContent()
|
||||
{
|
||||
return ! is_null($this->content);
|
||||
}
|
||||
|
||||
public function getCategoryAssociatedContent()
|
||||
{
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
public function setCategoryAssociatedContent(CategoryAssociatedContent $content)
|
||||
{
|
||||
$this->content = $content;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
120
core/lib/Thelia/Core/Event/FolderCreateEvent.php
Normal file
120
core/lib/Thelia/Core/Event/FolderCreateEvent.php
Normal file
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
|
||||
/**
|
||||
* Class FolderCreateEvent
|
||||
* @package Thelia\Core\Event
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class FolderCreateEvent extends FolderEvent {
|
||||
protected $title;
|
||||
protected $parent;
|
||||
protected $locale;
|
||||
protected $visible;
|
||||
|
||||
/**
|
||||
* @param mixed $locale
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setLocale($locale)
|
||||
{
|
||||
$this->locale = $locale;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getLocale()
|
||||
{
|
||||
return $this->locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $parent
|
||||
*
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setParent($parent)
|
||||
{
|
||||
$this->parent = $parent;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getParent()
|
||||
{
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $title
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->title = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $visible
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setVisible($visible)
|
||||
{
|
||||
$this->visible = $visible;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getVisible()
|
||||
{
|
||||
return $this->visible;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
64
core/lib/Thelia/Core/Event/FolderDeleteEvent.php
Normal file
64
core/lib/Thelia/Core/Event/FolderDeleteEvent.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
|
||||
/**
|
||||
* Class FolderDeleteEvent
|
||||
* @package Thelia\Core\Event
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class FolderDeleteEvent extends FolderEvent{
|
||||
|
||||
/**
|
||||
* @var int folder id
|
||||
*/
|
||||
protected $folder_id;
|
||||
|
||||
/**
|
||||
* @param int $folder_id
|
||||
*/
|
||||
function __construct($folder_id)
|
||||
{
|
||||
$this->folder_id = $folder_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $folder_id
|
||||
*/
|
||||
public function setFolderId($folder_id)
|
||||
{
|
||||
$this->folder_id = $folder_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getFolderId()
|
||||
{
|
||||
return $this->folder_id;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
73
core/lib/Thelia/Core/Event/FolderEvent.php
Normal file
73
core/lib/Thelia/Core/Event/FolderEvent.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
use Thelia\Model\Folder;
|
||||
|
||||
|
||||
/**
|
||||
* Class FolderEvent
|
||||
* @package Thelia\Core\Event
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class FolderEvent extends ActionEvent {
|
||||
|
||||
/**
|
||||
* @var \Thelia\Model\Folder
|
||||
*/
|
||||
protected $folder;
|
||||
|
||||
function __construct(Folder $folder = null)
|
||||
{
|
||||
$this->folder = $folder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Thelia\Model\Folder $folder
|
||||
*/
|
||||
public function setFolder(Folder $folder)
|
||||
{
|
||||
$this->folder = $folder;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Thelia\Model\Folder
|
||||
*/
|
||||
public function getFolder()
|
||||
{
|
||||
return $this->folder;
|
||||
}
|
||||
|
||||
/**
|
||||
* test if a folder object exists
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasFolder()
|
||||
{
|
||||
return null !== $this->folder;
|
||||
}
|
||||
|
||||
}
|
||||
34
core/lib/Thelia/Core/Event/FolderToggleVisibilityEvent.php
Normal file
34
core/lib/Thelia/Core/Event/FolderToggleVisibilityEvent.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
|
||||
/**
|
||||
* Class FolderToggleVisibilityEvent
|
||||
* @package Thelia\Core\Event
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class FolderToggleVisibilityEvent extends FolderEvent {
|
||||
|
||||
}
|
||||
136
core/lib/Thelia/Core/Event/FolderUpdateEvent.php
Normal file
136
core/lib/Thelia/Core/Event/FolderUpdateEvent.php
Normal file
@@ -0,0 +1,136 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
|
||||
/**
|
||||
* Class FolderUpdateEvent
|
||||
* @package Thelia\Core\Event
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class FolderUpdateEvent extends FolderCreateEvent {
|
||||
protected $folder_id;
|
||||
|
||||
protected $chapo;
|
||||
protected $description;
|
||||
protected $postscriptum;
|
||||
|
||||
protected $url;
|
||||
|
||||
function __construct($folder_id)
|
||||
{
|
||||
$this->folder_id = $folder_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $chapo
|
||||
*/
|
||||
public function setChapo($chapo)
|
||||
{
|
||||
$this->chapo = $chapo;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getChapo()
|
||||
{
|
||||
return $this->chapo;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $description
|
||||
*/
|
||||
public function setDescription($description)
|
||||
{
|
||||
$this->description = $description;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getDescription()
|
||||
{
|
||||
return $this->description;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $folder_id
|
||||
*/
|
||||
public function setFolderId($folder_id)
|
||||
{
|
||||
$this->folder_id = $folder_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getFolderId()
|
||||
{
|
||||
return $this->folder_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $postscriptum
|
||||
*/
|
||||
public function setPostscriptum($postscriptum)
|
||||
{
|
||||
$this->postscriptum = $postscriptum;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getPostscriptum()
|
||||
{
|
||||
return $this->postscriptum;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $url
|
||||
*/
|
||||
public function setUrl($url)
|
||||
{
|
||||
$this->url = $url;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getUrl()
|
||||
{
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
}
|
||||
60
core/lib/Thelia/Core/Event/GenerateRewrittenUrlEvent.php
Normal file
60
core/lib/Thelia/Core/Event/GenerateRewrittenUrlEvent.php
Normal file
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
|
||||
/**
|
||||
* Class GenerateRewrittenUrlEvent
|
||||
* @package Thelia\Core\Event
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class GenerateRewrittenUrlEvent extends ActionEvent {
|
||||
|
||||
protected $object;
|
||||
protected $locale;
|
||||
|
||||
protected $url;
|
||||
|
||||
public function __construct($object, $locale)
|
||||
{
|
||||
$this->object;
|
||||
$this->locale;
|
||||
}
|
||||
|
||||
public function setUrl($url)
|
||||
{
|
||||
$this->url = $url;
|
||||
}
|
||||
|
||||
public function isRewritten()
|
||||
{
|
||||
return null !== $this->url;
|
||||
}
|
||||
|
||||
public function getUrl()
|
||||
{
|
||||
return $this->url;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -23,17 +23,18 @@
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
use Thelia\Model\Address;
|
||||
use Thelia\Model\AddressQuery;
|
||||
use Thelia\Model\Module;
|
||||
use Thelia\Model\Order;
|
||||
|
||||
class OrderEvent extends ActionEvent
|
||||
{
|
||||
protected $order = null;
|
||||
protected $billingAddress = null;
|
||||
protected $placedOrder = null;
|
||||
protected $invoiceAddress = null;
|
||||
protected $deliveryAddress = null;
|
||||
protected $deliveryModule = null;
|
||||
protected $paymentModule = null;
|
||||
protected $postage = null;
|
||||
protected $ref = null;
|
||||
|
||||
/**
|
||||
* @param Order $order
|
||||
@@ -51,12 +52,20 @@ class OrderEvent extends ActionEvent
|
||||
$this->order = $order;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Order $order
|
||||
*/
|
||||
public function setPlacedOrder(Order $order)
|
||||
{
|
||||
$this->placedOrder = $order;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $address
|
||||
*/
|
||||
public function setBillingAddress($address)
|
||||
public function setInvoiceAddress($address)
|
||||
{
|
||||
$this->deliveryAddress = $address;
|
||||
$this->invoiceAddress = $address;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,6 +84,30 @@ class OrderEvent extends ActionEvent
|
||||
$this->deliveryModule = $module;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $module
|
||||
*/
|
||||
public function setPaymentModule($module)
|
||||
{
|
||||
$this->paymentModule = $module;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $postage
|
||||
*/
|
||||
public function setPostage($postage)
|
||||
{
|
||||
$this->postage = $postage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $ref
|
||||
*/
|
||||
public function setRef($ref)
|
||||
{
|
||||
$this->ref = $ref;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|Order
|
||||
*/
|
||||
@@ -84,15 +117,23 @@ class OrderEvent extends ActionEvent
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|mixed|Address
|
||||
* @return null|Order
|
||||
*/
|
||||
public function getBillingAddress()
|
||||
public function getPlacedOrder()
|
||||
{
|
||||
return $this->billingAddress;
|
||||
return $this->placedOrder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|mixed|Address
|
||||
* @return null|int
|
||||
*/
|
||||
public function getInvoiceAddress()
|
||||
{
|
||||
return $this->invoiceAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|int
|
||||
*/
|
||||
public function getDeliveryAddress()
|
||||
{
|
||||
@@ -100,10 +141,34 @@ class OrderEvent extends ActionEvent
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array|mixed|Address
|
||||
* @return null|int
|
||||
*/
|
||||
public function getDeliveryModule()
|
||||
{
|
||||
return $this->deliveryModule;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|int
|
||||
*/
|
||||
public function getPaymentModule()
|
||||
{
|
||||
return $this->paymentModule;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|int
|
||||
*/
|
||||
public function getPostage()
|
||||
{
|
||||
return $this->postage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return null|int
|
||||
*/
|
||||
public function getRef()
|
||||
{
|
||||
return $this->ref;
|
||||
}
|
||||
}
|
||||
|
||||
48
core/lib/Thelia/Core/Event/ProductAddAccessoryEvent.php
Normal file
48
core/lib/Thelia/Core/Event/ProductAddAccessoryEvent.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
use Thelia\Model\Product;
|
||||
|
||||
class ProductAddAccessoryEvent extends ProductEvent
|
||||
{
|
||||
protected $accessory_id;
|
||||
|
||||
public function __construct(Product $product, $accessory_id)
|
||||
{
|
||||
parent::__construct($product);
|
||||
|
||||
$this->accessory_id = $accessory_id;
|
||||
}
|
||||
|
||||
public function getAccessoryId()
|
||||
{
|
||||
return $this->accessory_id;
|
||||
}
|
||||
|
||||
public function setAccessoryId($accessory_id)
|
||||
{
|
||||
$this->accessory_id = $accessory_id;
|
||||
}
|
||||
}
|
||||
54
core/lib/Thelia/Core/Event/ProductAssociatedContentEvent.php
Normal file
54
core/lib/Thelia/Core/Event/ProductAssociatedContentEvent.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
use Thelia\Model\ProductAssociatedContent;
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
|
||||
class ProductAssociatedContentEvent extends ActionEvent
|
||||
{
|
||||
public $content = null;
|
||||
|
||||
public function __construct(ProductAssociatedContent $content = null)
|
||||
{
|
||||
$this->content = $content;
|
||||
}
|
||||
|
||||
public function hasProductAssociatedContent()
|
||||
{
|
||||
return ! is_null($this->content);
|
||||
}
|
||||
|
||||
public function getProductAssociatedContent()
|
||||
{
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
public function setProductAssociatedContent(ProductAssociatedContent $content)
|
||||
{
|
||||
$this->content = $content;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -25,11 +25,23 @@ namespace Thelia\Core\Event;
|
||||
|
||||
class ProductCreateEvent extends ProductEvent
|
||||
{
|
||||
protected $ref;
|
||||
protected $title;
|
||||
protected $parent;
|
||||
protected $locale;
|
||||
protected $default_category;
|
||||
protected $visible;
|
||||
|
||||
public function getRef()
|
||||
{
|
||||
return $this->ref;
|
||||
}
|
||||
|
||||
public function setRef($ref)
|
||||
{
|
||||
$this->ref = $ref;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
@@ -38,19 +50,6 @@ class ProductCreateEvent extends ProductEvent
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->title = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getParent()
|
||||
{
|
||||
return $this->parent;
|
||||
}
|
||||
|
||||
public function setParent($parent)
|
||||
{
|
||||
$this->parent = $parent;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -62,7 +61,17 @@ class ProductCreateEvent extends ProductEvent
|
||||
public function setLocale($locale)
|
||||
{
|
||||
$this->locale = $locale;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getDefaultCategory()
|
||||
{
|
||||
return $this->default_category;
|
||||
}
|
||||
|
||||
public function setDefaultCategory($default_category)
|
||||
{
|
||||
$this->default_category = $default_category;
|
||||
return $this;
|
||||
}
|
||||
|
||||
@@ -74,7 +83,6 @@ class ProductCreateEvent extends ProductEvent
|
||||
public function setVisible($visible)
|
||||
{
|
||||
$this->visible = $visible;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
|
||||
48
core/lib/Thelia/Core/Event/ProductDeleteAccessoryEvent.php
Normal file
48
core/lib/Thelia/Core/Event/ProductDeleteAccessoryEvent.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event;
|
||||
|
||||
use Thelia\Model\Product;
|
||||
|
||||
class ProductDeleteAccessoryEvent extends ProductEvent
|
||||
{
|
||||
protected $accessory_id;
|
||||
|
||||
public function __construct(Product $product, $accessory_id)
|
||||
{
|
||||
parent::__construct($product);
|
||||
|
||||
$this->accessory_id = $accessory_id;
|
||||
}
|
||||
|
||||
public function getAccessoryId()
|
||||
{
|
||||
return $this->accessory_id;
|
||||
}
|
||||
|
||||
public function setAccessoryId($accessory_id)
|
||||
{
|
||||
$this->accessory_id = $accessory_id;
|
||||
}
|
||||
}
|
||||
@@ -165,6 +165,37 @@ final class TheliaEvents
|
||||
const BEFORE_UPDATECATEGORY = "action.before_updateCategory";
|
||||
const AFTER_UPDATECATEGORY = "action.after_updateCategory";
|
||||
|
||||
// -- folder management -----------------------------------------------
|
||||
|
||||
const FOLDER_CREATE = "action.createFolder";
|
||||
const FOLDER_UPDATE = "action.updateFolder";
|
||||
const FOLDER_DELETE = "action.deleteFolder";
|
||||
const FOLDER_TOGGLE_VISIBILITY = "action.toggleFolderVisibility";
|
||||
const FOLDER_UPDATE_POSITION = "action.updateFolderPosition";
|
||||
|
||||
// const FOLDER_ADD_CONTENT = "action.categoryAddContent";
|
||||
// const FOLDER_REMOVE_CONTENT = "action.categoryRemoveContent";
|
||||
|
||||
const BEFORE_CREATEFOLDER = "action.before_createFolder";
|
||||
const AFTER_CREATEFOLDER = "action.after_createFolder";
|
||||
|
||||
const BEFORE_DELETEFOLDER = "action.before_deleteFolder";
|
||||
const AFTER_DELETEFOLDER = "action.after_deleteFolder";
|
||||
|
||||
const BEFORE_UPDATEFOLDER = "action.before_updateFolder";
|
||||
const AFTER_UPDATEFOLDER = "action.after_updateFolder";
|
||||
|
||||
// -- Categories Associated Content ----------------------------------------
|
||||
|
||||
const BEFORE_CREATECATEGORY_ASSOCIATED_CONTENT = "action.before_createCategoryAssociatedContent";
|
||||
const AFTER_CREATECATEGORY_ASSOCIATED_CONTENT = "action.after_createCategoryAssociatedContent";
|
||||
|
||||
const BEFORE_DELETECATEGORY_ASSOCIATED_CONTENT = "action.before_deleteCategoryAssociatedContenty";
|
||||
const AFTER_DELETECATEGORY_ASSOCIATED_CONTENT = "action.after_deleteproduct_accessory";
|
||||
|
||||
const BEFORE_UPDATECATEGORY_ASSOCIATED_CONTENT = "action.before_updateCategoryAssociatedContent";
|
||||
const AFTER_UPDATECATEGORY_ASSOCIATED_CONTENT = "action.after_updateCategoryAssociatedContent";
|
||||
|
||||
// -- Product management -----------------------------------------------
|
||||
|
||||
const PRODUCT_CREATE = "action.createProduct";
|
||||
@@ -176,6 +207,10 @@ final class TheliaEvents
|
||||
const PRODUCT_ADD_CONTENT = "action.productAddContent";
|
||||
const PRODUCT_REMOVE_CONTENT = "action.productRemoveContent";
|
||||
|
||||
const PRODUCT_ADD_ACCESSORY = "action.productAddAccessory";
|
||||
const PRODUCT_REMOVE_ACCESSORY = "action.productRemoveAccessory";
|
||||
const PRODUCT_UPDATE_ACCESSORY_POSITION = "action.updateProductPosition";
|
||||
|
||||
const BEFORE_CREATEPRODUCT = "action.before_createproduct";
|
||||
const AFTER_CREATEPRODUCT = "action.after_createproduct";
|
||||
|
||||
@@ -185,6 +220,28 @@ final class TheliaEvents
|
||||
const BEFORE_UPDATEPRODUCT = "action.before_updateProduct";
|
||||
const AFTER_UPDATEPRODUCT = "action.after_updateProduct";
|
||||
|
||||
// -- Product Accessories --------------------------------------------------
|
||||
|
||||
const BEFORE_CREATEACCESSORY = "action.before_createAccessory";
|
||||
const AFTER_CREATEACCESSORY = "action.after_createAccessory";
|
||||
|
||||
const BEFORE_DELETEACCESSORY = "action.before_deleteAccessory";
|
||||
const AFTER_DELETEACCESSORY = "action.after_deleteAccessory";
|
||||
|
||||
const BEFORE_UPDATEACCESSORY = "action.before_updateAccessory";
|
||||
const AFTER_UPDATEACCESSORY = "action.after_updateAccessory";
|
||||
|
||||
// -- Product Associated Content --------------------------------------------------
|
||||
|
||||
const BEFORE_CREATEPRODUCT_ASSOCIATED_CONTENT = "action.before_createProductAssociatedContent";
|
||||
const AFTER_CREATEPRODUCT_ASSOCIATED_CONTENT = "action.after_createProductAssociatedContent";
|
||||
|
||||
const BEFORE_DELETEPRODUCT_ASSOCIATED_CONTENT = "action.before_deleteProductAssociatedContenty";
|
||||
const AFTER_DELETEPRODUCT_ASSOCIATED_CONTENT = "action.after_deleteproduct_accessory";
|
||||
|
||||
const BEFORE_UPDATEPRODUCT_ASSOCIATED_CONTENT = "action.before_updateProductAssociatedContent";
|
||||
const AFTER_UPDATEPRODUCT_ASSOCIATED_CONTENT = "action.after_updateProductAssociatedContent";
|
||||
|
||||
/**
|
||||
* sent when a new existing cat id duplicated. This append when current customer is different from current cart
|
||||
*/
|
||||
@@ -215,9 +272,17 @@ final class TheliaEvents
|
||||
/**
|
||||
* Order linked event
|
||||
*/
|
||||
const ORDER_SET_BILLING_ADDRESS = "action.order.setBillingAddress";
|
||||
const ORDER_SET_DELIVERY_ADDRESS = "action.order.setDeliveryAddress";
|
||||
const ORDER_SET_DELIVERY_MODULE = "action.order.setDeliveryModule";
|
||||
const ORDER_SET_INVOICE_ADDRESS = "action.order.setInvoiceAddress";
|
||||
const ORDER_SET_PAYMENT_MODULE = "action.order.setPaymentModule";
|
||||
const ORDER_PAY = "action.order.pay";
|
||||
const ORDER_BEFORE_CREATE = "action.order.beforeCreate";
|
||||
const ORDER_AFTER_CREATE = "action.order.afterCreate";
|
||||
const ORDER_BEFORE_PAYMENT = "action.order.beforePayment";
|
||||
|
||||
const ORDER_PRODUCT_BEFORE_CREATE = "action.orderProduct.beforeCreate";
|
||||
const ORDER_PRODUCT_AFTER_CREATE = "action.orderProduct.afterCreate";
|
||||
|
||||
/**
|
||||
* Sent on image processing
|
||||
@@ -451,4 +516,9 @@ final class TheliaEvents
|
||||
*/
|
||||
const MAILTRANSPORTER_CONFIG = 'action.mailertransporter.config';
|
||||
|
||||
/**
|
||||
* sent when Thelia try to generate a rewriten url
|
||||
*/
|
||||
const GENERATE_REWRITTENURL = 'action.generate_rewritenurl';
|
||||
|
||||
}
|
||||
|
||||
@@ -28,8 +28,10 @@ use Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\Routing\Router;
|
||||
use Thelia\Core\Template\Exception\ResourceNotFoundException;
|
||||
use Thelia\Core\Template\ParserInterface;
|
||||
use Thelia\Exception\OrderException;
|
||||
use Thelia\Tools\Redirect;
|
||||
use Thelia\Tools\URL;
|
||||
use Thelia\Core\Security\Exception\AuthenticationException;
|
||||
@@ -77,16 +79,39 @@ class ViewListener implements EventSubscriberInterface
|
||||
$content = $parser->getContent();
|
||||
|
||||
if ($content instanceof Response) {
|
||||
$event->setResponse($content);
|
||||
$response = $content;$event->setResponse($content);
|
||||
} else {
|
||||
$event->setResponse(new Response($content, $parser->getStatus() ?: 200));
|
||||
$response = new Response($content, $parser->getStatus() ?: 200);
|
||||
}
|
||||
|
||||
$response->setCache(array(
|
||||
'last_modified' => new \DateTime(),
|
||||
'max_age' => 600,
|
||||
's_maxage' => 600,
|
||||
'private' => false,
|
||||
'public' => true,
|
||||
));
|
||||
|
||||
$event->setResponse($response);
|
||||
} catch (ResourceNotFoundException $e) {
|
||||
$event->setResponse(new Response($e->getMessage(), 404));
|
||||
} catch (AuthenticationException $ex) {
|
||||
|
||||
// Redirect to the login template
|
||||
Redirect::exec($this->container->get('thelia.url.manager')->viewUrl($ex->getLoginTemplate()));
|
||||
} catch (OrderException $e) {
|
||||
switch($e->getCode()) {
|
||||
case OrderException::CART_EMPTY:
|
||||
// Redirect to the cart template
|
||||
Redirect::exec($this->container->get('router.chainRequest')->generate($e->cartRoute, $e->arguments, Router::ABSOLUTE_URL));
|
||||
break;
|
||||
case OrderException::UNDEFINED_DELIVERY:
|
||||
// Redirect to the delivery choice template
|
||||
Redirect::exec($this->container->get('router.chainRequest')->generate($e->orderDeliveryRoute, $e->arguments, Router::ABSOLUTE_URL));
|
||||
break;
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -218,6 +218,9 @@ class Session extends BaseSession
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Order
|
||||
*/
|
||||
public function getOrder()
|
||||
{
|
||||
return $this->get("thelia.order");
|
||||
|
||||
@@ -128,7 +128,7 @@ class RewritingRouter implements RouterInterface, RequestMatcherInterface
|
||||
*/
|
||||
public function generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH)
|
||||
{
|
||||
// TODO: Implement generate() method.
|
||||
throw new RouteNotFoundException();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -65,6 +65,8 @@ abstract class BaseI18nLoop extends BaseLoop
|
||||
{
|
||||
/* manage translations */
|
||||
|
||||
$fr = $this->getForce_return();
|
||||
|
||||
return ModelCriteriaTools::getI18n(
|
||||
$this->getBackend_context(),
|
||||
$this->getLang(),
|
||||
|
||||
@@ -93,8 +93,10 @@ class Accessory extends Product
|
||||
$accessories = $this->search($search);
|
||||
|
||||
$accessoryIdList = array(0);
|
||||
$accessoryPosition = array();
|
||||
foreach ($accessories as $accessory) {
|
||||
array_push($accessoryIdList, $accessory->getAccessory());
|
||||
$accessoryPosition[$accessory->getAccessory()] = $accessory->getPosition();
|
||||
}
|
||||
|
||||
$receivedIdList = $this->getId();
|
||||
@@ -106,7 +108,15 @@ class Accessory extends Product
|
||||
$this->args->get('id')->setValue( implode(',', array_intersect($receivedIdList, $accessoryIdList)) );
|
||||
}
|
||||
|
||||
return parent::exec($pagination);
|
||||
$loopResult = parent::exec($pagination);
|
||||
|
||||
foreach($loopResult as $loopResultRow) {
|
||||
$loopResultRow
|
||||
->set("POSITION" , $accessoryPosition[$loopResultRow->get('ID')])
|
||||
;
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -54,7 +54,13 @@ class Address extends BaseLoop
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
Argument::createIntListTypeArgument('id'),
|
||||
new Argument(
|
||||
'id',
|
||||
new TypeCollection(
|
||||
new Type\IntListType(),
|
||||
new Type\EnumType(array('*', 'any'))
|
||||
)
|
||||
),
|
||||
new Argument(
|
||||
'customer',
|
||||
new TypeCollection(
|
||||
@@ -63,8 +69,14 @@ class Address extends BaseLoop
|
||||
),
|
||||
'current'
|
||||
),
|
||||
Argument::createBooleanTypeArgument('default'),
|
||||
Argument::createIntListTypeArgument('exclude')
|
||||
Argument::createBooleanOrBothTypeArgument('default'),
|
||||
new Argument(
|
||||
'exclude',
|
||||
new TypeCollection(
|
||||
new Type\IntListType(),
|
||||
new Type\EnumType(array('none'))
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -79,7 +91,7 @@ class Address extends BaseLoop
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
if (null !== $id) {
|
||||
if (null !== $id && !in_array($id, array('*', 'any'))) {
|
||||
$search->filterById($id, Criteria::IN);
|
||||
}
|
||||
|
||||
@@ -106,7 +118,7 @@ class Address extends BaseLoop
|
||||
|
||||
$exclude = $this->getExclude();
|
||||
|
||||
if (!is_null($exclude)) {
|
||||
if (null !== $exclude && 'none' !== $exclude) {
|
||||
$search->filterById($exclude, Criteria::NOT_IN);
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,19 @@ class Argument
|
||||
|
||||
public function setValue($value)
|
||||
{
|
||||
$this->value = $value === null ? null : (string) $value;
|
||||
$x = $value === null;
|
||||
|
||||
if($value === null) {
|
||||
$this->value = null;
|
||||
} else {
|
||||
if(false === $value) {
|
||||
/* (string) $value = "" */
|
||||
$this->value = 0;
|
||||
} else {
|
||||
$this->value = (string) $value;
|
||||
}
|
||||
}
|
||||
//$this->value = $value === null ? null : (string) $value;
|
||||
}
|
||||
|
||||
public static function createAnyTypeArgument($name, $default=null, $mandatory=false, $empty=true)
|
||||
|
||||
@@ -97,9 +97,9 @@ class AssociatedContent extends Content
|
||||
|
||||
$exclude_product = $this->getExcludeProduct();
|
||||
|
||||
// If we have to filter by template, find all attributes assigned to this template, and filter by found IDs
|
||||
// If we have to filter by product, find all products assigned to this product, and filter by found IDs
|
||||
if (null !== $exclude_product) {
|
||||
// Exclure tous les attribut qui sont attachés aux templates indiqués
|
||||
// Exclude all contents related to the given product
|
||||
$search->filterById(
|
||||
ProductAssociatedContentQuery::create()->filterByProductId($exclude_product)->select('product_id')->find(),
|
||||
Criteria::NOT_IN
|
||||
@@ -108,7 +108,7 @@ class AssociatedContent extends Content
|
||||
|
||||
$exclude_category = $this->getExcludeCategory();
|
||||
|
||||
// If we have to filter by template, find all attributes assigned to this template, and filter by found IDs
|
||||
// If we have to filter by category, find all contents assigned to this category, and filter by found IDs
|
||||
if (null !== $exclude_category) {
|
||||
// Exclure tous les attribut qui sont attachés aux templates indiqués
|
||||
$search->filterById(
|
||||
|
||||
@@ -29,7 +29,6 @@ use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Model\ModuleQuery;
|
||||
|
||||
/**
|
||||
* Class Delivery
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
@@ -93,6 +92,8 @@ class BaseSpecificModule extends BaseI18nLoop
|
||||
{
|
||||
$search = ModuleQuery::create();
|
||||
|
||||
$search->filterByActivate(1);
|
||||
|
||||
if (null !== $id = $this->getId()) {
|
||||
$search->filterById($id);
|
||||
}
|
||||
|
||||
@@ -81,6 +81,8 @@ class Cart extends BaseLoop
|
||||
return $result;
|
||||
}
|
||||
|
||||
$taxCountry = CountryQuery::create()->findPk(64); // @TODO : make it magic;
|
||||
|
||||
foreach ($cartItems as $cartItem) {
|
||||
$product = $cartItem->getProduct();
|
||||
$productSaleElement = $cartItem->getProductSaleElements();
|
||||
@@ -97,12 +99,8 @@ class Cart extends BaseLoop
|
||||
->set("STOCK", $productSaleElement->getQuantity())
|
||||
->set("PRICE", $cartItem->getPrice())
|
||||
->set("PROMO_PRICE", $cartItem->getPromoPrice())
|
||||
->set("TAXED_PRICE", $cartItem->getTaxedPrice(
|
||||
CountryQuery::create()->findOneById(64) // @TODO : make it magic
|
||||
))
|
||||
->set("PROMO_TAXED_PRICE", $cartItem->getTaxedPromoPrice(
|
||||
CountryQuery::create()->findOneById(64) // @TODO : make it magic
|
||||
))
|
||||
->set("TAXED_PRICE", $cartItem->getTaxedPrice($taxCountry))
|
||||
->set("PROMO_TAXED_PRICE", $cartItem->getTaxedPromoPrice($taxCountry))
|
||||
->set("IS_PROMO", $cartItem->getPromo() === 1 ? 1 : 0);
|
||||
$result->addRow($loopResultRow);
|
||||
}
|
||||
@@ -110,4 +108,13 @@ class Cart extends BaseLoop
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the event dispatcher,
|
||||
*
|
||||
* @return \Symfony\Component\EventDispatcher\EventDispatcher
|
||||
*/
|
||||
public function getDispatcher()
|
||||
{
|
||||
return $this->dispatcher;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,7 +206,8 @@ class Category extends BaseI18nLoop
|
||||
->set("POSTSCRIPTUM", $category->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||
->set("PARENT", $category->getParent())
|
||||
->set("URL", $category->getUrl($locale))
|
||||
->set("PRODUCT_COUNT", $category->countChild())
|
||||
->set("PRODUCT_COUNT", $category->countAllProducts())
|
||||
->set("CHILD_COUNT", $category->countChild())
|
||||
->set("VISIBLE", $category->getVisible() ? "1" : "0")
|
||||
->set("POSITION", $category->getPosition())
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ class CategoryTree extends BaseI18nLoop
|
||||
}
|
||||
|
||||
// changement de rubrique
|
||||
protected function buildCategoryTree($parent, $visible, $level, $max_level, $exclude, LoopResult &$loopResult)
|
||||
protected function buildCategoryTree($parent, $visible, $level, $previousLevel, $max_level, $exclude, LoopResult &$loopResult)
|
||||
{
|
||||
if ($level > $max_level) return;
|
||||
|
||||
@@ -87,11 +87,12 @@ class CategoryTree extends BaseI18nLoop
|
||||
->set("ID", $result->getId())->set("TITLE", $result->getVirtualColumn('i18n_TITLE'))
|
||||
->set("PARENT", $result->getParent())->set("URL", $result->getUrl($locale))
|
||||
->set("VISIBLE", $result->getVisible() ? "1" : "0")->set("LEVEL", $level)
|
||||
->set('CHILD_COUNT', $result->countChild())->set('PREV_LEVEL', $previousLevel)
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
|
||||
$this->buildCategoryTree($result->getId(), $visible, 1 + $level, $max_level, $exclude, $loopResult);
|
||||
$this->buildCategoryTree($result->getId(), $visible, 1 + $level, $level, $max_level, $exclude, $loopResult);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,7 +110,7 @@ class CategoryTree extends BaseI18nLoop
|
||||
|
||||
$loopResult = new LoopResult();
|
||||
|
||||
$this->buildCategoryTree($id, $visible, 0, $depth, $exclude, $loopResult);
|
||||
$this->buildCategoryTree($id, $visible, 0, 0, $depth, $exclude, $loopResult);
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@ class Country extends BaseI18nLoop
|
||||
|
||||
if (true === $withArea) {
|
||||
$search->filterByAreaId(null, Criteria::ISNOTNULL);
|
||||
} elseif (false == $withArea) {
|
||||
} elseif (false === $withArea) {
|
||||
$search->filterByAreaId(null, Criteria::ISNULL);
|
||||
}
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ class Delivery extends BaseSpecificModule
|
||||
->set('CHAPO', $deliveryModule->getVirtualColumn('i18n_CHAPO'))
|
||||
->set('DESCRIPTION', $deliveryModule->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set('POSTSCRIPTUM', $deliveryModule->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||
->set('PRICE', $moduleInstance->calculate($country))
|
||||
->set('POSTAGE', $moduleInstance->getPostage($country))
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
|
||||
@@ -31,10 +31,12 @@ 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\Base\ProductCategoryQuery;
|
||||
use Thelia\Model\Base\FeatureQuery;
|
||||
use Thelia\Model\CategoryQuery;
|
||||
use Thelia\Model\FeatureI18nQuery;
|
||||
use Thelia\Model\ProductCategoryQuery;
|
||||
use Thelia\Model\FeatureQuery;
|
||||
use Thelia\Model\Map\ProductCategoryTableMap;
|
||||
use Thelia\Model\ProductQuery;
|
||||
use Thelia\Type\TypeCollection;
|
||||
use Thelia\Type;
|
||||
use Thelia\Type\BooleanOrBothType;
|
||||
@@ -71,7 +73,8 @@ class Feature extends BaseI18nLoop
|
||||
new Type\EnumListType(array('alpha', 'alpha-reverse', 'manual', 'manual_reverse'))
|
||||
),
|
||||
'manual'
|
||||
)
|
||||
),
|
||||
Argument::createAnyTypeArgument('title')
|
||||
);
|
||||
}
|
||||
|
||||
@@ -134,6 +137,23 @@ class Feature extends BaseI18nLoop
|
||||
);
|
||||
}
|
||||
|
||||
$title = $this->getTitle();
|
||||
|
||||
if (null !== $title) {
|
||||
//find all feture that match exactly this title and find with all locales.
|
||||
$features = FeatureI18nQuery::create()
|
||||
->filterByTitle($title, Criteria::LIKE)
|
||||
->select('id')
|
||||
->find();
|
||||
|
||||
if($features) {
|
||||
$search->filterById(
|
||||
$features,
|
||||
Criteria::IN
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
$orders = $this->getOrder();
|
||||
|
||||
foreach ($orders as $order) {
|
||||
|
||||
@@ -162,7 +162,8 @@ class Folder extends BaseI18nLoop
|
||||
->set("POSTSCRIPTUM", $folder->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||
->set("PARENT", $folder->getParent())
|
||||
->set("URL", $folder->getUrl($locale))
|
||||
->set("CONTENT_COUNT", $folder->countChild())
|
||||
->set("CHILD_COUNT", $folder->countChild())
|
||||
->set("CONTENT_COUNT", $folder->countAllContents())
|
||||
->set("VISIBLE", $folder->getVisible() ? "1" : "0")
|
||||
->set("POSITION", $folder->getPosition())
|
||||
;
|
||||
|
||||
118
core/lib/Thelia/Core/Template/Loop/FolderTree.php
Normal file
118
core/lib/Thelia/Core/Template/Loop/FolderTree.php
Normal file
@@ -0,0 +1,118 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Template\Loop;
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
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\Model\FolderQuery;
|
||||
use Thelia\Type;
|
||||
use Thelia\Type\BooleanOrBothType;
|
||||
use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
|
||||
/**
|
||||
*
|
||||
* Folder tree loop, to get a folder tree from a given folder to a given depth.
|
||||
*
|
||||
* - folder is the folder id
|
||||
* - depth is the maximum depth to go, default unlimited
|
||||
* - visible if true or missing, only visible categories will be displayed. If false, all categories (visible or not) are returned.
|
||||
*
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Franck Allimant <franck@cqfdev.fr>
|
||||
*/
|
||||
class FolderTree extends BaseI18nLoop
|
||||
{
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
*/
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
Argument::createIntTypeArgument('folder', null, true),
|
||||
Argument::createIntTypeArgument('depth', PHP_INT_MAX),
|
||||
Argument::createBooleanOrBothTypeArgument('visible', true, false),
|
||||
Argument::createIntListTypeArgument('exclude', array())
|
||||
);
|
||||
}
|
||||
|
||||
// changement de rubrique
|
||||
protected function buildFolderTree($parent, $visible, $level, $max_level, $exclude, LoopResult &$loopResult)
|
||||
{
|
||||
if ($level > $max_level) return;
|
||||
|
||||
$search = FolderQuery::create();
|
||||
|
||||
$locale = $this->configureI18nProcessing($search, array(
|
||||
'TITLE'
|
||||
));
|
||||
|
||||
$search->filterByParent($parent);
|
||||
|
||||
if ($visible != BooleanOrBothType::ANY) $search->filterByVisible($visible);
|
||||
|
||||
if ($exclude != null) $search->filterById($exclude, Criteria::NOT_IN);
|
||||
|
||||
$search->orderByPosition(Criteria::ASC);
|
||||
|
||||
$results = $search->find();
|
||||
|
||||
foreach ($results as $result) {
|
||||
|
||||
$loopResultRow = new LoopResultRow();
|
||||
|
||||
$loopResultRow
|
||||
->set("ID", $result->getId())->set("TITLE", $result->getVirtualColumn('i18n_TITLE'))
|
||||
->set("PARENT", $result->getParent())->set("URL", $result->getUrl($locale))
|
||||
->set("VISIBLE", $result->getVisible() ? "1" : "0")->set("LEVEL", $level)
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
|
||||
$this->buildFolderTree($result->getId(), $visible, 1 + $level, $max_level, $exclude, $loopResult);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination (ignored)
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
{
|
||||
$id = $this->getFolder();
|
||||
$depth = $this->getDepth();
|
||||
$visible = $this->getVisible();
|
||||
$exclude = $this->getExclude();
|
||||
|
||||
$loopResult = new LoopResult();
|
||||
|
||||
$this->buildFolderTree($id, $visible, 0, $depth, $exclude, $loopResult);
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
}
|
||||
@@ -48,7 +48,7 @@ class Image extends BaseI18nLoop
|
||||
/**
|
||||
* @var array Possible image sources
|
||||
*/
|
||||
protected $possible_sources = array('category', 'product', 'folder', 'content');
|
||||
protected $possible_sources = array('category', 'product', 'folder', 'content', 'module');
|
||||
|
||||
/**
|
||||
* @return \Thelia\Core\Template\Loop\Argument\ArgumentCollection
|
||||
@@ -93,7 +93,8 @@ class Image extends BaseI18nLoop
|
||||
new EnumType($this->possible_sources)
|
||||
)
|
||||
),
|
||||
Argument::createIntTypeArgument('source_id')
|
||||
Argument::createIntTypeArgument('source_id'),
|
||||
Argument::createBooleanTypeArgument('force_return', true)
|
||||
);
|
||||
|
||||
// Add possible image sources
|
||||
@@ -175,7 +176,7 @@ class Image extends BaseI18nLoop
|
||||
$source_id = $this->getSourceId();
|
||||
$id = $this->getId();
|
||||
|
||||
//echo "source = ".$this->getSource()."source_id=$source_id, id=$id<br />";
|
||||
//echo "source = ".$this->getSourceId()."source_id=$source_id, id=$id<br />";
|
||||
|
||||
if (is_null($source_id) && is_null($id)) {
|
||||
throw new \InvalidArgumentException("If 'source' argument is specified, 'id' or 'source_id' argument should be specified");
|
||||
@@ -214,6 +215,7 @@ class Image extends BaseI18nLoop
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
{
|
||||
|
||||
// Select the proper query to use, and get the object type
|
||||
$object_type = $object_id = null;
|
||||
|
||||
@@ -262,13 +264,14 @@ class Image extends BaseI18nLoop
|
||||
|
||||
}
|
||||
|
||||
//echo "sql=".$search->toString();
|
||||
// echo "sql=".$search->toString();
|
||||
|
||||
$results = $this->search($search, $pagination);
|
||||
|
||||
$loopResult = new LoopResult($results);
|
||||
|
||||
foreach ($results as $result) {
|
||||
|
||||
// Create image processing event
|
||||
$event = new ImageEvent($this->request);
|
||||
|
||||
@@ -315,7 +318,8 @@ 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);
|
||||
}
|
||||
|
||||
137
core/lib/Thelia/Core/Template/Loop/Module.php
Executable file
137
core/lib/Thelia/Core/Template/Loop/Module.php
Executable file
@@ -0,0 +1,137 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Template\Loop;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
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\Model\ModuleQuery;
|
||||
|
||||
use Thelia\Module\BaseModule;
|
||||
use Thelia\Type;
|
||||
|
||||
/**
|
||||
*
|
||||
* Module loop
|
||||
*
|
||||
*
|
||||
* Class Module
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class Module extends BaseI18nLoop
|
||||
{
|
||||
public $timestampable = true;
|
||||
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
*/
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
Argument::createIntListTypeArgument('id'),
|
||||
new Argument(
|
||||
'module_type',
|
||||
new Type\TypeCollection(
|
||||
new Type\EnumListType(array(
|
||||
BaseModule::CLASSIC_MODULE_TYPE,
|
||||
BaseModule::DELIVERY_MODULE_TYPE,
|
||||
BaseModule::PAYMENT_MODULE_TYPE,
|
||||
))
|
||||
)
|
||||
),
|
||||
Argument::createIntListTypeArgument('exclude'),
|
||||
Argument::createBooleanOrBothTypeArgument('active', Type\BooleanOrBothType::ANY)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
{
|
||||
$search = ModuleQuery::create();
|
||||
|
||||
/* manage translations */
|
||||
$locale = $this->configureI18nProcessing($search);
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
if (null !== $id) {
|
||||
$search->filterById($id, Criteria::IN);
|
||||
}
|
||||
|
||||
$moduleType = $this->getModule_type();
|
||||
|
||||
if (null !== $moduleType) {
|
||||
$search->filterByType($moduleType, Criteria::IN);
|
||||
}
|
||||
|
||||
$exclude = $this->getExclude();
|
||||
|
||||
if (!is_null($exclude)) {
|
||||
$search->filterById($exclude, Criteria::NOT_IN);
|
||||
}
|
||||
|
||||
$active = $this->getActive();
|
||||
|
||||
if($active !== Type\BooleanOrBothType::ANY) {
|
||||
$search->filterByActivate($active ? 1 : 0, Criteria::EQUAL);
|
||||
}
|
||||
|
||||
$search->orderByPosition();
|
||||
|
||||
/* perform search */
|
||||
$modules = $this->search($search, $pagination);
|
||||
|
||||
$loopResult = new LoopResult($modules);
|
||||
|
||||
foreach ($modules as $module) {
|
||||
$loopResultRow = new LoopResultRow($loopResult, $module, $this->versionable, $this->timestampable, $this->countable);
|
||||
$loopResultRow->set("ID", $module->getId())
|
||||
->set("IS_TRANSLATED",$module->getVirtualColumn('IS_TRANSLATED'))
|
||||
->set("LOCALE",$locale)
|
||||
->set("TITLE",$module->getVirtualColumn('i18n_TITLE'))
|
||||
->set("CHAPO", $module->getVirtualColumn('i18n_CHAPO'))
|
||||
->set("DESCRIPTION", $module->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set("POSTSCRIPTUM", $module->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||
->set("CODE", $module->getCode())
|
||||
->set("TYPE", $module->getType())
|
||||
->set("ACTIVE", $module->getActivate())
|
||||
->set("CLASS", $module->getFullNamespace())
|
||||
->set("POSITION", $module->getPosition());
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
}
|
||||
@@ -23,12 +23,16 @@
|
||||
|
||||
namespace Thelia\Core\Template\Loop;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
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\Model\OrderQuery;
|
||||
use Thelia\Type\TypeCollection;
|
||||
use Thelia\Type;
|
||||
/**
|
||||
*
|
||||
* @package Thelia\Core\Template\Loop
|
||||
@@ -37,19 +41,94 @@ use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
*/
|
||||
class Order extends BaseLoop
|
||||
{
|
||||
public $countable = true;
|
||||
public $timestampable = true;
|
||||
public $versionable = false;
|
||||
|
||||
public function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection();
|
||||
return new ArgumentCollection(
|
||||
Argument::createIntListTypeArgument('id'),
|
||||
new Argument(
|
||||
'customer',
|
||||
new TypeCollection(
|
||||
new Type\IntType(),
|
||||
new Type\EnumType(array('current'))
|
||||
),
|
||||
'current'
|
||||
),
|
||||
Argument::createIntListTypeArgument('status')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination
|
||||
*
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
* @return LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
{
|
||||
// TODO : a coder !
|
||||
return new LoopResult();
|
||||
$search = OrderQuery::create();
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
if (null !== $id) {
|
||||
$search->filterById($id, Criteria::IN);
|
||||
}
|
||||
|
||||
$customer = $this->getCustomer();
|
||||
|
||||
if ($customer === 'current') {
|
||||
$currentCustomer = $this->securityContext->getCustomerUser();
|
||||
if ($currentCustomer === null) {
|
||||
return new LoopResult();
|
||||
} else {
|
||||
$search->filterByCustomerId($currentCustomer->getId(), Criteria::EQUAL);
|
||||
}
|
||||
} else {
|
||||
$search->filterByCustomerId($customer, Criteria::EQUAL);
|
||||
}
|
||||
|
||||
$status = $this->getStatus();
|
||||
|
||||
if (null !== $status) {
|
||||
$search->filterByStatusId($status, Criteria::IN);
|
||||
}
|
||||
|
||||
$orders = $this->search($search, $pagination);
|
||||
|
||||
$loopResult = new LoopResult($orders);
|
||||
|
||||
foreach ($orders as $order) {
|
||||
$tax = 0;
|
||||
$amount = $order->getTotalAmount($tax);
|
||||
$loopResultRow = new LoopResultRow($loopResult, $order, $this->versionable, $this->timestampable, $this->countable);
|
||||
$loopResultRow
|
||||
->set("ID", $order->getId())
|
||||
->set("REF", $order->getRef())
|
||||
->set("CUSTOMER", $order->getCustomerId())
|
||||
->set("DELIVERY_ADDRESS", $order->getDeliveryOrderAddressId())
|
||||
->set("INVOICE_ADDRESS", $order->getInvoiceOrderAddressId())
|
||||
->set("INVOICE_DATE", $order->getInvoiceDate())
|
||||
->set("CURRENCY", $order->getCurrencyId())
|
||||
->set("CURRENCY_RATE", $order->getCurrencyRate())
|
||||
->set("TRANSACTION_REF", $order->getTransactionRef())
|
||||
->set("DELIVERY_REF", $order->getDeliveryRef())
|
||||
->set("INVOICE_REF", $order->getInvoiceRef())
|
||||
->set("POSTAGE", $order->getPostage())
|
||||
->set("PAYMENT_MODULE", $order->getPaymentModuleId())
|
||||
->set("DELIVERY_MODULE", $order->getDeliveryModuleId())
|
||||
->set("STATUS", $order->getStatusId())
|
||||
->set("LANG", $order->getLangId())
|
||||
->set("POSTAGE", $order->getPostage())
|
||||
->set("TOTAL_TAX", $tax)
|
||||
->set("TOTAL_AMOUNT", $amount - $tax)
|
||||
->set("TOTAL_TAXED_AMOUNT", $amount)
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
}
|
||||
|
||||
84
core/lib/Thelia/Core/Template/Loop/Payment.php
Normal file
84
core/lib/Thelia/Core/Template/Loop/Payment.php
Normal file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Template\Loop;
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
use Thelia\Module\BaseModule;
|
||||
|
||||
/**
|
||||
* Class Payment
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Etienne Roudeix <eroudeix@gmail.com>
|
||||
*/
|
||||
class Payment extends BaseSpecificModule
|
||||
{
|
||||
|
||||
public function getArgDefinitions()
|
||||
{
|
||||
$collection = parent::getArgDefinitions();
|
||||
|
||||
return $collection;
|
||||
}
|
||||
|
||||
public function exec(&$pagination)
|
||||
{
|
||||
$search = parent::exec($pagination);
|
||||
/* manage translations */
|
||||
$locale = $this->configureI18nProcessing($search);
|
||||
|
||||
$search->filterByType(BaseModule::PAYMENT_MODULE_TYPE, Criteria::EQUAL);
|
||||
|
||||
/* perform search */
|
||||
$paymentModules = $this->search($search, $pagination);
|
||||
|
||||
$loopResult = new LoopResult($paymentModules);
|
||||
|
||||
foreach ($paymentModules as $paymentModule) {
|
||||
$loopResultRow = new LoopResultRow($loopResult, $paymentModule, $this->versionable, $this->timestampable, $this->countable);
|
||||
|
||||
$moduleReflection = new \ReflectionClass($paymentModule->getFullNamespace());
|
||||
if ($moduleReflection->isSubclassOf("Thelia\Module\PaymentModuleInterface") === false) {
|
||||
throw new \RuntimeException(sprintf("payment module %s is not a Thelia\Module\PaymentModuleInterface", $paymentModule->getCode()));
|
||||
}
|
||||
$moduleInstance = $moduleReflection->newInstance();
|
||||
|
||||
$moduleInstance->setRequest($this->request);
|
||||
$moduleInstance->setDispatcher($this->dispatcher);
|
||||
|
||||
$loopResultRow
|
||||
->set('ID', $paymentModule->getId())
|
||||
->set('TITLE', $paymentModule->getVirtualColumn('i18n_TITLE'))
|
||||
->set('CHAPO', $paymentModule->getVirtualColumn('i18n_CHAPO'))
|
||||
->set('DESCRIPTION', $paymentModule->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set('POSTSCRIPTUM', $paymentModule->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,7 @@ use Thelia\Core\Template\Element\LoopResultRow;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
use Thelia\Exception\TaxEngineException;
|
||||
use Thelia\Model\CategoryQuery;
|
||||
use Thelia\Model\CountryQuery;
|
||||
use Thelia\Model\CurrencyQuery;
|
||||
@@ -597,32 +598,66 @@ class Product extends BaseI18nLoop
|
||||
|
||||
$loopResult = new LoopResult($products);
|
||||
|
||||
$taxCountry = CountryQuery::create()->findPk(64); // @TODO : make it magic
|
||||
|
||||
foreach ($products as $product) {
|
||||
|
||||
$loopResultRow = new LoopResultRow($loopResult, $product, $this->versionable, $this->timestampable, $this->countable);
|
||||
|
||||
$price = $product->getRealLowestPrice();
|
||||
$taxedPrice = $product->getTaxedPrice(
|
||||
CountryQuery::create()->findOneById(64) // @TODO : make it magic
|
||||
);
|
||||
|
||||
try {
|
||||
$taxedPrice = $product->getTaxedPrice(
|
||||
$taxCountry
|
||||
);
|
||||
} catch(TaxEngineException $e) {
|
||||
$taxedPrice = null;
|
||||
}
|
||||
|
||||
$loopResultRow->set("ID", $product->getId())
|
||||
->set("REF",$product->getRef())
|
||||
->set("IS_TRANSLATED",$product->getVirtualColumn('IS_TRANSLATED'))
|
||||
->set("LOCALE",$locale)
|
||||
->set("TITLE",$product->getVirtualColumn('i18n_TITLE'))
|
||||
->set("CHAPO", $product->getVirtualColumn('i18n_CHAPO'))
|
||||
->set("DESCRIPTION", $product->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set("POSTSCRIPTUM", $product->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||
->set("URL", $product->getUrl($locale))
|
||||
->set("BEST_PRICE", $price)
|
||||
->set("BEST_PRICE_TAX", $taxedPrice - $price)
|
||||
->set("BEST_TAXED_PRICE", $taxedPrice)
|
||||
->set("IS_PROMO", $product->getVirtualColumn('main_product_is_promo'))
|
||||
->set("IS_NEW", $product->getVirtualColumn('main_product_is_new'))
|
||||
->set("POSITION", $product->getPosition())
|
||||
// Find previous and next product, in the default category.
|
||||
$default_category_id = $product->getDefaultCategoryId();
|
||||
|
||||
$previous = ProductQuery::create()
|
||||
->joinProductCategory()
|
||||
->where('ProductCategory.category_id = ?', $default_category_id)
|
||||
->filterByPosition($product->getPosition(), Criteria::LESS_THAN)
|
||||
->orderByPosition(Criteria::DESC)
|
||||
->findOne()
|
||||
;
|
||||
|
||||
$next = ProductQuery::create()
|
||||
->joinProductCategory()
|
||||
->where('ProductCategory.category_id = ?', $default_category_id)
|
||||
->filterByPosition($product->getPosition(), Criteria::GREATER_THAN)
|
||||
->orderByPosition(Criteria::ASC)
|
||||
->findOne()
|
||||
;
|
||||
|
||||
$loopResultRow
|
||||
->set("ID" , $product->getId())
|
||||
->set("REF" , $product->getRef())
|
||||
->set("IS_TRANSLATED" , $product->getVirtualColumn('IS_TRANSLATED'))
|
||||
->set("LOCALE" , $locale)
|
||||
->set("TITLE" , $product->getVirtualColumn('i18n_TITLE'))
|
||||
->set("CHAPO" , $product->getVirtualColumn('i18n_CHAPO'))
|
||||
->set("DESCRIPTION" , $product->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set("POSTSCRIPTUM" , $product->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||
->set("URL" , $product->getUrl($locale))
|
||||
->set("BEST_PRICE" , $price)
|
||||
->set("BEST_PRICE_TAX" , $taxedPrice - $price)
|
||||
->set("BEST_TAXED_PRICE" , $taxedPrice)
|
||||
->set("IS_PROMO" , $product->getVirtualColumn('main_product_is_promo'))
|
||||
->set("IS_NEW" , $product->getVirtualColumn('main_product_is_new'))
|
||||
->set("POSITION" , $product->getPosition())
|
||||
->set("VISIBLE" , $product->getVisible() ? "1" : "0")
|
||||
->set("HAS_PREVIOUS" , $previous != null ? 1 : 0)
|
||||
->set("HAS_NEXT" , $next != null ? 1 : 0)
|
||||
->set("PREVIOUS" , $previous != null ? $previous->getId() : -1)
|
||||
->set("NEXT" , $next != null ? $next->getId() : -1)
|
||||
->set("DEFAULT_CATEGORY" , $default_category_id)
|
||||
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ use Thelia\Core\Template\Element\LoopResultRow;
|
||||
use Thelia\Core\Template\Loop\Argument\ArgumentCollection;
|
||||
use Thelia\Core\Template\Loop\Argument\Argument;
|
||||
|
||||
use Thelia\Exception\TaxEngineException;
|
||||
use Thelia\Model\Base\ProductSaleElementsQuery;
|
||||
use Thelia\Model\CountryQuery;
|
||||
use Thelia\Model\CurrencyQuery;
|
||||
@@ -147,17 +148,27 @@ class ProductSaleElements extends BaseLoop
|
||||
|
||||
$loopResult = new LoopResult($PSEValues);
|
||||
|
||||
$taxCountry = CountryQuery::create()->findPk(64); // @TODO : make it magic
|
||||
|
||||
foreach ($PSEValues as $PSEValue) {
|
||||
$loopResultRow = new LoopResultRow($loopResult, $PSEValue, $this->versionable, $this->timestampable, $this->countable);
|
||||
|
||||
$price = $PSEValue->getPrice();
|
||||
$taxedPrice = $PSEValue->getTaxedPrice(
|
||||
CountryQuery::create()->findOneById(64) // @TODO : make it magic
|
||||
);
|
||||
try {
|
||||
$taxedPrice = $PSEValue->getTaxedPrice(
|
||||
$taxCountry
|
||||
);
|
||||
} catch(TaxEngineException $e) {
|
||||
$taxedPrice = null;
|
||||
}
|
||||
$promoPrice = $PSEValue->getPromoPrice();
|
||||
$taxedPromoPrice = $PSEValue->getTaxedPromoPrice(
|
||||
CountryQuery::create()->findOneById(64) // @TODO : make it magic
|
||||
);
|
||||
try {
|
||||
$taxedPromoPrice = $PSEValue->getTaxedPromoPrice(
|
||||
$taxCountry
|
||||
);
|
||||
} catch(TaxEngineException $e) {
|
||||
$taxedPromoPrice = null;
|
||||
}
|
||||
|
||||
$loopResultRow->set("ID", $PSEValue->getId())
|
||||
->set("QUANTITY", $PSEValue->getQuantity())
|
||||
|
||||
135
core/lib/Thelia/Core/Template/Loop/TaxRule.php
Normal file
135
core/lib/Thelia/Core/Template/Loop/TaxRule.php
Normal file
@@ -0,0 +1,135 @@
|
||||
<?php
|
||||
/*************************************************************************************/
|
||||
/* */
|
||||
/* Thelia */
|
||||
/* */
|
||||
/* Copyright (c) OpenStudio */
|
||||
/* email : info@thelia.net */
|
||||
/* web : http://www.thelia.net */
|
||||
/* */
|
||||
/* This program is free software; you can redistribute it and/or modify */
|
||||
/* it under the terms of the GNU General Public License as published by */
|
||||
/* the Free Software Foundation; either version 3 of the License */
|
||||
/* */
|
||||
/* This program is distributed in the hope that it will be useful, */
|
||||
/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
|
||||
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
|
||||
/* GNU General Public License for more details. */
|
||||
/* */
|
||||
/* You should have received a copy of the GNU General Public License */
|
||||
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Template\Loop;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
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\Type\TypeCollection;
|
||||
use Thelia\Type;
|
||||
use Thelia\Model\TaxRuleQuery;
|
||||
|
||||
/**
|
||||
*
|
||||
* TaxRule loop
|
||||
*
|
||||
*
|
||||
* Class TaxRule
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class TaxRule extends BaseI18nLoop
|
||||
{
|
||||
public $timestampable = true;
|
||||
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
*/
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
Argument::createIntListTypeArgument('id'),
|
||||
Argument::createIntListTypeArgument('exclude'),
|
||||
new Argument(
|
||||
'order',
|
||||
new TypeCollection(
|
||||
new Type\EnumListType(array('id', 'id_reverse', 'alpha', 'alpha_reverse'))
|
||||
),
|
||||
'alpha'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
{
|
||||
$search = TaxRuleQuery::create();
|
||||
|
||||
/* manage translations */
|
||||
$locale = $this->configureI18nProcessing($search, array('TITLE', 'DESCRIPTION'));
|
||||
|
||||
$id = $this->getId();
|
||||
|
||||
if (null !== $id) {
|
||||
$search->filterById($id, Criteria::IN);
|
||||
}
|
||||
|
||||
$exclude = $this->getExclude();
|
||||
|
||||
if (null !== $exclude) {
|
||||
$search->filterById($exclude, Criteria::NOT_IN);
|
||||
}
|
||||
|
||||
$orders = $this->getOrder();
|
||||
|
||||
foreach ($orders as $order) {
|
||||
switch ($order) {
|
||||
case "id":
|
||||
$search->orderById(Criteria::ASC);
|
||||
break;
|
||||
case "id_reverse":
|
||||
$search->orderById(Criteria::DESC);
|
||||
break;
|
||||
case "alpha":
|
||||
$search->addAscendingOrderByColumn('i18n_TITLE');
|
||||
break;
|
||||
case "alpha_reverse":
|
||||
$search->addDescendingOrderByColumn('i18n_TITLE');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* perform search */
|
||||
$tax_rules = $this->search($search, $pagination);
|
||||
|
||||
$loopResult = new LoopResult($tax_rules);
|
||||
|
||||
foreach ($tax_rules as $tax_rule) {
|
||||
|
||||
$loopResultRow = new LoopResultRow($loopResult, $tax_rule, $this->versionable, $this->timestampable, $this->countable);
|
||||
|
||||
$loopResultRow
|
||||
->set("ID" , $tax_rule->getId())
|
||||
->set("IS_TRANSLATED" , $tax_rule->getVirtualColumn('IS_TRANSLATED'))
|
||||
->set("LOCALE" , $locale)
|
||||
->set("TITLE" , $tax_rule->getVirtualColumn('i18n_TITLE'))
|
||||
->set("DESCRIPTION" , $tax_rule->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set("IS_DEFAULT" , $tax_rule->getIsDefault() ? '1' : '0')
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,7 @@
|
||||
namespace Thelia\Core\Template\Smarty\Plugins;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\ModelCriteria;
|
||||
use Symfony\Component\EventDispatcher\ContainerAwareEventDispatcher;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Thelia\Core\Template\Smarty\AbstractSmartyPlugin;
|
||||
use Thelia\Core\Security\SecurityContext;
|
||||
@@ -53,12 +54,14 @@ class DataAccessFunctions extends AbstractSmartyPlugin
|
||||
private $securityContext;
|
||||
protected $parserContext;
|
||||
protected $request;
|
||||
protected $dispatcher;
|
||||
|
||||
public function __construct(Request $request, SecurityContext $securityContext, ParserContext $parserContext)
|
||||
public function __construct(Request $request, SecurityContext $securityContext, ParserContext $parserContext, ContainerAwareEventDispatcher $dispatcher)
|
||||
{
|
||||
$this->securityContext = $securityContext;
|
||||
$this->parserContext = $parserContext;
|
||||
$this->request = $request;
|
||||
$this->dispatcher = $dispatcher;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -188,7 +191,22 @@ class DataAccessFunctions extends AbstractSmartyPlugin
|
||||
|
||||
public function orderDataAccess($params, &$smarty)
|
||||
{
|
||||
return $this->dataAccess("Order", $params, $this->request->getSession()->getOrder());
|
||||
$order = $this->request->getSession()->getOrder();
|
||||
$attribute = $this->getNormalizedParam($params, array('attribute', 'attrib', 'attr'));
|
||||
switch($attribute) {
|
||||
case 'postage':
|
||||
return $order->getPostage();
|
||||
case 'delivery_address':
|
||||
return $order->chosenDeliveryAddress;
|
||||
case 'invoice_address':
|
||||
return $order->chosenInvoiceAddress;
|
||||
case 'delivery_module':
|
||||
return $order->getDeliveryModuleId();
|
||||
case 'payment_module':
|
||||
return $order->getPaymentModuleId();
|
||||
}
|
||||
|
||||
throw new \InvalidArgumentException(sprintf("%s has no '%s' attribute", 'Order', $attribute));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -196,6 +214,8 @@ class DataAccessFunctions extends AbstractSmartyPlugin
|
||||
*
|
||||
* @param $params
|
||||
* @param $smarty
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function langDataAccess($params, $smarty)
|
||||
{
|
||||
@@ -294,6 +314,7 @@ class DataAccessFunctions extends AbstractSmartyPlugin
|
||||
*/
|
||||
public function getPluginDescriptors()
|
||||
{
|
||||
|
||||
return array(
|
||||
new SmartyPluginDescriptor('function', 'admin', $this, 'adminDataAccess'),
|
||||
new SmartyPluginDescriptor('function', 'customer', $this, 'customerDataAccess'),
|
||||
@@ -308,4 +329,14 @@ class DataAccessFunctions extends AbstractSmartyPlugin
|
||||
new SmartyPluginDescriptor('function', 'order', $this, 'orderDataAccess'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the event dispatcher,
|
||||
*
|
||||
* @return \Symfony\Component\EventDispatcher\EventDispatcher
|
||||
*/
|
||||
public function getDispatcher()
|
||||
{
|
||||
return $this->dispatcher;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,8 @@ use Thelia\Core\Template\Smarty\AbstractSmartyPlugin;
|
||||
use Thelia\Core\Security\SecurityContext;
|
||||
use Thelia\Core\Security\Exception\AuthenticationException;
|
||||
use Thelia\Exception\OrderException;
|
||||
use Thelia\Model\AddressQuery;
|
||||
use Thelia\Model\ModuleQuery;
|
||||
|
||||
class Security extends AbstractSmartyPlugin
|
||||
{
|
||||
@@ -78,7 +80,22 @@ class Security extends AbstractSmartyPlugin
|
||||
{
|
||||
$cart = $this->request->getSession()->getCart();
|
||||
if($cart===null || $cart->countCartItems() == 0) {
|
||||
throw new OrderException('Cart must not be empty', OrderException::CART_EMPTY);
|
||||
throw new OrderException('Cart must not be empty', OrderException::CART_EMPTY, array('empty' => 1));
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
public function checkValidDeliveryFunction($params, &$smarty)
|
||||
{
|
||||
$order = $this->request->getSession()->getOrder();
|
||||
/* Does address and module still exists ? We assume address owner can't change neither module type */
|
||||
if($order !== null) {
|
||||
$checkAddress = AddressQuery::create()->findPk($order->chosenDeliveryAddress);
|
||||
$checkModule = ModuleQuery::create()->findPk($order->getDeliveryModuleId());
|
||||
}
|
||||
if(null === $order || null == $checkAddress || null === $checkModule) {
|
||||
throw new OrderException('Delivery must be defined', OrderException::UNDEFINED_DELIVERY, array('missing' => 1));
|
||||
}
|
||||
|
||||
return "";
|
||||
@@ -94,6 +111,7 @@ class Security extends AbstractSmartyPlugin
|
||||
return array(
|
||||
new SmartyPluginDescriptor('function', 'check_auth', $this, 'checkAuthFunction'),
|
||||
new SmartyPluginDescriptor('function', 'check_cart_not_empty', $this, 'checkCartNotEmptyFunction'),
|
||||
new SmartyPluginDescriptor('function', 'check_valid_delivery', $this, 'checkValidDeliveryFunction'),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,6 +132,8 @@ class TheliaLoop extends AbstractSmartyPlugin
|
||||
|
||||
$loopResults = $loop->exec(self::$pagination[$name]);
|
||||
|
||||
$loopResults->rewind();
|
||||
|
||||
$this->loopstack[$name] = $loopResults;
|
||||
|
||||
// Pas de résultat ? la boucle est terminée, ne pas évaluer le contenu.
|
||||
|
||||
@@ -27,6 +27,7 @@ use Thelia\Core\Template\Smarty\SmartyPluginDescriptor;
|
||||
use Thelia\Core\Template\Smarty\AbstractSmartyPlugin;
|
||||
use Thelia\Tools\URL;
|
||||
use Thelia\Core\HttpFoundation\Request;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
|
||||
class UrlGenerator extends AbstractSmartyPlugin
|
||||
{
|
||||
@@ -47,11 +48,27 @@ class UrlGenerator extends AbstractSmartyPlugin
|
||||
public function generateUrlFunction($params, &$smarty)
|
||||
{
|
||||
// the path to process
|
||||
$path = $this->getParam($params, 'path');
|
||||
$path = $this->getParam($params, 'path', null);
|
||||
$file = $this->getParam($params, 'file', null);
|
||||
|
||||
if ($file !== null) {
|
||||
$path = $file;
|
||||
$mode = URL::PATH_TO_FILE;
|
||||
}
|
||||
else if ($path !== null) {
|
||||
$mode = URL::WITH_INDEX_PAGE;
|
||||
}
|
||||
else {
|
||||
throw \InvalidArgumentException(Translator::getInstance()->trans("Please specify either 'path' or 'file' parameter in {url} function."));
|
||||
}
|
||||
|
||||
$target = $this->getParam($params, 'target', null);
|
||||
|
||||
$url = URL::getInstance()->absoluteUrl($path, $this->getArgsFromParam($params, array('path', 'target')));
|
||||
$url = URL::getInstance()->absoluteUrl(
|
||||
$path,
|
||||
$this->getArgsFromParam($params, array('path', 'file', 'target')),
|
||||
$mode
|
||||
);
|
||||
|
||||
if ($target != null) $url .= '#'.$target;
|
||||
|
||||
@@ -169,7 +186,8 @@ class UrlGenerator extends AbstractSmartyPlugin
|
||||
|
||||
protected function getCurrentUrl()
|
||||
{
|
||||
return URL::getInstance()->retrieveCurrent($this->request)->toString();
|
||||
//return URL::getInstance()->retrieveCurrent($this->request)->toString();
|
||||
return $this->request->getUri();
|
||||
}
|
||||
|
||||
protected function getReturnToUrl()
|
||||
|
||||
Reference in New Issue
Block a user