Merge branch 'master' of https://github.com/thelia/thelia into upload_management
# By Manuel Raynaud (60) and others # Via Manuel Raynaud (16) and others * 'master' of https://github.com/thelia/thelia: (113 commits) implement process for changing folder position allow possibility to change folder visibility allow to create folder add dispatcher before/after for folder crud management icreate folder delete event process folder update action create folder events display info in folders edition template push model re-add home link in menu comment dev menu in layout translate some missing string fixes order integration order process change some informations in layou fix query in Thelia\Model\Folder::countAllContents allow to order products on category page Add default language & editing language default field Vertical align middle tables Fixed translations ... Conflicts: core/lib/Thelia/Tools/I18n.php templates/admin/default/category-edit.html
This commit is contained in:
63
core/lib/Thelia/Form/ContentCreationForm.php
Normal file
63
core/lib/Thelia/Form/ContentCreationForm.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?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\NotBlank;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
|
||||
class ContentCreationForm extends BaseForm
|
||||
{
|
||||
protected function buildForm($change_mode = false)
|
||||
{
|
||||
$this->formBuilder
|
||||
->add("title", "text", array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"label" => "Content title *",
|
||||
"label_attr" => array(
|
||||
"for" => "title"
|
||||
)
|
||||
))
|
||||
->add("default_folder", "integer", array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
)
|
||||
))
|
||||
->add("locale", "text", array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
)
|
||||
))
|
||||
->add("visible", "integer", array(
|
||||
"label" => Translator::getInstance()->trans("This content is online."),
|
||||
"label_attr" => array("for" => "visible_create")
|
||||
))
|
||||
;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return "thelia_content_creation";
|
||||
}
|
||||
}
|
||||
66
core/lib/Thelia/Form/FolderCreationForm.php
Normal file
66
core/lib/Thelia/Form/FolderCreationForm.php
Normal file
@@ -0,0 +1,66 @@
|
||||
<?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\NotBlank;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
|
||||
class FolderCreationForm extends BaseForm
|
||||
{
|
||||
protected function buildForm()
|
||||
{
|
||||
$this->formBuilder
|
||||
->add("title", "text", array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"label" => Translator::getInstance()->trans("Folder title *"),
|
||||
"label_attr" => array(
|
||||
"for" => "title"
|
||||
)
|
||||
))
|
||||
->add("parent", "text", array(
|
||||
"label" => Translator::getInstance()->trans("Parent folder *"),
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"label_attr" => array("for" => "parent_create")
|
||||
))
|
||||
->add("locale", "text", array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"label_attr" => array("for" => "locale_create")
|
||||
))
|
||||
->add("visible", "integer", array(
|
||||
"label" => Translator::getInstance()->trans("This folder is online."),
|
||||
"label_attr" => array("for" => "visible_create")
|
||||
))
|
||||
;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return "thelia_folder_creation";
|
||||
}
|
||||
}
|
||||
55
core/lib/Thelia/Form/FolderModificationForm.php
Normal file
55
core/lib/Thelia/Form/FolderModificationForm.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?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\GreaterThan;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
|
||||
class FolderModificationForm extends FolderCreationForm
|
||||
{
|
||||
use StandardDescriptionFieldsTrait;
|
||||
|
||||
protected function buildForm()
|
||||
{
|
||||
parent::buildForm(true);
|
||||
|
||||
$this->formBuilder
|
||||
->add("id", "hidden", array("constraints" => array(new GreaterThan(array('value' => 0)))))
|
||||
|
||||
->add("url", "text", array(
|
||||
"label" => Translator::getInstance()->trans("Rewriten URL *"),
|
||||
"constraints" => array(new NotBlank()),
|
||||
"label_attr" => array("for" => "rewriten_url")
|
||||
))
|
||||
;
|
||||
|
||||
// Add standard description fields, excluding title and locale, which a re defined in parent class
|
||||
$this->addStandardDescFields(array('title', 'locale'));
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return "thelia_folder_modification";
|
||||
}
|
||||
}
|
||||
@@ -80,11 +80,18 @@ class OrderDelivery extends BaseForm
|
||||
->filterByType(BaseModule::DELIVERY_MODULE_TYPE)
|
||||
->filterByActivate(1)
|
||||
->filterById($value)
|
||||
->find();
|
||||
->findOne();
|
||||
|
||||
if(null === $module) {
|
||||
$context->addViolation("Delivery module ID not found");
|
||||
}
|
||||
|
||||
$moduleReflection = new \ReflectionClass($module->getFullNamespace());
|
||||
if ($moduleReflection->isSubclassOf("Thelia\Module\DeliveryModuleInterface") === false) {
|
||||
$context->addViolation(
|
||||
sprintf("delivery module %s is not a Thelia\Module\DeliveryModuleInterface", $module->getCode())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function getName()
|
||||
|
||||
101
core/lib/Thelia/Form/OrderPayment.php
Executable file
101
core/lib/Thelia/Form/OrderPayment.php
Executable 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\ExecutionContextInterface;
|
||||
use Thelia\Model\AddressQuery;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Model\ModuleQuery;
|
||||
use Thelia\Module\BaseModule;
|
||||
|
||||
/**
|
||||
* Class OrderPayment
|
||||
* @package Thelia\Form
|
||||
* @author Etienne Roudeix <eroudeix@openstudio.fr>
|
||||
*/
|
||||
class OrderPayment extends BaseForm
|
||||
{
|
||||
protected function buildForm()
|
||||
{
|
||||
$this->formBuilder
|
||||
->add("invoice-address", "integer", array(
|
||||
"required" => true,
|
||||
"constraints" => array(
|
||||
new Constraints\NotBlank(),
|
||||
new Constraints\Callback(array(
|
||||
"methods" => array(
|
||||
array($this, "verifyInvoiceAddress")
|
||||
)
|
||||
))
|
||||
)
|
||||
))
|
||||
->add("payment-module", "integer", array(
|
||||
"required" => true,
|
||||
"constraints" => array(
|
||||
new Constraints\NotBlank(),
|
||||
new Constraints\Callback(array(
|
||||
"methods" => array(
|
||||
array($this, "verifyPaymentModule")
|
||||
)
|
||||
))
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
public function verifyInvoiceAddress($value, ExecutionContextInterface $context)
|
||||
{
|
||||
$address = AddressQuery::create()
|
||||
->findPk($value);
|
||||
|
||||
if(null === $address) {
|
||||
$context->addViolation("Address ID not found");
|
||||
}
|
||||
}
|
||||
|
||||
public function verifyPaymentModule($value, ExecutionContextInterface $context)
|
||||
{
|
||||
$module = ModuleQuery::create()
|
||||
->filterByType(BaseModule::PAYMENT_MODULE_TYPE)
|
||||
->filterByActivate(1)
|
||||
->filterById($value)
|
||||
->findOne();
|
||||
|
||||
if(null === $module) {
|
||||
$context->addViolation("Payment module ID not found");
|
||||
}
|
||||
|
||||
$moduleReflection = new \ReflectionClass($module->getFullNamespace());
|
||||
if ($moduleReflection->isSubclassOf("Thelia\Module\PaymentModuleInterface") === false) {
|
||||
$context->addViolation(
|
||||
sprintf("delivery module %s is not a Thelia\Module\PaymentModuleInterface", $module->getCode())
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return "thelia_order_payment";
|
||||
}
|
||||
}
|
||||
@@ -23,45 +23,62 @@
|
||||
namespace Thelia\Form;
|
||||
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Model\ProductQuery;
|
||||
use Symfony\Component\Validator\Constraints\Callback;
|
||||
use Symfony\Component\Validator\ExecutionContextInterface;
|
||||
|
||||
class ProductCreationForm extends BaseForm
|
||||
{
|
||||
protected function buildForm()
|
||||
protected function buildForm($change_mode = false)
|
||||
{
|
||||
$ref_constraints = array(new NotBlank());
|
||||
|
||||
if (! $change_mode) {
|
||||
$ref_constraints[] = new Callback(array(
|
||||
"methods" => array(array($this, "checkDuplicateRef"))
|
||||
));
|
||||
}
|
||||
|
||||
$this->formBuilder
|
||||
->add("ref", "text", array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"label" => "Product reference *",
|
||||
"label_attr" => array(
|
||||
"for" => "ref"
|
||||
)
|
||||
"constraints" => $ref_constraints,
|
||||
"label" => "Product reference *",
|
||||
"label_attr" => array("for" => "ref")
|
||||
))
|
||||
->add("title", "text", array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
),
|
||||
"label" => "Product title *",
|
||||
"label_attr" => array(
|
||||
"for" => "title"
|
||||
)
|
||||
"label_attr" => array("for" => "title")
|
||||
))
|
||||
->add("default_category", "integer", array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
)
|
||||
"constraints" => array(new NotBlank()),
|
||||
"label" => Translator::getInstance()->trans("Default product category."),
|
||||
"label_attr" => array("for" => "default_category_field")
|
||||
))
|
||||
->add("locale", "text", array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
)
|
||||
"constraints" => array(new NotBlank())
|
||||
))
|
||||
->add("visible", "integer", array(
|
||||
"label" => Translator::getInstance()->trans("This product is online."),
|
||||
"label_attr" => array("for" => "visible_create")
|
||||
"label" => Translator::getInstance()->trans("This product is online."),
|
||||
"label_attr" => array("for" => "visible_field")
|
||||
))
|
||||
;
|
||||
;
|
||||
}
|
||||
|
||||
public function checkDuplicateRef($value, ExecutionContextInterface $context)
|
||||
{
|
||||
$count = ProductQuery::create()->filterByRef($value)->count();
|
||||
|
||||
if ($count > 0) {
|
||||
$context->addViolation(
|
||||
Translator::getInstance()->trans(
|
||||
"A product with reference %ref already exists. Please choose another reference.",
|
||||
array('%ref' => $value)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
public function getName()
|
||||
|
||||
119
core/lib/Thelia/Form/ProfileModificationForm.php
Normal file
119
core/lib/Thelia/Form/ProfileModificationForm.php
Normal 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;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Model\ConfigQuery;
|
||||
|
||||
/**
|
||||
* Class ProfileModification
|
||||
* @package Thelia\Form
|
||||
* @author Manuel Raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class ProfileModificationForm extends BaseForm
|
||||
{
|
||||
|
||||
|
||||
protected function buildForm()
|
||||
{
|
||||
|
||||
$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(
|
||||
"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"
|
||||
)
|
||||
))
|
||||
;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return "thelia_profile_modification";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user