Line 13... |
Line 13... |
13 |
|
13 |
|
14 |
private $motsASurligner = array();
|
14 |
private $motsASurligner = array();
|
15 |
private $noms = array();
|
15 |
private $noms = array();
|
Line 16... |
Line -... |
16 |
private $infosPourTpl = array();
|
- |
|
17 |
|
16 |
private $infosPourTpl = array();
|
18 |
|
17 |
|
19 |
public function __construct(ParametresResultats $parametres, Array $resultats,
|
18 |
public function __construct(ParametresResultats $parametres, Array $resultats,
|
Line 20... |
Line 19... |
20 |
Surligneur $surligneur = null, Trieur $trieur = null, AppUrls $urls = null,
|
19 |
Surligneur $surligneur = null, Trieur $trieur = null, AppUrls $urls = null,
|
Line 93... |
Line 92... |
93 |
}
|
92 |
}
|
94 |
}
|
93 |
}
|
95 |
}
|
94 |
}
|
96 |
return $ids;
|
95 |
return $ids;
|
97 |
}
|
96 |
}
|
- |
|
97 |
|
- |
|
98 |
private function extraireNumerosNomSynonymes() {
|
- |
|
99 |
$numNomsASynonyme = array();
|
- |
|
100 |
foreach ($this->noms as $id => $nom) {
|
- |
|
101 |
$num_nom_retenu = $nom['nom_retenu.id'];
|
- |
|
102 |
if(!isset($numNomsASynonyme[$num_nom_retenu])) {
|
- |
|
103 |
$numNomsASynonyme[$num_nom_retenu] = array();
|
- |
|
104 |
}
|
- |
|
105 |
$numNomsASynonyme[$num_nom_retenu][] = $id;
|
- |
|
106 |
if($num_nom_retenu != $id) {
|
- |
|
107 |
$numNomsASynonyme[$id] = $numNomsASynonyme[$num_nom_retenu];
|
- |
|
108 |
}
|
- |
|
109 |
}
|
- |
|
110 |
return $numNomsASynonyme;
|
- |
|
111 |
}
|
- |
|
112 |
|
98 |
private function supprimerCodeReferentielDesIds($urls) {
|
113 |
private function supprimerCodeReferentielDesIds($urls) {
|
99 |
$urlsNettoyees = array();
|
114 |
$urlsNettoyees = array();
|
100 |
foreach ($urls as $id => $url) {
|
115 |
foreach ($urls as $id => $url) {
|
101 |
$id = $this->supprimerCodeReferentiel($id);
|
116 |
$id = $this->supprimerCodeReferentiel($id);
|
102 |
$urlsNettoyees[$id] = $url;
|
117 |
$urlsNettoyees[$id] = $url;
|
103 |
}
|
118 |
}
|
104 |
return $urlsNettoyees;
|
119 |
return $urlsNettoyees;
|
105 |
}
|
120 |
}
|
- |
|
121 |
|
106 |
private function supprimerCodeReferentiel($chaine) {
|
122 |
private function supprimerCodeReferentiel($chaine) {
|
107 |
$codeReferentiel = Registre::get('parametres.referentiel').'.';
|
123 |
$codeReferentiel = Registre::get('parametres.referentiel').'.';
|
108 |
$chaine = str_replace($codeReferentiel, '', $chaine);
|
124 |
$chaine = str_replace($codeReferentiel, '', $chaine);
|
109 |
return $chaine;
|
125 |
return $chaine;
|
110 |
}
|
126 |
}
|
Line 115... |
Line 131... |
115 |
$conteneur = new Conteneur();
|
131 |
$conteneur = new Conteneur();
|
116 |
$cartesWs = $conteneur->getApiCartes();
|
132 |
$cartesWs = $conteneur->getApiCartes();
|
117 |
$cartesWs->setProjet(Config::get(Registre::get('parametres.referentiel').'.baseRepartition'));
|
133 |
$cartesWs->setProjet(Config::get(Registre::get('parametres.referentiel').'.baseRepartition'));
|
118 |
$cartesWs->setLargeur('108x101');
|
134 |
$cartesWs->setLargeur('108x101');
|
119 |
$urls = array();
|
135 |
$urls = array();
|
- |
|
136 |
$numsNomsASynonymes = $this->extraireNumerosNomSynonymes();
|
120 |
foreach ($this->noms as $id => $nom) {
|
137 |
foreach ($this->noms as $id => $nom) {
|
121 |
if (array_key_exists('nom_retenu.id', $nom)) {
|
138 |
if (array_key_exists('nom_retenu.id', $nom)) {
|
122 |
$id = $nom['nom_retenu.id'];
|
139 |
$id = $nom['nom_retenu.id'];
|
- |
|
140 |
$idsNoms = $numsNomsASynonymes[$id];
|
123 |
$cartesWs->setId("nn:$id");
|
141 |
$cartesWs->setId("nn:".implode(',',$idsNoms)."");
|
124 |
if (array_key_exists($id, $urls) == false) {
|
142 |
if (array_key_exists($id, $urls) == false) {
|
125 |
$urls[$id] = $cartesWs->getUrlPng();
|
143 |
$urls[$id] = $cartesWs->getUrlPng();
|
126 |
}
|
144 |
}
|
127 |
}
|
145 |
}
|
128 |
}
|
146 |
}
|
Line 134... |
Line 152... |
134 |
$tri = $this->diviserResultats();
|
152 |
$tri = $this->diviserResultats();
|
135 |
$this->infosPourTpl['nomsSansCorrespondance'] = isset($tri['sansCorres']) ? $tri['sansCorres'] : false;
|
153 |
$this->infosPourTpl['nomsSansCorrespondance'] = isset($tri['sansCorres']) ? $tri['sansCorres'] : false;
|
136 |
$this->infosPourTpl['noms'] = isset($tri['retenus']) ? $tri['retenus'] : false;
|
154 |
$this->infosPourTpl['noms'] = isset($tri['retenus']) ? $tri['retenus'] : false;
|
137 |
$this->infosPourTpl['synonymes'] = isset($tri['synonymes'] ) ? $tri['synonymes'] : false;
|
155 |
$this->infosPourTpl['synonymes'] = isset($tri['synonymes'] ) ? $tri['synonymes'] : false;
|
138 |
}
|
156 |
}
|
- |
|
157 |
|
139 |
/**
|
158 |
/**
|
140 |
* division ordonnée par
|
159 |
* division ordonnée par
|
141 |
* 1 - noms retenus qui commencent par la requete
|
160 |
* 1 - noms retenus qui commencent par la requete
|
142 |
* 2 - requete contenue dans un synonyme dont le nom retenu ne contient pas la requete
|
161 |
* 2 - requete contenue dans un synonyme dont le nom retenu ne contient pas la requete
|
143 |
* 3 - requete contenue dans un hybride retenu
|
162 |
* 3 - requete contenue dans un hybride retenu
|
Line 178... |
Line 197... |
178 |
$tri['retenus'] = $retenus;
|
197 |
$tri['retenus'] = $retenus;
|
179 |
$tri['synonymes'] = $synonymes;
|
198 |
$tri['synonymes'] = $synonymes;
|
180 |
$tri['sansCorres'] = $sansCorres;
|
199 |
$tri['sansCorres'] = $sansCorres;
|
181 |
return $tri;
|
200 |
return $tri;
|
182 |
}
|
201 |
}
|
- |
|
202 |
|
183 |
private function retournerInfosNomRetenu($cle, $nom_sci, $rang) {
|
203 |
private function retournerInfosNomRetenu($cle, $nom_sci, $rang) {
|
184 |
$infos = array();
|
204 |
$infos = array();
|
185 |
$infos['nomSciRetenu'] = $nom_sci;
|
205 |
$infos['nomSciRetenu'] = $nom_sci;
|
186 |
$infos['urlFiche'] = $this->urls->obtenirUrlFiche($cle, $this->parametres->typeNom, strtolower($this->parametres->masqueRecherche), $nom_sci);
|
206 |
$infos['urlFiche'] = $this->urls->obtenirUrlFiche($cle, $this->parametres->typeNom, strtolower($this->parametres->masqueRecherche), $nom_sci);
|
187 |
$infos['rang'] = $rang;
|
207 |
$infos['rang'] = $rang;
|
188 |
return $infos;
|
208 |
return $infos;
|
189 |
}
|
209 |
}
|
- |
|
210 |
|
190 |
private function retournerInfosSynonyme($cle, $valeurs) {
|
211 |
private function retournerInfosSynonyme($cle, $valeurs) {
|
191 |
$infos = array();
|
212 |
$infos = array();
|
192 |
$infos['nn'] = $cle;
|
213 |
$infos['nn'] = $cle;
|
193 |
$infos['nomSci'] = $valeurs['nom_sci_complet'];
|
214 |
$infos['nomSci'] = $valeurs['nom_sci_complet'];
|
194 |
$infos['urlFiche'] = $this->urls->obtenirUrlFiche($cle, $this->parametres->typeNom, $this->parametres->masqueRecherche, $valeurs['nom_retenu.libelle']);
|
215 |
$infos['urlFiche'] = $this->urls->obtenirUrlFiche($cle, $this->parametres->typeNom, $this->parametres->masqueRecherche, $valeurs['nom_retenu.libelle']);
|
195 |
return $infos;
|
216 |
return $infos;
|
196 |
}
|
217 |
}
|
- |
|
218 |
|
197 |
public function trier() {
|
219 |
public function trier() {
|
198 |
/*if (count($this->infosPourTpl['noms']) <= 1) { // classement par score
|
- |
|
199 |
$nomsRetenus = array();
|
220 |
$nomsRetenus = array();
|
200 |
foreach ($this->infosPourTpl['noms'] as $categorie) { //ote la division des retenus
|
- |
|
201 |
$nomsRetenus += $categorie;
|
- |
|
202 |
}
|
- |
|
203 |
$this->ajouterAuxNomsScoreSimilariteAvec($this->parametres->masqueRecherche);
|
- |
|
204 |
$this->trieur->setTableau($nomsRetenus);
|
- |
|
205 |
$this->trieur->setChampsEtOrdres(array('score' => SORT_DESC));
|
- |
|
206 |
$this->infosPourTpl['noms'] = $this->trieur->trier();
|
- |
|
207 |
$this->infosPourTpl['nomsSansCorrespondance'] =
|
- |
|
208 |
$this->classerAlphabetiquement('nomSciRetenu', $this->infosPourTpl['nomsSansCorrespondance'] );
|
- |
|
209 |
} else { // classement alphabétique
|
- |
|
210 |
*/
|
- |
|
211 |
$nomsRetenus = array();
|
- |
|
212 |
foreach ($this->infosPourTpl['noms'] as $categorie => $valeurs ) { //classement alpha par groupes
|
221 |
foreach ($this->infosPourTpl['noms'] as $categorie => $valeurs ) { //classement alpha par groupes
|
213 |
$nomsRetenus += $this->classerAlphabetiquement('nomSciRetenu', $valeurs);
|
222 |
$nomsRetenus += $this->classerAlphabetiquement('nomSciRetenu', $valeurs);
|
214 |
}
|
223 |
}
|
215 |
$this->infosPourTpl['noms'] = $nomsRetenus;
|
224 |
$this->infosPourTpl['noms'] = $nomsRetenus;
|
216 |
$this->infosPourTpl['nomsSansCorrespondance'] =
|
225 |
$this->infosPourTpl['nomsSansCorrespondance'] =
|
217 |
$this->classerAlphabetiquement('nomSciRetenu', $this->infosPourTpl['nomsSansCorrespondance'] );
|
226 |
$this->classerAlphabetiquement('nomSciRetenu', $this->infosPourTpl['nomsSansCorrespondance'] );
|
218 |
//}
|
- |
|
219 |
}
|
227 |
}
|
Line 220... |
Line 228... |
220 |
|
228 |
|
221 |
private function ajouterAuxNomsScoreSimilariteAvec($masque) {
|
229 |
private function ajouterAuxNomsScoreSimilariteAvec($masque) {
|
222 |
$nom_demande_ss = strtolower($this->manipulateurDeChaine->supprimerAccents($masque));
|
230 |
$nom_demande_ss = strtolower($this->manipulateurDeChaine->supprimerAccents($masque));
|
Line 229... |
Line 237... |
229 |
$score = $score + (similar_text($nom_demande_ss, $nom_flou_ss) * 3);
|
237 |
$score = $score + (similar_text($nom_demande_ss, $nom_flou_ss) * 3);
|
230 |
$nom['score'] = $score;
|
238 |
$nom['score'] = $score;
|
231 |
$this->infosPourTpl['noms'][$id] = $nom;
|
239 |
$this->infosPourTpl['noms'][$id] = $nom;
|
232 |
}
|
240 |
}
|
233 |
}
|
241 |
}
|
- |
|
242 |
|
234 |
private function classerAlphabetiquement($champs, $valeurs) {
|
243 |
private function classerAlphabetiquement($champs, $valeurs) {
|
235 |
$this->trieur->setTableau($valeurs);
|
244 |
$this->trieur->setTableau($valeurs);
|
236 |
$this->trieur->setChampsEtOrdres(array($champs => 'nat'));
|
245 |
$this->trieur->setChampsEtOrdres(array($champs => 'nat'));
|
237 |
return $this->trieur->trier();
|
246 |
return $this->trieur->trier();
|
238 |
}
|
247 |
}
|
Line 239... |
Line -... |
239 |
|
- |
|
240 |
|
- |
|
241 |
|
248 |
|
242 |
public function surligner() {
|
249 |
public function surligner() {
|
243 |
$this->definirMotsASurligner();
|
250 |
$this->definirMotsASurligner();
|
244 |
foreach ($this->infosPourTpl['noms'] as $idNom => $nom) {
|
251 |
foreach ($this->infosPourTpl['noms'] as $idNom => $nom) {
|
245 |
$this->infosPourTpl['noms'][$idNom]['nomSciRetenu'] = $this->surlignerMotsMasqueRecherche($nom['nomSciRetenu']);
|
252 |
$this->infosPourTpl['noms'][$idNom]['nomSciRetenu'] = $this->surlignerMotsMasqueRecherche($nom['nomSciRetenu']);
|
Line 248... |
Line 255... |
248 |
$this->infosPourTpl['synonymes'][$idNom][$idSyn]['nomSci'] = $this->surlignerMotsMasqueRecherche($synonyme['nomSci']);
|
255 |
$this->infosPourTpl['synonymes'][$idNom][$idSyn]['nomSci'] = $this->surlignerMotsMasqueRecherche($synonyme['nomSci']);
|
249 |
}
|
256 |
}
|
250 |
}
|
257 |
}
|
251 |
}
|
258 |
}
|
252 |
}
|
259 |
}
|
- |
|
260 |
|
253 |
private function definirMotsASurligner() {
|
261 |
private function definirMotsASurligner() {
|
254 |
$this->motsASurligner = explode(' ', $this->parametres->masqueRecherche);
|
262 |
$this->motsASurligner = explode(' ', $this->parametres->masqueRecherche);
|
255 |
}
|
263 |
}
|
256 |
private function surlignerMotsMasqueRecherche($nom) {
|
264 |
private function surlignerMotsMasqueRecherche($nom) {
|
257 |
$this->surligneur->setTexte($nom);
|
265 |
$this->surligneur->setTexte($nom);
|