Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
lib
unicaen
renderer
Commits
c1c795a5
Commit
c1c795a5
authored
Sep 17, 2021
by
Jean-Philippe Metivier
Browse files
Renommage
parent
a66b5e2c
Changes
39
Hide whitespace changes
Inline
Side-by-side
src/UnicaenRenderer/Controller/ContenuController.php
0 → 100755
View file @
c1c795a5
<?php
namespace
UnicaenRenderer\Controller
;
use
UnicaenRenderer\Entity\Db\Content
;
use
UnicaenRenderer\Form\Contenu\ContenuFormAwareTrait
;
use
UnicaenRenderer\Service\Contenu\ContenuServiceAwareTrait
;
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
;
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-renderer/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
(
'unicaen-renderer/default/confirmation'
);
$vm
->
setVariables
([
'title'
=>
"Suppression du contenu ["
.
$contenu
->
getCode
()
.
"]"
,
'text'
=>
"La suppression est définitive êtes-vous sûr·e de vouloir continuer ?"
,
'action'
=>
$this
->
url
()
->
fromRoute
(
'contenu/contenu/detruire'
,
[
"contenu"
=>
$contenu
->
getId
()],
[],
true
),
]);
}
return
$vm
;
}
}
\ No newline at end of file
src/UnicaenRenderer/Controller/ContenuControllerFactory.php
0 → 100755
View file @
c1c795a5
<?php
namespace
UnicaenRenderer\Controller
;
use
Interop\Container\ContainerInterface
;
use
UnicaenRenderer\Form\Contenu\ContenuForm
;
use
UnicaenRenderer\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
src/UnicaenRenderer/Controller/IndexController.php
0 → 100755
View file @
c1c795a5
<?php
namespace
UnicaenRenderer\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
src/UnicaenRenderer/Controller/IndexControllerFactory.php
0 → 100755
View file @
c1c795a5
<?php
namespace
UnicaenRenderer\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
src/UnicaenRenderer/Controller/MacroController.php
0 → 100755
View file @
c1c795a5
<?php
namespace
UnicaenRenderer\Controller
;
use
Application\Service\Agent\AgentServiceAwareTrait
;
use
UnicaenRenderer\Entity\Db\Macro
;
use
UnicaenRenderer\Form\Macro\MacroFormAwareTrait
;
use
UnicaenRenderer\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-renderer/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-renderer/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-renderer/default/confirmation'
);
$vm
->
setVariables
([
'title'
=>
"Suppression de la macro "
.
$macro
->
getCode
(),
'text'
=>
"La suppression est définitive êtes-vous sûr·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
src/UnicaenRenderer/Controller/MacroControllerFactory.php
0 → 100755
View file @
c1c795a5
<?php
namespace
UnicaenRenderer\Controller
;
use
Application\Service\Agent\AgentService
;
use
Interop\Container\ContainerInterface
;
use
UnicaenRenderer\Form\Macro\MacroForm
;
use
UnicaenRenderer\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
src/UnicaenRenderer/Entity/Db/Content.php
0 → 100755
View file @
c1c795a5
<?php
namespace
UnicaenRenderer\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
;
}
/**
* @param string|null $complement
* @return Content
*/
public
function
setComplement
(
?string
$complement
)
:
Content
{
$this
->
complement
=
$complement
;
return
$this
;
}
/**
* @return string
*/
public
function
getContent
()
:
?string
{
return
$this
->
content
;
}
/**
* @param string|null $content
* @return Content
*/
public
function
setContent
(
?string
$content
)
:
Content
{
$this
->
content
=
$content
;
return
$this
;
}
/**
* @return string|null
*/
public
function
getCss
():
?string
{
return
$this
->
css
;
}
/**
* @param string|null $css
* @return Content
*/
public
function
setCss
(
?string
$css
):
Content
{
$this
->
css
=
$css
;
return
$this
;
}
}
\ No newline at end of file
src/UnicaenRenderer/Entity/Db/Macro.php
0 → 100755
View file @
c1c795a5
<?php
namespace
UnicaenRenderer\Entity\Db
;
use
UnicaenUtilisateur\Entity\HistoriqueAwareInterface
;
use
UnicaenUtilisateur\Entity\HistoriqueAwareTrait
;
class
Macro
implements
HistoriqueAwareInterface
{
use
HistoriqueAwareTrait
;
/** @var integer */
private
$id
;
/** @var string */
private
$code
;
/** @var string */
private
$variable
;
/** @var string */
private
$description
;
/** @var string */
private
$methode
;
/**
* @return int
*/
public
function
getId
()
:
int
{
return
$this
->
id
;
}
/**
* @return string
*/
public
function
getCode
()
:
?string
{
return
$this
->
code
;
}
/**
* @param string|null $code
* @return Macro
*/
public
function
setCode
(
?string
$code
)
:
Macro
{
$this
->
code
=
$code
;
return
$this
;
}
/**
* @return string
*/
public
function
getVariable
()
{
return
$this
->
variable
;
}
/**
* @param string $variable
* @return Macro
*/
public
function
setVariable
(
$variable
)
:
Macro
{
$this
->
variable
=
$variable
;
return
$this
;
}
/**
* @return string
*/
public
function
getDescription
()
:
?string
{
return
$this
->
description
;
}
/**
* @param string|null $description