Merge branch 'master' into loops

Conflicts:
	core/lib/Thelia/Core/Template/Loop/Category.php
	core/lib/Thelia/Core/Template/Loop/FeatureValue.php
	core/lib/Thelia/Core/Template/Loop/Folder.php
	core/lib/Thelia/Core/Template/Loop/Product.php
	core/lib/Thelia/Core/Template/Smarty/Plugins/TheliaLoop.php
	install/faker.php
This commit is contained in:
Etienne Roudeix
2013-08-21 09:19:56 +02:00
3275 changed files with 929970 additions and 274940 deletions

View File

@@ -0,0 +1,30 @@
<?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\Controller\Front;
use Thelia\Controller\BaseController;
class BaseFrontController extends BaseController
{
}

View File

@@ -0,0 +1,140 @@
<?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\Controller\Front;
use Propel\Runtime\Exception\PropelException;
use Thelia\Form\Exception\FormValidationException;
use Thelia\Core\Event\CartEvent;
use Thelia\Core\Event\TheliaEvents;
use Symfony\Component\HttpFoundation\Request;
use Thelia\Form\CartAdd;
class CartController extends BaseFrontController
{
use \Thelia\Cart\CartTrait;
public function addItem()
{
$request = $this->getRequest();
$cartAdd = $this->getAddCartForm($request);
$message = null;
try {
$form = $this->validateForm($cartAdd);
$cartEvent = $this->getCartEvent();
$cartEvent->setNewness($form->get("newness")->getData());
$cartEvent->setAppend($form->get("append")->getData());
$cartEvent->setQuantity($form->get("quantity")->getData());
$cartEvent->setProductSaleElementsId($form->get("product_sale_elements_id")->getData());
$cartEvent->setProduct($form->get("product")->getData());
$this->getDispatcher()->dispatch(TheliaEvents::CART_ADDITEM, $cartEvent);
$this->redirectSuccess();
} catch (PropelException $e) {
\Thelia\Log\Tlog::getInstance()->error(sprintf("Failed to add item to cart with message : %s", $e->getMessage()));
$message = "Failed to add this article to your cart, please try again";
} catch (FormValidationException $e) {
$message = $e->getMessage();
}
if ($message) {
$cartAdd->setErrorMessage($e->getMessage());
$this->getParserContext()->setErrorForm($cartAdd);
}
}
public function changeItem()
{
$cartEvent = $this->getCartEvent();
$cartEvent->setCartItem($this->getRequest()->get("cart_item"));
$cartEvent->setQuantity($this->getRequest()->get("quantity"));
try {
$this->getDispatcher()->dispatch(TheliaEvents::CART_CHANGEITEM, $cartEvent);
$this->redirectSuccess();
} catch(PropelException $e) {
$this->getParserContext()->setGeneralError($e->getMessage());
}
}
public function deleteItem()
{
$cartEvent = $this->getCartEvent();
$cartEvent->setCartItem($this->getRequest()->get("cart_item"));
try {
$this->getDispatcher()->dispatch(TheliaEvents::CART_DELETEITEM, $cartEvent);
$this->redirectSuccess();
} catch (PropelException $e) {
\Thelia\Log\Tlog::getInstance()->error(sprintf("error during deleting cartItem with message : %s", $e->getMessage()));
$this->getParserContext()->setGeneralError($e->getMessage());
}
}
/**
* use Thelia\Cart\CartTrait for searching current cart or create a new one
*
* @return CartEvent
*/
protected function getCartEvent()
{
$cart = $this->getCart($this->getRequest());
return new CartEvent($cart);
}
/**
* Find the good way to construct the cart form
*
* @param Request $request
* @return CartAdd
*/
private function getAddCartForm(Request $request)
{
if ($request->isMethod("post")) {
$cartAdd = new CartAdd($request);
} else {
$cartAdd = new CartAdd(
$request,
"form",
array(),
array(
'csrf_protection' => false,
)
);
}
return $cartAdd;
}
}

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\Controller\Front;
use Thelia\Core\Event\CustomerEvent;
use Thelia\Core\Security\SecurityContext;
use Thelia\Model\Customer;
use Thelia\Core\Event\TheliaEvents;
class CustomerController extends BaseFrontController
{
public function createAction()
{
$event = $this->dispatchEvent("createCustomer");
if (null !== $customer = $event->customer) {
$this->processLogin($event->customer);
}
}
public function displayCreateAction()
{
}
public function loginAction()
{
$event = $this->dispatchEvent("loginCustomer");
$customerEvent = new CustomerEvent($event->getCustomer());
$this->processLogin($event->getCustomer(), $customerEvent, true);
}
public function processLogin(Customer $customer,$event = null, $sendLogin = false)
{
$this->getSecurityContext(SecurityContext::CONTEXT_FRONT_OFFICE)->setUser($customer);
if($sendLogin) $this->dispatch(TheliaEvents::CUSTOMER_LOGIN, $event);
}
}

View File

@@ -0,0 +1,56 @@
<?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\Controller\Front;
use Symfony\Component\HttpFoundation\Request;
/**
*
* Must be the last controller call. It fixes default values
*
* @author Manuel Raynaud <mraynadu@openstudio.fr>
*/
class DefaultController extends BaseFrontController
{
/**
*
* set the default value for thelia
*
* In this case there is no action so we have to verify if some needed params are not missing
*
* @param \Symfony\Component\HttpFoundation\Request $request
*/
public function noAction(Request $request)
{
if (! $view = $request->query->get('view')) {
$view = "index";
if ($request->request->has('view')) {
$view = $request->request->get('view');
}
}
$request->attributes->set('_view', $view);
}
}