Commit c01bfd09 authored by Jean-Philippe Metivier's avatar Jean-Philippe Metivier
Browse files

renommage Content en Template

parent 720e1227
-- TABLE DES MACROS
create table unicaen_renderer_macro
(
id serial not null constraint unicaen_renderer_macro_pk primary key,
code varchar(256) not null,
description text,
variable_name varchar(256) not null,
methode_name varchar(256) not null,
histo_creation timestamp not null,
histo_createur_id integer not null constraint unicaen_renderer_macro_user_id_fk references "user",
histo_modification timestamp not null,
histo_modificateur_id integer not null constraint unicaen_renderer_macro_user_id_fk_2 references "user",
histo_destruction timestamp,
histo_destructeur_id integer constraint unicaen_renderer_macro_user_id_fk_3 references "user"
);
create unique index unicaen_renderer_macro_id_uindex on unicaen_renderer_macro (id);
create unique index unicaen_renderer_macro_code_uindex on unicaen_renderer_macro (code);
-- TABLE DES CONTENUS
create table unicaen_renderer_content
(
id serial not null constraint unicaen_content_content_pk primary key,
code varchar(256) not null,
description text,
renderer_type varchar(256) not null,
renderer_complement text not null,
renderer_content text not null,
histo_creation timestamp not null,
histo_createur_id integer not null constraint unicaen_content_content_user_id_fk references "user",
histo_modification timestamp not null,
histo_modificateur_id integer not null constraint unicaen_content_content_user_id_fk_2 references "user",
histo_destruction timestamp,
histo_destructeur_id integer constraint unicaen_content_content_user_id_fk_3 references "user"
);
create unique index unicaen_content_content_id_uindex on unicaen_renderer_content (id);
create unique index unicaen_content_content_code_uindex on unicaen_renderer_content (code);
INSERT INTO public.unicaen_privilege_categorie (code, libelle, ordre, namespace)
VALUES ('documentcontent', 'UnicaenDocument - Gestion des contenus', 11020, 'UnicaenRenderer\\Provider\\Privilege');
\ No newline at end of file
<?php
use UnicaenRenderer\Controller\ContenuController;
use UnicaenRenderer\Controller\ContenuControllerFactory;
use UnicaenRenderer\Form\Contenu\ContenuForm;
use UnicaenRenderer\Form\Contenu\ContenuFormFactory;
use UnicaenRenderer\Form\Contenu\ContenuHydrator;
use UnicaenRenderer\Form\Contenu\ContenuHydratorFactory;
use UnicaenRenderer\Controller\TemplateController;
use UnicaenRenderer\Controller\TemplateControllerFactory;
use UnicaenRenderer\Form\Template\TemplateForm;
use UnicaenRenderer\Form\Template\TemplateFormFactory;
use UnicaenRenderer\Form\Template\TemplateHydrator;
use UnicaenRenderer\Form\Template\TemplateHydratorFactory;
use UnicaenRenderer\Provider\Privilege\DocumentcontentPrivileges;
use UnicaenRenderer\Service\Contenu\ContenuService;
use UnicaenRenderer\Service\Contenu\ContenuServiceFactory;
use UnicaenRenderer\Service\Template\TemplateService;
use UnicaenRenderer\Service\Template\TemplateServiceFactory;
use UnicaenPrivilege\Guard\PrivilegeController;
use Zend\Router\Http\Literal;
use Zend\Router\Http\Segment;
......@@ -18,7 +18,7 @@ return [
'guards' => [
PrivilegeController::class => [
[
'controller' => ContenuController::class,
'controller' => TemplateController::class,
'action' => [
'index',
'afficher',
......@@ -28,7 +28,7 @@ return [
],
],
[
'controller' => ContenuController::class,
'controller' => TemplateController::class,
'action' => [
'ajouter',
],
......@@ -37,7 +37,7 @@ return [
],
],
[
'controller' => ContenuController::class,
'controller' => TemplateController::class,
'action' => [
'modifier',
],
......@@ -46,7 +46,7 @@ return [
],
],
[
'controller' => ContenuController::class,
'controller' => TemplateController::class,
'action' => [
'historiser',
'restaurer',
......@@ -56,7 +56,7 @@ return [
],
],
[
'controller' => ContenuController::class,
'controller' => TemplateController::class,
'action' => [
'detruire',
],
......@@ -77,9 +77,9 @@ return [
'contenu' => [
'pages' => [
'contenu' => [
'label' => 'Contenu',
'route' => 'contenu/contenu',
'resource' => PrivilegeController::getResourceId(ContenuController::class, 'index'),
'label' => 'Template',
'route' => 'contenu/template',
'resource' => PrivilegeController::getResourceId(TemplateController::class, 'index'),
'order' => 10001,
],
],
......@@ -98,9 +98,9 @@ return [
'contenu' => [
'type' => Literal::class,
'options' => [
'route' => '/contenu',
'route' => '/template',
'defaults' => [
'controller' => ContenuController::class,
'controller' => TemplateController::class,
'action' => 'index',
],
],
......@@ -109,9 +109,9 @@ return [
'afficher' => [
'type' => Segment::class,
'options' => [
'route' => '/afficher/:contenu',
'route' => '/afficher/:template',
'defaults' => [
'controller' => ContenuController::class,
'controller' => TemplateController::class,
'action' => 'afficher',
],
],
......@@ -121,7 +121,7 @@ return [
'options' => [
'route' => '/ajouter',
'defaults' => [
'controller' => ContenuController::class,
'controller' => TemplateController::class,
'action' => 'ajouter',
],
],
......@@ -129,9 +129,9 @@ return [
'modifier' => [
'type' => Segment::class,
'options' => [
'route' => '/modifier/:contenu',
'route' => '/modifier/:template',
'defaults' => [
'controller' => ContenuController::class,
'controller' => TemplateController::class,
'action' => 'modifier',
],
],
......@@ -139,9 +139,9 @@ return [
'restaurer' => [
'type' => Segment::class,
'options' => [
'route' => '/restaurer/:contenu',
'route' => '/restaurer/:template',
'defaults' => [
'controller' => ContenuController::class,
'controller' => TemplateController::class,
'action' => 'restaurer',
],
],
......@@ -149,9 +149,9 @@ return [
'historiser' => [
'type' => Segment::class,
'options' => [
'route' => '/historiser/:contenu',
'route' => '/historiser/:template',
'defaults' => [
'controller' => ContenuController::class,
'controller' => TemplateController::class,
'action' => 'historiser',
],
],
......@@ -159,9 +159,9 @@ return [
'detruire' => [
'type' => Segment::class,
'options' => [
'route' => '/detruire/:contenu',
'route' => '/detruire/:template',
'defaults' => [
'controller' => ContenuController::class,
'controller' => TemplateController::class,
'action' => 'detruire',
],
],
......@@ -175,22 +175,22 @@ return [
'service_manager' => [
'factories' => [
ContenuService::class => ContenuServiceFactory::class,
TemplateService::class => TemplateServiceFactory::class,
],
],
'form_elements' => [
'factories' => [
ContenuForm::class => ContenuFormFactory::class,
TemplateForm::class => TemplateFormFactory::class,
],
],
'hydrators' => [
'factories' => [
ContenuHydrator::class => ContenuHydratorFactory::class,
TemplateHydrator::class => TemplateHydratorFactory::class,
],
],
'controllers' => [
'factories' => [
ContenuController::class => ContenuControllerFactory::class,
TemplateController::class => TemplateControllerFactory::class,
]
],
];
......@@ -2,59 +2,59 @@
namespace UnicaenRenderer\Controller;
use UnicaenRenderer\Entity\Db\Content;
use UnicaenRenderer\Form\Contenu\ContenuFormAwareTrait;
use UnicaenRenderer\Service\Contenu\ContenuServiceAwareTrait;
use UnicaenRenderer\Entity\Db\Template;
use UnicaenRenderer\Form\Template\TemplateFormAwareTrait;
use UnicaenRenderer\Service\Template\TemplateServiceAwareTrait;
use UnicaenRenderer\Service\Macro\MacroServiceAwareTrait;
use Zend\Http\Request;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
class ContenuController extends AbstractActionController {
use ContenuServiceAwareTrait;
class TemplateController extends AbstractActionController {
use TemplateServiceAwareTrait;
use MacroServiceAwareTrait;
use ContenuFormAwareTrait;
use TemplateFormAwareTrait;
public function indexAction()
{
$contenus = $this->getContenuService()->getContenus();
$templates = $this->getTemplateService()->getTemplates();
return new ViewModel([
'contenus' => $contenus,
'templates' => $templates,
]);
}
public function afficherAction()
{
$contenu = $this->getContenuService()->getRequestedContenu($this);
$template = $this->getTemplateService()->getRequestedTemplate($this);
return new ViewModel([
'title' => "Affichage du contenu",
'contenu' => $contenu,
'title' => "Affichage du template",
'contenu' => $template,
]);
}
public function ajouterAction()
{
$contenu = new Content();
$template = new Template();
$form = $this->getContenuForm();
$form->setAttribute('action', $this->url()->fromRoute('contenu/contenu/ajouter', [], [], true));
$form->bind($contenu);
$form = $this->getTemplateForm();
$form->setAttribute('action', $this->url()->fromRoute('contenu/template/ajouter', [], [], true));
$form->bind($template);
$request = $this->getRequest();
if ($request->isPost()) {
$data = $request->getPost();
$form->setData($data);
if ($form->isValid()) {
$this->getContenuService()->create($contenu);
$this->getTemplateService()->create($template);
}
}
$vm = new ViewModel();
$vm->setTemplate('unicaen-renderer/contenu/modifier');
$vm->setTemplate('unicaen-renderer/template/modifier');
$vm->setVariables([
'title' => "Création d'un contenu",
'title' => "Création d'un template",
'form' => $form,
]);
return $vm;
......@@ -62,64 +62,64 @@ class ContenuController extends AbstractActionController {
public function modifierAction()
{
$contenu = $this->getContenuService()->getRequestedContenu($this);
$template = $this->getTemplateService()->getRequestedTemplate($this);
$form = $this->getContenuForm();
$form->setAttribute('action', $this->url()->fromRoute('contenu/contenu/modifier', ['contenu' => $contenu->getId()], [], true));
$form->bind($contenu);
$form = $this->getTemplateForm();
$form->setAttribute('action', $this->url()->fromRoute('contenu/template/modifier', ['template' => $template->getId()], [], true));
$form->bind($template);
$request = $this->getRequest();
if ($request->isPost()) {
$data = $request->getPost();
$form->setData($data);
if ($form->isValid()) {
$this->getContenuService()->update($contenu);
$this->getTemplateService()->update($template);
}
}
return new ViewModel([
'title' => "Modification d'un contenu",
'title' => "Modification d'un template",
'form' => $form,
]);
}
public function historiserAction()
{
$contenu = $this->getContenuService()->getRequestedContenu($this);
$this->getContenuService()->historise($contenu);
$template = $this->getTemplateService()->getRequestedTemplate($this);
$this->getTemplateService()->historise($template);
return $this->redirect()->toRoute('contenu/contenu', [], [], true);
return $this->redirect()->toRoute('contenu/template', [], [], true);
}
public function restaurerAction()
{
$contenu = $this->getContenuService()->getRequestedContenu($this);
$this->getContenuService()->restore($contenu);
$template = $this->getTemplateService()->getRequestedTemplate($this);
$this->getTemplateService()->restore($template);
return $this->redirect()->toRoute('contenu/contenu', [], [], true);
return $this->redirect()->toRoute('contenu/template', [], [], true);
}
public function detruireAction()
{
$contenu = $this->getContenuService()->getRequestedContenu($this);
$template = $this->getTemplateService()->getRequestedTemplate($this);
/** @var Request $request */
$request = $this->getRequest();
if ($request->isPost()) {
$data = $request->getPost();
if ($data["reponse"] === "oui") {
$this->getContenuService()->delete($contenu);
$this->getTemplateService()->delete($template);
}
exit();
}
$vm = new ViewModel();
if ($contenu !== null) {
if ($template !== null) {
$vm->setTemplate('unicaen-renderer/default/confirmation');
$vm->setVariables([
'title' => "Suppression du contenu [" . $contenu->getCode() . "]",
'title' => "Suppression du template [" . $template->getCode() . "]",
'text' => "La suppression est définitive êtes-vous sûr&middot;e de vouloir continuer ?",
'action' => $this->url()->fromRoute('contenu/contenu/detruire', ["contenu" => $contenu->getId()], [], true),
'action' => $this->url()->fromRoute('contenu/template/detruire', ["template" => $template->getId()], [], true),
]);
}
return $vm;
......
......@@ -3,30 +3,30 @@
namespace UnicaenRenderer\Controller;
use Interop\Container\ContainerInterface;
use UnicaenRenderer\Form\Contenu\ContenuForm;
use UnicaenRenderer\Service\Contenu\ContenuService;
use UnicaenRenderer\Form\Template\TemplateForm;
use UnicaenRenderer\Service\Template\TemplateService;
class ContenuControllerFactory {
class TemplateControllerFactory {
/**
* @param ContainerInterface $container
* @return ContenuController
* @return TemplateController
*/
public function __invoke(ContainerInterface $container)
{
/**
* @var ContenuService $contenuService
* @var TemplateService $templateService
*/
$contenuService = $container->get(ContenuService::class);
$templateService = $container->get(TemplateService::class);
/**
* @var ContenuForm $contentForm
* @var TemplateForm $contentForm
*/
$contentForm = $container->get('FormElementManager')->get(ContenuForm::class);
$contentForm = $container->get('FormElementManager')->get(TemplateForm::class);
$controller = new ContenuController();
$controller->setContenuService($contenuService);
$controller->setContenuForm($contentForm);
$controller = new TemplateController();
$controller->setTemplateService($templateService);
$controller->setTemplateForm($contentForm);
return $controller;
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" ?>
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<entity name="UnicaenRenderer\Entity\Db\Content" table="unicaen_renderer_content">
<entity name="UnicaenRenderer\Entity\Db\Template" table="unicaen_renderer_template">
<id name="id" column="id" type="integer">
<generator strategy="IDENTITY"/>
......
......@@ -5,7 +5,7 @@ namespace UnicaenRenderer\Entity\Db;
use UnicaenUtilisateur\Entity\HistoriqueAwareInterface;
use UnicaenUtilisateur\Entity\HistoriqueAwareTrait;
class Content implements HistoriqueAwareInterface {
class Template implements HistoriqueAwareInterface {
use HistoriqueAwareTrait;
const TYPE_TXT = 'texte';
......@@ -37,9 +37,9 @@ class Content implements HistoriqueAwareInterface {
/**
* @param int $id
* @return Content
* @return Template
*/
public function setId(int $id) : Content
public function setId(int $id) : Template
{
$this->id = $id;
return $this;
......@@ -55,9 +55,9 @@ class Content implements HistoriqueAwareInterface {
/**
* @param string|null $code
* @return Content
* @return Template
*/
public function setCode(?string $code) : Content
public function setCode(?string $code) : Template
{
$this->code = $code;
return $this;
......@@ -73,9 +73,9 @@ class Content implements HistoriqueAwareInterface {
/**
* @param string|null $description
* @return Content
* @return Template
*/
public function setDescription(?string $description) : Content
public function setDescription(?string $description) : Template
{
$this->description = $description;
return $this;
......@@ -91,9 +91,9 @@ class Content implements HistoriqueAwareInterface {
/**
* @param string|null $type
* @return Content
* @return Template
*/
public function setType(?string $type) : Content
public function setType(?string $type) : Template
{
$this->type = $type;
return $this;
......@@ -109,9 +109,9 @@ class Content implements HistoriqueAwareInterface {
/**
* @param string|null $complement
* @return Content
* @return Template
*/
public function setComplement(?string $complement) : Content
public function setComplement(?string $complement) : Template
{
$this->complement = $complement;
return $this;
......@@ -120,16 +120,16 @@ class Content implements HistoriqueAwareInterface {
/**
* @return string
*/
public function getContent() : ?string
public function getTemplate() : ?string
{
return $this->content;
}
/**
* @param string|null $content
* @return Content
* @return Template
*/
public function setContent(?string $content) : Content
public function setTemplate(?string $content) : Template
{
$this->content = $content;
return $this;
......@@ -145,9 +145,9 @@ class Content implements HistoriqueAwareInterface {
/**
* @param string|null $css
* @return Content
* @return Template
*/
public function setCss(?string $css): Content
public function setCss(?string $css): Template
{
$this->css = $css;
return $this;
......
<?php
namespace UnicaenRenderer\Form\Contenu;
trait ContenuFormAwareTrait {
/** @var ContenuForm */
private $contenuForm;
/**
* @return ContenuForm
*/
public function getContenuForm(): ContenuForm
{
return $this->contenuForm;
}
/**
* @param ContenuForm $contenuForm
* @return ContenuForm
*/
public function setContenuForm(ContenuForm $contenuForm)
{
$this->contenuForm = $contenuForm;
return $this->contenuForm;
}
}
\ No newline at end of file
<?php
namespace UnicaenRenderer\Form\Contenu;
namespace UnicaenRenderer\Form\Template;
use UnicaenApp\Service\EntityManagerAwareTrait;
use UnicaenRenderer\Entity\Db\Content;
use UnicaenRenderer\Entity\Db\Template;
use UnicaenRenderer\Entity\Db\Macro;
use UnicaenRenderer\Service\Macro\MacroServiceAwareTrait;
use Zend\Form\Element\Button;
......@@ -14,7 +14,7 @@ use Zend\Form\Form;
use Zend\InputFilter\Factory;
use Zend\Validator\Callback;
class ContenuForm extends Form {
class TemplateForm extends Form {
use EntityManagerAwareTrait;
use MacroServiceAwareTrait;
......@@ -51,9 +51,9 @@ class ContenuForm extends Form {
'label' => 'Type * : ',
'empty_option' => "Sélectionner un type de contenu",
'value_options' => [
Content::TYPE_PDF => "Fichier PDF",
Content::TYPE_TXT => "Contenu textuel",
Content::TYPE_MAIL => "Courrier électronique",
Template::TYPE_PDF => "Fichier PDF",
Template::