Changeset 3173 for trunk/include/functions.inc.php
- Timestamp:
- Mar 6, 2009, 2:06:18 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/functions.inc.php
r3172 r3173 1502 1502 global $conf; 1503 1503 1504 $navbar = array(); 1504 1505 $pages_around = $conf['paginate_pages_around']; 1505 1506 $start_str = $clean_url ? '/start-' : (strpos($url, '?')===false ? '?':'&').'start='; … … 1510 1511 } 1511 1512 1512 $navbar = array();1513 1514 1513 // navigation bar useful only if more than one page to display ! 1515 1514 if ($nb_element > $nb_element_page) 1516 1515 { 1517 // current page and last page1518 1516 $cur_page = ceil($start / $nb_element_page) + 1; 1519 1517 $maximum = ceil($nb_element / $nb_element_page); 1518 $previous = $start - $nb_element_page; 1519 $next = $start + $nb_element_page; 1520 $last = ($maximum - 1) * $nb_element_page; 1520 1521 1521 1522 $navbar['CURRENT_PAGE'] = $cur_page; 1522 1523 1523 // link to first page ?1524 // link to first page and previous page? 1524 1525 if ($cur_page != 1) 1525 1526 { 1526 1527 $navbar['URL_FIRST'] = $url; 1527 }1528 // link on previous page ?1529 if ($start != 0)1530 {1531 $previous = $start - $nb_element_page;1532 1528 $navbar['URL_PREV'] = $url.($previous > 0 ? $start_str.$previous : ''); 1533 1529 } 1534 // link on next page ? 1535 if ($nb_element > $nb_element_page and $start + $nb_element_page < $nb_element) 1536 { 1537 $next = $start + $nb_element_page; 1530 // link on next page and last page? 1531 if ($cur_page != $maximum) 1532 { 1538 1533 $navbar['URL_NEXT'] = $url.$start_str.$next; 1539 } 1540 // link to last page ? 1541 if ($cur_page != $maximum) 1542 { 1543 $temp_start = ($maximum - 1) * $nb_element_page; 1544 $navbar['URL_LAST'] = $url.$start_str.$temp_start; 1534 $navbar['URL_LAST'] = $url.$start_str.$last; 1545 1535 } 1546 1536 1547 1537 // pages to display 1548 1538 $navbar['pages'] = array(); 1549 1550 1539 $navbar['pages'][1] = $url; 1551 $navbar['pages'][$maximum] = $url.$start_str. ($maximum - 1) * $nb_element_page; 1552 1553 for ($i = $cur_page - $pages_around, $stop = $cur_page + $pages_around + 1; $i < $stop; $i++) 1554 { 1555 if ($i < 2 or $i > $maximum - 1) 1556 { 1557 continue; 1558 } 1559 $navbar['pages'][$i] = $url.$start_str. ($i - 1) * $nb_element_page; 1540 $navbar['pages'][$maximum] = $url.$start_str.$last; 1541 1542 for ($i = max($cur_page - $pages_around , 2), $stop = min($cur_page + $pages_around + 1, $maximum); 1543 $i < $stop; $i++) 1544 { 1545 $navbar['pages'][$i] = $url.$start_str.(($i - 1) * $nb_element_page); 1560 1546 } 1561 1547 ksort($navbar['pages']);
Note: See TracChangeset
for help on using the changeset viewer.