Skip to content
Snippets Groups Projects
Commit 5baf6d80 authored by Laurent's avatar Laurent
Browse files

POC suggestions recherche

parent 0ad6fe3b
Branches
Tags
3 merge requests!1132Hotline#29412 images des articles dans le resultat de recherche,!1120Master,!1092Sandbox gladys suggests
......@@ -244,6 +244,7 @@ class RechercheController extends ZendAfi_Controller_Action {
$this->view->tri = $criteres_recherche->getTri();
$this->view->facettes = $facettes;
$this->view->tags = $tags;
$this->view->suggests = $facettes_and_tags['suggests'];
}
......
......@@ -104,10 +104,18 @@ $html_facettes = '<div class="facette_outer" style="margin-left:10px;margin-top:
'</div>';
?>
<?php
$html_suggests = '';
if ($this->criteres_recherche->getExpressionRecherche())
$html_suggests = $this->suggests($this->criteres_recherche, $this->suggests)
?>
<?php
$html_filters = '';
if ($hasFacettes || $hasTags) {
$html_filters .= '<div class="filtre_recherche">';
$html_filters .= $html_suggests;
if ($hasTags && (1 == $tagsPosition)) $html_filters.= $html_nuage_tags;
if ($hasFacettes) $html_filters.= $html_facettes;
if ($hasTags && (2 == $tagsPosition)) $html_filters.= $html_nuage_tags;
......
......@@ -61,10 +61,12 @@ class Class_MoteurRecherche_Facettes {
// Constituer le tableau des tags
$result['tags'] = $this->extractTags($p_tag['types'], $p_tag['nombre'], $codes_count);
$result['suggests'] = $this->extractSuggests($codes_count);;
return $result;
}
public function fetchFacetsRows($req) {
$all = array_count_values(
array_filter(
......@@ -126,6 +128,20 @@ class Class_MoteurRecherche_Facettes {
return $table_tags;
}
public function extractSuggests($facettes) {
$table_tags = [];
$codification = Class_Codification::getInstance();
foreach($facettes as $code => $count) {
$table_tags[] = ['id' => $code,
'nombre' => $count,
'libelle' => $codification->getLibelleFacette($code)];
}
return $table_tags;
}
}
?>
\ No newline at end of file
<?php
/**
* Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class ZendAfi_View_Helper_Suggests extends ZendAfi_View_Helper_BaseHelper {
public function suggests($criteres, $tags) {
$ix = new Class_Indexation();
$mots = $ix->getMots($criteres->getExpressionRecherche());
$matches = [];
foreach($tags as $tag) {
if (!empty(array_diff($mots,
$ix->getMots($tag['libelle']))))
continue;
$matches []= $tag;
if (count($matches) >= 5)
break;
}
$html = '<ul>';
$url_base = $this->view->url(array_merge($criteres->getUrlRetourListe(),
['controller' => 'recherche',
'action' => 'simple',
'page' => null]), null, true);
foreach ($matches as $match) {
$facette = Class_Notice_Facette::find($match['id']);
$url = $url_base . '/code_rebond/'.$match['id'];
$html .= '<li><a href="' . $url . '">'. $match['libelle'] . ' ('. $facette->getCodeRubriqueLibelle() .')</a></li>';
}
$html .= '</ul>';
return '<div><h2>suggestions</h2>' . $html .'</div>';
}
}
?>
\ No newline at end of file
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