diff options
Diffstat (limited to '')
-rw-r--r-- | admin/template/goto/navigation_bar.tpl | 56 | ||||
-rw-r--r-- | include/functions.inc.php | 38 | ||||
-rw-r--r-- | template/yoga/navigation_bar.tpl | 56 |
3 files changed, 58 insertions, 92 deletions
diff --git a/admin/template/goto/navigation_bar.tpl b/admin/template/goto/navigation_bar.tpl index 94c8ad05f..d21e7a031 100644 --- a/admin/template/goto/navigation_bar.tpl +++ b/admin/template/goto/navigation_bar.tpl @@ -1,39 +1,29 @@ {* $Id: navigation_bar.tpl 3145 2009-02-14 02:24:10Z patdenice $ *} <div class="navigationBar"> + {if isset($navbar.URL_FIRST)} + <a href="{$navbar.URL_FIRST}" rel="first">{'first_page'|@translate}</a> | + <a href="{$navbar.URL_PREV}" rel="prev">{'previous_page'|@translate}</a> | + {else} + {'first_page'|@translate} | + {'previous_page'|@translate} | + {/if} -{if isset($navbar.URL_FIRST)} -<a href="{$navbar.URL_FIRST}" rel="first">{'first_page'|@translate}</a> -{else} -{'first_page'|@translate} -{/if} -| -{if isset($navbar.URL_PREV)} -<a href="{$navbar.URL_PREV}" rel="prev">{'previous_page'|@translate}</a> -{else} -{'previous_page'|@translate} -{/if} -| -{assign var='prev_page' value=0} -{foreach from=$navbar.pages key=page item=url} - {if $page > $prev_page+1} ... {/if} - {if $page == $navbar.CURRENT_PAGE} + {assign var='prev_page' value=0} + {foreach from=$navbar.pages key=page item=url} + {if $page > $prev_page+1}...{/if} + {if $page == $navbar.CURRENT_PAGE} <span class="pageNumberSelected">{$page}</span> - {else} + {else} <a href="{$url}">{$page}</a> - {/if} -{assign var='prev_page' value=$page} -{/foreach} -| -{if isset($navbar.URL_NEXT)} -<a href="{$navbar.URL_NEXT}" rel="next">{'next_page'|@translate}</a> -{else} -{'next_page'|@translate} -{/if} -| -{if isset($navbar.URL_LAST)} -<a href="{$navbar.URL_LAST}" rel="last">{'last_page'|@translate}</a> -{else} -{'last_page'|@translate} -{/if} + {/if} + {assign var='prev_page' value=$page} + {/foreach} -</div>
\ No newline at end of file + {if isset($navbar.URL_NEXT)} + | <a href="{$navbar.URL_NEXT}" rel="next">{'next_page'|@translate}</a> + | <a href="{$navbar.URL_LAST}" rel="last">{'last_page'|@translate}</a> + {else} + | {'next_page'|@translate} + | {'last_page'|@translate} + {/if} +</div> diff --git a/include/functions.inc.php b/include/functions.inc.php index 3f43b943a..2e72eb2cb 100644 --- a/include/functions.inc.php +++ b/include/functions.inc.php @@ -1501,6 +1501,7 @@ function create_navigation_bar($url, $nb_element, $start, $nb_element_page, $cle { global $conf; + $navbar = array(); $pages_around = $conf['paginate_pages_around']; $start_str = $clean_url ? '/start-' : (strpos($url, '?')===false ? '?':'&').'start='; @@ -1509,54 +1510,39 @@ function create_navigation_bar($url, $nb_element, $start, $nb_element_page, $cle $start = 0; } - $navbar = array(); - // navigation bar useful only if more than one page to display ! if ($nb_element > $nb_element_page) { - // current page and last page $cur_page = ceil($start / $nb_element_page) + 1; $maximum = ceil($nb_element / $nb_element_page); + $previous = $start - $nb_element_page; + $next = $start + $nb_element_page; + $last = ($maximum - 1) * $nb_element_page; $navbar['CURRENT_PAGE'] = $cur_page; - // link to first page ? + // link to first page and previous page? if ($cur_page != 1) { $navbar['URL_FIRST'] = $url; - } - // link on previous page ? - if ($start != 0) - { - $previous = $start - $nb_element_page; $navbar['URL_PREV'] = $url.($previous > 0 ? $start_str.$previous : ''); } - // link on next page ? - if ($nb_element > $nb_element_page and $start + $nb_element_page < $nb_element) - { - $next = $start + $nb_element_page; - $navbar['URL_NEXT'] = $url.$start_str.$next; - } - // link to last page ? + // link on next page and last page? if ($cur_page != $maximum) { - $temp_start = ($maximum - 1) * $nb_element_page; - $navbar['URL_LAST'] = $url.$start_str.$temp_start; + $navbar['URL_NEXT'] = $url.$start_str.$next; + $navbar['URL_LAST'] = $url.$start_str.$last; } // pages to display $navbar['pages'] = array(); - $navbar['pages'][1] = $url; - $navbar['pages'][$maximum] = $url.$start_str. ($maximum - 1) * $nb_element_page; + $navbar['pages'][$maximum] = $url.$start_str.$last; - for ($i = $cur_page - $pages_around, $stop = $cur_page + $pages_around + 1; $i < $stop; $i++) + for ($i = max($cur_page - $pages_around , 2), $stop = min($cur_page + $pages_around + 1, $maximum); + $i < $stop; $i++) { - if ($i < 2 or $i > $maximum - 1) - { - continue; - } - $navbar['pages'][$i] = $url.$start_str. ($i - 1) * $nb_element_page; + $navbar['pages'][$i] = $url.$start_str.(($i - 1) * $nb_element_page); } ksort($navbar['pages']); } diff --git a/template/yoga/navigation_bar.tpl b/template/yoga/navigation_bar.tpl index 94c8ad05f..d21e7a031 100644 --- a/template/yoga/navigation_bar.tpl +++ b/template/yoga/navigation_bar.tpl @@ -1,39 +1,29 @@ {* $Id: navigation_bar.tpl 3145 2009-02-14 02:24:10Z patdenice $ *} <div class="navigationBar"> + {if isset($navbar.URL_FIRST)} + <a href="{$navbar.URL_FIRST}" rel="first">{'first_page'|@translate}</a> | + <a href="{$navbar.URL_PREV}" rel="prev">{'previous_page'|@translate}</a> | + {else} + {'first_page'|@translate} | + {'previous_page'|@translate} | + {/if} -{if isset($navbar.URL_FIRST)} -<a href="{$navbar.URL_FIRST}" rel="first">{'first_page'|@translate}</a> -{else} -{'first_page'|@translate} -{/if} -| -{if isset($navbar.URL_PREV)} -<a href="{$navbar.URL_PREV}" rel="prev">{'previous_page'|@translate}</a> -{else} -{'previous_page'|@translate} -{/if} -| -{assign var='prev_page' value=0} -{foreach from=$navbar.pages key=page item=url} - {if $page > $prev_page+1} ... {/if} - {if $page == $navbar.CURRENT_PAGE} + {assign var='prev_page' value=0} + {foreach from=$navbar.pages key=page item=url} + {if $page > $prev_page+1}...{/if} + {if $page == $navbar.CURRENT_PAGE} <span class="pageNumberSelected">{$page}</span> - {else} + {else} <a href="{$url}">{$page}</a> - {/if} -{assign var='prev_page' value=$page} -{/foreach} -| -{if isset($navbar.URL_NEXT)} -<a href="{$navbar.URL_NEXT}" rel="next">{'next_page'|@translate}</a> -{else} -{'next_page'|@translate} -{/if} -| -{if isset($navbar.URL_LAST)} -<a href="{$navbar.URL_LAST}" rel="last">{'last_page'|@translate}</a> -{else} -{'last_page'|@translate} -{/if} + {/if} + {assign var='prev_page' value=$page} + {/foreach} -</div>
\ No newline at end of file + {if isset($navbar.URL_NEXT)} + | <a href="{$navbar.URL_NEXT}" rel="next">{'next_page'|@translate}</a> + | <a href="{$navbar.URL_LAST}" rel="last">{'last_page'|@translate}</a> + {else} + | {'next_page'|@translate} + | {'last_page'|@translate} + {/if} +</div> |