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

Suppression

parent c1c795a5
<?php
namespace UnicaenDocument;
namespace UnicaenRenderer;
use Zend\Mvc\ModuleRouteListener;
use Zend\Mvc\MvcEvent;
......
......@@ -14,7 +14,6 @@
},
"autoload": {
"psr-0": {
"UnicaenUtilisateurLdapAdapter": "src/"
},
"classmap": [
"./Module.php"
......
<?php
use UnicaenDocument\Controller\ContenuController;
use UnicaenDocument\Controller\ContenuControllerFactory;
use UnicaenDocument\Form\Contenu\ContenuForm;
use UnicaenDocument\Form\Contenu\ContenuFormFactory;
use UnicaenDocument\Form\Contenu\ContenuHydrator;
use UnicaenDocument\Form\Contenu\ContenuHydratorFactory;
use UnicaenDocument\Provider\Privilege\DocumentcontentPrivileges;
use UnicaenDocument\Service\Contenu\ContenuService;
use UnicaenDocument\Service\Contenu\ContenuServiceFactory;
use UnicaenDocument\Service\Exporter\ExporterService;
use UnicaenDocument\Service\Exporter\ExporterServiceFactory;
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\Provider\Privilege\DocumentcontentPrivileges;
use UnicaenRenderer\Service\Contenu\ContenuService;
use UnicaenRenderer\Service\Contenu\ContenuServiceFactory;
use UnicaenPrivilege\Guard\PrivilegeController;
use Zend\Router\Http\Literal;
use Zend\Router\Http\Segment;
......@@ -178,7 +176,6 @@ return [
'service_manager' => [
'factories' => [
ContenuService::class => ContenuServiceFactory::class,
ExporterService::class => ExporterServiceFactory::class,
],
],
'form_elements' => [
......
<?php
use UnicaenDocument\Controller\IndexController;
use UnicaenDocument\Controller\IndexControllerFactory;
use UnicaenDocument\Provider\Privilege\DocumentcontentPrivileges;
use UnicaenDocument\Provider\Privilege\DocumentmacroPrivileges;
use UnicaenRenderer\Controller\IndexController;
use UnicaenRenderer\Controller\IndexControllerFactory;
use UnicaenRenderer\Provider\Privilege\DocumentcontentPrivileges;
use UnicaenRenderer\Provider\Privilege\DocumentmacroPrivileges;
use UnicaenPrivilege\Guard\PrivilegeController;
use Zend\Router\Http\Literal;
......
<?php
use UnicaenDocument\Controller\MacroController;
use UnicaenDocument\Controller\MacroControllerFactory;
use UnicaenDocument\Form\Macro\MacroForm;
use UnicaenDocument\Form\Macro\MacroFormFactory;
use UnicaenDocument\Form\Macro\MacroHydrator;
use UnicaenDocument\Form\Macro\MacroHydratorFactory;
use UnicaenDocument\Provider\Privilege\DocumentmacroPrivileges;
use UnicaenDocument\Service\Macro\MacroService;
use UnicaenDocument\Service\Macro\MacroServiceFactory;
use UnicaenRenderer\Controller\MacroController;
use UnicaenRenderer\Controller\MacroControllerFactory;
use UnicaenRenderer\Form\Macro\MacroForm;
use UnicaenRenderer\Form\Macro\MacroFormFactory;
use UnicaenRenderer\Form\Macro\MacroHydrator;
use UnicaenRenderer\Form\Macro\MacroHydratorFactory;
use UnicaenRenderer\Provider\Privilege\DocumentmacroPrivileges;
use UnicaenRenderer\Service\Macro\MacroService;
use UnicaenRenderer\Service\Macro\MacroServiceFactory;
use UnicaenPrivilege\Guard\PrivilegeController;
use Zend\Router\Http\Literal;
use Zend\Router\Http\Segment;
......
......@@ -9,14 +9,14 @@ return [
'orm_default' => [
'class' => MappingDriverChain::class,
'drivers' => [
'UnicaenDocument\Entity\Db' => 'orm_default_xml_driver',
'UnicaenRenderer\Entity\Db' => 'orm_default_xml_driver',
],
],
'orm_default_xml_driver' => [
'class' => XmlDriver::class,
'cache' => 'apc',
'paths' => [
__DIR__ . '/../src/UnicaenDocument/Entity/Db/Mapping',
__DIR__ . '/../src/UnicaenRenderer/Entity/Db/Mapping',
],
],
],
......
Module Unicaen Renderer
=======================
Le module **unicaen/renderer** est en charge du stockage des templates et des macros associées.
Deux tables sont utilisées pour stocker les données :
- unicaen_renderer_content
- unicaen_renderer_macro
Les scripts associées à la création est trouvable dans ModuleRenderer\Entity\SQL\001_table.sql
\ No newline at end of file
<?php
namespace UnicaenDocument\Controller;
use UnicaenDocument\Entity\Db\Content;
use UnicaenDocument\Form\Contenu\ContenuFormAwareTrait;
use UnicaenDocument\Service\Contenu\ContenuServiceAwareTrait;
use UnicaenDocument\Service\Macro\MacroServiceAwareTrait;
use Zend\Http\Request;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
class ContenuController extends AbstractActionController {
use ContenuServiceAwareTrait;
use MacroServiceAwareTrait;
use ContenuFormAwareTrait;
public function indexAction()
{
$contenus = $this->getContenuService()->getContenus();
return new ViewModel([
'contenus' => $contenus,
]);
}
public function afficherAction()
{
$contenu = $this->getContenuService()->getRequestedContenu($this);
return new ViewModel([
'title' => "Affichage du contenu",
'contenu' => $contenu,
]);
}
public function ajouterAction()
{
$contenu = new Content();
$form = $this->getContenuForm();
$form->setAttribute('action', $this->url()->fromRoute('contenu/contenu/ajouter', [], [], true));
$form->bind($contenu);
$request = $this->getRequest();
if ($request->isPost()) {
$data = $request->getPost();
$form->setData($data);
if ($form->isValid()) {
$this->getContenuService()->create($contenu);
}
}
$vm = new ViewModel();
$vm->setTemplate('unicaen-document/contenu/modifier');
$vm->setVariables([
'title' => "Création d'un contenu",
'form' => $form,
]);
return $vm;
}
public function modifierAction()
{
$contenu = $this->getContenuService()->getRequestedContenu($this);
$form = $this->getContenuForm();
$form->setAttribute('action', $this->url()->fromRoute('contenu/contenu/modifier', ['contenu' => $contenu->getId()], [], true));
$form->bind($contenu);
$request = $this->getRequest();
if ($request->isPost()) {
$data = $request->getPost();
$form->setData($data);
if ($form->isValid()) {
$this->getContenuService()->update($contenu);
}
}
return new ViewModel([
'title' => "Modification d'un contenu",
'form' => $form,
]);
}
public function historiserAction()
{
$contenu = $this->getContenuService()->getRequestedContenu($this);
$this->getContenuService()->historise($contenu);
return $this->redirect()->toRoute('contenu/contenu', [], [], true);
}
public function restaurerAction()
{
$contenu = $this->getContenuService()->getRequestedContenu($this);
$this->getContenuService()->restore($contenu);
return $this->redirect()->toRoute('contenu/contenu', [], [], true);
}
public function detruireAction()
{
$contenu = $this->getContenuService()->getRequestedContenu($this);
/** @var Request $request */
$request = $this->getRequest();
if ($request->isPost()) {
$data = $request->getPost();
if ($data["reponse"] === "oui") {
$this->getContenuService()->delete($contenu);
}
exit();
}
$vm = new ViewModel();
if ($contenu !== null) {
$vm->setTemplate('application/default/confirmation');
$vm->setVariables([
'title' => "Suppression du contenu [" . $contenu->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),
]);
}
return $vm;
}
}
\ No newline at end of file
<?php
namespace UnicaenDocument\Controller;
use Interop\Container\ContainerInterface;
use UnicaenDocument\Form\Contenu\ContenuForm;
use UnicaenDocument\Service\Contenu\ContenuService;
class ContenuControllerFactory {
/**
* @param ContainerInterface $container
* @return ContenuController
*/
public function __invoke(ContainerInterface $container)
{
/**
* @var ContenuService $contenuService
*/
$contenuService = $container->get(ContenuService::class);
/**
* @var ContenuForm $contentForm
*/
$contentForm = $container->get('FormElementManager')->get(ContenuForm::class);
$controller = new ContenuController();
$controller->setContenuService($contenuService);
$controller->setContenuForm($contentForm);
return $controller;
}
}
\ No newline at end of file
<?php
namespace UnicaenDocument\Controller;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
class IndexController extends AbstractActionController {
public function indexAction()
{
return new ViewModel();
}
}
\ No newline at end of file
<?php
namespace UnicaenDocument\Controller;
use Interop\Container\ContainerInterface;
class IndexControllerFactory {
/**
* @param ContainerInterface $container
* @return IndexController
*/
public function __invoke(ContainerInterface $container)
{
$controller = new IndexController();
return $controller;
}
}
\ No newline at end of file
<?php
namespace UnicaenDocument\Controller;
use Application\Service\Agent\AgentServiceAwareTrait;
use UnicaenDocument\Entity\Db\Macro;
use UnicaenDocument\Form\Macro\MacroFormAwareTrait;
use UnicaenDocument\Service\Macro\MacroServiceAwareTrait;
use Zend\Http\Request;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
class MacroController extends AbstractActionController {
use MacroServiceAwareTrait;
use MacroFormAwareTrait;
public function indexAction() {
$macrosAll = $this->getMacroService()->getMacros();
$variable = $this->params()->fromQuery('variable');
$macros = [];
$variables = [];
foreach ($macrosAll as $macro) {
$variables[$macro->getVariable()] = $macro->getVariable();
if ($variable === null OR $variable ==='' OR $macro->getVariable() === $variable) {
$macros[] = $macro;
}
}
return new ViewModel([
'macros' => $macros,
'variables' => $variables,
'variable' => $variable,
]);
}
public function ajouterAction() {
$macro = new Macro();
$form = $this->getMacroForm();
$form->setAttribute('action', $this->url()->fromRoute('contenu/macro/ajouter', [], [], true));
$form->bind($macro);
/** @var Request $request */
$request = $this->getRequest();
if ($request->isPost()) {
$data = $request->getPost();
$form->setData($data);
if ($form->isValid()) {
$this->getMacroService()->create($macro);
}
}
$vm = new ViewModel();
$vm->setTemplate('unicaen-document/default/default-form');
$vm->setVariables([
'title' => "Ajout d'une nouvelle macro",
'form' => $form,
]);
return $vm;
}
public function modifierAction() {
$macro = $this->getMacroService()->getRequestedMacro($this);
$form = $this->getMacroForm();
$form->setAttribute('action', $this->url()->fromRoute('contenu/macro/modifier', ['macro' => $macro->getId()], [], true));
$form->bind($macro);
$form->setOldCode($macro->getCode());
/** @var Request $request */
$request = $this->getRequest();
if ($request->isPost()) {
$data = $request->getPost();
$form->setData($data);
if ($form->isValid()) {
$this->getMacroService()->update($macro);
}
}
$vm = new ViewModel();
$vm->setTemplate('unicaen-document/default/default-form');
$vm->setVariables([
'title' => "Modification d'une macro",
'form' => $form,
]);
return $vm;
}
public function historiserAction()
{
$macro = $this->getMacroService()->getRequestedMacro($this);
$this->getMacroService()->historise($macro);
return $this->redirect()->toRoute('contenu/macro', [], [], true);
}
public function restaurerAction()
{
$macro = $this->getMacroService()->getRequestedMacro($this);
$this->getMacroService()->restore($macro);
return $this->redirect()->toRoute('contenu/macro', [], [], true);
}
public function supprimerAction()
{
$macro = $this->getMacroService()->getRequestedMacro($this);
/** @var Request $request */
$request = $this->getRequest();
if ($request->isPost()) {
$data = $request->getPost();
if ($data["reponse"] === "oui") $this->getMacroService()->delete($macro);
exit();
}
$vm = new ViewModel();
if ($macro !== null) {
$vm->setTemplate('unicaen-document/default/confirmation');
$vm->setVariables([
'title' => "Suppression de la macro " . $macro->getCode(),
'text' => "La suppression est définitive êtes-vous sûr&middot;e de vouloir continuer ?",
'action' => $this->url()->fromRoute('contenu/macro/supprimer', ["macro" => $macro->getId()], [], true),
]);
}
return $vm;
}
public function genererJsonAction()
{
$json = $this->getMacroService()->generateJSON();
return new ViewModel([
'title' => 'JSON pour tinyMCE',
'json' => $json,
]);
}
}
\ No newline at end of file
<?php
namespace UnicaenDocument\Controller;
use Application\Service\Agent\AgentService;
use Interop\Container\ContainerInterface;
use UnicaenDocument\Form\Macro\MacroForm;
use UnicaenDocument\Service\Macro\MacroService;
class MacroControllerFactory {
/**
* @param ContainerInterface $container
* @return MacroController
*/
public function __invoke(ContainerInterface $container)
{
/**
* @var MacroService $macroService
*/
$macroService = $container->get(MacroService::class);
/**
* @var MacroForm $macroForm
*/
$macroForm = $container->get('FormElementManager')->get(MacroForm::class);
$controller = new MacroController();
$controller->setMacroService($macroService);
$controller->setMacroForm($macroForm);
return $controller;
}
}
\ No newline at end of file
<?php
namespace UnicaenDocument\Entity\Db;
use UnicaenUtilisateur\Entity\HistoriqueAwareInterface;
use UnicaenUtilisateur\Entity\HistoriqueAwareTrait;
class Content implements HistoriqueAwareInterface {
use HistoriqueAwareTrait;
const TYPE_TXT = 'texte';
const TYPE_PDF = 'pdf';
const TYPE_MAIL = 'mail';
/** @var integer */
private $id;
/** @var string */
private $code;
/** @var string */
private $description;
/** @var string */
private $type;
/** @var string */
private $complement;
/** @var string */
private $content;
/** @var string */
private $css;
/**
* @return int
*/
public function getId() : int
{
return $this->id;
}
/**
* @param int $id
* @return Content
*/
public function setId(int $id) : Content
{
$this->id = $id;
return $this;
}
/**
* @return string
*/
public function getCode() : ?string
{
return $this->code;
}
/**
* @param string|null $code
* @return Content
*/
public function setCode(?string $code) : Content
{
$this->code = $code;
return $this;
}
/**
* @return string
*/
public function getDescription() : ?string
{
return $this->description;
}
/**
* @param string|null $description
* @return Content
*/
public function setDescription(?string $description) : Content
{
$this->description = $description;
return $this;
}
/**
* @return string
*/
public function getType() : ?string
{
return $this->type;
}
/**
* @param string|null $type
* @return Content
*/
public function setType(?string $type) : Content
{
$this->type = $type;
return $this;
}
/**
* @return string
*/
public function getComplement() : ?string
{
return $this->complement;
}
/**