c99de5b725bd90b6fb5c03dc4c99a4a48e54f0bc
5 function display_group(&$group, &$exalead_data, $keywords=false
,$class = 'exa_groupe', $img_path = 'images/'){
7 $titre = ($keywords)?
'Mot-clés':$group->title
;
8 $gid = ($keywords)?
'k':$group->gid
;
13 $array = & $group->categories
;
15 $res=" <div class=\"exa_groupe\"
16 <div class=\"titre\">".$titre.":</div>
17 <ul id=\"exa_group_".$gid."\">";
18 foreach($array as $categorie){
20 $res+
="<li class=\"exa_categorie\" id=\"exa_group_".$gid."_".$compteur.";\">";
21 if($categorie->is_normal()){
22 $res+
="<a style=\"text-decoration: none;\"
23 href=\"?_C=".$exalead_data->query
->context
."&".$categorie->refine_href
.";?>&_f=xml2\"
24 title=\"Afficher seulement ces résultats\">
25 <img style=\"vertical-align: text-bottom;\" src=\"images/select.png\" alt=\"[+]\" />";
26 if (empty($categorie->display
)){
27 $res+
=$categorie->name
;
30 $res+
=$categorie->display
;
32 if(!empty($categorie->count
)){
33 $res+
=$categorie->count
;
36 <a href=\"?_C=".$exalead_data->query
->context
."&".$categorie->exclude_href
.";&_f=xml2\"
37 title=\"Ne pas afficher ces résultats\">
38 <img style=\"vertical-align: text-bottom;\" src=\"images/moins.png\" alt=\"[-]\"/></a>";
40 elseif($categorie->is_excluded()){
41 $res+
="<span style=\"text-decoration: line-through;\">
42 <a href=\"?_C=".$exalead_data->query
->context
."&".$categorie->reset_href
.";&_f=xml2\">
43 <img style=\"vertical-align: text-bottom;\" src=\"images/select.png\" alt=\"[+]\" />
44 ".$categorie->display
.";</a>
48 $res+
="<strong>".$categorie->display
.";</strong>
49 <a href=\"?_C=".$exalead_data->query
->context
."&".$categorie->reset_href
.";&_f=xml2\">
50 <img style=\"vertical-align: text-bottom;\" src=\"images/moins.png\" alt=\"[-]\"/></a>";
62 function _display_groupes($params, &$smarty){
64 if(!empty($params['exalead_data'])){
65 $exalead_data = &$GLOBALS[$params['exalead_data']];
68 $exalead_data = &$GLOBALS['exalead_data'];
71 foreach($exalead_data->groups
as $group){
72 display_group($group, $exalead_data);
77 function _display_keywords($params, &$smarty){
78 if(!empty($params['exalead_data'])){
79 $exalead_data = &$GLOBALS[$params['exalead_data']];
82 $exalead_data = &$GLOBALS['exalead_data'];
85 display_group($exalead_data->keywords
, $exalead_data, true
);
88 function _exa_navigation_gauche($params, &$smarty){
89 if(!empty($params['exalead_data'])){
90 $exalead_data = &$GLOBALS[$params['exalead_data']];
93 $exalead_data = &$GLOBALS['exalead_data'];
96 if($exalead_data->start
> 0){
97 $debut_g = $exalead_data->start
- 9;
98 $debut_d = $debut_g +
9;
100 $res .= "<a href=\"?_C={$exalead_data->query->context}&_s=0\">[1-10]</a>";
103 $res .= "<a href=\"?_C={$exalead_data->query->context}&_s=".($debut_g-1)."\">[$debut_g-$debut_d]</a>";
108 function _exa_navigation_droite($params, &$smarty){
109 if(!empty($params['exalead_data'])){
110 $exalead_data = &$GLOBALS[$params['exalead_data']];
113 $exalead_data = &$GLOBALS['exalead_data'];
116 if(!empty($params['max'])){
117 $max = (int) $params['max'];
118 if(($max < 0) ||
($max > $exalead_data->nhits
)){
119 $max = $exalead_data->nhits
;
123 $max = $exalead_data->nhits
;
126 if(($exalead_data->end
< $max) && ($max > 10)){
127 $fin_g = $exalead_data->end +
1;
128 $fin_d = $fin_g +
10;
130 $res .= "<a href=\"?_C={$exalead_data->query->context}&_s=".($max-10)."\">[".($max-10)."-".($max)."]</a>";
133 $res .= "<a href=\"?_C={$exalead_data->query->context}&_s=$fin_g\">[".($fin_g+
1)."-$fin_d]</a>";
139 function _exa_navigation_barre($params, &$smarty){
140 if(!empty($params['exalead_data'])){
141 $exalead_data = &$GLOBALS[$params['exalead_data']];
144 $exalead_data = &$GLOBALS['exalead_data'];
146 if(!empty($params['nb_res_per_page'])){
147 $nb_res_per_page = (int) $params['nb_res_per_page'];
150 $nb_res_per_page = 10;//10 results per page
151 if(!empty($params['max_results']) && ((int) $params['max_results'] < $exalead_data->nhits
)){
152 $nb_hits = (int) $params['max_results'];
155 $nb_hits = (int) $exalead_data->nhits
;
158 foreach($exalead_data->query
->query_parameters
as $parameter){
159 if($parameter->name
=="_sf"){
160 if($parameter->value
=="-date")
167 $nb_numero = 5;//We want 5 links
168 $current_page = (empty($_GET['_s'])?
1:1+
(int) ($_GET['_s'] / $nb_res_per_page));
170 if($nb_hits < ($nb_numero) * $nb_res_per_page){
171 $nb_numero = (int) ($nb_hits / $nb_res_per_page);
174 if($current_page > ((int)$nb_numero/2))
175 $first_number = 1 +
$current_page - (int)($nb_numero/2);
176 if($nb_hits < (($first_number +
$nb_numero - 1) * $nb_res_per_page)){
177 $first_number = (int) ($nb_hits / $nb_res_per_page) - $nb_numero+
2;
181 if ($current_page*$nb_res_per_page >$nb_res_per_page){
182 $res.="<a href=\"?_C={$exalead_data->query->context}&_s=".(($current_page-2)*$nb_res_per_page);
183 if($date) $res.="&_sf=-date";
184 $res.="\">Précédent</a> ";
186 for($i = $first_number; $i <= $nb_numero +
$first_number; $i++
){
187 $k=$nb_res_per_page*($i-1)+
1;
188 $j=$nb_res_per_page*$i;
189 if($i == $current_page){
190 $res .= "<strong>$k-$j</strong> ";
192 elseif($k<=$nb_hits){
193 $res .= "<a href=\"?_C={$exalead_data->query->context}&_s=".(($i-1)*$nb_res_per_page);
194 if($date) $res.="&_sf=-date";
195 $res.="\">$k-$j</a> ";
198 if ($current_page*10<$nb_hits){
199 $res.="<a href=\"?_C={$exalead_data->query->context}&_s=".(($current_page)*$nb_res_per_page);
200 if($date) $res.="&_sf=-date";
201 $res.="\">Suivant</a>";
204 $res.=" - <a href=\"?_C={$exalead_data->query->context}&_f=xml2\">[Classer par pertinence]</a>";
206 $res.=" - <a href=\"?_C={$exalead_data->query->context}&_sf=-date&_f=xml2\">[Classer par date]</a>";
211 function _little_nav_barre($params, &$smarty){
212 if(!empty($params['exalead_data'])){
213 $exalead_data = &$GLOBALS[$params['exalead_data']];
216 $exalead_data = &$GLOBALS['exalead_data'];
219 if(!empty($params['where']))
220 if($params['where']=='box')
223 foreach($exalead_data->query
->query_parameters
as $parameter){
224 if($parameter->name
=="_sf"){
225 if($parameter->value
=="-date")
229 $dizaine=10*(int)($exalead_data->start
/10);
234 $res.= "<table class=\"table\">";
237 $res.="<td class=\"gauche\">";
239 $res .=" <td width=\"20%\" style=\"text-align: left;\">";
240 if($exalead_data->start
!= 0){
241 $num=$exalead_data->start
-1;
242 $res .="<a href=\"?_C={$exalead_data->query->context}&_s=".$num."\">Précédent</a>";
244 $num=$exalead_data->start+
1;
247 $res.="<td class=\"centre\">
248 CV : ".$num." / {$exalead_data->nhits}<br />";
251 $res.="<td width=\"60%\" style=\"text-align: center;\">
252 CV : ".$num." / {$exalead_data->nhits} -";
255 $res.="<a href=\"ec_cherche_cv.php?_C={$exalead_data->query->context}&_sf=-date&_f=xml2&_s=".$dizaine."\">Retour à la recherche</a>";
257 $res.="<a href=\"ec_cherche_cv.php?_C={$exalead_data->query->context}&_f=xml2&_s=".$dizaine."\">Retour à la recherche</a>";
260 $res.="<td class=\"droite\">";
262 $res .= "<td width=\"20%\" style=\"text-align: right;\">";
263 $num=$exalead_data->start+
1;
264 if( $exalead_data->start+
1 < $exalead_data->nhits
)
265 $res .= "<a href=\"?_C={$exalead_data->query->context}&_s=".$num."\">Suivant</a>";
272 //categorie = true if this line is for a category, false if this is for a keyword
273 function _display_3_columns($title, $count, $refine, $exclude, $categorie){
274 if ($title!='Inconnu'){
275 global $exa_max_length;
276 if($categorie) $title_exclude = 'Ne pas afficher cette catégorie';
277 else $title_exclude = 'Ne pas afficher ce mot-clé';
278 $extract = ((strlen($title) > $exa_max_length +
3)?
substr($title,0,$exa_max_length).'...':$title);
279 return "<tr class=\"categ\">
281 <a style=\"text-decoration: none;\"
282 href=\"?_C=".$refine."&_f=xml2\"
284 >$extract</a></td><td width=\"10%\">$count</td><td width=\"10%\">
285 <a href=\"?_C=".$exclude."&_f=xml2\"
286 title=\"$title_exclude\">[-]</a></td>
291 //excluded = true if this line is an excluded result, = false if this line is a refined result
292 //categorie = true if this line is for a category, false if this is for a keyword
293 function _display_2_columns($title, $reset, $excluded, $categorie){
294 global $exa_max_length;
296 if($categorie) $title_link = 'Afficher de nouveau cette catégorie';
297 else $title_link = 'Afficher de nouveau ce mot-clé';
299 $style = 'text-decoration: line-through;';
301 if($categorie) $title_link = 'Voir les autres catégories';
302 else $title_link = 'Voir les autres mots-clés';
304 $style = 'text-decoration: none; font-weight: bold;';
306 $extract = ((strlen($title) > $exa_max_length +
3)?
substr($title,0,$exa_max_length).'...':$title);
307 return "<tr class=\"categ\">
309 <a style=\"$style\" href=\"?_C=".$reset."&_f=xml2\"
310 title=\"$title\">$extract</a>
312 <td width=\"10%\"><a style=\"$style\"
313 href=\"?_C=".$reset."&_f=xml2\"
314 title=\"$title_link\"
320 function _display_resume_groupe_category(&$group, $context, $padding = ''){
322 foreach($group->categories
as $categorie){
323 $title = (empty($categorie->display
)?
$categorie->name
:$categorie->display
);
324 $count = (empty($categorie->count
)?
'':' ('.$categorie->count
.')');
325 $refine = $context.'&'.$categorie->refine_href
;
326 $exclude = $context.'&'.$categorie->exclude_href
;
327 $reset = $context.'&'.$categorie->reset_href
;
329 if($categorie->display
!= ''){
330 if($categorie->is_normal()){
331 $result .= _display_3_columns($padding.$title, $count, $refine, $exclude, true
);
334 $result .= _display_2_columns($padding.$title, $reset, $categorie->is_excluded(), true
);
337 if(count($categorie->categories
) > 0){
338 $result .= _display_resume_groupe_category($categorie, $context, $padding.'-');
345 * This function is used to resume database content for given group (template argument 'groupe')
347 function _display_resume_groupe($params, &$smarty){
348 global $exa_max_length;
349 if(!empty($params['exalead_data'])){
350 $exalead_data = &$GLOBALS[$params['exalead_data']];
353 $exalead_data = &$GLOBALS['exalead_data'];
355 if(empty($params['groupe'])){
358 $groupe = $params['groupe'];
359 $name = $params['display'];
360 foreach($exalead_data->groups
as $group){
361 if($group->title
== $groupe){
362 $result = "<table class=\"exa_resume\"><th colspan=\"3\" class=\"titre\">".gettext($name)."</th>";
363 $result .= _display_resume_groupe_category($group, $exalead_data->query
->context
);
364 $result .= "</table>";
371 * This function is used to resume database content for keywords
373 function _display_resume_keywords($params, &$smarty){
374 global $exa_max_length;
375 if(!empty($params['exalead_data'])){
376 $exalead_data = &$GLOBALS[$params['exalead_data']];
379 $exalead_data = &$GLOBALS['exalead_data'];
382 //if no keywrods, do not display anything
383 if(count($exalead_data->keywords
) == 0) return '';
384 $name=$params['display'];
385 $result = "<table class=\"exa_resume\"><th colspan=\"3\" class=\"titre\">".gettext($name)."</th>";
386 foreach($exalead_data->keywords
as $keyword){
387 if($keyword->display
!= ''){
388 $title = (empty($keyword->display
)?
$keyword->name
:$keyword->display
);
389 $count = (empty($keyword->count
)?
'':' ('.$keyword->count
.')');
390 $refine = $exalead_data->query
->context
.'/'.$keyword->refine_href
;
391 $exclude = $exalead_data->query
->context
.'/'.$keyword->exclude_href
;
392 $reset = $exalead_data->query
->context
.'/'.$keyword->reset_href
;
393 if($keyword->is_normal()){
394 $result .= _display_3_columns($title, $count, $refine, $exclude, false
);
397 $result .= _display_2_columns($title, $reset, $keyword->is_excluded(), false
);
401 $result .= "</table>";
405 function register_smarty_exalead(&$page){
406 $page->register_function('little_nav_barre','_little_nav_barre');
407 $page->register_function('exa_display_groupes', '_display_groupes');
408 $page->register_function('exa_display_resume_groupe', '_display_resume_groupe');
409 $page->register_function('exa_display_resume_keywords', '_display_resume_keywords');
410 $page->register_function('exa_display_keywords', '_display_keywords');
411 $page->register_function('exa_navigation_gauche', '_exa_navigation_gauche');
412 $page->register_function('exa_navigation_droite', '_exa_navigation_droite');
413 $page->register_function('exa_navigation_barre', '_exa_navigation_barre');
417 register_smarty_exalead($page);