Skip to content
Extraits de code Groupes Projets
Valider 2675cc3e rédigé par JamesRezo's avatar JamesRezo :tada:
Parcourir les fichiers

moins de globales sur la pagination. On peut surcharger le calcul des bornes

parent 1fc3e624
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -2648,6 +2648,19 @@ function form_hidden($action) { ...@@ -2648,6 +2648,19 @@ function form_hidden($action) {
return $hidden; return $hidden;
} }
function calcul_bornes_pagination($max, $nombre, $courante) {
if (function_exists("bornes_pagination"))
return bornes_pagination($max, $nombre, $courante);
if($max<=0 OR $max>=$nombre)
return array(1, $nombre);
$premiere = max(1, $courante-floor($max/2));
$derniere = min($nombre, $premiere+$max-1);
$premiere = $derniere == $nombre ? $derniere-$max+1 : $premiere;
return array($premiere, $derniere);
}
// //
// fonction standard de calcul de la balise #PAGINATION // fonction standard de calcul de la balise #PAGINATION
// on peut la surcharger en definissant dans mes_fonctions : // on peut la surcharger en definissant dans mes_fonctions :
...@@ -2657,10 +2670,11 @@ function calcul_pagination($total, $nom, $pas, $liste = true) { ...@@ -2657,10 +2670,11 @@ function calcul_pagination($total, $nom, $pas, $liste = true) {
if (function_exists("pagination")) if (function_exists("pagination"))
return pagination($total, $nom, $pas, $liste); return pagination($total, $nom, $pas, $liste);
global $pagination_item_avant, $pagination_item_apres, $pagination_separateur; $pagination_separateur = '&nbsp;| ';
global $pagination_max, $pagination_max_texte;
tester_variable('pagination_separateur', '&nbsp;| '); global $pagination_max;
tester_variable('pagination_max_texte', '...'); tester_variable($pagination_max, 10);
$pagination_max = intval($pagination_max);
$debut = 'debut'.$nom; $debut = 'debut'.$nom;
...@@ -2677,21 +2691,6 @@ function calcul_pagination($total, $nom, $pas, $liste = true) { ...@@ -2677,21 +2691,6 @@ function calcul_pagination($total, $nom, $pas, $liste = true) {
$ancre='pagination'.$nom; $ancre='pagination'.$nom;
$bloc_ancre = unique("<a name='$ancre' id='$ancre'></a>"); $bloc_ancre = unique("<a name='$ancre' id='$ancre'></a>");
if($pagination_max == 0 OR $pagination_max>=$pagination['nombre_pages']) {
$premiere = 1;
$derniere = $pagination['nombre_pages'];
$texte_avant = '';
$texte_apres = '';
}
else {
$premiere = max(1, $pagination['page_courante']-floor($pagination_max/2));
$derniere = min($pagination['nombre_pages'], $premiere+$pagination_max-1);
$premiere = $derniere == $pagination['nombre_pages'] ? $derniere-$pagination_max+1 : $premiere;
$texte_avant = $premiere>1 ? $pagination_max_texte.' ' : '';
$texte_apres = $derniere<$pagination['nombre_pages'] ? ' '.$pagination_max_texte : '';
}
// Pas de pagination // Pas de pagination
if($pagination['nombre_pages']<=1) if($pagination['nombre_pages']<=1)
return ''; return '';
...@@ -2700,6 +2699,8 @@ function calcul_pagination($total, $nom, $pas, $liste = true) { ...@@ -2700,6 +2699,8 @@ function calcul_pagination($total, $nom, $pas, $liste = true) {
if (!$liste) if (!$liste)
return $bloc_ancre; return $bloc_ancre;
list($premiere, $derniere) = calcul_bornes_pagination($pagination_max, $pagination['nombre_pages'], $pagination['page_courante']);
// liste = true : on retourne tout (ancre + bloc de navigation) // liste = true : on retourne tout (ancre + bloc de navigation)
$texte = ''; $texte = '';
for($i = $premiere;$i<=$derniere;$i++) { for($i = $premiere;$i<=$derniere;$i++) {
...@@ -2711,10 +2712,10 @@ function calcul_pagination($total, $nom, $pas, $liste = true) { ...@@ -2711,10 +2712,10 @@ function calcul_pagination($total, $nom, $pas, $liste = true) {
array($url.'#'.$ancre, $_item), array($url.'#'.$ancre, $_item),
$pagination['lien_pagination']) : $pagination['lien_pagination']) :
$_item; $_item;
$texte .= $pagination_item_avant.$item.$pagination_item_apres; $texte .= $item;
if($i<$pagination['nombre_pages']) $texte .= $pagination_separateur; if($i<$pagination['nombre_pages']) $texte .= $pagination_separateur;
} }
return $bloc_ancre.$texte_avant.$texte.$texte_apres; return $bloc_ancre.$texte;
} }
### fonction depreciee, laissee ici pour compat ascendante 1.9 ### fonction depreciee, laissee ici pour compat ascendante 1.9
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter