WIP : Upload management (upload+save+delete done) need to finish integration and add all image fields
This commit is contained in:
71
core/lib/Thelia/Form/CategoryImageCreationForm.php
Normal file
71
core/lib/Thelia/Form/CategoryImageCreationForm.php
Normal 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 Thelia\Core\Translation\Translator;
|
||||
use Thelia\Form\Type\ImageCategoryType;
|
||||
|
||||
/**
|
||||
* Created by JetBrains PhpStorm.
|
||||
* Date: 9/18/13
|
||||
* Time: 3:56 PM
|
||||
*
|
||||
* Form allowing to process an image collection
|
||||
*
|
||||
* @package Image
|
||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
class CategoryImageCreationForm extends BaseForm
|
||||
{
|
||||
/**
|
||||
* Allow to build a form
|
||||
*/
|
||||
protected function buildForm()
|
||||
{
|
||||
$this->formBuilder
|
||||
->add('pictures',
|
||||
'collection',
|
||||
array(
|
||||
'type' => new ImageCategoryType(),
|
||||
'options' => array(
|
||||
'required' => false
|
||||
),
|
||||
'allow_add' => true,
|
||||
'allow_delete' => true,
|
||||
'by_reference' => false,
|
||||
)
|
||||
)
|
||||
->add('formSuccessUrl');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get form name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'thelia_category_image_creation';
|
||||
}
|
||||
}
|
||||
@@ -1,100 +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\Form;
|
||||
|
||||
use Symfony\Component\Validator\Constraints\Image;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
|
||||
class CategoryPictureCreationForm extends BaseForm
|
||||
{
|
||||
protected function buildForm()
|
||||
{
|
||||
$this->formBuilder
|
||||
// ->add('alt')
|
||||
->add('file', 'file', array(
|
||||
'constraints' => array(
|
||||
new NotBlank(),
|
||||
new Image(
|
||||
array(
|
||||
'minWidth' => 200,
|
||||
'maxWidth' => 400,
|
||||
'minHeight' => 200,
|
||||
'maxHeight' => 400,
|
||||
)
|
||||
)
|
||||
)))
|
||||
// ->add('category_id', 'model', array(
|
||||
// 'disabled' => false,
|
||||
// 'class' => 'Thelia\Model\ProductImage'
|
||||
// ))
|
||||
// ->add('position', 'integer', array(
|
||||
// 'constraints' => array(
|
||||
// new NotBlank()
|
||||
// )
|
||||
// ))
|
||||
->add('title', 'text', array(
|
||||
'constraints' => array(
|
||||
// new NotBlank()
|
||||
),
|
||||
// 'label' => Translator::getInstance()->trans('Category picture title *'),
|
||||
// 'label_attr' => array(
|
||||
// 'for' => 'title'
|
||||
// )
|
||||
))
|
||||
// ->add('description', 'text', array(
|
||||
// 'constraints' => array(
|
||||
// new NotBlank()
|
||||
// ),
|
||||
// 'label' => Translator::getInstance()->trans('Category picture description *'),
|
||||
// 'label_attr' => array(
|
||||
// 'for' => 'description'
|
||||
// )
|
||||
// ))
|
||||
// ->add('chapo', 'text', array(
|
||||
// 'constraints' => array(
|
||||
// new NotBlank()
|
||||
// ),
|
||||
// 'label' => Translator::getInstance()->trans('Category picture chapo *'),
|
||||
// 'label_attr' => array(
|
||||
// 'for' => 'chapo'
|
||||
// )
|
||||
// ))
|
||||
// ->add('postscriptum', 'text', array(
|
||||
// 'constraints' => array(
|
||||
// new NotBlank()
|
||||
// ),
|
||||
// 'label' => Translator::getInstance()->trans('Category picture postscriptum *'),
|
||||
// 'label_attr' => array(
|
||||
// 'for' => 'postscriptum'
|
||||
// )
|
||||
// ))
|
||||
|
||||
;
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return 'thelia_category_picture_creation';
|
||||
}
|
||||
}
|
||||
79
core/lib/Thelia/Form/Type/ImageCategoryType.php
Normal file
79
core/lib/Thelia/Form/Type/ImageCategoryType.php
Normal file
@@ -0,0 +1,79 @@
|
||||
<?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\Type;
|
||||
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
|
||||
use Thelia\Form\Type\ImageType;
|
||||
|
||||
/**
|
||||
* Created by JetBrains PhpStorm.
|
||||
* Date: 9/18/13
|
||||
* Time: 3:56 PM
|
||||
*
|
||||
* Form allowing to process a category picture
|
||||
*
|
||||
* @package Image
|
||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
class ImageCategoryType extends ImageType
|
||||
{
|
||||
/**
|
||||
* Build a Picture form
|
||||
*
|
||||
* @param FormBuilderInterface $builder Form builder
|
||||
* @param array $options Form options
|
||||
*/
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder->add('category_id', 'integer');
|
||||
|
||||
parent::buildForm($builder, $options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set default options
|
||||
* Map the form to the given Model
|
||||
*
|
||||
* @param OptionsResolverInterface $resolver Option resolver
|
||||
*/
|
||||
public function setDefaultOptions(OptionsResolverInterface $resolver)
|
||||
{
|
||||
$resolver->setDefaults(
|
||||
array(
|
||||
'data_class' => 'Thelia\Model\CategoryImage'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get form name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'thelia_category_picture_creation_type';
|
||||
}
|
||||
}
|
||||
82
core/lib/Thelia/Form/Type/ImageType.php
Normal file
82
core/lib/Thelia/Form/Type/ImageType.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?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\Type;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\Validator\Constraints\Image;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
|
||||
/**
|
||||
* Created by JetBrains PhpStorm.
|
||||
* Date: 9/18/13
|
||||
* Time: 3:56 PM
|
||||
*
|
||||
* Form allowing to process a picture
|
||||
*
|
||||
* @todo refactor make all pictures using propel inheritance and factorise image behaviour into one single clean action
|
||||
*
|
||||
* @package Image
|
||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
abstract class ImageType extends AbstractType
|
||||
{
|
||||
/**
|
||||
* Build a Picture form
|
||||
*
|
||||
* @param FormBuilderInterface $builder Form builder
|
||||
* @param array $options Form options
|
||||
*/
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
// $builder->add('position');
|
||||
$builder->add(
|
||||
'title',
|
||||
'text',
|
||||
array(
|
||||
'constraints' => new NotBlank()
|
||||
)
|
||||
);
|
||||
$builder->add(
|
||||
'file',
|
||||
'file',
|
||||
array(
|
||||
'constraints' => array(
|
||||
new NotBlank(),
|
||||
new Image(
|
||||
array(
|
||||
'minWidth' => 200,
|
||||
// 'maxWidth' => 400,
|
||||
'minHeight' => 200,
|
||||
// 'maxHeight' => 400,
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
// $builder->add('description');
|
||||
// $builder->add('chapo');
|
||||
// $builder->add('postscriptum');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user