diff --git a/Module.php b/Module.php
index 57d23f5eafb2db536fead5bc071dd272c23e663c..a6f5d607eb114c84f0f6e428b1e40f2afc2f9737 100644
--- a/Module.php
+++ b/Module.php
@@ -17,16 +17,6 @@ class Module
$moduleRouteListener = new ModuleRouteListener();
$moduleRouteListener->attach($eventManager);
- /* Active un layout spécial si la requête est de type AJAX. Valable pour TOUS les modules de l'application. */
- $eventManager->getSharedManager()->attach('Zend\Mvc\Controller\AbstractActionController', 'dispatch',
- function (MvcEvent $e) {
- $request = $e->getRequest();
- if ($request instanceof HttpRequest && $request->isXmlHttpRequest()) {
- $e->getTarget()->layout('layout/ajax.phtml');
- }
- }
- );
-
}
public function getConfig()
diff --git a/src/UnicaenAutoform/Entity/Db/Categorie.php b/src/UnicaenAutoform/Entity/Db/Categorie.php
index c38c5119fb64953a20fc3039ce57b5181262662e..a872ed005a936fa4b04594ed29b7cc5e997e1311 100644
--- a/src/UnicaenAutoform/Entity/Db/Categorie.php
+++ b/src/UnicaenAutoform/Entity/Db/Categorie.php
@@ -5,9 +5,11 @@ namespace UnicaenAutoform\Entity\Db;
use Doctrine\Common\Collections\ArrayCollection;
use UnicaenApp\Entity\HistoriqueAwareInterface;
use UnicaenApp\Entity\HistoriqueAwareTrait;
+use UnicaenAutoform\Entity\HasMotsClefsAwareTrait;
class Categorie implements HistoriqueAwareInterface {
use HistoriqueAwareTrait;
+ use HasMotsClefsAwareTrait;
/** @var integer */
private $id;
diff --git a/src/UnicaenAutoform/Entity/Db/FormulaireInstance.php b/src/UnicaenAutoform/Entity/Db/FormulaireInstance.php
index e77d90df75948b65aee31cfb12ba1d39bf67c365..8ad53cd8d272446f04a03ce4403f06805ef84526 100644
--- a/src/UnicaenAutoform/Entity/Db/FormulaireInstance.php
+++ b/src/UnicaenAutoform/Entity/Db/FormulaireInstance.php
@@ -190,7 +190,12 @@ class FormulaireInstance implements HistoriqueAwareInterface {
public function fetchChampReponseByMotsClefs(array $mots) : string
{
foreach ($this->getReponses() as $reponse) {
- if ($reponse->getChamp()->hasMotsClefs($mots) AND $reponse->estNonHistorise()) return $reponse->getReponse();
+ if ($reponse->getChamp()->hasMotsClefs($mots) AND $reponse->estNonHistorise()) {
+ if ($reponse->getChamp()->getElement() !== 'Multiple') return $reponse->getReponse();
+ else {
+ return str_replace('on_','',$reponse->getReponse());
+ }
+ }
}
return "";
}
diff --git a/src/UnicaenAutoform/Entity/Db/Mapping/UnicaenAutoform.Entity.Db.Categorie.dcm.xml b/src/UnicaenAutoform/Entity/Db/Mapping/UnicaenAutoform.Entity.Db.Categorie.dcm.xml
index a967a26fa3217245af009beca864bcbacdee2042..53ab2f25da54ca72c6e97a6385c05b606c428c53 100644
--- a/src/UnicaenAutoform/Entity/Db/Mapping/UnicaenAutoform.Entity.Db.Categorie.dcm.xml
+++ b/src/UnicaenAutoform/Entity/Db/Mapping/UnicaenAutoform.Entity.Db.Categorie.dcm.xml
@@ -9,6 +9,7 @@
<field name="code" column="code" type="string" length="64" nullable="false" />
<field name="libelle" column="libelle" type="string" length="256" nullable="false" />
<field name="ordre" column="ordre" type="integer" nullable="false" />
+ <field name="motsClefs" column="mots_clefs" type="string" length="1024" nullable="true" />
<many-to-one target-entity="UnicaenAutoform\Entity\Db\Formulaire" field="formulaire">
<join-column name="formulaire" referenced-column-name="id"/>
diff --git a/src/UnicaenAutoform/View/Helper/partial/input/custom.phtml b/src/UnicaenAutoform/View/Helper/partial/input/custom.phtml
index 13b0938fdc01086194abc65c9c6c5cec0446a9bb..8f4902ca98f8f617f24a5b441652c790962d4bcd 100644
--- a/src/UnicaenAutoform/View/Helper/partial/input/custom.phtml
+++ b/src/UnicaenAutoform/View/Helper/partial/input/custom.phtml
@@ -32,7 +32,7 @@ $reponses = explode(';', $reponse);
<?php $found = true; ?>
<input class="form-control" type="text"
id="<?php echo $champ->getId()?>_<?php echo $position; ?>" name="<?php echo $champ->getId()?>_<?php echo $position; ?>"
- value="<?php echo trim($reponses[$position]); ?>"
+ value="<?php echo isset($reponses[$position])?trim($reponses[$position]):null; ?>"
/>
<?php endif; ?>
<?php if ($params[0] === 'texte long') : ?>
@@ -47,7 +47,8 @@ $reponses = explode(';', $reponse);
id="<?php echo $champ->getId(); ?>_<?php echo $position; ?>" name="<?php echo $champ->getId(); ?>_<?php echo $position; ?>"
>
<?php for ($param_position = 2; $param_position < count($params) ; $param_position++) : ?>
- <option value="<?php echo $params[$param_position]; ?>" <?php if ($params[$param_position]===$reponses[$position]) echo " selected "; ?>>
+ <?php $creponse = isset($reponses[$position])?trim($reponses[$position]):null; ?>
+ <option value="<?php echo $params[$param_position]; ?>" <?php if ($params[$param_position]===$creponse) echo " selected "; ?>>
<?php echo $params[$param_position]; ?>
</option>
<?php endfor; ?>
diff --git a/view/unicaen-autoform/formulaire/afficher-formulaire.phtml b/view/unicaen-autoform/formulaire/afficher-formulaire.phtml
index 9df51891e895dbfda9e9d0b900b54ee02365a057..5964fc6d81ad5fdf28d3fe4aeea1d1ffabc04280 100644
--- a/view/unicaen-autoform/formulaire/afficher-formulaire.phtml
+++ b/view/unicaen-autoform/formulaire/afficher-formulaire.phtml
@@ -48,7 +48,9 @@ $a=1;
</div>
<div class="panel-body body-reductible">
<?php foreach ($champs as $champ) : ?>
- <div> <?php echo $this->champAsInput()->render($champ, $reponses); ?> </div>
+ <div>
+ <?php echo $this->champAsInput()->render($champ, $reponses); ?>
+ </div>
<?php endforeach; ?>
</div>
</div>
diff --git a/view/unicaen-autoform/formulaire/modifier.phtml b/view/unicaen-autoform/formulaire/modifier.phtml
index ab3c3f5cba87cc133c164c86dee9b78aeaa9ddb1..9e3afde2358ccd49965e02c31c3da5ef6e36ce1f 100644
--- a/view/unicaen-autoform/formulaire/modifier.phtml
+++ b/view/unicaen-autoform/formulaire/modifier.phtml
@@ -83,6 +83,15 @@ $canDetruireChamp = $this->isAllowed(ChampPrivileges::getResourceId(Ch
<?php if ($categorie->estHistorise()) : ?>
<small>(<?php echo count($categorie->getChamps()); ?> champs)</small>
<?php endif; ?>
+ <br/>
+ <?php
+ $mots = explode(";",$categorie->getMotsClefs());
+ $mots = array_filter($mots, function ($a) { return trim($a) !== '';});
+ ?>
+
+ <?php foreach ($mots as $motclef) : ?>
+ <span class="motclef"> <?php echo $motclef; ?> </span>
+ <?php endforeach; ?>
</div>
<div class="col-md-2">
@@ -157,8 +166,16 @@ $canDetruireChamp = $this->isAllowed(ChampPrivileges::getResourceId(Ch
<div class="row survol">
<div class="col-md-10">
<?php
- echo $this->champAsInput()->render($champ);
+ echo $this->champAsInput()->render($champ);
+ ?>
+ <?php
+ $mots = explode(";",$champ->getMotsClefs());
+ $mots = array_filter($mots, function ($a) { return trim($a) !== '';});
?>
+
+ <?php foreach ($mots as $motclef) : ?>
+ <span class="motclef"> <?php echo $motclef; ?> </span>
+ <?php endforeach; ?>
</div>
<div class="col-md-2">
<?php if ($canModifierChamp) : ?>
@@ -232,4 +249,18 @@ $canDetruireChamp = $this->isAllowed(ChampPrivileges::getResourceId(Ch
window.location.reload();
});
});
-</script>
\ No newline at end of file
+</script>
+
+<style>
+ .motclef {
+ background: lightgrey;
+ color: black;
+ font-family: monospace;
+ border: 1px grey solid;
+ border-radius: 0.5rem;
+ margin-left: 0.5rem;
+ margin-bottom: 0.5rem;
+ padding-left: 1rem;
+ padding-right: 1rem;
+ }
+</style>
\ No newline at end of file