Merge branch 'master' of https://github.com/thelia/thelia into coupon

# By Manuel Raynaud (68) and others
# Via Manuel Raynaud (12) and others
* 'master' of https://github.com/thelia/thelia: (119 commits)
  order tests
  action order tests
  cache dataccessfunctions
  order action test
  fire event on insert content in createmethod
  fix issue, default foler is set on content creation
  allow to create new content
  update default param of content model
  create content listener for crud management
  dispatch event in pre/post crud method for content model
  display content modification page
  create contentUpdateEvent
  create contentCreateEvent
  create ContentEvent
  create contentModificationForm
  create content controller
  change folder_id parm by parent in list folder view
  use placeholder in folder update route
  implement process for changing folder position
  allow possibility to change folder visibility
  ...

Conflicts:
	core/lib/Thelia/Coupon/CouponBaseAdapter.php
	templates/admin/default/coupon-list.html
	templates/admin/default/coupon-read.html
This commit is contained in:
gmorel
2013-09-23 21:03:26 +02:00
643 changed files with 38690 additions and 4156 deletions

View 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;
}
}

View 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\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;
}
}

View File

@@ -0,0 +1,124 @@
<?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\Content;
/**
* Class ContentCreateEvent
* @package Thelia\Core\Event\Content
* @author manuel raynaud <mraynaud@openstudio.fr>
*/
class ContentCreateEvent extends ContentEvent
{
protected $title;
protected $default_folder;
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 $default_folder
*
* @return $this
*/
public function setDefaultFolder($default_folder)
{
$this->default_folder = $default_folder;
return $this;
}
/**
* @return mixed
*/
public function getDefaultFolder()
{
return $this->default_folder;
}
/**
* @param mixed $visible
*
* @return $this
*/
public function setVisible($visible)
{
$this->visible = $visible;
return $this;
}
/**
* @return mixed
*/
public function getVisible()
{
return $this->visible;
}
/**
* @param mixed $title
*
* @return $this
*/
public function setTitle($title)
{
$this->title = $title;
return $this;
}
/**
* @return mixed
*/
public function getTitle()
{
return $this->title;
}
}

View 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\Content;
use Thelia\Core\Event\ActionEvent;
use Thelia\Model\Content;
/**
* Class ContentEvent
* @package Thelia\Core\Event\Content
* @author manuel raynaud <mraynaud@openstudio.fr>
*/
class ContentEvent extends ActionEvent
{
/**
* @var \Thelia\Model\Content
*/
protected $content;
function __construct(Content $content = null)
{
$this->content = $content;
}
/**
* @param \Thelia\Model\Content $content
*/
public function setContent(Content $content)
{
$this->content = $content;
return $this;
}
/**
* @return \Thelia\Model\Content
*/
public function getContent()
{
return $this->content;
}
/**
* check if content exists
*
* @return bool
*/
public function hasContent()
{
return null !== $this->content;
}
}

View File

@@ -0,0 +1,150 @@
<?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\Content;
/**
* Class ContentUpdateEvent
* @package Thelia\Core\Event\Content
* @author manuel raynaud <mraynaud@openstudio.fr>
*/
class ContentUpdateEvent extends ContentCreateEvent
{
protected $content_id;
protected $chapo;
protected $description;
protected $postscriptum;
protected $url;
function __construct($content_id)
{
$this->content_id = $content_id;
}
/**
* @param mixed $chapo
*
* @return $this
*/
public function setChapo($chapo)
{
$this->chapo = $chapo;
return $this;
}
/**
* @return mixed
*/
public function getChapo()
{
return $this->chapo;
}
/**
* @param mixed $content_id
*
* @return $this
*/
public function setContentId($content_id)
{
$this->content_id = $content_id;
return $this;
}
/**
* @return mixed
*/
public function getContentId()
{
return $this->content_id;
}
/**
* @param mixed $description
*
* @return $this
*/
public function setDescription($description)
{
$this->description = $description;
return $this;
}
/**
* @return mixed
*/
public function getDescription()
{
return $this->description;
}
/**
* @param mixed $postscriptum
*
* @return $this
*/
public function setPostscriptum($postscriptum)
{
$this->postscriptum = $postscriptum;
return $this;
}
/**
* @return mixed
*/
public function getPostscriptum()
{
return $this->postscriptum;
}
/**
* @param mixed $url
*
* @return $this
*/
public function setUrl($url)
{
$this->url = $url;
return $this;
}
/**
* @return mixed
*/
public function getUrl()
{
return $this->url;
}
}

View 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;
}
}

View 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;
}
}

View 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;
}
}

View 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 {
}

View 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;
}
}

View 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;
}
}

View File

@@ -28,11 +28,13 @@ use Thelia\Model\Order;
class OrderEvent extends ActionEvent
{
protected $order = 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
@@ -50,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 setInvoiceAddress($address)
{
$this->deliveryAddress = $address;
$this->invoiceAddress = $address;
}
/**
@@ -90,6 +100,14 @@ class OrderEvent extends ActionEvent
$this->postage = $postage;
}
/**
* @param $ref
*/
public function setRef($ref)
{
$this->ref = $ref;
}
/**
* @return null|Order
*/
@@ -98,6 +116,14 @@ class OrderEvent extends ActionEvent
return $this->order;
}
/**
* @return null|Order
*/
public function getPlacedOrder()
{
return $this->placedOrder;
}
/**
* @return null|int
*/
@@ -137,4 +163,12 @@ class OrderEvent extends ActionEvent
{
return $this->postage;
}
/**
* @return null|int
*/
public function getRef()
{
return $this->ref;
}
}

View 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;
}
}

View 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;
}
}

View File

@@ -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;
}
}

View 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;
}
}

View File

@@ -165,6 +165,57 @@ 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";
// -- content management -----------------------------------------------
const CONTENT_CREATE = "action.createContent";
const CONTENT_UPDATE = "action.updateContent";
const CONTENT_DELETE = "action.deleteContent";
const CONTENT_TOGGLE_VISIBILITY = "action.toggleContentVisibility";
const CONTENT_UPDATE_POSITION = "action.updateContentPosition";
// const FOLDER_ADD_CONTENT = "action.categoryAddContent";
// const FOLDER_REMOVE_CONTENT = "action.categoryRemoveContent";
const BEFORE_CREATECONTENT = "action.before_createContent";
const AFTER_CREATECONTENT = "action.after_createContent";
const BEFORE_DELETECONTENT = "action.before_deleteContent";
const AFTER_DELETECONTENT = "action.after_deleteContent";
const BEFORE_UPDATECONTENT = "action.before_updateContent";
const AFTER_UPDATECONTENT = "action.after_updateContent";
// -- 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 +227,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 +240,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 +292,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
@@ -441,4 +526,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';
}

View File

@@ -79,10 +79,20 @@ 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) {

View File

@@ -65,6 +65,8 @@ abstract class BaseI18nLoop extends BaseLoop
{
/* manage translations */
$fr = $this->getForce_return();
return ModelCriteriaTools::getI18n(
$this->getBackend_context(),
$this->getLang(),

View File

@@ -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;
}
}

View File

@@ -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)

View File

@@ -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(

View File

@@ -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;
}
}

View File

@@ -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())

View File

@@ -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;
}

View File

@@ -234,6 +234,7 @@ class Content extends BaseI18nLoop
->set("DESCRIPTION", $content->getVirtualColumn('i18n_DESCRIPTION'))
->set("POSTSCRIPTUM", $content->getVirtualColumn('i18n_POSTSCRIPTUM'))
->set("POSITION", $content->getPosition())
->set("DEFAULT_FOLDER", $content->getDefaultFolderId())
->set("URL", $content->getUrl($locale))
;

View File

@@ -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) {

View File

@@ -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())
;

View 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;
}
}

View File

@@ -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);
}

View 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;
}
}

View File

@@ -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;
}
}

View File

@@ -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);
}

View File

@@ -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())

View 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;
}
}

View File

@@ -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,16 @@ class DataAccessFunctions extends AbstractSmartyPlugin
private $securityContext;
protected $parserContext;
protected $request;
protected $dispatcher;
public function __construct(Request $request, SecurityContext $securityContext, ParserContext $parserContext)
private static $dataAccessCache = array();
public function __construct(Request $request, SecurityContext $securityContext, ParserContext $parserContext, ContainerAwareEventDispatcher $dispatcher)
{
$this->securityContext = $securityContext;
$this->parserContext = $parserContext;
$this->request = $request;
$this->dispatcher = $dispatcher;
}
/**
@@ -157,7 +162,12 @@ class DataAccessFunctions extends AbstractSmartyPlugin
public function countryDataAccess($params, $smarty)
{
$defaultCountry = CountryQuery::create()->findOneByByDefault(1);
if(array_key_exists('defaultCountry', self::$dataAccessCache)) {
$defaultCountry = self::$dataAccessCache['defaultCountry'];
} else {
$defaultCountry = CountryQuery::create()->findOneByByDefault(1);
self::$dataAccessCache['defaultCountry'] = $defaultCountry;
}
switch($params["attr"]) {
case "default":
@@ -167,6 +177,13 @@ class DataAccessFunctions extends AbstractSmartyPlugin
public function cartDataAccess($params, $smarty)
{
if(array_key_exists('currentCountry', self::$dataAccessCache)) {
$currentCountry = self::$dataAccessCache['currentCountry'];
} else {
$currentCountry = CountryQuery::create()->findOneById(64); // @TODO : make it magic
self::$dataAccessCache['currentCountry'] = $currentCountry;
}
$cart = $this->getCart($this->request);
$result = "";
switch($params["attr"]) {
@@ -177,9 +194,7 @@ class DataAccessFunctions extends AbstractSmartyPlugin
$result = $cart->getTotalAmount();
break;
case "total_taxed_price":
$result = $cart->getTaxedAmount(
CountryQuery::create()->findOneById(64) // @TODO : make it magic
);
$result = $cart->getTaxedAmount($currentCountry);
break;
}
@@ -195,6 +210,12 @@ class DataAccessFunctions extends AbstractSmartyPlugin
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));
@@ -225,24 +246,30 @@ 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) {
$lang = $this->request->getSession()->getLang()->getId();
if(array_key_exists('data_' . $objectLabel, self::$dataAccessCache)) {
$data = self::$dataAccessCache['data_' . $objectLabel];
} else {
$lang = $this->getNormalizedParam($params, array('lang'));
if ($lang === null) {
$lang = $this->request->getSession()->getLang()->getId();
}
ModelCriteriaTools::getI18n(
false,
$lang,
$search,
$this->request->getSession()->getLang()->getLocale(),
$columns,
$foreignTable,
$foreignKey,
true
);
$data = $search->findOne();
self::$dataAccessCache['data_' . $objectLabel] = $data;
}
ModelCriteriaTools::getI18n(
false,
$lang,
$search,
$this->request->getSession()->getLang()->getLocale(),
$columns,
$foreignTable,
$foreignKey,
true
);
$data = $search->findOne();
$noGetterData = array();
foreach ($columns as $column) {
$noGetterData[$column] = $data->getVirtualColumn('i18n_' . $column);
@@ -320,4 +347,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;
}
}

View File

@@ -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
{
@@ -87,7 +89,12 @@ class Security extends AbstractSmartyPlugin
public function checkValidDeliveryFunction($params, &$smarty)
{
$order = $this->request->getSession()->getOrder();
if(null === $order || null === $order->chosenDeliveryAddress || null === $order->getDeliveryModuleId()) {
/* 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));
}

View File

@@ -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.

View File

@@ -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()