Ability to Add excluding words to element search

parent 309f7968
v2.3.4
======
* FEATURE: Ability to add excluding words for element search
* FEATURE: Complete reorganisation of user role management. Please update your users & groups roles
* FEATURE: Element import, ability to map ontology and taxonomy
* BUG: Fix list mode
......
......@@ -62,17 +62,8 @@ class ConfigurationMapAdmin extends ConfigurationAbstractAdmin
->add('reportFeature','sonata_type_admin', $featureFormOption, $featureFormTypeOption)->end()
->with('Etiquetter les éléments', $featureStyle)
->add('stampFeature','sonata_type_admin', $featureFormOption, $featureFormTypeOption)->end()
->with('Mode Liste', $featureStyle)
->add('listModeFeature','sonata_type_admin', $featureFormOption, $featureFormTypeOption)->end()
->with("Recherche d'un lieu", $featureStyle)
->add('searchPlaceFeature','sonata_type_admin', $featureFormOption, $featureFormTypeOption)->end()
->with("Bouton geolocalisation", $featureStyle)
->add('searchGeolocateFeature','sonata_type_admin', $featureFormOption, $featureFormTypeOption)->end()
->with("Recherche d'un élément", $featureStyle)
->add('searchElementsFeature','sonata_type_admin', $featureFormOption, $featureFormTypeOption)->end()
->with('Choix du fond de carte', $featureStyle)
->add('layersFeature','sonata_type_admin', $featureFormOption, $featureFormTypeOption)->end()
->with('Revenir à la vue par défault', $featureStyle)
......@@ -82,6 +73,17 @@ class ConfigurationMapAdmin extends ConfigurationAbstractAdmin
->with('Affichage des éléments en attente de validation', $featureStyle)
->add('pendingFeature','sonata_type_admin', $featureFormOption, $featureFormTypeOption)->end()
->end()
->tab('Recherche')
->with("Recherche d'un lieu", $featureStyle)
->add('searchPlaceFeature','sonata_type_admin', $featureFormOption, $featureFormTypeOption)->end()
->with("Bouton geolocalisation", $featureStyle)
->add('searchGeolocateFeature','sonata_type_admin', $featureFormOption, $featureFormTypeOption)->end()
->with("Recherche d'un élément", $featureStyle)
->add('searchElementsFeature','sonata_type_admin', $featureFormOption, $featureFormTypeOption)->end()
->with("Paramètre de la recherche")
->add('searchExcludingWords', null, ['label' => 'Mots à exclure de la recherche, séparés par des virgules', 'label_attr' => ['title' => 'Si vous faites un annuaire de producteurs locaux, vous voudrez peut être exclure les mots comme "bio", car ce genre de recherche donnerait de mauvais résultats. Par exemple si vous cherchez "Ferme du bayou bio", des résultat qui n\'ont rien à voir tel que "Amap bio" sortiraient dans les résultats, juste à cause du mot "bio". De manière générale, excluez les mots communément utilisés dans les titres de vos fiches. Notez que la recherche par titre de la fiche est aussi utilisée dans la détection de doublons']])
->end()
->end()
->tab('Message personnalisé')
->with('Message personnalisé à faire apparaitre dans un coin de la carte', ['class' => 'gogo-feature'])
->add('customPopupFeature','sonata_type_admin', $featureFormOption, $featureFormTypeOption)
......
......@@ -40,7 +40,8 @@ class MigrationCommand extends GoGoAbstractCommand
"Vous pouvez maintenant renseigner la licence qui protège vos données dans Personnalisation -> Configuration Générale",
// v2.3.4
"Amélioration du <b>système d'import</b>: vous pouvez maintenant faire correspondre les champs et les catégories avant d'importer",
"La gestion des permissions des utilisateurs fait peau neuve ! Votre ancienne configuration ne sera <u>peut être plus valide</u>. Veuillez vous rendre dans le <b>menu Utilisateurs pour mettre à jour les roles des utilisateurs et des groupes</b> d'utilisateurs."
"<b>La gestion des permissions des utilisateurs fait peau neuve !</b> Votre ancienne configuration ne sera <u>peut être plus valide</u>. Veuillez vous rendre dans le <b>menu Utilisateurs pour mettre à jour les roles des utilisateurs et des groupes</b> d'utilisateurs.",
"Vous pouvez maintenant configurer des mot clés à exclure dans la recherche des éléments. Rendez-vous dans Personnalisation -> La Carte -> Onglet Recherche"
];
......
......@@ -33,9 +33,9 @@ class Configuration implements \JsonSerializable
/** @MongoDB\Field(type="string") */
protected $appName;
/**
* @MongoDB\Field(type="string")
/**
* @MongoDB\Field(type="string")
* @Gedmo\Slug(fields={"appName"}, updatable=false)
*/
protected $appSlug;
......@@ -71,22 +71,22 @@ class Configuration implements \JsonSerializable
// ----------------------------
// The strings to describe an element of the directory (it can be a "point" an "organization" ...)
/** @MongoDB\Field(type="string") */
/** @MongoDB\Field(type="string") */
protected $elementDisplayName = "élément"; // element
/** @MongoDB\Field(type="string") */
/** @MongoDB\Field(type="string") */
protected $elementDisplayNameDefinite = "l'élément"; // the element
/** @MongoDB\Field(type="string") */
protected $elementDisplayNameIndefinite = "un élément"; // an element
/** @MongoDB\Field(type="string") */
protected $elementDisplayNameIndefinite = "un élément"; // an element
/** @MongoDB\Field(type="string") */
protected $elementDisplayNamePlural = "éléments"; // elements
/** @MongoDB\Field(type="string") */
protected $elementDisplayNamePlural = "éléments"; // elements
// ----------------------------
// --------- GENRAL -----------
// ----------------------------
/** @MongoDB\Field(type="bool") */
protected $activateHomePage;
......@@ -104,14 +104,14 @@ class Configuration implements \JsonSerializable
// ----------------------------
// ---------- USER -----------
// ----------------------------
// ----------------------------
/** @MongoDB\EmbedOne(targetDocument="Biopen\CoreBundle\Document\Configuration\ConfigurationUser") */
protected $user;
// ----------------------------
// ----------- HOME -----------
// ----------------------------
// ----------------------------
/** @MongoDB\ReferenceOne(targetDocument="Biopen\CoreBundle\Document\ConfImage", cascade={"all"}) */
protected $backgroundImage;
......@@ -133,13 +133,13 @@ class Configuration implements \JsonSerializable
protected $exportIframeFeature;
/** @MongoDB\EmbedOne(targetDocument="Biopen\CoreBundle\Document\FeatureConfiguration") */
protected $directionsFeature;
protected $directionsFeature;
/** @MongoDB\EmbedOne(targetDocument="Biopen\CoreBundle\Document\FeatureConfiguration") */
protected $reportFeature;
protected $reportFeature;
/** @MongoDB\EmbedOne(targetDocument="Biopen\CoreBundle\Document\FeatureConfiguration") */
protected $stampFeature;
protected $stampFeature;
/** @MongoDB\EmbedOne(targetDocument="Biopen\CoreBundle\Document\FeatureConfiguration") */
protected $pendingFeature;
......@@ -168,6 +168,8 @@ class Configuration implements \JsonSerializable
/** @MongoDB\EmbedOne(targetDocument="Biopen\CoreBundle\Document\FeatureConfiguration") */
protected $mapDefaultViewFeature;
/** @MongoDB\Field(type="string") */
protected $searchExcludingWords;
// ---------------------------------
// --------- CONTRIBUTIONS ---------
......@@ -203,8 +205,8 @@ class Configuration implements \JsonSerializable
/** @MongoDB\Field(type="int") */
protected $maxDaysLeavingAnElementPending = 15;
/** @MongoDB\Field(type="string") */
protected $collaborativeModerationExplanations;
/** @MongoDB\Field(type="string") */
protected $collaborativeModerationExplanations;
// -------------------------
......@@ -221,7 +223,7 @@ class Configuration implements \JsonSerializable
protected $marker;
/** @MongoDB\ReferenceOne(targetDocument="Biopen\CoreBundle\Document\TileLayer") */
protected $defaultTileLayer;
protected $defaultTileLayer;
/** @MongoDB\Field(type="float") */
protected $defaultNorthEastBoundsLat;
......@@ -240,15 +242,15 @@ class Configuration implements \JsonSerializable
/** @MongoDB\Field(type="bool") */
protected $saveTileLayerInCookies = true;
// -------------------------
// ------ MAP POPUP --------
// -------------------------
/** @MongoDB\Field(type="string") */
/** @MongoDB\Field(type="string") */
protected $customPopupText;
/** @MongoDB\Field(type="int") */
......@@ -313,10 +315,10 @@ class Configuration implements \JsonSerializable
// -------- IMPORTS -----------
// ----------------------------
/** @MongoDB\Field(type="string") */
/** @MongoDB\Field(type="string") */
protected $fontImport;
/** @MongoDB\Field(type="string") */
/** @MongoDB\Field(type="string") */
protected $iconImport;
......@@ -325,7 +327,7 @@ class Configuration implements \JsonSerializable
// -------------------------
/** @MongoDB\Field(type="string") */
protected $theme;
protected $theme;
// FONTS
......@@ -338,7 +340,7 @@ class Configuration implements \JsonSerializable
// COLORS BASIC
/** @MongoDB\Field(type="string") */
protected $textColor;
protected $textColor;
/** @MongoDB\Field(type="string") */
protected $primaryColor;
......@@ -370,7 +372,7 @@ class Configuration implements \JsonSerializable
protected $contentBackgroundColor;
/** @MongoDB\Field(type="string") */
protected $contentBackgroundElementBodyColor;
protected $contentBackgroundElementBodyColor;
/** @MongoDB\Field(type="string") */
protected $headerColor;
......@@ -381,7 +383,7 @@ class Configuration implements \JsonSerializable
/** @MongoDB\Field(type="string") */
protected $headerHoverColor;
// COLORS ADVANCED
// COLORS ADVANCED
/** @MongoDB\Field(type="string") */
protected $searchBarColor;
......@@ -393,7 +395,7 @@ class Configuration implements \JsonSerializable
protected $errorColor;
/** @MongoDB\Field(type="string") */
protected $pendingColor;
protected $pendingColor;
/** @MongoDB\Field(type="string") */
protected $interactiveSectionColor;
......@@ -401,7 +403,7 @@ class Configuration implements \JsonSerializable
// -------------------------
// ---- CUSTOM ASSETS ------
// -------------------------
// -------------------------
/** @MongoDB\Field(type="string") */
protected $customCSS = '';
......@@ -411,19 +413,19 @@ class Configuration implements \JsonSerializable
// -------------------------
// ---- CUSTOM ASSETS ------
// -------------------------
// -------------------------
/** @MongoDB\Field(type="string") */
protected $customDashboard = '';
// -------------------------
// --------- API -----------
// -------------------------
// -------------------------
/** @MongoDB\EmbedOne(targetDocument="Biopen\CoreBundle\Document\Configuration\ConfigurationApi") */
protected $api;
public function __toString()
public function __toString()
{
return "Configuration Générale";
}
......@@ -442,7 +444,7 @@ class Configuration implements \JsonSerializable
$this->shareFeature = new FeatureConfiguration();
$this->exportIframeFeature = new FeatureConfiguration();
$this->directionsFeature = new FeatureConfiguration();
$this->reportFeature = new FeatureConfiguration();
$this->reportFeature = new FeatureConfiguration();
$this->stampFeature = new FeatureConfiguration();
$this->pendingFeature = new FeatureConfiguration();
$this->listModeFeature = new FeatureConfiguration();
......@@ -453,9 +455,9 @@ class Configuration implements \JsonSerializable
$this->mapDefaultViewFeature = new FeatureConfiguration();
$this->sendMailFeature = new InteractionConfiguration();
$this->addFeature = new InteractionConfiguration();
$this->editFeature = new InteractionConfiguration();
$this->editFeature = new InteractionConfiguration();
$this->deleteFeature = new InteractionConfiguration();
$this->collaborativeModerationFeature = new InteractionConfiguration();
$this->directModerationFeature = new InteractionConfiguration();
......@@ -490,14 +492,14 @@ class Configuration implements \JsonSerializable
else return new Rgba($colorString);
} catch (\Exception $e) {
return new Hex("#000");
}
}
}
public function getDefaultColor($colorName)
{
$method = "getDefault" . ucfirst($colorName);
if (method_exists($this, $method))
if (method_exists($this, $method))
return $this->$method();
else
else
return null;
}
......@@ -644,7 +646,7 @@ class Configuration implements \JsonSerializable
/* --------------------------------------- */
/* END DEFAULT COLORS
/* ---------------------------------------- */
/**
* Set favoriteFeature
......@@ -1936,7 +1938,7 @@ class Configuration implements \JsonSerializable
return $this->elementFormGeocodingHelp;
}
/**
* Set activateHomePage
......@@ -2067,7 +2069,7 @@ class Configuration implements \JsonSerializable
*/
public function getHome()
{
if(!$this->home) $this->home = new ConfigurationHome();
if(!$this->home) $this->home = new ConfigurationHome();
return $this->home;
}
......@@ -2575,8 +2577,8 @@ class Configuration implements \JsonSerializable
public function getTheme()
{
return $this->theme;
}
}
/**
* Set textColor
......@@ -3006,4 +3008,26 @@ class Configuration implements \JsonSerializable
{
return $this->dataLicenseUrl;
}
/**
* Set searchExcludingWords
*
* @param string $searchExcludingWords
* @return $this
*/
public function setSearchExcludingWords($searchExcludingWords)
{
$this->searchExcludingWords = $searchExcludingWords;
return $this;
}
/**
* Get searchExcludingWords
*
* @return string $searchExcludingWords
*/
public function getSearchExcludingWords()
{
return str_replace(' ', '', $this->searchExcludingWords);
}
}
......@@ -32,7 +32,7 @@ class ElementRepository extends DocumentRepository
$radius = $distance / 110;
$status = $includeDeleted ? ElementStatus::Duplicate : ElementStatus::PendingModification;
$qb->addOr($qb->expr()->text($element->getName())->language('fr'));
$qb->addOr($this->queryText($qb->expr(), $element->getName()));
if ($element->getEmail()) $qb->addOr($qb->expr()->field('email')->equals($element->getEmail()));
$qb->limit($maxResults)
......@@ -83,8 +83,7 @@ class ElementRepository extends DocumentRepository
{
$qb = $this->createQueryBuilder('BiopenGeoDirectoryBundle:Element');
$qb->text($text)->sortMeta('score', 'textScore');
$this->queryText($qb, $text)->sortMeta('score', 'textScore');
$this->filterVisibles($qb);
$this->selectJson($qb, $fullRepresentation, $isAdmin);
......@@ -186,6 +185,13 @@ class ElementRepository extends DocumentRepository
if ($limit && $limit > 0) $qb->limit($limit);
}
private function queryText($qb, $text)
{
$config = $this->getDocumentManager()->getRepository('BiopenCoreBundle:Configuration')->findConfiguration();
$text = $text . ' --' . str_replace(',', ' --', $config->getSearchExcludingWords());
return $qb->text($text)->language('fr');
}
private function filterVisibles($qb, $status = ElementStatus::PendingModification)
{
// fetching pendings and validated
......@@ -291,9 +297,9 @@ class ElementRepository extends DocumentRepository
{
$formProperties = [];
$propTypeToIgnore = ['separator', 'header', 'address', 'title', 'email', 'taxonomy', 'openhours'];
$config = $this->getDocumentManager()->getRepository('BiopenCoreBundle:Configuration')->findConfiguration();
$config = $this->getDocumentManager()->getRepository('BiopenCoreBundle:Configuration')->findConfiguration();
foreach ($config->getElementFormFields() as $key => $field) {
if (property_exists($field, 'name') && !in_array($field->type, $propTypeToIgnore))
if (property_exists($field, 'name') && !in_array($field->type, $propTypeToIgnore))
$formProperties[] = $field->name;
}
return $formProperties;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment