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
77a49052
Commit
77a49052
authored
Oct 11, 2021
by
Jean-Philippe Metivier
Browse files
Modification des templates (privileges, form, ...)
parent
f069c6be
Pipeline
#11023
passed with stage
in 21 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/UnicaenRenderer/Form/Template/TemplateForm.php
View file @
77a49052
...
...
@@ -77,7 +77,7 @@ class TemplateForm extends Form {
'name'
=>
'complement'
,
'type'
=>
'textarea'
,
'options'
=>
[
'label'
=>
'
Complément (
nom du fichier, étiquette, ... ) * : '
,
'label'
=>
'
Sujet (sujet du courrier électronique,
nom du fichier, étiquette, ... ) * : '
,
'label_attributes'
=>
[
'class'
=>
'control-label'
,
],
...
...
@@ -92,7 +92,7 @@ class TemplateForm extends Form {
'name'
=>
'template'
,
'type'
=>
'textarea'
,
'options'
=>
[
'label'
=>
'
Template
* : '
,
'label'
=>
'
Corps
* : '
,
'label_attributes'
=>
[
'class'
=>
'control-label'
,
],
...
...
src/UnicaenRenderer/Provider/Privilege/DocumenttemplatePrivileges.php
View file @
77a49052
...
...
@@ -2,15 +2,14 @@
namespace
UnicaenRenderer\Provider\Privilege
;
use
UnicaenPrivilege\Entity\Db\Privilege
;
use
UnicaenPrivilege\Provider\Privilege\Privileges
;
class
DocumenttemplatePrivileges
extends
Privileges
{
const
DOCUMENTTEMPLATE_INDEX
=
'document
content
-documenttemplate_index'
;
const
DOCUMENTTEMPLATE_AJOUTER
=
'document
content
-documenttemplate_ajouter'
;
const
DOCUMENTTEMPLATE_AFFICHER
=
'document
content
-documenttemplate_afficher'
;
const
DOCUMENTTEMPLATE_MODIFIER
=
'document
content
-documenttemplate_modifier'
;
const
DOCUMENTTEMPLATE_HISTORISER
=
'document
content
-documenttemplate_historiser'
;
const
DOCUMENTTEMPLATE_SUPPRIMER
=
'document
content
-documenttemplate_supprimer'
;
const
DOCUMENTTEMPLATE_INDEX
=
'document
template
-documenttemplate_index'
;
const
DOCUMENTTEMPLATE_AJOUTER
=
'document
template
-documenttemplate_ajouter'
;
const
DOCUMENTTEMPLATE_AFFICHER
=
'document
template
-documenttemplate_afficher'
;
const
DOCUMENTTEMPLATE_MODIFIER
=
'document
template
-documenttemplate_modifier'
;
const
DOCUMENTTEMPLATE_HISTORISER
=
'document
template
-documenttemplate_historiser'
;
const
DOCUMENTTEMPLATE_SUPPRIMER
=
'document
template
-documenttemplate_supprimer'
;
}
\ No newline at end of file
src/UnicaenRenderer/Service/Contenu/ContenuService.php
View file @
77a49052
...
...
@@ -2,15 +2,20 @@
namespace
UnicaenRenderer\Service\Contenu
;
use
DateTime
;
use
Doctrine\ORM\NonUniqueResultException
;
use
Doctrine\ORM\ORMException
;
use
Doctrine\ORM\QueryBuilder
;
use
UnicaenApp\Exception\RuntimeException
;
use
UnicaenApp\Service\EntityManagerAwareTrait
;
use
UnicaenRenderer\Entity\Db\Contenu
;
use
UnicaenRenderer\Entity\Db\Template
;
use
UnicaenRenderer\Service\Template\TemplateServiceAwareTrait
;
use
Zend\Mvc\Controller\AbstractActionController
;
class
ContenuService
{
use
EntityManagerAwareTrait
;
use
TemplateServiceAwareTrait
;
/** Gestion des entités *******************************************************************************************/
...
...
@@ -112,4 +117,31 @@ class ContenuService {
$result
=
$this
->
getContenu
(
$id
);
return
$result
;
}
/** facade ********************************************************************************************************/
/**
* @param Template|string $template
* @param array $variables
* @return Contenu
*/
public
function
generateContenu
(
$template
,
array
$variables
)
:
Contenu
{
if
(
is_string
(
$template
))
{
$template
=
$this
->
getTemplateService
()
->
getTemplateByCode
(
$template
);
if
(
$template
===
null
)
throw
new
RuntimeException
(
"Aucun template trouvé avec le code ["
.
$template
.
"]"
);
}
$contenu
=
new
Contenu
();
$contenu
->
setTemplate
(
$template
);
$contenu
->
setDate
(
new
DateTime
());
$sujet
=
$this
->
getTemplateService
()
->
generateTitre
(
$template
,
$variables
);
$contenu
->
setSujet
(
$sujet
);
$corps
=
$this
->
getTemplateService
()
->
generateContenu
(
$template
,
$variables
);
$contenu
->
setCorps
(
$corps
);
$this
->
create
(
$contenu
);
return
$contenu
;
}
}
src/UnicaenRenderer/Service/Template/TemplateService.php
View file @
77a49052
...
...
@@ -129,7 +129,7 @@ class TemplateService {
public
function
getTemplate
(
?int
$id
)
:
?Template
{
$qb
=
$this
->
createQueryBuilder
()
->
andWhere
(
'temp
a
lte.id = :id'
)
->
andWhere
(
'templ
a
te.id = :id'
)
->
setParameter
(
'id'
,
$id
)
;
...
...
@@ -157,9 +157,6 @@ class TemplateService {
}
catch
(
NonUniqueResultException
$e
)
{
throw
new
RuntimeException
(
"Plusieurs Template partagent le même code ["
.
$code
.
"]"
);
}
if
(
$result
===
null
)
{
throw
new
RuntimeException
(
"Aucun Template pour le code ["
.
$code
.
"]"
);
}
return
$result
;
}
...
...
view/unicaen-renderer/template/index.phtml
View file @
77a49052
...
...
@@ -2,31 +2,31 @@
/**
* @see \UnicaenRenderer\Controller\ContenuController::indexAction()
* @var
Content[] $contenu
s
* @var
Template[] $template
s
*/
use
UnicaenRenderer\Entity\Db\
Content
;
use
UnicaenRenderer\Provider\Privilege\Document
content
Privileges
;
use
UnicaenRenderer\Entity\Db\
Template
;
use
UnicaenRenderer\Provider\Privilege\Document
template
Privileges
;
$canAjouter
=
$this
->
isAllowed
(
DocumentcontentPrivileges
::
getResourceId
(
DocumentcontentPrivileges
::
DOCUMENTCONTENU_AJOUTER
));
$canAfficher
=
$this
->
isAllowed
(
DocumentcontentPrivileges
::
getResourceId
(
DocumentcontentPrivileges
::
DOCUMENTCONTENU_INDEX
));
$canModifier
=
$this
->
isAllowed
(
DocumentcontentPrivileges
::
getResourceId
(
DocumentcontentPrivileges
::
DOCUMENTCONTENU_MODIFIER
));
$canHistoriser
=
$this
->
isAllowed
(
DocumentcontentPrivileges
::
getResourceId
(
DocumentcontentPrivileges
::
DOCUMENTCONTENU_HISTORISER
));
$canDetruire
=
$this
->
isAllowed
(
DocumentcontentPrivileges
::
getResourceId
(
DocumentcontentPrivileges
::
DOCUMENTCONTENU_SUPPRIMER
));
$this
->
isAllowed
(
null
,
DocumentcontentPrivileges
::
DOCUMENTCONTENU_AJOUTER
);
$canAjouter
=
$this
->
isAllowed
(
DocumenttemplatePrivileges
::
getResourceId
(
DocumenttemplatePrivileges
::
DOCUMENTTEMPLATE_AJOUTER
));
$canAfficher
=
$this
->
isAllowed
(
DocumenttemplatePrivileges
::
getResourceId
(
DocumenttemplatePrivileges
::
DOCUMENTTEMPLATE_AFFICHER
));
$canModifier
=
$this
->
isAllowed
(
DocumenttemplatePrivileges
::
getResourceId
(
DocumenttemplatePrivileges
::
DOCUMENTTEMPLATE_MODIFIER
));
$canHistoriser
=
$this
->
isAllowed
(
DocumenttemplatePrivileges
::
getResourceId
(
DocumenttemplatePrivileges
::
DOCUMENTTEMPLATE_HISTORISER
));
$canDetruire
=
$this
->
isAllowed
(
DocumenttemplatePrivileges
::
getResourceId
(
DocumenttemplatePrivileges
::
DOCUMENTTEMPLATE_SUPPRIMER
));
$this
->
headTitle
(
"Index des
contenu
s"
);
$this
->
headTitle
(
"Index des
template
s"
);
?>
<h1
class=
"page-header"
>
Index des
contenu
s
Index des
template
s
</h1>
<?php
if
(
$canAjouter
)
:
?>
<a
href=
"
<?php
echo
$this
->
url
(
'contenu/contenu/ajouter'
,
[],
[],
true
);
?>
"
<?php
/** @see \UnicaenRenderer\Controller\TemplateController::ajouterAction() */
?>
<a
href=
"
<?php
echo
$this
->
url
(
'contenu/template/ajouter'
,
[],
[],
true
);
?>
"
class=
"btn btn-primary action ajax-modal"
data-event=
"modification"
>
<span
class=
"icon ajouter"
></span>
Ajouter un
contenu
Ajouter un
template
</a>
<?php
endif
;
?>
...
...
@@ -39,43 +39,48 @@ $this->headTitle("Index des contenus");
</tr>
</thead>
<tbody>
<?php
foreach
(
$
contenus
as
$contenu
)
:
?>
<tr
class=
"
<?php
if
(
$
contenu
->
estHistorise
())
echo
'historise '
;
?>
"
>
<?php
foreach
(
$
templates
as
$template
)
:
?>
<tr
class=
"
<?php
if
(
$
template
->
estHistorise
())
echo
'historise '
;
?>
"
>
<td>
<?php
echo
$
contenu
->
getCode
();
?>
<?php
if
(
$
contenu
->
getDescription
()
!==
null
)
:
?>
<span
class=
"icon information"
title=
"
<?php
echo
$
contenu
->
getDescription
();
?>
"
data-toggle=
"tooltip"
data-html=
"true"
></span>
<?php
echo
$
template
->
getCode
();
?>
<?php
if
(
$
template
->
getDescription
()
!==
null
)
:
?>
<span
class=
"icon information"
title=
"
<?php
echo
$
template
->
getDescription
();
?>
"
data-toggle=
"tooltip"
data-html=
"true"
></span>
<?php
endif
;
?>
</td>
<td>
<span
class=
"icon
<?php
echo
$
contenu
->
getType
();
?>
"
></span>
<span
class=
"icon
<?php
echo
$
template
->
getType
();
?>
"
></span>
</td>
<td>
<?php
if
(
$canAfficher
)
:
?>
<a
href=
"
<?php
echo
$this
->
url
(
'contenu/contenu/afficher'
,
[
'contenu'
=>
$contenu
->
getId
()],
[],
true
);
?>
"
<?php
/** @see \UnicaenRenderer\Controller\TemplateController::afficherAction() */
?>
<a
href=
"
<?php
echo
$this
->
url
(
'contenu/template/afficher'
,
[
'template'
=>
$template
->
getId
()],
[],
true
);
?>
"
class=
"ajax-modal"
>
<span
class=
"icon voir"
></span></a>
<?php
endif
;
?>
<?php
if
(
$canModifier
)
:
?>
<a
href=
"
<?php
echo
$this
->
url
(
'contenu/contenu/modifier'
,
[
'contenu'
=>
$contenu
->
getId
()],
[],
true
);
?>
"
<?php
/** @see \UnicaenRenderer\Controller\TemplateController::modifierAction() */
?>
<a
href=
"
<?php
echo
$this
->
url
(
'contenu/template/modifier'
,
[
'template'
=>
$template
->
getId
()],
[],
true
);
?>
"
class=
"ajax-modal"
data-event=
"modification"
>
<span
class=
"icon editer"
></span></a>
<?php
endif
;
?>
<?php
if
(
$canHistoriser
)
:
?>
<?php
if
(
$contenu
->
estNonHistorise
())
:
?>
<a
href=
"
<?php
echo
$this
->
url
(
'contenu/contenu/historiser'
,
[
'contenu'
=>
$contenu
->
getId
()],
[],
true
);
?>
"
<?php
if
(
$template
->
estNonHistorise
())
:
?>
<?php
/** @see \UnicaenRenderer\Controller\TemplateController::historiserAction() */
?>
<a
href=
"
<?php
echo
$this
->
url
(
'contenu/template/historiser'
,
[
'template'
=>
$template
->
getId
()],
[],
true
);
?>
"
>
<span
class=
"icon historiser"
></span></a>
<?php
else
:
?>
<a
href=
"
<?php
echo
$this
->
url
(
'contenu/contenu/restaurer'
,
[
'contenu'
=>
$contenu
->
getId
()],
[],
true
);
?>
"
<?php
/** @see \UnicaenRenderer\Controller\TemplateController::restaurerAction() */
?>
<a
href=
"
<?php
echo
$this
->
url
(
'contenu/template/restaurer'
,
[
'template'
=>
$template
->
getId
()],
[],
true
);
?>
"
>
<span
class=
"icon restaurer"
></span></a>
<?php
endif
;
?>
<?php
endif
;
?>
<?php
if
(
$canDetruire
)
:
?>
<a
href=
"
<?php
echo
$this
->
url
(
'contenu/contenu/detruire'
,
[
'contenu'
=>
$contenu
->
getId
()],
[],
true
);
?>
"
<?php
/** @see \UnicaenRenderer\Controller\TemplateController::detruireAction() */
?>
<a
href=
"
<?php
echo
$this
->
url
(
'contenu/template/detruire'
,
[
'template'
=>
$template
->
getId
()],
[],
true
);
?>
"
class=
"ajax-modal"
data-event=
"modification"
>
<span
class=
"icon detruire"
></span></a>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment