Merge with master
This commit is contained in:
@@ -30,7 +30,7 @@ use Thelia\Core\DependencyInjection\Compiler\RegisterCouponPass;
|
||||
use Thelia\Core\DependencyInjection\Compiler\RegisterListenersPass;
|
||||
use Thelia\Core\DependencyInjection\Compiler\RegisterParserPluginPass;
|
||||
use Thelia\Core\DependencyInjection\Compiler\RegisterRouterPass;
|
||||
use Thelia\Core\DependencyInjection\Compiler\RegisterRulePass;
|
||||
use Thelia\Core\DependencyInjection\Compiler\RegisterCouponConditionPass;
|
||||
|
||||
/**
|
||||
* First Bundle use in Thelia
|
||||
@@ -63,8 +63,6 @@ class TheliaBundle extends Bundle
|
||||
->addCompilerPass(new RegisterParserPluginPass())
|
||||
->addCompilerPass(new RegisterRouterPass())
|
||||
->addCompilerPass(new RegisterCouponPass())
|
||||
->addCompilerPass(new RegisterRulePass())
|
||||
;
|
||||
|
||||
->addCompilerPass(new RegisterCouponConditionPass());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,11 +35,13 @@ use Symfony\Component\DependencyInjection\Reference;
|
||||
* Class RegisterListenersPass
|
||||
* Source code come from Symfony\Bundle\FrameworkBundle\DependencyInjection\Compiler\RegisterKernelListenersPass class
|
||||
*
|
||||
* Register all available Conditions for the coupon module
|
||||
*
|
||||
* @package Thelia\Core\DependencyInjection\Compiler
|
||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
class RegisterRulePass implements CompilerPassInterface
|
||||
class RegisterCouponConditionPass implements CompilerPassInterface
|
||||
{
|
||||
/**
|
||||
* You can modify the container here before it is dumped to PHP code.
|
||||
@@ -55,11 +57,11 @@ class RegisterRulePass implements CompilerPassInterface
|
||||
}
|
||||
|
||||
$couponManager = $container->getDefinition('thelia.coupon.manager');
|
||||
$services = $container->findTaggedServiceIds("thelia.coupon.addRule");
|
||||
$services = $container->findTaggedServiceIds("thelia.coupon.addCondition");
|
||||
|
||||
foreach ($services as $id => $rule) {
|
||||
foreach ($services as $id => $condition) {
|
||||
$couponManager->addMethodCall(
|
||||
'addAvailableRule',
|
||||
'addAvailableCondition',
|
||||
array(
|
||||
new Reference($id)
|
||||
)
|
||||
120
core/lib/Thelia/Core/Event/Administrator/AdministratorEvent.php
Normal file
120
core/lib/Thelia/Core/Event/Administrator/AdministratorEvent.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\Administrator;
|
||||
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
use Thelia\Model\Admin;
|
||||
|
||||
class AdministratorEvent extends ActionEvent
|
||||
{
|
||||
protected $administrator = null;
|
||||
protected $id = null;
|
||||
protected $firstname = null;
|
||||
protected $lastname = null;
|
||||
protected $login = null;
|
||||
protected $password = null;
|
||||
protected $profile = null;
|
||||
|
||||
public function __construct(Admin $administrator = null)
|
||||
{
|
||||
$this->administrator = $administrator;
|
||||
}
|
||||
|
||||
public function hasAdministrator()
|
||||
{
|
||||
return ! is_null($this->administrator);
|
||||
}
|
||||
|
||||
public function getAdministrator()
|
||||
{
|
||||
return $this->administrator;
|
||||
}
|
||||
|
||||
public function setAdministrator(Admin $administrator)
|
||||
{
|
||||
$this->administrator = $administrator;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setId($id)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setFirstname($firstname)
|
||||
{
|
||||
$this->firstname = $firstname;
|
||||
}
|
||||
|
||||
public function getFirstname()
|
||||
{
|
||||
return $this->firstname;
|
||||
}
|
||||
|
||||
public function setLastname($lastname)
|
||||
{
|
||||
$this->lastname = $lastname;
|
||||
}
|
||||
|
||||
public function getLastname()
|
||||
{
|
||||
return $this->lastname;
|
||||
}
|
||||
|
||||
public function setLogin($login)
|
||||
{
|
||||
$this->login = $login;
|
||||
}
|
||||
|
||||
public function getLogin()
|
||||
{
|
||||
return $this->login;
|
||||
}
|
||||
|
||||
public function setPassword($password)
|
||||
{
|
||||
$this->password = $password;
|
||||
}
|
||||
|
||||
public function getPassword()
|
||||
{
|
||||
return $this->password;
|
||||
}
|
||||
|
||||
public function setProfile($profile)
|
||||
{
|
||||
$this->profile = $profile;
|
||||
}
|
||||
|
||||
public function getProfile()
|
||||
{
|
||||
return $this->profile;
|
||||
}
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
<?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\Condition;
|
||||
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
use Thelia\Coupon\ConditionCollection;
|
||||
use Thelia\Coupon\Type\CouponInterface;
|
||||
|
||||
/**
|
||||
* Created by JetBrains PhpStorm.
|
||||
* Date: 8/29/13
|
||||
* Time: 3:45 PM
|
||||
*
|
||||
* Occurring when a Condition is created or updated
|
||||
*
|
||||
* @package Coupon
|
||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
class ConditionCreateOrUpdateEvent extends ActionEvent
|
||||
{
|
||||
/** @var ConditionCollection Array of ConditionManagerInterface */
|
||||
protected $conditions = null;
|
||||
|
||||
/** @var CouponInterface Coupon model associated with this conditions */
|
||||
protected $couponModel = null;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param ConditionCollection $conditions Array of ConditionManagerInterface
|
||||
*/
|
||||
public function __construct(ConditionCollection $conditions)
|
||||
{
|
||||
$this->conditions = $conditions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Conditions
|
||||
*
|
||||
* @return null|ConditionCollection Array of ConditionManagerInterface
|
||||
*/
|
||||
public function getConditions()
|
||||
{
|
||||
return $this->conditions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Conditions
|
||||
*
|
||||
* @param ConditionCollection $conditions Array of ConditionManagerInterface
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setConditions(ConditionCollection $conditions)
|
||||
{
|
||||
$this->conditions = $conditions;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set Coupon Model associated to this condition
|
||||
*
|
||||
* @param CouponInterface $couponModel Coupon Model
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCouponModel($couponModel)
|
||||
{
|
||||
$this->couponModel = $couponModel;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Coupon Model associated to this condition
|
||||
*
|
||||
* @return null|CouponInterface
|
||||
*/
|
||||
public function getCouponModel()
|
||||
{
|
||||
return $this->couponModel;
|
||||
}
|
||||
}
|
||||
@@ -31,7 +31,7 @@ use Thelia\Model\Coupon;
|
||||
* Date: 8/29/13
|
||||
* Time: 3:45 PM
|
||||
*
|
||||
* Occurring when a Coupon is created
|
||||
* Occurring when a Coupon is created or updated
|
||||
*
|
||||
* @package Coupon
|
||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||
@@ -76,10 +76,10 @@ class CouponCreateOrUpdateEvent extends ActionEvent
|
||||
protected $isAvailableOnSpecialOffers = false;
|
||||
|
||||
/** @var Coupon Coupon model */
|
||||
protected $coupon = null;
|
||||
protected $couponModel = null;
|
||||
|
||||
/** @var string Coupon type */
|
||||
protected $type;
|
||||
/** @var string Coupon Service id */
|
||||
protected $serviceId;
|
||||
|
||||
/** @var string Language code ISO (ex: fr_FR) */
|
||||
protected $locale = null;
|
||||
@@ -90,7 +90,7 @@ class CouponCreateOrUpdateEvent extends ActionEvent
|
||||
* @param string $code Coupon Code
|
||||
* @param string $title Coupon title
|
||||
* @param float $amount Amount removed from the Total Checkout
|
||||
* @param string $type Coupon type
|
||||
* @param string $serviceId Coupon Service id
|
||||
* @param string $shortDescription Coupon short description
|
||||
* @param string $description Coupon description
|
||||
* @param bool $isEnabled Enable/Disable
|
||||
@@ -102,7 +102,7 @@ class CouponCreateOrUpdateEvent extends ActionEvent
|
||||
* @param string $locale Coupon Language code ISO (ex: fr_FR)
|
||||
*/
|
||||
public function __construct(
|
||||
$code, $title, $amount, $type, $shortDescription, $description, $isEnabled, \DateTime $expirationDate, $isAvailableOnSpecialOffers, $isCumulative, $isRemovingPostage, $maxUsage, $locale
|
||||
$code, $title, $amount, $serviceId, $shortDescription, $description, $isEnabled, \DateTime $expirationDate, $isAvailableOnSpecialOffers, $isCumulative, $isRemovingPostage, $maxUsage, $locale
|
||||
)
|
||||
{
|
||||
$this->amount = $amount;
|
||||
@@ -116,7 +116,7 @@ class CouponCreateOrUpdateEvent extends ActionEvent
|
||||
$this->maxUsage = $maxUsage;
|
||||
$this->shortDescription = $shortDescription;
|
||||
$this->title = $title;
|
||||
$this->type = $type;
|
||||
$this->serviceId = $serviceId;
|
||||
$this->locale = $locale;
|
||||
}
|
||||
|
||||
@@ -234,13 +234,13 @@ class CouponCreateOrUpdateEvent extends ActionEvent
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Coupon type (effect)
|
||||
* Get Coupon Service id (Type)
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getType()
|
||||
public function getServiceId()
|
||||
{
|
||||
return $this->type;
|
||||
return $this->serviceId;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -256,13 +256,13 @@ class CouponCreateOrUpdateEvent extends ActionEvent
|
||||
/**
|
||||
* Set Coupon Model
|
||||
*
|
||||
* @param \Thelia\Model\Coupon $coupon Coupon Model
|
||||
* @param Coupon $couponModel Coupon Model
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCoupon($coupon)
|
||||
public function setCouponModel(Coupon $couponModel)
|
||||
{
|
||||
$this->coupon = $coupon;
|
||||
$this->couponModel = $couponModel;
|
||||
|
||||
return $this;
|
||||
}
|
||||
@@ -272,13 +272,13 @@ class CouponCreateOrUpdateEvent extends ActionEvent
|
||||
*
|
||||
* @return \Thelia\Model\Coupon
|
||||
*/
|
||||
public function getCoupon()
|
||||
public function getCouponModel()
|
||||
{
|
||||
return $this->coupon;
|
||||
return $this->couponModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Rules
|
||||
* Get Conditions
|
||||
*
|
||||
* @return null|ConditionCollection Array of ConditionManagerInterface
|
||||
*/
|
||||
@@ -288,15 +288,15 @@ class CouponCreateOrUpdateEvent extends ActionEvent
|
||||
}
|
||||
|
||||
/**
|
||||
* set Rules
|
||||
* Set Conditions
|
||||
*
|
||||
* @param ConditionCollection $rules Array of ConditionManagerInterface
|
||||
* @param ConditionCollection $conditions Array of ConditionManagerInterface
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setConditions(ConditionCollection $rules)
|
||||
public function setConditions(ConditionCollection $conditions)
|
||||
{
|
||||
$this->conditions = $rules;
|
||||
$this->conditions = $conditions;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
141
core/lib/Thelia/Core/Event/Lang/LangCreateEvent.php
Normal file
141
core/lib/Thelia/Core/Event/Lang/LangCreateEvent.php
Normal file
@@ -0,0 +1,141 @@
|
||||
<?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\Lang;
|
||||
|
||||
|
||||
/**
|
||||
* Class LangCreateEvent
|
||||
* @package Thelia\Core\Event\Lang
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class LangCreateEvent extends LangEvent
|
||||
{
|
||||
protected $title;
|
||||
protected $code;
|
||||
protected $locale;
|
||||
protected $date_format;
|
||||
protected $time_format;
|
||||
|
||||
/**
|
||||
* @param mixed $code
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setCode($code)
|
||||
{
|
||||
$this->code = $code;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getCode()
|
||||
{
|
||||
return $this->code;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $date_format
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setDateFormat($date_format)
|
||||
{
|
||||
$this->date_format = $date_format;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getDateFormat()
|
||||
{
|
||||
return $this->date_format;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $locale
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setLocale($locale)
|
||||
{
|
||||
$this->locale = $locale;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getLocale()
|
||||
{
|
||||
return $this->locale;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $time_format
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setTimeFormat($time_format)
|
||||
{
|
||||
$this->time_format = $time_format;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getTimeFormat()
|
||||
{
|
||||
return $this->time_format;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $title
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setTitle($title)
|
||||
{
|
||||
$this->title = $title;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return mixed
|
||||
*/
|
||||
public function getTitle()
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
64
core/lib/Thelia/Core/Event/Lang/LangDefaultBehaviorEvent.php
Normal file
64
core/lib/Thelia/Core/Event/Lang/LangDefaultBehaviorEvent.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\Lang;
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
|
||||
|
||||
/**
|
||||
* Class LangDefaultBehaviorEvent
|
||||
* @package Thelia\Core\Event\Lang
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class LangDefaultBehaviorEvent extends ActionEvent
|
||||
{
|
||||
/**
|
||||
* @var int default behavior status
|
||||
*/
|
||||
protected $defaultBehavior;
|
||||
|
||||
function __construct($defaultBehavior)
|
||||
{
|
||||
$this->defaultBehavior = $defaultBehavior;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $defaultBehavior
|
||||
*/
|
||||
public function setDefaultBehavior($defaultBehavior)
|
||||
{
|
||||
$this->defaultBehavior = $defaultBehavior;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getDefaultBehavior()
|
||||
{
|
||||
return $this->defaultBehavior;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
67
core/lib/Thelia/Core/Event/Lang/LangDeleteEvent.php
Normal file
67
core/lib/Thelia/Core/Event/Lang/LangDeleteEvent.php
Normal file
@@ -0,0 +1,67 @@
|
||||
<?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\Lang;
|
||||
|
||||
|
||||
/**
|
||||
* Class LangDeleteEvent
|
||||
* @package Thelia\Core\Event\Lang
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class LangDeleteEvent extends LangEvent
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $lang_id;
|
||||
|
||||
/**
|
||||
* @param int $lang_id
|
||||
*/
|
||||
function __construct($lang_id)
|
||||
{
|
||||
$this->lang_id = $lang_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $lang_id
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setLangId($lang_id)
|
||||
{
|
||||
$this->lang_id = $lang_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getLangId()
|
||||
{
|
||||
return $this->lang_id;
|
||||
}
|
||||
|
||||
}
|
||||
76
core/lib/Thelia/Core/Event/Lang/LangEvent.php
Normal file
76
core/lib/Thelia/Core/Event/Lang/LangEvent.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?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\Lang;
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
use Thelia\Model\Lang;
|
||||
|
||||
|
||||
/**
|
||||
* Class LangEvent
|
||||
* @package Thelia\Core\Event\Lang
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class LangEvent extends ActionEvent
|
||||
{
|
||||
/**
|
||||
* @var \Thelia\Model\Lang
|
||||
*/
|
||||
protected $lang;
|
||||
|
||||
function __construct(Lang $lang = null)
|
||||
{
|
||||
$this->lang = $lang;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param \Thelia\Model\Lang $lang
|
||||
*/
|
||||
public function setLang(Lang $lang)
|
||||
{
|
||||
$this->lang = $lang;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \Thelia\Model\Lang
|
||||
*/
|
||||
public function getLang()
|
||||
{
|
||||
return $this->lang;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* check if lang object is present
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasLang()
|
||||
{
|
||||
return null !== $this->lang;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
69
core/lib/Thelia/Core/Event/Lang/LangToggleDefaultEvent.php
Normal file
69
core/lib/Thelia/Core/Event/Lang/LangToggleDefaultEvent.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?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\Lang;
|
||||
|
||||
|
||||
/**
|
||||
* Class LangToggleDefaultEvent
|
||||
* @package Thelia\Core\Event\Lang
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class LangToggleDefaultEvent extends LangEvent
|
||||
{
|
||||
/**
|
||||
* @var int
|
||||
*/
|
||||
protected $lang_id;
|
||||
|
||||
/**
|
||||
* @param int $lang_id
|
||||
*/
|
||||
function __construct($lang_id)
|
||||
{
|
||||
$this->lang_id = $lang_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $lang_id
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setLangId($lang_id)
|
||||
{
|
||||
$this->lang_id = $lang_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getLangId()
|
||||
{
|
||||
return $this->lang_id;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
69
core/lib/Thelia/Core/Event/Lang/LangUpdateEvent.php
Normal file
69
core/lib/Thelia/Core/Event/Lang/LangUpdateEvent.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?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\Lang;
|
||||
|
||||
|
||||
/**
|
||||
* Class LangUpdateEvent
|
||||
* @package Thelia\Core\Event\Lang
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class LangUpdateEvent extends LangCreateEvent
|
||||
{
|
||||
/**
|
||||
* @var int lang id
|
||||
*/
|
||||
protected $id;
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
*/
|
||||
function __construct($id)
|
||||
{
|
||||
$this->id = $id;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param int $id
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setId($id)
|
||||
{
|
||||
$this->id = $id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -21,21 +21,24 @@
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event\Product;
|
||||
namespace Thelia\Core\Event\ProductSaleElement;
|
||||
|
||||
use Thelia\Model\Product;
|
||||
use Thelia\Core\Event\Product\ProductEvent;
|
||||
|
||||
class ProductCreateCombinationEvent extends ProductEvent
|
||||
class ProductSaleElementCreateEvent extends ProductSaleElementEvent
|
||||
{
|
||||
protected $product;
|
||||
protected $attribute_av_list;
|
||||
protected $currency_id;
|
||||
|
||||
public function __construct(Product $product, $attribute_av_list, $currency_id)
|
||||
{
|
||||
parent::__construct($product);
|
||||
parent::__construct();
|
||||
|
||||
$this->attribute_av_list = $attribute_av_list;
|
||||
$this->currency_id = $currency_id;
|
||||
$this->setAttributeAvList($attribute_av_list);
|
||||
$this->setCurrencyId($currency_id);
|
||||
$this->setProduct($product);
|
||||
}
|
||||
|
||||
public function getAttributeAvList()
|
||||
@@ -62,4 +65,15 @@ class ProductCreateCombinationEvent extends ProductEvent
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getProduct() {
|
||||
return $this->product;
|
||||
}
|
||||
|
||||
public function setProduct($product) {
|
||||
$this->product = $product;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -21,19 +21,21 @@
|
||||
/* */
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Core\Event\Product;
|
||||
|
||||
namespace Thelia\Core\Event\ProductSaleElement;
|
||||
use Thelia\Model\Product;
|
||||
use Thelia\Core\Event\Product\ProductEvent;
|
||||
|
||||
class ProductDeleteCombinationEvent extends ProductEvent
|
||||
class ProductSaleElementDeleteEvent extends ProductSaleElementEvent
|
||||
{
|
||||
protected $product_sale_element_id;
|
||||
protected $currency_id;
|
||||
|
||||
public function __construct(Product $product, $product_sale_element_id)
|
||||
public function __construct($product_sale_element_id, $currency_id)
|
||||
{
|
||||
parent::__construct($product);
|
||||
parent::__construct();
|
||||
|
||||
$this->product_sale_element_id = $product_sale_element_id;
|
||||
$this->setCurrencyId($currency_id);
|
||||
}
|
||||
|
||||
public function getProductSaleElementId()
|
||||
@@ -44,5 +46,19 @@ class ProductDeleteCombinationEvent extends ProductEvent
|
||||
public function setProductSaleElementId($product_sale_element_id)
|
||||
{
|
||||
$this->product_sale_element_id = $product_sale_element_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCurrencyId()
|
||||
{
|
||||
return $this->currency_id;
|
||||
}
|
||||
|
||||
public function setCurrencyId($currency_id)
|
||||
{
|
||||
$this->currency_id = $currency_id;
|
||||
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\ProductSaleElement;
|
||||
|
||||
use Thelia\Model\ProductSaleElement;
|
||||
use Thelia\Core\Event\ActionEvent;
|
||||
|
||||
class ProductSaleElementEvent extends ActionEvent
|
||||
{
|
||||
public $product_sale_element = null;
|
||||
|
||||
public function __construct(ProductSaleElement $product_sale_element = null)
|
||||
{
|
||||
$this->product_sale_element = $product_sale_element;
|
||||
}
|
||||
|
||||
public function hasProductSaleElement()
|
||||
{
|
||||
return ! is_null($this->product_sale_element);
|
||||
}
|
||||
|
||||
public function getProductSaleElement()
|
||||
{
|
||||
return $this->product_sale_element;
|
||||
}
|
||||
|
||||
public function setProductSaleElement(ProductSaleElement $product_sale_element)
|
||||
{
|
||||
$this->product_sale_element = $product_sale_element;
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,211 @@
|
||||
<?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\ProductSaleElement;
|
||||
use Thelia\Core\Event\Product\ProductCreateEvent;
|
||||
use Thelia\Model\Product;
|
||||
use Thelia\Core\Event\Product\ProductEvent;
|
||||
|
||||
class ProductSaleElementUpdateEvent extends ProductSaleElementEvent
|
||||
{
|
||||
protected $product_sale_element_id;
|
||||
|
||||
protected $product;
|
||||
protected $reference;
|
||||
protected $price;
|
||||
protected $currency_id;
|
||||
protected $weight;
|
||||
protected $quantity;
|
||||
protected $sale_price;
|
||||
protected $onsale;
|
||||
protected $isnew;
|
||||
protected $isdefault;
|
||||
protected $ean_code;
|
||||
protected $taxrule;
|
||||
|
||||
public function __construct(Product $product, $product_sale_element_id)
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
$this->setProduct($product);
|
||||
|
||||
$this->setProductSaleElementId($product_sale_element_id);
|
||||
}
|
||||
|
||||
public function getProductSaleElementId()
|
||||
{
|
||||
return $this->product_sale_element_id;
|
||||
}
|
||||
|
||||
public function setProductSaleElementId($product_sale_element_id)
|
||||
{
|
||||
$this->product_sale_element_id = $product_sale_element_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getPrice()
|
||||
{
|
||||
return $this->price;
|
||||
}
|
||||
|
||||
public function setPrice($price)
|
||||
{
|
||||
$this->price = $price;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getCurrencyId()
|
||||
{
|
||||
return $this->currency_id;
|
||||
}
|
||||
|
||||
public function setCurrencyId($currency_id)
|
||||
{
|
||||
$this->currency_id = $currency_id;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getWeight()
|
||||
{
|
||||
return $this->weight;
|
||||
}
|
||||
|
||||
public function setWeight($weight)
|
||||
{
|
||||
$this->weight = $weight;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getQuantity()
|
||||
{
|
||||
return $this->quantity;
|
||||
}
|
||||
|
||||
public function setQuantity($quantity)
|
||||
{
|
||||
$this->quantity = $quantity;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getSalePrice()
|
||||
{
|
||||
return $this->sale_price;
|
||||
}
|
||||
|
||||
public function setSalePrice($sale_price)
|
||||
{
|
||||
$this->sale_price = $sale_price;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getOnsale()
|
||||
{
|
||||
return $this->onsale;
|
||||
}
|
||||
|
||||
public function setOnsale($onsale)
|
||||
{
|
||||
$this->onsale = $onsale;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getIsnew()
|
||||
{
|
||||
return $this->isnew;
|
||||
}
|
||||
|
||||
public function setIsnew($isnew)
|
||||
{
|
||||
$this->isnew = $isnew;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getEanCode()
|
||||
{
|
||||
return $this->ean_code;
|
||||
}
|
||||
|
||||
public function setEanCode($ean_code)
|
||||
{
|
||||
$this->ean_code = $ean_code;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getIsdefault()
|
||||
{
|
||||
return $this->isdefault;
|
||||
}
|
||||
|
||||
public function setIsdefault($isdefault)
|
||||
{
|
||||
$this->isdefault = $isdefault;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getReference()
|
||||
{
|
||||
return $this->reference;
|
||||
}
|
||||
|
||||
public function setReference($reference)
|
||||
{
|
||||
$this->reference = $reference;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getProduct()
|
||||
{
|
||||
return $this->product;
|
||||
}
|
||||
|
||||
public function setProduct($product)
|
||||
{
|
||||
$this->product = $product;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getTaxrule()
|
||||
{
|
||||
return $this->taxrule;
|
||||
}
|
||||
|
||||
public function setTaxrule($taxrule)
|
||||
{
|
||||
$this->taxrule = $taxrule;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -36,6 +36,8 @@ class ProfileEvent extends ActionEvent
|
||||
protected $chapo = null;
|
||||
protected $description = null;
|
||||
protected $postscriptum = null;
|
||||
protected $resourceAccess = null;
|
||||
protected $moduleAccess = null;
|
||||
|
||||
public function __construct(Profile $profile = null)
|
||||
{
|
||||
@@ -128,4 +130,24 @@ class ProfileEvent extends ActionEvent
|
||||
{
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
public function setResourceAccess($resourceAccess)
|
||||
{
|
||||
$this->resourceAccess = $resourceAccess;
|
||||
}
|
||||
|
||||
public function getResourceAccess()
|
||||
{
|
||||
return $this->resourceAccess;
|
||||
}
|
||||
|
||||
public function setModuleAccess($moduleAccess)
|
||||
{
|
||||
$this->moduleAccess = $moduleAccess;
|
||||
}
|
||||
|
||||
public function getModuleAccess()
|
||||
{
|
||||
return $this->moduleAccess;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -260,14 +260,14 @@ final class TheliaEvents
|
||||
|
||||
// -- Categories Associated Content ----------------------------------------
|
||||
|
||||
const BEFORE_CREATECATEGORY_ASSOCIATED_CONTENT = "action.before_createCategoryAssociatedContent";
|
||||
const AFTER_CREATECATEGORY_ASSOCIATED_CONTENT = "action.after_createCategoryAssociatedContent";
|
||||
const BEFORE_CREATECATEGORY_ASSOCIATED_CONTENT = "action.before_createCategoryAssociatedContent";
|
||||
const AFTER_CREATECATEGORY_ASSOCIATED_CONTENT = "action.after_createCategoryAssociatedContent";
|
||||
|
||||
const BEFORE_DELETECATEGORY_ASSOCIATED_CONTENT = "action.before_deleteCategoryAssociatedContent";
|
||||
const AFTER_DELETECATEGORY_ASSOCIATED_CONTENT = "action.after_deleteCategoryAssociatedContent";
|
||||
const BEFORE_DELETECATEGORY_ASSOCIATED_CONTENT = "action.before_deleteCategoryAssociatedContent";
|
||||
const AFTER_DELETECATEGORY_ASSOCIATED_CONTENT = "action.after_deleteCategoryAssociatedContent";
|
||||
|
||||
const BEFORE_UPDATECATEGORY_ASSOCIATED_CONTENT = "action.before_updateCategoryAssociatedContent";
|
||||
const AFTER_UPDATECATEGORY_ASSOCIATED_CONTENT = "action.after_updateCategoryAssociatedContent";
|
||||
const BEFORE_UPDATECATEGORY_ASSOCIATED_CONTENT = "action.before_updateCategoryAssociatedContent";
|
||||
const AFTER_UPDATECATEGORY_ASSOCIATED_CONTENT = "action.after_updateCategoryAssociatedContent";
|
||||
|
||||
// -- Product management -----------------------------------------------
|
||||
|
||||
@@ -281,8 +281,9 @@ final class TheliaEvents
|
||||
const PRODUCT_REMOVE_CONTENT = "action.productRemoveContent";
|
||||
const PRODUCT_UPDATE_CONTENT_POSITION = "action.updateProductContentPosition";
|
||||
|
||||
const PRODUCT_ADD_COMBINATION = "action.productAddCombination";
|
||||
const PRODUCT_DELETE_COMBINATION = "action.productDeleteCombination";
|
||||
const PRODUCT_ADD_PRODUCT_SALE_ELEMENT = "action.addProductSaleElement";
|
||||
const PRODUCT_DELETE_PRODUCT_SALE_ELEMENT = "action.deleteProductSaleElement";
|
||||
const PRODUCT_UPDATE_PRODUCT_SALE_ELEMENT = "action.updateProductSaleElement";
|
||||
|
||||
const PRODUCT_SET_TEMPLATE = "action.productSetTemplate";
|
||||
|
||||
@@ -362,8 +363,8 @@ final class TheliaEvents
|
||||
* sent on modify article action
|
||||
*/
|
||||
const CART_UPDATEITEM = "action.updateArticle";
|
||||
|
||||
const CART_DELETEITEM = "action.deleteArticle";
|
||||
const CART_CLEAR = "action.clear";
|
||||
|
||||
/**
|
||||
* Order linked event
|
||||
@@ -554,9 +555,17 @@ final class TheliaEvents
|
||||
|
||||
// -- Profile management ---------------------------------------------
|
||||
|
||||
const PROFILE_CREATE = "action.createProfile";
|
||||
const PROFILE_UPDATE = "action.updateProfile";
|
||||
const PROFILE_DELETE = "action.deleteProfile";
|
||||
const PROFILE_CREATE = "action.createProfile";
|
||||
const PROFILE_UPDATE = "action.updateProfile";
|
||||
const PROFILE_DELETE = "action.deleteProfile";
|
||||
const PROFILE_RESOURCE_ACCESS_UPDATE = "action.updateProfileResourceAccess";
|
||||
const PROFILE_MODULE_ACCESS_UPDATE = "action.updateProfileModuleAccess";
|
||||
|
||||
// -- Administrator management ---------------------------------------------
|
||||
|
||||
const ADMINISTRATOR_CREATE = "action.createAdministrator";
|
||||
const ADMINISTRATOR_UPDATE = "action.updateAdministrator";
|
||||
const ADMINISTRATOR_DELETE = "action.deleteAdministrator";
|
||||
|
||||
// -- Tax Rules management ---------------------------------------------
|
||||
|
||||
@@ -693,4 +702,24 @@ final class TheliaEvents
|
||||
const NEWSLETTER_SUBSCRIBE = 'thelia.newsletter.subscribe';
|
||||
const NEWSLETTER_UPDATE = 'thelia.newsletter.update';
|
||||
const NEWSLETTER_UNSUBSCRIBE = 'thelia.newsletter.unsubscribe';
|
||||
|
||||
/************ LANG MANAGEMENT ****************************/
|
||||
|
||||
const LANG_UPDATE = 'action.lang.update';
|
||||
const LANG_CREATE = 'action.lang.create';
|
||||
const LANG_DELETE = 'action.lang.delete';
|
||||
|
||||
const LANG_DEFAULTBEHAVIOR = 'action.lang.defaultBehavior';
|
||||
const LANG_URL = 'action.lang.url';
|
||||
|
||||
const LANG_TOGGLEDEFAULT = 'action.lang.toggleDefault';
|
||||
|
||||
const BEFORE_UPDATELANG = 'action.lang.beforeUpdate';
|
||||
const AFTER_UPDATELANG = 'action.lang.afterUpdate';
|
||||
|
||||
const BEFORE_CREATELANG = 'action.lang.beforeCreate';
|
||||
const AFTER_CREATELANG = 'action.lang.afterCreate';
|
||||
|
||||
const BEFORE_DELETELANG = 'action.lang.beforeDelete';
|
||||
const AFTER_DELETELANG = 'action.lang.afterDelete';
|
||||
}
|
||||
|
||||
@@ -70,6 +70,13 @@ class Session extends BaseSession
|
||||
$this->set("thelia.current.currency", $currency);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return current currency
|
||||
*
|
||||
* @param bool $forceDefault If default currency forced
|
||||
*
|
||||
* @return Currency
|
||||
*/
|
||||
public function getCurrency($forceDefault = true)
|
||||
{
|
||||
$currency = $this->get("thelia.current.currency");
|
||||
|
||||
@@ -49,7 +49,7 @@ class AccessManager
|
||||
self::DELETE => false,
|
||||
);
|
||||
|
||||
protected $accessPows = array(
|
||||
static protected $accessPows = array(
|
||||
self::VIEW => 3,
|
||||
self::CREATE => 2,
|
||||
self::UPDATE => 1,
|
||||
@@ -62,14 +62,7 @@ class AccessManager
|
||||
{
|
||||
$this->accessValue = $accessValue;
|
||||
|
||||
foreach($this->accessPows as $type => $value) {
|
||||
if($accessValue >= $value) {
|
||||
$accessValue -= $value;
|
||||
$this->accessGranted[$type] = true;
|
||||
} else {
|
||||
$this->accessGranted[$type] = false;
|
||||
}
|
||||
}
|
||||
$this->fillGrantedAccess();
|
||||
}
|
||||
|
||||
public function can($type)
|
||||
@@ -81,4 +74,41 @@ class AccessManager
|
||||
return $this->accessGranted[$type];
|
||||
|
||||
}
|
||||
|
||||
static public function getMaxAccessValue()
|
||||
{
|
||||
return pow(2, current(array_slice( self::$accessPows, -1, 1, true ))) - 1;
|
||||
}
|
||||
|
||||
public function build($accesses)
|
||||
{
|
||||
$this->accessValue = 0;
|
||||
foreach($accesses as $access) {
|
||||
if(array_key_exists($access, self::$accessPows)) {
|
||||
$this->accessValue += pow(2, self::$accessPows[$access]);
|
||||
}
|
||||
}
|
||||
|
||||
$this->fillGrantedAccess();
|
||||
}
|
||||
|
||||
protected function fillGrantedAccess()
|
||||
{
|
||||
$accessValue = $this->accessValue;
|
||||
foreach(self::$accessPows as $type => $value) {
|
||||
$pow = pow(2, $value);
|
||||
if($accessValue >= $pow) {
|
||||
$accessValue -= $pow;
|
||||
$this->accessGranted[$type] = true;
|
||||
} else {
|
||||
$this->accessGranted[$type] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function getAccessValue()
|
||||
{
|
||||
return $this->accessValue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,16 +37,16 @@ final class AdminResources
|
||||
|
||||
static public function retrieve($name)
|
||||
{
|
||||
$contantName = strtoupper($name);
|
||||
$constantName = strtoupper($name);
|
||||
|
||||
if(null === self::$selfReflection) {
|
||||
self::$selfReflection = new \ReflectionClass(__CLASS__);
|
||||
}
|
||||
|
||||
if(self::$selfReflection->hasConstant($contantName)) {
|
||||
return self::$selfReflection->getConstant($contantName);
|
||||
if(self::$selfReflection->hasConstant($constantName)) {
|
||||
return self::$selfReflection->getConstant($constantName);
|
||||
} else {
|
||||
throw new ResourceException(sprintf('Resource `%s` not found', $contantName), ResourceException::RESOURCE_NOT_FOUND);
|
||||
throw new ResourceException(sprintf('Resource `%s` not found', $constantName), ResourceException::RESOURCE_NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ final class AdminResources
|
||||
|
||||
const ADDRESS = "admin.address";
|
||||
|
||||
const ADMIN = "admin.configuration.admin";
|
||||
const ADMINISTRATOR = "admin.configuration.administrator";
|
||||
|
||||
const AREA = "admin.configuration.area";
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ namespace Thelia\Core\Template\Loop;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
use Thelia\Core\Template\Element\BaseLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
|
||||
@@ -44,7 +45,7 @@ use Thelia\Type\BooleanOrBothType;
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class Admin extends BaseI18nLoop
|
||||
class Admin extends BaseLoop
|
||||
{
|
||||
public $timestampable = true;
|
||||
|
||||
@@ -83,17 +84,17 @@ class Admin extends BaseI18nLoop
|
||||
$search->orderByFirstname(Criteria::ASC);
|
||||
|
||||
/* perform search */
|
||||
$features = $this->search($search, $pagination);
|
||||
$admins = $this->search($search, $pagination);
|
||||
|
||||
$loopResult = new LoopResult($features);
|
||||
$loopResult = new LoopResult($admins);
|
||||
|
||||
foreach ($features as $feature) {
|
||||
$loopResultRow = new LoopResultRow($loopResult, $feature, $this->versionable, $this->timestampable, $this->countable);
|
||||
$loopResultRow->set("ID", $feature->getId())
|
||||
->set("PROFILE",$feature->getProfileId())
|
||||
->set("FIRSTNAME",$feature->getFirstname())
|
||||
->set("LASTNAME",$feature->getLastname())
|
||||
->set("LOGIN",$feature->getLogin())
|
||||
foreach ($admins as $admin) {
|
||||
$loopResultRow = new LoopResultRow($loopResult, $admin, $this->versionable, $this->timestampable, $this->countable);
|
||||
$loopResultRow->set("ID", $admin->getId())
|
||||
->set("PROFILE",$admin->getProfileId())
|
||||
->set("FIRSTNAME",$admin->getFirstname())
|
||||
->set("LASTNAME",$admin->getLastname())
|
||||
->set("LOGIN",$admin->getLogin())
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
namespace Thelia\Core\Template\Loop;
|
||||
|
||||
use Thelia\Core\Security\AccessManager;
|
||||
use Thelia\Core\Template\Element\BaseLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
@@ -45,7 +46,7 @@ class Auth extends BaseLoop
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
new Argument(
|
||||
'roles',
|
||||
'role',
|
||||
new TypeCollection(
|
||||
new AlphaNumStringListType()
|
||||
),
|
||||
@@ -61,7 +62,7 @@ class Auth extends BaseLoop
|
||||
new Argument(
|
||||
'access',
|
||||
new TypeCollection(
|
||||
new EnumListType(array("view", "create", "update", "delete"))
|
||||
new EnumListType(array(AccessManager::VIEW, AccessManager::CREATE, AccessManager::UPDATE, AccessManager::DELETE))
|
||||
)
|
||||
),
|
||||
Argument::createAnyTypeArgument('context', 'front', false)
|
||||
@@ -75,7 +76,7 @@ class Auth extends BaseLoop
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
{
|
||||
$roles = $this->getRoles();
|
||||
$roles = $this->getRole();
|
||||
$resource = $this->getResource();
|
||||
$access = $this->getAccess();
|
||||
|
||||
|
||||
@@ -113,13 +113,13 @@ class Country extends BaseI18nLoop
|
||||
->set("CHAPO", $country->getVirtualColumn('i18n_CHAPO'))
|
||||
->set("DESCRIPTION", $country->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set("POSTSCRIPTUM", $country->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||
->set("IS_DEFAULT", $country->getByDefault() === 1 ? "1" : "0")
|
||||
->set("ISOCODE", $country->getIsocode())
|
||||
->set("ISOALPHA2", $country->getIsoalpha2())
|
||||
->set("ISOALPHA3", $country->getIsoalpha3())
|
||||
->set('IS_DEFAULT', $country->getByDefault())
|
||||
->set("IS_DEFAULT", $country->getByDefault() ? "1" : "0")
|
||||
->set("IS_SHOP_COUNTRY", $country->getShopCountry() ? "1" : "0")
|
||||
;
|
||||
|
||||
;
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,8 @@ class Lang extends BaseLoop
|
||||
->set("LOCALE", $result->getLocale())
|
||||
->set("URL", $result->getUrl())
|
||||
->set("IS_DEFAULT", $result->getByDefault())
|
||||
->set("URL", $result->getUrl())
|
||||
->set("DATE_FORMAT", $result->getDateFormat())
|
||||
->set("TIME_FORMAT", $result->getTimeFormat())
|
||||
->set("POSITION", $result->getPosition())
|
||||
;
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
namespace Thelia\Core\Template\Loop;
|
||||
|
||||
use Propel\Runtime\ActiveQuery\Criteria;
|
||||
use Thelia\Core\Security\AccessManager;
|
||||
use Thelia\Core\Template\Element\BaseI18nLoop;
|
||||
use Thelia\Core\Template\Element\LoopResult;
|
||||
use Thelia\Core\Template\Element\LoopResultRow;
|
||||
@@ -56,6 +57,13 @@ class Module extends BaseI18nLoop
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
Argument::createIntListTypeArgument('id'),
|
||||
Argument::createIntTypeArgument('profile'),
|
||||
new Argument(
|
||||
'code',
|
||||
new Type\TypeCollection(
|
||||
new Type\AlphaNumStringListType()
|
||||
)
|
||||
),
|
||||
new Argument(
|
||||
'module_type',
|
||||
new Type\TypeCollection(
|
||||
@@ -89,6 +97,20 @@ class Module extends BaseI18nLoop
|
||||
$search->filterById($id, Criteria::IN);
|
||||
}
|
||||
|
||||
$profile = $this->getProfile();
|
||||
|
||||
if (null !== $profile) {
|
||||
$search->leftJoinProfileModule('profile_module')
|
||||
->addJoinCondition('profile_module', 'profile_module.PROFILE_ID=?', $profile, null, \PDO::PARAM_INT)
|
||||
->withColumn('profile_module.access', 'access');
|
||||
}
|
||||
|
||||
$code = $this->getCode();
|
||||
|
||||
if(null !== $code) {
|
||||
$search->filterByCode($code, Criteria::IN);
|
||||
}
|
||||
|
||||
$moduleType = $this->getModule_type();
|
||||
|
||||
if (null !== $moduleType) {
|
||||
@@ -129,6 +151,16 @@ class Module extends BaseI18nLoop
|
||||
->set("CLASS", $module->getFullNamespace())
|
||||
->set("POSITION", $module->getPosition());
|
||||
|
||||
if (null !== $profile) {
|
||||
$accessValue = $module->getVirtualColumn('access');
|
||||
$manager = new AccessManager($accessValue);
|
||||
|
||||
$loopResultRow->set("VIEWABLE", $manager->can(AccessManager::VIEW)? 1 : 0)
|
||||
->set("CREATABLE", $manager->can(AccessManager::CREATE) ? 1 : 0)
|
||||
->set("UPDATABLE", $manager->can(AccessManager::UPDATE)? 1 : 0)
|
||||
->set("DELETABLE", $manager->can(AccessManager::DELETE)? 1 : 0);
|
||||
}
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
|
||||
@@ -108,6 +108,7 @@ class OrderProduct extends BaseLoop
|
||||
->set("TAX_RULE_TITLE", $product->getTaxRuleTitle())
|
||||
->set("TAX_RULE_DESCRIPTION", $product->getTaxRuledescription())
|
||||
->set("PARENT", $product->getParent())
|
||||
->set("EAN_CODE", $product->getEanCode())
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
|
||||
@@ -177,6 +177,7 @@ class ProductSaleElements extends BaseLoop
|
||||
->set("IS_NEW" , $PSEValue->getNewness() === 1 ? 1 : 0)
|
||||
->set("IS_DEFAULT" , $PSEValue->getIsDefault() === 1 ? 1 : 0)
|
||||
->set("WEIGHT" , $PSEValue->getWeight())
|
||||
->set("EAN_CODE" , $PSEValue->getEanCode())
|
||||
->set("PRICE" , $price)
|
||||
->set("PRICE_TAX" , $taxedPrice - $price)
|
||||
->set("TAXED_PRICE" , $taxedPrice)
|
||||
|
||||
@@ -79,20 +79,20 @@ class Profile extends BaseI18nLoop
|
||||
$search->orderById(Criteria::ASC);
|
||||
|
||||
/* perform search */
|
||||
$features = $this->search($search, $pagination);
|
||||
$profiles = $this->search($search, $pagination);
|
||||
|
||||
$loopResult = new LoopResult($features);
|
||||
$loopResult = new LoopResult($profiles);
|
||||
|
||||
foreach ($features as $feature) {
|
||||
$loopResultRow = new LoopResultRow($loopResult, $feature, $this->versionable, $this->timestampable, $this->countable);
|
||||
$loopResultRow->set("ID", $feature->getId())
|
||||
->set("IS_TRANSLATED",$feature->getVirtualColumn('IS_TRANSLATED'))
|
||||
foreach ($profiles as $profile) {
|
||||
$loopResultRow = new LoopResultRow($loopResult, $profile, $this->versionable, $this->timestampable, $this->countable);
|
||||
$loopResultRow->set("ID", $profile->getId())
|
||||
->set("IS_TRANSLATED",$profile->getVirtualColumn('IS_TRANSLATED'))
|
||||
->set("LOCALE",$locale)
|
||||
->set("CODE",$feature->getCode())
|
||||
->set("TITLE",$feature->getVirtualColumn('i18n_TITLE'))
|
||||
->set("CHAPO", $feature->getVirtualColumn('i18n_CHAPO'))
|
||||
->set("DESCRIPTION", $feature->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set("POSTSCRIPTUM", $feature->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||
->set("CODE",$profile->getCode())
|
||||
->set("TITLE",$profile->getVirtualColumn('i18n_TITLE'))
|
||||
->set("CHAPO", $profile->getVirtualColumn('i18n_CHAPO'))
|
||||
->set("DESCRIPTION", $profile->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set("POSTSCRIPTUM", $profile->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||
;
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
|
||||
128
core/lib/Thelia/Core/Template/Loop/Resource.php
Executable file
128
core/lib/Thelia/Core/Template/Loop/Resource.php
Executable file
@@ -0,0 +1,128 @@
|
||||
<?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\Security\AccessManager;
|
||||
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\ResourceQuery;
|
||||
use Thelia\Type;
|
||||
use Thelia\Type\BooleanOrBothType;
|
||||
|
||||
/**
|
||||
*
|
||||
* Resource loop
|
||||
*
|
||||
*
|
||||
* Class Resource
|
||||
* @package Thelia\Core\Template\Loop
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class Resource extends BaseI18nLoop
|
||||
{
|
||||
public $timestampable = true;
|
||||
|
||||
/**
|
||||
* @return ArgumentCollection
|
||||
*/
|
||||
protected function getArgDefinitions()
|
||||
{
|
||||
return new ArgumentCollection(
|
||||
Argument::createIntTypeArgument('profile'),
|
||||
new Argument(
|
||||
'code',
|
||||
new Type\TypeCollection(
|
||||
new Type\AlphaNumStringListType()
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $pagination
|
||||
*
|
||||
* @return \Thelia\Core\Template\Element\LoopResult
|
||||
*/
|
||||
public function exec(&$pagination)
|
||||
{
|
||||
$search = ResourceQuery::create();
|
||||
|
||||
/* manage translations */
|
||||
$locale = $this->configureI18nProcessing($search);
|
||||
|
||||
$profile = $this->getProfile();
|
||||
|
||||
if (null !== $profile) {
|
||||
$search->leftJoinProfileResource('profile_resource')
|
||||
->addJoinCondition('profile_resource', 'profile_resource.PROFILE_ID=?', $profile, null, \PDO::PARAM_INT)
|
||||
->withColumn('profile_resource.access', 'access');
|
||||
}
|
||||
|
||||
$code = $this->getCode();
|
||||
|
||||
if(null !== $code) {
|
||||
$search->filterByCode($code, Criteria::IN);
|
||||
}
|
||||
|
||||
$search->orderById(Criteria::ASC);
|
||||
|
||||
/* perform search */
|
||||
$resources = $this->search($search, $pagination);
|
||||
|
||||
$loopResult = new LoopResult($resources);
|
||||
|
||||
foreach ($resources as $resource) {
|
||||
$loopResultRow = new LoopResultRow($loopResult, $resource, $this->versionable, $this->timestampable, $this->countable);
|
||||
$loopResultRow->set("ID", $resource->getId())
|
||||
->set("IS_TRANSLATED",$resource->getVirtualColumn('IS_TRANSLATED'))
|
||||
->set("LOCALE",$locale)
|
||||
->set("CODE",$resource->getCode())
|
||||
->set("TITLE",$resource->getVirtualColumn('i18n_TITLE'))
|
||||
->set("CHAPO", $resource->getVirtualColumn('i18n_CHAPO'))
|
||||
->set("DESCRIPTION", $resource->getVirtualColumn('i18n_DESCRIPTION'))
|
||||
->set("POSTSCRIPTUM", $resource->getVirtualColumn('i18n_POSTSCRIPTUM'))
|
||||
;
|
||||
|
||||
if (null !== $profile) {
|
||||
$accessValue = $resource->getVirtualColumn('access');
|
||||
$manager = new AccessManager($accessValue);
|
||||
|
||||
$loopResultRow->set("VIEWABLE", $manager->can(AccessManager::VIEW)? 1 : 0)
|
||||
->set("CREATABLE", $manager->can(AccessManager::CREATE) ? 1 : 0)
|
||||
->set("UPDATABLE", $manager->can(AccessManager::UPDATE)? 1 : 0)
|
||||
->set("DELETABLE", $manager->can(AccessManager::DELETE)? 1 : 0);
|
||||
}
|
||||
|
||||
$loopResult->addRow($loopResultRow);
|
||||
}
|
||||
|
||||
return $loopResult;
|
||||
}
|
||||
}
|
||||
@@ -22,9 +22,6 @@
|
||||
/*************************************************************************************/
|
||||
namespace Thelia\Core\Template\Smarty\Plugins;
|
||||
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
|
||||
use Symfony\Component\Form\Extension\Core\View\ChoiceView;
|
||||
use Symfony\Component\Form\FormView;
|
||||
use Thelia\Core\Form\Type\TheliaType;
|
||||
use Thelia\Form\BaseForm;
|
||||
@@ -33,6 +30,9 @@ use Symfony\Component\HttpFoundation\Request;
|
||||
use Thelia\Core\Template\Smarty\SmartyPluginDescriptor;
|
||||
use Thelia\Core\Template\Smarty\AbstractSmartyPlugin;
|
||||
use Thelia\Core\Template\ParserContext;
|
||||
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CollectionType;
|
||||
use Symfony\Component\Form\Extension\Core\View\ChoiceView;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -78,8 +78,8 @@ class Form extends AbstractSmartyPlugin
|
||||
{
|
||||
foreach ($formDefinition as $name => $className) {
|
||||
if (array_key_exists($name, $this->formDefinition)) {
|
||||
throw new \InvalidArgumentException(sprintf("%s form name already exists for %s class", $name,
|
||||
$className));
|
||||
throw new \InvalidArgumentException(
|
||||
sprintf("%s form name already exists for %s class", $name, $className));
|
||||
}
|
||||
|
||||
$this->formDefinition[$name] = $className;
|
||||
@@ -113,7 +113,8 @@ class Form extends AbstractSmartyPlugin
|
||||
|
||||
$template->assign("form_error", $instance->hasError() ? true : false);
|
||||
$template->assign("form_error_message", $instance->getErrorMessage());
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
@@ -139,7 +140,7 @@ class Form extends AbstractSmartyPlugin
|
||||
|
||||
$template->assign("error", empty($errors) ? false : true);
|
||||
|
||||
if (! empty($errors)) {
|
||||
if (!empty($errors)) {
|
||||
$this->assignFieldErrorVars($template, $errors);
|
||||
}
|
||||
|
||||
@@ -205,30 +206,37 @@ class Form extends AbstractSmartyPlugin
|
||||
$this->assignFormTypeValues($template, $formFieldConfig, $formFieldView);
|
||||
|
||||
$value = $formFieldView->vars["value"];
|
||||
/* FIXME: doesnt work. We got "This form should not contain extra fields." error.
|
||||
// We have a collection
|
||||
if (is_array($value)) {
|
||||
|
||||
$key = $this->getParam($params, 'value_key');
|
||||
// We have a collection
|
||||
if (count($formFieldView->children) > 0) {
|
||||
|
||||
if ($key != null) {
|
||||
$key = $this->getParam($params, 'value_key');
|
||||
|
||||
if (isset($value[$key])) {
|
||||
if ($key != null) {
|
||||
|
||||
$name = sprintf("%s[%s]", $formFieldView->vars["full_name"], $key);
|
||||
$val = $value[$key];
|
||||
if (isset($value[$key])) {
|
||||
|
||||
$this->assignFieldValues($template, $name, $val, $formFieldView->vars);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$this->assignFieldValues($template, $formFieldView->vars["full_name"], $fieldVars["value"], $formFieldView->vars);
|
||||
}
|
||||
*/
|
||||
$this->assignFieldValues($template, $formFieldView->vars["full_name"], $formFieldView->vars["value"], $formFieldView->vars);
|
||||
$name = sprintf("%s[%s]", $formFieldView->vars["full_name"], $key);
|
||||
|
||||
$val = $value[$key];
|
||||
|
||||
$this->assignFieldValues($template, $name, $val, $formFieldView->vars);
|
||||
}
|
||||
else {
|
||||
throw new \LogicException(sprintf("Cannot find a value for key '%s' in field '%s'", $key, $formFieldView->vars["name"]));
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new \InvalidArgumentException(sprintf("Missing or empty parameter 'value_key' for field '%s'", $formFieldView->vars["name"]));
|
||||
}
|
||||
}
|
||||
else {
|
||||
$this->assignFieldValues($template, $formFieldView->vars["full_name"], $formFieldView->vars["value"], $formFieldView->vars);
|
||||
}
|
||||
|
||||
$formFieldView->setRendered();
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
@@ -262,7 +270,9 @@ $this->assignFieldValues($template, $formFieldView->vars["full_name"], $fieldVar
|
||||
self::$taggedFieldsStackPosition = null;
|
||||
}
|
||||
|
||||
return $content;
|
||||
if(null !== $content) {
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
|
||||
public function renderHiddenFormField($params, \Smarty_Internal_Template $template)
|
||||
@@ -298,7 +308,7 @@ $this->assignFieldValues($template, $formFieldView->vars["full_name"], $fieldVar
|
||||
$formView = $instance->getView();
|
||||
|
||||
if ($formView->vars["multipart"]) {
|
||||
return sprintf('%s="%s"',"enctype", "multipart/form-data");
|
||||
return sprintf('%s="%s"', "enctype", "multipart/form-data");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -314,7 +324,8 @@ $this->assignFieldValues($template, $formFieldView->vars["full_name"], $fieldVar
|
||||
|
||||
if ($repeat) {
|
||||
$this->assignFieldErrorVars($template, $errors);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
@@ -337,11 +348,10 @@ $this->assignFieldValues($template, $formFieldView->vars["full_name"], $fieldVar
|
||||
|
||||
$fieldName = $this->getParam($params, 'field');
|
||||
|
||||
if (null == $fieldName)
|
||||
throw new \InvalidArgumentException("'field' parameter is missing");
|
||||
if (null == $fieldName) throw new \InvalidArgumentException("'field' parameter is missing");
|
||||
|
||||
if (empty($instance->getView()[$fieldName]))
|
||||
throw new \InvalidArgumentException(sprintf("Field name '%s' not found in form %s", $fieldName, $instance->getName()));
|
||||
if (empty($instance->getView()[$fieldName])) throw new \InvalidArgumentException(
|
||||
sprintf("Field name '%s' not found in form %s", $fieldName, $instance->getName()));
|
||||
|
||||
return $instance->getView()[$fieldName];
|
||||
}
|
||||
@@ -396,8 +406,10 @@ $this->assignFieldValues($template, $formFieldView->vars["full_name"], $fieldVar
|
||||
throw new \InvalidArgumentException("Missing 'form' parameter in form arguments");
|
||||
}
|
||||
|
||||
if (! $instance instanceof \Thelia\Form\BaseForm) {
|
||||
throw new \InvalidArgumentException(sprintf("form parameter in form_field block must be an instance of
|
||||
if (!$instance instanceof \Thelia\Form\BaseForm) {
|
||||
throw new \InvalidArgumentException(
|
||||
sprintf(
|
||||
"form parameter in form_field block must be an instance of
|
||||
\Thelia\Form\BaseForm, instance of %s found", get_class($instance)));
|
||||
}
|
||||
|
||||
@@ -412,10 +424,7 @@ $this->assignFieldValues($template, $formFieldView->vars["full_name"], $fieldVar
|
||||
|
||||
$class = new \ReflectionClass($this->formDefinition[$name]);
|
||||
|
||||
return $class->newInstance(
|
||||
$this->request,
|
||||
"form"
|
||||
);
|
||||
return $class->newInstance($this->request, "form");
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -28,6 +28,7 @@ use Thelia\Core\Template\Smarty\AbstractSmartyPlugin;
|
||||
use Thelia\Core\Template\Smarty\Exception\SmartyPluginException;
|
||||
use Thelia\Core\Template\Smarty\SmartyPluginDescriptor;
|
||||
use Thelia\Tools\DateTimeFormat;
|
||||
use Thelia\Tools\NumberFormat;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -69,21 +70,20 @@ class Format extends AbstractSmartyPlugin
|
||||
*/
|
||||
public function formatDate($params, $template = null)
|
||||
{
|
||||
$date = $this->getParam($params, "date", false);
|
||||
|
||||
if (array_key_exists("date", $params) === false) {
|
||||
if ($date === false) {
|
||||
throw new SmartyPluginException("date is a mandatory parameter in format_date function");
|
||||
}
|
||||
|
||||
$date = $params["date"];
|
||||
|
||||
if (!$date instanceof \DateTime) {
|
||||
return "";
|
||||
}
|
||||
|
||||
if (array_key_exists("format", $params)) {
|
||||
$format = $params["format"];
|
||||
} else {
|
||||
$format = DateTimeFormat::getInstance($this->request)->getFormat(array_key_exists("output", $params) ? $params["output"] : null);
|
||||
$format = $this->getParam($params, "format", false);
|
||||
|
||||
if ($format === false) {
|
||||
$format = DateTimeFormat::getInstance($this->request)->getFormat($this->getParam($params, "output", null));
|
||||
}
|
||||
|
||||
return $date->format($format);
|
||||
@@ -109,23 +109,22 @@ class Format extends AbstractSmartyPlugin
|
||||
*/
|
||||
public function formatNumber($params, $template = null)
|
||||
{
|
||||
if (array_key_exists("number", $params) === false) {
|
||||
$number = $this->getParam($params, "number", false);
|
||||
|
||||
if ($number === false) {
|
||||
throw new SmartyPluginException("number is a mandatory parameter in format_number function");
|
||||
}
|
||||
|
||||
$number = $params["number"];
|
||||
|
||||
if (empty($number)) {
|
||||
if ($number == '') {
|
||||
return "";
|
||||
}
|
||||
|
||||
$lang = $this->request->getSession()->getLang();
|
||||
|
||||
$decimals = array_key_exists("decimals", $params) ? $params["decimals"] : $lang->getDecimals();
|
||||
$decPoint = array_key_exists("dec_point", $params) ? $params["dec_point"] : $lang->getDecimalSeparator();
|
||||
$thousandsSep = array_key_exists("thousands_sep", $params) ? $params["thousands_sep"] : $lang->getThousandsSeparator();
|
||||
|
||||
return number_format($number, $decimals, $decPoint, $thousandsSep);
|
||||
return NumberFormat::getInstance($this->request)->format(
|
||||
$number,
|
||||
$this->getParam($params, "decimals", null),
|
||||
$this->getParam($params, "dec_point", null),
|
||||
$this->getParam($params, "thousands_sep", null)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -96,7 +96,10 @@ class Thelia extends Kernel
|
||||
{
|
||||
parent::boot();
|
||||
|
||||
$this->getContainer()->get("event_dispatcher")->dispatch(TheliaEvents::BOOT);
|
||||
if (file_exists(THELIA_ROOT . '/local/config/database.yml') === true) {
|
||||
$this->getContainer()->get("event_dispatcher")->dispatch(TheliaEvents::BOOT);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user