WIP : upload document : add forms
This commit is contained in:
54
core/lib/Thelia/Form/CategoryDocumentModification.php
Normal file
54
core/lib/Thelia/Form/CategoryDocumentModification.php
Normal file
@@ -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\Form;
|
||||
|
||||
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Form\Image\DocumentModification;
|
||||
use Thelia\Form\Image\ImageModification;
|
||||
|
||||
/**
|
||||
* Created by JetBrains PhpStorm.
|
||||
* Date: 9/18/13
|
||||
* Time: 3:56 PM
|
||||
*
|
||||
* Form allowing to process an document collection
|
||||
*
|
||||
* @package Image
|
||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
class CategoryDocumentModification extends DocumentModification
|
||||
{
|
||||
|
||||
/**
|
||||
* Get form name
|
||||
* This name must be unique
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'thelia_category_document_modification';
|
||||
}
|
||||
}
|
||||
54
core/lib/Thelia/Form/ContentDocumentModification.php
Normal file
54
core/lib/Thelia/Form/ContentDocumentModification.php
Normal file
@@ -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\Form;
|
||||
|
||||
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Form\Image\DocumentModification;
|
||||
use Thelia\Form\Image\ImageModification;
|
||||
|
||||
/**
|
||||
* Created by JetBrains PhpStorm.
|
||||
* Date: 9/18/13
|
||||
* Time: 3:56 PM
|
||||
*
|
||||
* Form allowing to process a file
|
||||
*
|
||||
* @package File
|
||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
class ContentDocumentModification extends DocumentModification
|
||||
{
|
||||
|
||||
/**
|
||||
* Get form name
|
||||
* This name must be unique
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'thelia_content_document_modification';
|
||||
}
|
||||
}
|
||||
54
core/lib/Thelia/Form/FolderDocumentModification.php
Normal file
54
core/lib/Thelia/Form/FolderDocumentModification.php
Normal file
@@ -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\Form;
|
||||
|
||||
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Form\Image\DocumentModification;
|
||||
use Thelia\Form\Image\ImageModification;
|
||||
|
||||
/**
|
||||
* Created by JetBrains PhpStorm.
|
||||
* Date: 9/18/13
|
||||
* Time: 3:56 PM
|
||||
*
|
||||
* Form allowing to process a file
|
||||
*
|
||||
* @package Image
|
||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
class FolderDocumentModification extends DocumentModification
|
||||
{
|
||||
|
||||
/**
|
||||
* Get form name
|
||||
* This name must be unique
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'thelia_folder_document_modification';
|
||||
}
|
||||
}
|
||||
138
core/lib/Thelia/Form/Image/DocumentModification.php
Normal file
138
core/lib/Thelia/Form/Image/DocumentModification.php
Normal file
@@ -0,0 +1,138 @@
|
||||
<?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\Image;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\Validator\Constraints\Image;
|
||||
use Symfony\Component\Validator\Constraints\NotBlank;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Form\BaseForm;
|
||||
|
||||
/**
|
||||
* Created by JetBrains PhpStorm.
|
||||
* Date: 9/18/13
|
||||
* Time: 3:56 PM
|
||||
*
|
||||
* Form allowing to process a file
|
||||
* @todo refactor make all document using propel inheritance and factorise image behaviour into one single clean action
|
||||
*
|
||||
* @package File
|
||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
abstract class DocumentModification 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->form attribute :
|
||||
*
|
||||
* $this->form->add('name', 'text')
|
||||
* ->add('email', 'email', array(
|
||||
* 'attr' => array(
|
||||
* 'class' => 'field'
|
||||
* ),
|
||||
* 'label' => 'email',
|
||||
* 'constraints' => array(
|
||||
* new NotBlank()
|
||||
* )
|
||||
* )
|
||||
* )
|
||||
* ->add('age', 'integer');
|
||||
*
|
||||
* @return null
|
||||
*/
|
||||
protected function buildForm()
|
||||
{
|
||||
$this->formBuilder->add(
|
||||
'file',
|
||||
'file',
|
||||
array(
|
||||
'constraints' => array(),
|
||||
'label' => Translator::getInstance()->trans('File'),
|
||||
'label_attr' => array(
|
||||
'for' => 'file'
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
$this->formBuilder
|
||||
->add(
|
||||
'title',
|
||||
'text',
|
||||
array(
|
||||
'constraints' => array(
|
||||
new NotBlank()
|
||||
),
|
||||
'label' => Translator::getInstance()->trans('Title'),
|
||||
'label_attr' => array(
|
||||
'for' => 'title'
|
||||
)
|
||||
)
|
||||
)
|
||||
->add(
|
||||
'description',
|
||||
'text',
|
||||
array(
|
||||
'constraints' => array(),
|
||||
'label' => Translator::getInstance()->trans('Description'),
|
||||
'label_attr' => array(
|
||||
'for' => 'description'
|
||||
)
|
||||
)
|
||||
)
|
||||
->add(
|
||||
'chapo',
|
||||
'text',
|
||||
array(
|
||||
'constraints' => array(),
|
||||
'label' => Translator::getInstance()->trans('Chapo'),
|
||||
'label_attr' => array(
|
||||
'for' => 'chapo'
|
||||
)
|
||||
)
|
||||
)
|
||||
->add(
|
||||
'postscriptum',
|
||||
'text',
|
||||
array(
|
||||
'constraints' => array(),
|
||||
'label' => Translator::getInstance()->trans('Post Scriptum'),
|
||||
'label_attr' => array(
|
||||
'for' => 'postscriptum'
|
||||
)
|
||||
)
|
||||
)
|
||||
->add(
|
||||
'postscriptum',
|
||||
'text',
|
||||
array(
|
||||
'constraints' => array(),
|
||||
'label' => Translator::getInstance()->trans('Post Scriptum'),
|
||||
'label_attr' => array(
|
||||
'for' => 'postscriptum'
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -43,15 +43,6 @@ use Thelia\Form\BaseForm;
|
||||
abstract class ImageModification extends BaseForm
|
||||
{
|
||||
|
||||
// public function __construct(Request $request, $type= "form", $data = array(), $options = array(), $isUpdate = false)
|
||||
// {
|
||||
// parent::__construct($request, $type, $data, $options);
|
||||
// $this->setIsUpdate($isUpdate);
|
||||
// }
|
||||
|
||||
// /** @var bool Flag for update/create mode */
|
||||
// protected $isUpdate = false;
|
||||
|
||||
/**
|
||||
*
|
||||
* in this function you add all the fields you need for your Form.
|
||||
@@ -74,27 +65,24 @@ abstract class ImageModification extends BaseForm
|
||||
*/
|
||||
protected function buildForm()
|
||||
{
|
||||
// if (false === $this->isUpdate) {
|
||||
$this->formBuilder->add(
|
||||
'file',
|
||||
'file',
|
||||
array(
|
||||
'constraints' => array(
|
||||
// new NotBlank(),
|
||||
new Image(
|
||||
array(
|
||||
'minWidth' => 200,
|
||||
'minHeight' => 200
|
||||
)
|
||||
$this->formBuilder->add(
|
||||
'file',
|
||||
'file',
|
||||
array(
|
||||
'constraints' => array(
|
||||
new Image(
|
||||
array(
|
||||
'minWidth' => 200,
|
||||
'minHeight' => 200
|
||||
)
|
||||
),
|
||||
'label' => Translator::getInstance()->trans('File'),
|
||||
'label_attr' => array(
|
||||
'for' => 'file'
|
||||
)
|
||||
),
|
||||
'label' => Translator::getInstance()->trans('File'),
|
||||
'label_attr' => array(
|
||||
'for' => 'file'
|
||||
)
|
||||
);
|
||||
// }
|
||||
)
|
||||
);
|
||||
|
||||
$this->formBuilder
|
||||
->add(
|
||||
@@ -154,30 +142,5 @@ abstract class ImageModification extends BaseForm
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Set form in update or create mode
|
||||
// *
|
||||
// * @param boolean $isUpdate
|
||||
// */
|
||||
// public function setIsUpdate($isUpdate)
|
||||
// {
|
||||
// $this->isUpdate = $isUpdate;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Get for mode
|
||||
// *
|
||||
// * @return boolean
|
||||
// */
|
||||
// public function getIsUpdate()
|
||||
// {
|
||||
// return $this->isUpdate;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
54
core/lib/Thelia/Form/ProductDocumentModification.php
Normal file
54
core/lib/Thelia/Form/ProductDocumentModification.php
Normal file
@@ -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\Form;
|
||||
|
||||
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Form\Image\DocumentModification;
|
||||
use Thelia\Form\Image\ImageModification;
|
||||
|
||||
/**
|
||||
* Created by JetBrains PhpStorm.
|
||||
* Date: 9/18/13
|
||||
* Time: 3:56 PM
|
||||
*
|
||||
* Form allowing to process a file
|
||||
*
|
||||
* @package File
|
||||
* @author Guillaume MOREL <gmorel@openstudio.fr>
|
||||
*
|
||||
*/
|
||||
class ProductDocumentModification extends DocumentModification
|
||||
{
|
||||
|
||||
/**
|
||||
* Get form name
|
||||
* This name must be unique
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'thelia_product_document_modification';
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ Parameters:
|
||||
<div class="image-manager" >
|
||||
<form action="{url path="/admin/image/type/$imageType/$parentId/save-ajax"}" class="dropzone" id="images-dropzone" enctype="multipart/form-data">
|
||||
<div class="fallback">
|
||||
<input name="file" type="file" multiple />
|
||||
<input name="file" type="file" />
|
||||
<button type="submit" class="btn btn-info btn-upload"><span class="glyphicon glyphicon-send"></span> {intl l="Send files"}</button>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user