Merge branch 'master' of https://github.com/thelia/thelia into coupon
* 'master' of https://github.com/thelia/thelia: (121 commits) set cartItem in cart add and update events need to unescape breadcrumb strings after been in array update readme file update insert.sql with new release version change changelog file format Prevent product and content création at catalog root dynamic delivery modules on delivery front template complete changelog Finished merging modules with master Revert "Merge branch 'cleanmaster' into modules" use TaxEngine::getDeliveryCountry in delivery loop refacto getTaxCountry which is actually getDeliveryCountry make it magic last stand change loop in shipping zone template using module insteadof delivery Fixed template loop Refactored templates processing complete readme file change email address of core contributors fix getPosition folder test add coupon tests ... Conflicts: core/lib/Thelia/Controller/Admin/ProductController.php
This commit is contained in:
@@ -23,8 +23,6 @@
|
||||
namespace Thelia\Form;
|
||||
|
||||
use Symfony\Component\Validator\Constraints\GreaterThan;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
|
||||
class CategoryModificationForm extends CategoryCreationForm
|
||||
{
|
||||
@@ -35,17 +33,15 @@ class CategoryModificationForm extends CategoryCreationForm
|
||||
parent::buildForm(true);
|
||||
|
||||
$this->formBuilder
|
||||
->add("id", "hidden", array("constraints" => array(new GreaterThan(array('value' => 0)))))
|
||||
|
||||
->add("url", "text", array(
|
||||
"label" => Translator::getInstance()->trans("Rewritten URL *"),
|
||||
"constraints" => array(new NotBlank()),
|
||||
"label_attr" => array("for" => "rewriten_url")
|
||||
))
|
||||
->add("id", "hidden", array(
|
||||
"constraints" => array(
|
||||
new GreaterThan(array('value' => 0))
|
||||
)
|
||||
))
|
||||
;
|
||||
|
||||
// Add standard description fields, excluding title and locale, which a re defined in parent class
|
||||
$this->addStandardDescFields(array('title', 'locale'));
|
||||
// Add standard description fields, excluding title which is defined in parent class
|
||||
$this->addStandardDescFields(array('title'));
|
||||
}
|
||||
|
||||
public function getName()
|
||||
|
||||
@@ -24,8 +24,6 @@
|
||||
namespace Thelia\Form;
|
||||
|
||||
use Symfony\Component\Validator\Constraints\GreaterThan;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Form\StandardDescriptionFieldsTrait;
|
||||
|
||||
/**
|
||||
@@ -43,12 +41,6 @@ class ContentModificationForm extends ContentCreationForm
|
||||
|
||||
$this->formBuilder
|
||||
->add("id", "hidden", array("constraints" => array(new GreaterThan(array('value' => 0)))))
|
||||
|
||||
->add("url", "text", array(
|
||||
"label" => Translator::getInstance()->trans("Rewritten URL *"),
|
||||
"constraints" => array(new NotBlank()),
|
||||
"label_attr" => array("for" => "rewritten_url")
|
||||
))
|
||||
;
|
||||
|
||||
// Add standard description fields, excluding title and locale, which a re defined in parent class
|
||||
|
||||
@@ -23,8 +23,6 @@
|
||||
namespace Thelia\Form;
|
||||
|
||||
use Symfony\Component\Validator\Constraints\GreaterThan;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
|
||||
class FolderModificationForm extends FolderCreationForm
|
||||
{
|
||||
@@ -36,12 +34,6 @@ class FolderModificationForm extends FolderCreationForm
|
||||
|
||||
$this->formBuilder
|
||||
->add("id", "hidden", array("constraints" => array(new GreaterThan(array('value' => 0)))))
|
||||
|
||||
->add("url", "text", array(
|
||||
"label" => Translator::getInstance()->trans("Rewritten 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
|
||||
|
||||
@@ -24,7 +24,7 @@ namespace Thelia\Form;
|
||||
|
||||
use Symfony\Component\Validator\Constraints\GreaterThan;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
|
||||
|
||||
class ProductModificationForm extends ProductCreationForm
|
||||
{
|
||||
@@ -39,17 +39,10 @@ class ProductModificationForm extends ProductCreationForm
|
||||
"label" => Translator::getInstance()->trans("Prodcut ID *"),
|
||||
"label_attr" => array("for" => "product_id_field"),
|
||||
"constraints" => array(new GreaterThan(array('value' => 0)))
|
||||
|
||||
))
|
||||
->add("template_id", "integer", array(
|
||||
"label" => Translator::getInstance()->trans("Product template"),
|
||||
"label_attr" => array("for" => "product_template_field")
|
||||
|
||||
))
|
||||
->add("url", "text", array(
|
||||
"label" => Translator::getInstance()->trans("Rewritten URL *"),
|
||||
"constraints" => array(new NotBlank()),
|
||||
"label_attr" => array("for" => "rewriten_url_field")
|
||||
))
|
||||
;
|
||||
|
||||
|
||||
89
core/lib/Thelia/Form/SeoFieldsTrait.php
Normal file
89
core/lib/Thelia/Form/SeoFieldsTrait.php
Normal file
@@ -0,0 +1,89 @@
|
||||
<?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;
|
||||
|
||||
/**
|
||||
* A trait to add standard localized description fields to a form.
|
||||
*
|
||||
* @author Christophe Laffont <claffont@openstudio.fr>
|
||||
*/
|
||||
trait SeoFieldsTrait
|
||||
{
|
||||
/**
|
||||
* Add seo meta title, meta description and meta keywords fields
|
||||
*
|
||||
* @param array $exclude name of the fields that should not be added to the form
|
||||
*/
|
||||
protected function addSeoFields($exclude = array())
|
||||
{
|
||||
|
||||
if (! in_array('url', $exclude))
|
||||
$this->formBuilder
|
||||
->add('url', 'text', array(
|
||||
'label' => Translator::getInstance()->trans('Rewriten URL'),
|
||||
'label_attr' => array(
|
||||
'for' => 'rewriten_url_field'
|
||||
),
|
||||
'required' => false
|
||||
)
|
||||
);
|
||||
|
||||
if (! in_array('meta_title', $exclude))
|
||||
$this->formBuilder
|
||||
->add('meta_title', 'text', array(
|
||||
'constraints' => array(
|
||||
new NotBlank()
|
||||
),
|
||||
'label' => Translator::getInstance()->trans('Page Title'),
|
||||
'label_attr' => array(
|
||||
'for' => 'meta_title'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
if (! in_array('meta_description', $exclude))
|
||||
$this->formBuilder
|
||||
->add('meta_description', 'text', array(
|
||||
'label' => Translator::getInstance()->trans('Meta Description'),
|
||||
'label_attr' => array(
|
||||
'for' => 'meta_description'
|
||||
),
|
||||
'required' => false
|
||||
)
|
||||
);
|
||||
|
||||
if (! in_array('meta_keywords', $exclude))
|
||||
$this->formBuilder
|
||||
->add('meta_keywords', 'text', array(
|
||||
'label' => Translator::getInstance()->trans('Meta Keywords'),
|
||||
'label_attr' => array(
|
||||
'for' => 'meta_keywords'
|
||||
),
|
||||
'required' => false
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
81
core/lib/Thelia/Form/SeoForm.php
Normal file
81
core/lib/Thelia/Form/SeoForm.php
Normal file
@@ -0,0 +1,81 @@
|
||||
<?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 Symfony\Component\Validator\Constraints\NotBlank;
|
||||
|
||||
/**
|
||||
* Class SeoForm
|
||||
* @package Thelia\Form
|
||||
* @author Christophe Laffont <claffont@openstudio.fr>
|
||||
*/
|
||||
class SeoForm extends BaseForm
|
||||
{
|
||||
use SeoFieldsTrait;
|
||||
|
||||
/**
|
||||
*
|
||||
* 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("id", "hidden", array(
|
||||
"constraints" => array(
|
||||
new GreaterThan(array('value' => 0))
|
||||
)
|
||||
))
|
||||
->add("locale", "hidden", array(
|
||||
"constraints" => array(
|
||||
new NotBlank()
|
||||
)
|
||||
))
|
||||
;
|
||||
|
||||
// Add SEO Fields
|
||||
$this->addSeoFields();
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return "thelia_seo";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user