diff --git a/core/lib/Thelia/Controller/Admin/ContentController.php b/core/lib/Thelia/Controller/Admin/ContentController.php index f0abe9a73..78ee63391 100644 --- a/core/lib/Thelia/Controller/Admin/ContentController.php +++ b/core/lib/Thelia/Controller/Admin/ContentController.php @@ -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 */ -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); } /** diff --git a/core/lib/Thelia/Core/Event/TheliaEvents.php b/core/lib/Thelia/Core/Event/TheliaEvents.php index 01c2495f8..346b41c3b 100755 --- a/core/lib/Thelia/Core/Event/TheliaEvents.php +++ b/core/lib/Thelia/Core/Event/TheliaEvents.php @@ -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"; diff --git a/core/lib/Thelia/Form/ContentCreationForm.php b/core/lib/Thelia/Form/ContentCreationForm.php index 8d8c2d1ca..2a4743bf8 100644 --- a/core/lib/Thelia/Form/ContentCreationForm.php +++ b/core/lib/Thelia/Form/ContentCreationForm.php @@ -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( diff --git a/core/lib/Thelia/Form/ContentModificationForm.php b/core/lib/Thelia/Form/ContentModificationForm.php new file mode 100644 index 000000000..38ad4e2cf --- /dev/null +++ b/core/lib/Thelia/Form/ContentModificationForm.php @@ -0,0 +1,61 @@ +. */ +/* */ +/*************************************************************************************/ + +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 + */ +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"; + } +} \ No newline at end of file diff --git a/core/lib/Thelia/Form/FolderModificationForm.php b/core/lib/Thelia/Form/FolderModificationForm.php index e075ea827..0ff90868c 100644 --- a/core/lib/Thelia/Form/FolderModificationForm.php +++ b/core/lib/Thelia/Form/FolderModificationForm.php @@ -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)))))