Merge branch 'master' into frontend

This commit is contained in:
touffies
2013-10-22 10:17:47 +02:00
233 changed files with 8781 additions and 7561 deletions

View File

@@ -28,7 +28,6 @@ use Symfony\Component\Validator\Constraints\GreaterThan;
use Symfony\Component\Validator\Constraints\NotBlank;
use Thelia\Form\BaseForm;
/**
* Class AreaCountryForm
* @package Thelia\Form\Area
@@ -86,4 +85,4 @@ class AreaCountryForm extends BaseForm
{
return 'thelia_area_country';
}
}
}

View File

@@ -26,7 +26,6 @@ use Thelia\Core\Translation\Translator;
use Symfony\Component\Validator\Constraints\NotBlank;
use Thelia\Form\BaseForm;
/**
* Class AreaCreateForm
* @package Thelia\Form\Shipping
@@ -76,4 +75,4 @@ class AreaCreateForm extends BaseForm
{
return 'thelia_area_creation';
}
}
}

View File

@@ -25,7 +25,6 @@ namespace Thelia\Form\Area;
use Symfony\Component\Validator\Constraints\GreaterThan;
use Thelia\Form\Area\AreaCreateForm;
/**
* Class AreaModificationForm
* @package Thelia\Form\Shipping
@@ -46,4 +45,4 @@ class AreaModificationForm extends AreaCreateForm
{
return 'thelia_area_modification';
}
}
}

View File

@@ -29,7 +29,6 @@ use Symfony\Component\Validator\Constraints\NotBlank;
use Thelia\Form\BaseForm;
use Thelia\Core\Translation\Translator;
/**
* Class AreaPostageForm
* @package Thelia\Form\Area
@@ -85,4 +84,4 @@ class AreaPostageForm extends BaseForm
{
return 'thelia_area_postage';
}
}
}

View File

@@ -0,0 +1,119 @@
<?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\Form;
use Symfony\Component\Validator\Constraints\Email;
use Symfony\Component\Validator\Constraints\NotBlank;
use Thelia\Core\Translation\Translator;
/**
* Class ContactForm
* @package Thelia\Form
* @author Manuel Raynaud <mraynaud@openstudio.fr>
*/
class ContactForm extends BaseForm
{
/**
*
* in this function you add all the fields you need for your Form.
* Form this you have to call add method on $this->formBuilder attribute :
*
* $this->formBuilder->add("name", "text")
* ->add("email", "email", array(
* "attr" => array(
* "class" => "field"
* ),
* "label" => "email",
* "constraints" => array(
* new \Symfony\Component\Validator\Constraints\NotBlank()
* )
* )
* )
* ->add('age', 'integer');
*
* @return null
*/
protected function buildForm()
{
$this->formBuilder
->add('firstname', 'text', array(
'constraints' => array(
new NotBlank()
),
'label' => Translator::getInstance()->trans('firstname'),
'label_attr' => array(
'for' => 'firstname_contact'
)
))
->add('lastname', 'text', array(
'constraints' => array(
new NotBlank()
),
'label' => Translator::getInstance()->trans('lastname'),
'label_attr' => array(
'for' => 'lastname_contact'
)
))
->add('email', 'email', array(
'constraints' => array(
new NotBlank(),
new Email()
),
'label' => Translator::getInstance()->trans('email'),
'label_attr' => array(
'for' => 'email_contact'
)
))
->add('subject', 'text', array(
'constraints' => array(
new NotBlank()
),
'label' => Translator::getInstance()->trans('subject'),
'label_attr' => array(
'for' => 'subject_contact'
)
))
->add('message', 'text', array(
'constraints' => array(
new NotBlank()
),
'label' => Translator::getInstance()->trans('message'),
'label_attr' => array(
'for' => 'message_contact'
)
))
;
}
/**
* @return string the name of you form. This name must be unique
*/
public function getName()
{
return 'thelia_contact';
}
}

View File

@@ -23,8 +23,6 @@
namespace Thelia\Form;
use Symfony\Component\Validator\Constraints\GreaterThan;
use Symfony\Component\Validator\Constraints\NotBlank;
use Thelia\Core\Translation\Translator;
class CountryModificationForm extends CountryCreationForm
{

View File

@@ -0,0 +1,80 @@
<?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\Form;
use Symfony\Component\Validator\Constraints;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\ExecutionContextInterface;
use Thelia\Core\Translation\Translator;
use Thelia\Model\ProfileQuery;
/**
* Class ProfileCreationForm
* @package Thelia\Form
* @author Etienne Roudeix <eroudeix@openstudio.fr>
*/
class ProfileCreationForm extends BaseForm
{
use StandardDescriptionFieldsTrait;
protected function buildForm($change_mode = false)
{
$this->formBuilder
->add("locale", "text", array(
"constraints" => array(new NotBlank())
))
->add("code", "text", array(
"constraints" => array(
new NotBlank(),
new Constraints\Callback(
array(
"methods" => array(
array($this, "verifyCode"),
),
)
),
),
"label" => Translator::getInstance()->trans("Profile Code"),
"label_attr" => array("for" => "profile_code_fiels"),
))
;
$this->addStandardDescFields(array('locale'));
}
public function getName()
{
return "thelia_profile_creation";
}
public function verifyCode($value, ExecutionContextInterface $context)
{
/* check unicity */
$profile = ProfileQuery::create()
->findOneByCode($value);
if (null !== $profile) {
$context->addViolation("Profile `code` already exists");
}
}
}

View File

@@ -1,7 +1,7 @@
<?php
/*************************************************************************************/
/* */
/* Thelia */
/* Thelia */
/* */
/* Copyright (c) OpenStudio */
/* email : info@thelia.net */
@@ -17,102 +17,57 @@
/* 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/>. */
/* along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* */
/*************************************************************************************/
namespace Thelia\Form;
use Symfony\Component\Validator\Constraints;
use Thelia\Core\Translation\Translator;
use Thelia\Model\ConfigQuery;
use Symfony\Component\Validator\ExecutionContextInterface;
use Thelia\Model\ProfileQuery;
/**
* Class ProfileModification
* Class ProfileModificationForm
* @package Thelia\Form
* @author Manuel Raynaud <mraynaud@openstudio.fr>
* @author Etienne Roudeix <eroudeix@openstudio.fr>
*/
class ProfileModificationForm extends BaseForm
class ProfileModificationForm extends ProfileCreationForm
{
protected function buildForm()
{
parent::buildForm(true);
$this->formBuilder
->add("firstname", "text", array(
"constraints" => array(
new Constraints\NotBlank()
),
"label" => Translator::getInstance()->trans("First Name"),
"label_attr" => array(
"for" => "firstname"
)
))
->add("lastname", "text", array(
"constraints" => array(
new Constraints\NotBlank()
),
"label" => Translator::getInstance()->trans("Last Name"),
"label_attr" => array(
"for" => "lastname"
)
))
->add("default_language", "text", array(
"constraints" => array(
new Constraints\NotBlank()
),
"label" => Translator::getInstance()->trans("Default language"),
"label_attr" => array(
"for" => "default_language"
)
))
->add("editing_language_default", "text", array(
"constraints" => array(
new Constraints\NotBlank()
),
"label" => Translator::getInstance()->trans("Editing language default"),
"label_attr" => array(
"for" => "editing_language_default"
)
))
->add("old_password", "password", array(
->add("id", "hidden", array(
"required" => true,
"constraints" => array(
new Constraints\NotBlank(),
new Constraints\Length(array("min" => ConfigQuery::read("password.length", 4)))
),
"label" => Translator::getInstance()->trans("Old password"),
"label_attr" => array(
"for" => "old_password"
)
))
->add("password", "password", array(
"constraints" => array(
new Constraints\NotBlank(),
new Constraints\Length(array("min" => ConfigQuery::read("password.length", 4)))
),
"label" => Translator::getInstance()->trans("Password"),
"label_attr" => array(
"for" => "password"
)
))
->add("password_confirm", "password", array(
"constraints" => array(
new Constraints\NotBlank(),
new Constraints\Length(array("min" => ConfigQuery::read("password.length", 4))),
new Constraints\Callback(array("methods" => array(
array($this, "verifyPasswordField")
)))
),
"label" => "Password confirmation",
"label_attr" => array(
"for" => "password_confirmation"
new Constraints\Callback(
array(
"methods" => array(
array($this, "verifyProfileId"),
),
)
),
)
))
;
$this->formBuilder->remove("code");
}
public function getName()
{
return "thelia_profile_modification";
}
public function verifyProfileId($value, ExecutionContextInterface $context)
{
$profile = ProfileQuery::create()
->findPk($value);
if (null === $profile) {
$context->addViolation("Profile ID not found");
}
}
}

View File

@@ -28,7 +28,6 @@ use Symfony\Component\Validator\Constraints\GreaterThan;
use Symfony\Component\Validator\Constraints\NotBlank;
use Thelia\Form\BaseForm;
/**
* Class ShippingZoneAddArea
* @package Thelia\Form\ShippingZone
@@ -84,4 +83,4 @@ class ShippingZoneAddArea extends BaseForm
{
return 'thelia_shippingzone_area';
}
}
}

View File

@@ -23,7 +23,6 @@
namespace Thelia\Form\ShippingZone;
/**
* Class ShippingZoneRemoveArea
* @package Thelia\Form\ShippingZone
@@ -39,4 +38,4 @@ class ShippingZoneRemoveArea extends ShippingZoneAddArea
{
return 'thelia_shippingzone_remove_area';
}
}
}

View File

@@ -0,0 +1,101 @@
<?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\Form;
use Symfony\Component\Validator\Constraints;
use Symfony\Component\Validator\Constraints\NotBlank;
use Thelia\Core\Form\Type\TheliaType;
use Thelia\Core\Translation\Translator;
use Thelia\TaxEngine\TaxEngine;
use Thelia\TaxEngine\TaxType;
/**
* Class TaxCreationForm
* @package Thelia\Form
* @author Etienne Roudeix <eroudeix@openstudio.fr>
*/
class TaxCreationForm extends BaseForm
{
use StandardDescriptionFieldsTrait;
protected function buildForm($change_mode = false)
{
$types = TaxEngine::getInstance()->getTaxTypeList();
$typeList = array();
$requirementList = array();
foreach($types as $type) {
$classPath = "\\Thelia\\TaxEngine\\TaxType\\$type";
$instance = new $classPath();
$typeList[$type] = $instance->getTitle();
$requirementList[$type] = $instance->getRequirementsList();
}
$this->formBuilder
->add("locale", "text", array(
"constraints" => array(new NotBlank())
))
->add("type", "choice", array(
"choices" => $typeList,
"required" => true,
"constraints" => array(
new Constraints\NotBlank(),
),
"label" => Translator::getInstance()->trans("Type"),
"label_attr" => array("for" => "type_field"),
))
;
foreach($requirementList as $type => $requirements) {
foreach($requirements as $name => $requirementType) {
$this->formBuilder
->add($type . ':' . $name, new TheliaType(), array(
//"instance" => $requirementType,
"constraints" => array(
new Constraints\Callback(
array(
"methods" => array(
array($requirementType, "verifyForm"),
),
)
),
),
"attr" => array(
"tag" => "requirements",
"tax_type" => $type,
),
"label" => Translator::getInstance()->trans($name),
"type" => $requirementType->getFormType(),
"options" => $requirementType->getFormOptions(),
))
;
}
}
$this->addStandardDescFields(array('postscriptum', 'chapo', 'locale'));
}
public function getName()
{
return "thelia_tax_creation";
}
}

View File

@@ -0,0 +1,71 @@
<?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\Form;
use Symfony\Component\Validator\Constraints;
use Symfony\Component\Validator\ExecutionContextInterface;
use Thelia\Model\TaxQuery;
/**
* Class TaxModificationForm
* @package Thelia\Form
* @author Etienne Roudeix <eroudeix@openstudio.fr>
*/
class TaxModificationForm extends TaxCreationForm
{
protected function buildForm()
{
parent::buildForm(true);
$this->formBuilder
->add("id", "hidden", array(
"required" => true,
"constraints" => array(
new Constraints\NotBlank(),
new Constraints\Callback(
array(
"methods" => array(
array($this, "verifyTaxId"),
),
)
),
)
))
;
}
public function getName()
{
return "thelia_tax_modification";
}
public function verifyTaxId($value, ExecutionContextInterface $context)
{
$tax = TaxQuery::create()
->findPk($value);
if (null === $tax) {
$context->addViolation("Tax ID not found");
}
}
}

View File

@@ -24,8 +24,6 @@ namespace Thelia\Form;
use Symfony\Component\Validator\Constraints;
use Symfony\Component\Validator\Constraints\NotBlank;
use Thelia\Core\Translation\Translator;
use Thelia\Model\CountryQuery;
class TaxRuleCreationForm extends BaseForm
{

View File

@@ -34,7 +34,7 @@ class TaxRuleTaxListUpdateForm extends BaseForm
protected function buildForm()
{
$countryList = array();
foreach(CountryQuery::create()->find() as $country) {
foreach (CountryQuery::create()->find() as $country) {
$countryList[$country->getId()] = $country->getId();
}
@@ -96,7 +96,7 @@ class TaxRuleTaxListUpdateForm extends BaseForm
public function verifyTaxList($value, ExecutionContextInterface $context)
{
$jsonType = new JsonType();
if(!$jsonType->isValid($value)) {
if (!$jsonType->isValid($value)) {
$context->addViolation("Tax list is not valid JSON");
}
@@ -104,10 +104,10 @@ class TaxRuleTaxListUpdateForm extends BaseForm
/* check we have 2 level max */
foreach($taxList as $taxLevel1) {
if(is_array($taxLevel1)) {
foreach($taxLevel1 as $taxLevel2) {
if(is_array($taxLevel2)) {
foreach ($taxList as $taxLevel1) {
if (is_array($taxLevel1)) {
foreach ($taxLevel1 as $taxLevel2) {
if (is_array($taxLevel2)) {
$context->addViolation("Bad tax list JSON");
} else {
$taxModel = TaxQuery::create()->findPk($taxLevel2);