7f0165c38a929a91d8a27b9232f46189bb8a3c24
6 function display_group(&$group, &$exalead_data, $keywords=false
,$class = 'exa_groupe', $img_path = 'images/'){
8 $titre = ($keywords)?
'Mot-clés':$group->title
;
9 $gid = ($keywords)?
'k':$group->gid
;
13 $array = & $group->categories
;
15 <div
class="exa_groupe">
16 <div
class="titre"><?php
echo $titre?
> :</div
>
17 <ul id
="exa_group_<?php echo $gid?>">
19 foreach($array as $categorie){
22 <li
class="exa_categorie" id
="exa_group_<?php echo $gid.'_'.$compteur;?>">
24 if($categorie->is_normal()){
26 <a style
="text-decoration: none;"
27 href
="?_C=<?php echo $exalead_data->query->context.'/'.$categorie->refine_href;?>&_f=xml2"
28 title
="Afficher seulement ces résultats"
29 ><img style
="vertical-align: text-bottom;" src
="images/select.png" alt
="[+]" />
30 <?php
echo (empty($categorie->display
)?
$categorie->name
:$categorie->display
).(empty($categorie->count
)?
'':' ('.$categorie->count
.')');?
></a
>
31 <a href
="?_C=<?php echo $exalead_data->query->context.'/'.$categorie->exclude_href;?>&_f=xml2"
32 title
="Ne pas afficher ces résultats"
33 ><img style
="vertical-align: text-bottom;" src
="images/moins.png" alt
="[-]"/></a
>
36 elseif($categorie->is_excluded()){
38 <span style
="text-decoration: line-through;">
39 <a href
="?_C=<?php echo $exalead_data->query->context.'/'.$categorie->reset_href;?>&_f=xml2"><img style
="vertical-align: text-bottom;" src
="images/select.png" alt
="[+]" />
40 <?php
echo $categorie->display
;?
></a
>
46 <strong
><?php
echo $categorie->display
;?
></strong
>
47 <a href
="?_C=<?php echo $exalead_data->query->context.'/'.$categorie->reset_href;?>&_f=xml2"><img style
="vertical-align: text-bottom;" src
="images/moins.png" alt
="[-]"/></a
>
58 function _display_groupes($params, &$smarty){
60 if(!empty($params['exalead_data'])){
61 $exalead_data = &$GLOBALS[$params['exalead_data']];
64 $exalead_data = &$GLOBALS['exalead_data'];
67 foreach($exalead_data->groups
as $group){
68 display_group($group, $exalead_data);
73 function _display_keywords($params, &$smarty){
74 if(!empty($params['exalead_data'])){
75 $exalead_data = &$GLOBALS[$params['exalead_data']];
78 $exalead_data = &$GLOBALS['exalead_data'];
81 display_group($exalead_data->keywords
, $exalead_data, true
);
84 function _exa_navigation_gauche($params, &$smarty){
85 if(!empty($params['exalead_data'])){
86 $exalead_data = &$GLOBALS[$params['exalead_data']];
89 $exalead_data = &$GLOBALS['exalead_data'];
92 if($exalead_data->start
> 0){
93 $debut_g = $exalead_data->start
- 9;
94 $debut_d = $debut_g +
9;
96 $res .= "<a href=\"?_C={$exalead_data->query->context}&_s=0\">[1-10]</a>";
99 $res .= "<a href=\"?_C={$exalead_data->query->context}&_s=".($debut_g-1)."\">[$debut_g-$debut_d]</a>";
104 function _exa_navigation_droite($params, &$smarty){
105 if(!empty($params['exalead_data'])){
106 $exalead_data = &$GLOBALS[$params['exalead_data']];
109 $exalead_data = &$GLOBALS['exalead_data'];
112 if(!empty($params['max'])){
113 $max = (int) $params['max'];
114 if(($max < 0) ||
($max > $exalead_data->nhits
)){
115 $max = $exalead_data->nhits
;
119 $max = $exalead_data->nhits
;
122 if(($exalead_data->end
< $max) && ($max > 10)){
123 $fin_g = $exalead_data->end +
1;
124 $fin_d = $fin_g +
10;
126 $res .= "<a href=\"?_C={$exalead_data->query->context}&_s=".($max-10)."\">[".($max-10)."-".($max)."]</a>";
129 $res .= "<a href=\"?_C={$exalead_data->query->context}&_s=$fin_g\">[".($fin_g+
1)."-$fin_d]</a>";
135 function _exa_navigation_barre($params, &$smarty){
136 if(!empty($params['exalead_data'])){
137 $exalead_data = &$GLOBALS[$params['exalead_data']];
140 $exalead_data = &$GLOBALS['exalead_data'];
142 if(!empty($params['nb_res_per_page'])){
143 $nb_res_per_page = (int) $params['nb_res_per_page'];
146 $nb_res_per_page = 10;//10 results per page
147 if(!empty($params['max_results']) && ((int) $params['max_results'] < $exalead_data->nhits
)){
148 $nb_hits = (int) $params['max_results'];
151 $nb_hits = (int) $exalead_data->nhits
;
154 $nb_numero = 5;//We want 5 links
155 $current_page = (empty($_GET['_s'])?
1:1+
(int) ($_GET['_s'] / $nb_res_per_page));
157 if($nb_hits < ($nb_numero) * $nb_res_per_page){
158 $nb_numero = (int) ($nb_hits / $nb_res_per_page);
161 if($current_page > ((int)$nb_numero/2))
162 $first_number = 1 +
$current_page - (int)($nb_numero/2);
163 if($nb_hits < (($first_number +
$nb_numero - 1) * $nb_res_per_page)){
164 $first_number = (int) ($nb_hits / $nb_res_per_page) - $nb_numero+
2;
168 if ($current_page*$nb_res_per_page >$nb_res_per_page)
169 $res.="<a href=\"?_C={$exalead_data->query->context}&_s=".(($current_page-2)*$nb_res_per_page)."\">Precedent</a> ";
170 for($i = $first_number; $i <= $nb_numero +
$first_number-1; $i++
){
171 $k=$nb_res_per_page*($i-1)+
1;
172 $j=$nb_res_per_page*$i;
173 if($i == $current_page){
174 $res .= "<strong>$k-$j</strong> ";
177 $res .= "<a href=\"?_C={$exalead_data->query->context}&_s=".(($i-1)*$nb_res_per_page)."\">$k-$j</a> ";
180 if ($current_page*10<$nb_hits)
181 $res.="<a href=\"?_C={$exalead_data->query->context}&_s=".(($current_page)*$nb_res_per_page)."\">Suivant</a>";
183 foreach($exalead_data->query
->query_parameters
as $parameter){
184 if($parameter->name
=="_sf"){
185 if($parameter->value
=="-date")
191 $res.=" - <a href=\"?_C={$exalead_data->query->context}/_sf=relevance&_f=xml2\">[Classer par pertinence]</a>";
193 $res.=" - <a href=\"?_C={$exalead_data->query->context}/_sf=-date&_f=xml2\">[Classer par date]</a>";
198 function _little_nav_barre($params, &$smarty){
199 if(!empty($params['exalead_data'])){
200 $exalead_data = &$GLOBALS[$params['exalead_data']];
203 $exalead_data = &$GLOBALS['exalead_data'];
206 if(!empty($params['where']))
207 if($params['where']=='box')
210 foreach($exalead_data->query
->query_parameters
as $parameter){
211 if($parameter->name
=="_sf"){
212 if($parameter->value
=="-date")
216 $dizaine=10*(int)($exalead_data->start
/10);
221 $res.= "<table class=\"table\">";
224 $res.="<td class=\"gauche\">";
226 $res .=" <td width=\"20%\" style=\"text-align: left;\">";
227 if($exalead_data->start
!= 0){
228 $num=$exalead_data->start
-1;
229 $res .="<a href=\"?_C={$exalead_data->query->context}&_s=".$num."\">Précédent</a>";
231 $num=$exalead_data->start+
1;
234 $res.="<td class=\"centre\">
235 CV : ".$num." / {$exalead_data->nhits}<br />";
238 $res.="<td width=\"60%\" style=\"text-align: center;\">
239 CV : ".$num." / {$exalead_data->nhits} -";
242 $res.="<a href=\"ec_cherche_cv.php?_C={$exalead_data->query->context}/_sf=-date&_f=xml2&_s=".$dizaine."\">Retour à la recherche</a>";
244 $res.="<a href=\"ec_cherche_cv.php?_C={$exalead_data->query->context}/_sf=-relevance&_f=xml2&_s=".$dizaine."\">Retour à la recherche</a>";
247 $res.="<td class=\"droite\">";
249 $res .= "<td width=\"20%\" style=\"text-align: right;\">";
250 $num=$exalead_data->start+
1;
251 if( $exalead_data->start+
1 < $exalead_data->nhits
)
252 $res .= "<a href=\"?_C={$exalead_data->query->context}&_s=".$num."\">Suivant</a>";
259 //categorie = true if this line is for a category, false if this is for a keyword
260 function _display_3_columns($title, $count, $refine, $exclude, $categorie){
261 if ($title!='Inconnu'){
262 global $exa_max_length;
263 if($categorie) $title_exclude = 'Ne pas afficher cette catégorie';
264 else $title_exclude = 'Ne pas afficher ce mot-clé';
265 $extract = ((strlen($title) > $exa_max_length +
3)?
substr($title,0,$exa_max_length).'...':$title);
266 return "<tr class=\"categ\">
268 <a style=\"text-decoration: none;\"
269 href=\"?_C=".$refine."&_f=xml2\"
271 >$extract</a></td><td width=\"10%\">$count</td><td width=\"10%\">
272 <a href=\"?_C=".$exclude."&_f=xml2\"
273 title=\"$title_exclude\">[-]</a></td>
278 //excluded = true if this line is an excluded result, = false if this line is a refined result
279 //categorie = true if this line is for a category, false if this is for a keyword
280 function _display_2_columns($title, $reset, $excluded, $categorie){
281 global $exa_max_length;
283 if($categorie) $title_link = 'Afficher de nouveau cette catégorie';
284 else $title_link = 'Afficher de nouveau ce mot-clé';
286 $style = 'text-decoration: line-through;';
288 if($categorie) $title_link = 'Voir les autres catégories';
289 else $title_link = 'Voir les autres mots-clés';
291 $style = 'text-decoration: none; font-weight: bold;';
293 $extract = ((strlen($title) > $exa_max_length +
3)?
substr($title,0,$exa_max_length).'...':$title);
294 return "<tr class=\"categ\">
296 <a style=\"$style\" href=\"?_C=".$reset."&_f=xml2\"
297 title=\"$title\">$extract</a>
299 <td width=\"10%\"><a style=\"$style\"
300 href=\"?_C=".$reset."&_f=xml2\"
301 title=\"$title_link\"
307 function _display_resume_groupe_category(&$group, $context, $padding = ''){
309 foreach($group->categories
as $categorie){
310 $title = (empty($categorie->display
)?
$categorie->name
:$categorie->display
);
311 $count = (empty($categorie->count
)?
'':' ('.$categorie->count
.')');
312 $refine = $context.'/'.$categorie->refine_href
;
313 $exclude = $context.'/'.$categorie->exclude_href
;
314 $reset = $context.'/'.$categorie->reset_href
;
316 if($categorie->display
!= ''){
317 if($categorie->is_normal()){
318 $result .= _display_3_columns($padding.$title, $count, $refine, $exclude, true
);
321 $result .= _display_2_columns($padding.$title, $reset, $categorie->is_excluded(), true
);
324 if(count($categorie->categories
) > 0){
325 $result .= _display_resume_groupe_category($categorie, $context, $padding.'-');
332 * This function is used to resume database content for given group (template argument 'groupe')
334 function _display_resume_groupe($params, &$smarty){
335 global $exa_max_length;
336 if(!empty($params['exalead_data'])){
337 $exalead_data = &$GLOBALS[$params['exalead_data']];
340 $exalead_data = &$GLOBALS['exalead_data'];
342 if(empty($params['groupe'])){
345 $groupe = $params['groupe'];
346 $name = $params['display'];
347 foreach($exalead_data->groups
as $group){
348 if($group->title
== $groupe){
349 $result = "<table class=\"exa_resume\"><th colspan=\"3\" class=\"titre\">".gettext($name)."</th>";
350 $result .= _display_resume_groupe_category($group, $exalead_data->query
->context
);
351 $result .= "</table>";
358 * This function is used to resume database content for keywords
360 function _display_resume_keywords($params, &$smarty){
361 global $exa_max_length;
362 if(!empty($params['exalead_data'])){
363 $exalead_data = &$GLOBALS[$params['exalead_data']];
366 $exalead_data = &$GLOBALS['exalead_data'];
369 //if no keywrods, do not display anything
370 if(count($exalead_data->keywords
) == 0) return '';
371 $name=$params['display'];
372 $result = "<table class=\"exa_resume\"><th colspan=\"3\" class=\"titre\">".gettext($name)."</th>";
373 foreach($exalead_data->keywords
as $keyword){
374 if($keyword->display
!= ''){
375 $title = (empty($keyword->display
)?
$keyword->name
:$keyword->display
);
376 $count = (empty($keyword->count
)?
'':' ('.$keyword->count
.')');
377 $refine = $exalead_data->query
->context
.'/'.$keyword->refine_href
;
378 $exclude = $exalead_data->query
->context
.'/'.$keyword->exclude_href
;
379 $reset = $exalead_data->query
->context
.'/'.$keyword->reset_href
;
380 if($keyword->is_normal()){
381 $result .= _display_3_columns($title, $count, $refine, $exclude, false
);
384 $result .= _display_2_columns($title, $reset, $keyword->is_excluded(), false
);
388 $result .= "</table>";
392 function register_smarty_exalead(&$page){
393 $page->register_function('little_nav_barre','_little_nav_barre');
394 $page->register_function('exa_display_groupes', '_display_groupes');
395 $page->register_function('exa_display_resume_groupe', '_display_resume_groupe');
396 $page->register_function('exa_display_resume_keywords', '_display_resume_keywords');
397 $page->register_function('exa_display_keywords', '_display_keywords');
398 $page->register_function('exa_navigation_gauche', '_exa_navigation_gauche');
399 $page->register_function('exa_navigation_droite', '_exa_navigation_droite');
400 $page->register_function('exa_navigation_barre', '_exa_navigation_barre');
404 register_smarty_exalead($page);