create contentModificationForm
This commit is contained in:
@@ -22,6 +22,9 @@
|
||||
/*************************************************************************************/
|
||||
|
||||
namespace Thelia\Controller\Admin;
|
||||
use Thelia\Core\Event\TheliaEvents;
|
||||
use Thelia\Form\ContentCreationForm;
|
||||
use Thelia\Form\ContentModificationForm;
|
||||
|
||||
|
||||
/**
|
||||
@@ -29,14 +32,35 @@ namespace Thelia\Controller\Admin;
|
||||
* @package Thelia\Controller\Admin
|
||||
* @author manuel raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class ContentController extends AbstractCrudController {
|
||||
class ContentController extends AbstractCrudController
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct(
|
||||
'content',
|
||||
'manual',
|
||||
'content_order',
|
||||
|
||||
'admin.content.default',
|
||||
'admin.content.create',
|
||||
'admin.content.update',
|
||||
'admin.content.delete',
|
||||
|
||||
TheliaEvents::CONTENT_CREATE,
|
||||
TheliaEvents::CONTENT_UPDATE,
|
||||
TheliaEvents::CONTENT_DELETE,
|
||||
TheliaEvents::CONTENT_TOGGLE_VISIBILITY,
|
||||
TheliaEvents::CONTENT_UPDATE_POSITION
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the creation form for this object
|
||||
*/
|
||||
protected function getCreationForm()
|
||||
{
|
||||
// TODO: Implement getCreationForm() method.
|
||||
return new ContentCreationForm($this->getRequest());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -44,17 +68,31 @@ class ContentController extends AbstractCrudController {
|
||||
*/
|
||||
protected function getUpdateForm()
|
||||
{
|
||||
// TODO: Implement getUpdateForm() method.
|
||||
return new ContentModificationForm($this->getRequest());
|
||||
}
|
||||
|
||||
/**
|
||||
* Hydrate the update form for this object, before passing it to the update template
|
||||
*
|
||||
* @param unknown $object
|
||||
* @param \Thelia\Form\ContentModificationForm $object
|
||||
*/
|
||||
protected function hydrateObjectForm($object)
|
||||
{
|
||||
// TODO: Implement hydrateObjectForm() method.
|
||||
// Prepare the data that will hydrate the form
|
||||
$data = array(
|
||||
'id' => $object->getId(),
|
||||
'locale' => $object->getLocale(),
|
||||
'title' => $object->getTitle(),
|
||||
'chapo' => $object->getChapo(),
|
||||
'description' => $object->getDescription(),
|
||||
'postscriptum' => $object->getPostscriptum(),
|
||||
'visible' => $object->getVisible(),
|
||||
'url' => $object->getRewrittenUrl($this->getCurrentEditionLocale()),
|
||||
'parent' => $object->getParent()
|
||||
);
|
||||
|
||||
// Setup the object form
|
||||
return new ContentModificationForm($this->getRequest(), "form", $data);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -185,6 +185,26 @@ final class TheliaEvents
|
||||
const BEFORE_UPDATEFOLDER = "action.before_updateFolder";
|
||||
const AFTER_UPDATEFOLDER = "action.after_updateFolder";
|
||||
|
||||
// -- content management -----------------------------------------------
|
||||
|
||||
const CONTENT_CREATE = "action.createFolder";
|
||||
const CONTENT_UPDATE = "action.updateFolder";
|
||||
const CONTENT_DELETE = "action.deleteFolder";
|
||||
const CONTENT_TOGGLE_VISIBILITY = "action.toggleFolderVisibility";
|
||||
const CONTENT_UPDATE_POSITION = "action.updateFolderPosition";
|
||||
|
||||
// const FOLDER_ADD_CONTENT = "action.categoryAddContent";
|
||||
// const FOLDER_REMOVE_CONTENT = "action.categoryRemoveContent";
|
||||
|
||||
const BEFORE_CREATECONTENT = "action.before_createFolder";
|
||||
const AFTER_CREATECONTENT = "action.after_createFolder";
|
||||
|
||||
const BEFORE_DELETECONTENT = "action.before_deleteFolder";
|
||||
const AFTER_DELETECONTENT = "action.after_deleteFolder";
|
||||
|
||||
const BEFORE_UPDATECONTENT = "action.before_updateFolder";
|
||||
const AFTER_UPDATECONTENT = "action.after_updateFolder";
|
||||
|
||||
// -- Categories Associated Content ----------------------------------------
|
||||
|
||||
const BEFORE_CREATECATEGORY_ASSOCIATED_CONTENT = "action.before_createCategoryAssociatedContent";
|
||||
|
||||
@@ -27,7 +27,7 @@ use Thelia\Core\Translation\Translator;
|
||||
|
||||
class ContentCreationForm extends BaseForm
|
||||
{
|
||||
protected function buildForm($change_mode = false)
|
||||
protected function buildForm()
|
||||
{
|
||||
$this->formBuilder
|
||||
->add("title", "text", array(
|
||||
|
||||
61
core/lib/Thelia/Form/ContentModificationForm.php
Normal file
61
core/lib/Thelia/Form/ContentModificationForm.php
Normal file
@@ -0,0 +1,61 @@
|
||||
<?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;
|
||||
use Thelia\Core\Translation\Translator;
|
||||
use Thelia\Form\StandardDescriptionFieldsTrait;
|
||||
|
||||
/**
|
||||
* Class ContentModificationForm
|
||||
* @package Thelia\Form
|
||||
* @author manuel raynaud <mraynaud@openstudio.fr>
|
||||
*/
|
||||
class ContentModificationForm extends ContentCreationForm {
|
||||
use StandardDescriptionFieldsTrait;
|
||||
|
||||
protected function buildForm()
|
||||
{
|
||||
parent::buildForm();
|
||||
|
||||
$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" => "rewritten_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_content_modification";
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,7 @@ class FolderModificationForm extends FolderCreationForm
|
||||
|
||||
protected function buildForm()
|
||||
{
|
||||
parent::buildForm(true);
|
||||
parent::buildForm();
|
||||
|
||||
$this->formBuilder
|
||||
->add("id", "hidden", array("constraints" => array(new GreaterThan(array('value' => 0)))))
|
||||
|
||||
Reference in New Issue
Block a user