aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpatdenice <patdenice@piwigo.org>2009-03-05 21:08:04 +0000
committerpatdenice <patdenice@piwigo.org>2009-03-05 21:08:04 +0000
commit254aee26953b4e862b73467968f92138a6283da1 (patch)
treef2a78dbce4e54be16dd1698b67bb4a5df2d9c0d1
parentd3e6eabb053f311d5d8fd4ec80cfb0c1b32cf141 (diff)
Create navigation_bar.tpl file.
Move create_navigation_bar function from functions_html.inc.php to functions.inc.php. git-svn-id: http://piwigo.org/svn/trunk@3172 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--admin/element_set_global.php2
-rw-r--r--admin/element_set_unit.php2
-rw-r--r--admin/history.php2
-rw-r--r--admin/rating.php2
-rw-r--r--admin/template/goto/element_set_global.tpl2
-rw-r--r--admin/template/goto/element_set_unit.tpl4
-rw-r--r--admin/template/goto/history.tpl15
-rw-r--r--admin/template/goto/navigation_bar.tpl39
-rw-r--r--admin/template/goto/rating.tpl5
-rw-r--r--admin/template/goto/user_list.tpl2
-rw-r--r--admin/user_list.php2
-rw-r--r--comments.php2
-rw-r--r--include/functions.inc.php69
-rw-r--r--include/functions_html.inc.php147
-rw-r--r--include/picture_comment.inc.php2
-rw-r--r--index.php7
-rw-r--r--template/yoga/comments.tpl2
-rw-r--r--template/yoga/index.tpl7
-rw-r--r--template/yoga/navigation_bar.tpl39
-rw-r--r--template/yoga/picture.tpl4
20 files changed, 167 insertions, 189 deletions
diff --git a/admin/element_set_global.php b/admin/element_set_global.php
index 2ad3ab164..4f223b2cc 100644
--- a/admin/element_set_global.php
+++ b/admin/element_set_global.php
@@ -467,7 +467,7 @@ if (count($page['cat_elements_id']) > 0)
$page['start'],
$page['nb_images']
);
- $template->assign('NAV_BAR', $nav_bar);
+ $template->assign('navbar', $nav_bar);
$query = '
SELECT id,path,tn_ext,file,filesize,level
diff --git a/admin/element_set_unit.php b/admin/element_set_unit.php
index cf6ef7781..67f5a62e6 100644
--- a/admin/element_set_unit.php
+++ b/admin/element_set_unit.php
@@ -184,7 +184,7 @@ if (count($page['cat_elements_id']) > 0)
$page['start'],
$page['nb_images']
);
- $template->assign(array('NAV_BAR' => $nav_bar));
+ $template->assign(array('navbar' => $nav_bar));
// tags
$all_tags = get_all_tags();
diff --git a/admin/history.php b/admin/history.php
index 04d60fcde..c357a498f 100644
--- a/admin/history.php
+++ b/admin/history.php
@@ -569,7 +569,7 @@ if (isset($page['search_id']))
$conf['nb_logs_page']
);
- $template->assign('NAV_BAR', $navbar);
+ $template->assign('navbar', $navbar);
}
// +-----------------------------------------------------------------------+
diff --git a/admin/rating.php b/admin/rating.php
index 67cc14502..e2f614abe 100644
--- a/admin/rating.php
+++ b/admin/rating.php
@@ -115,7 +115,7 @@ $template->set_filename('rating', 'rating.tpl');
$template->assign(
array(
- 'NAVBAR' => create_navigation_bar(
+ 'navbar' => create_navigation_bar(
PHPWG_ROOT_PATH.'admin.php'.get_query_string_diff(array('start','del')),
$nb_images,
$start,
diff --git a/admin/template/goto/element_set_global.tpl b/admin/template/goto/element_set_global.tpl
index 0dfa11876..cd12410bc 100644
--- a/admin/template/goto/element_set_global.tpl
+++ b/admin/template/goto/element_set_global.tpl
@@ -37,7 +37,7 @@
<legend>{'Elements'|@translate}</legend>
- {if !empty($NAV_BAR)}<div class="navigationBar">{$NAV_BAR}</div>{/if}
+ {if !empty($navbar) }{include file='navigation_bar.tpl'}{/if}
{if !empty($thumbnails)}
<ul class="thumbnails">
diff --git a/admin/template/goto/element_set_unit.tpl b/admin/template/goto/element_set_unit.tpl
index 14d5a34a5..1c9d99ae2 100644
--- a/admin/template/goto/element_set_unit.tpl
+++ b/admin/template/goto/element_set_unit.tpl
@@ -24,9 +24,7 @@
</fieldset>
-{if !empty($NAV_BAR) }
-<div class="navigationBar">{$NAV_BAR}</div>
-{/if}
+{if !empty($navbar) }{include file='navigation_bar.tpl'}{/if}
{if !empty($elements) }
<input type="hidden" name="element_ids" value="{$ELEMENT_IDS}" />
diff --git a/admin/template/goto/history.tpl b/admin/template/goto/history.tpl
index 3e4bcce6c..9291f4a36 100644
--- a/admin/template/goto/history.tpl
+++ b/admin/template/goto/history.tpl
@@ -102,13 +102,7 @@
</fieldset>
{/if}
-
-{if !empty($NAV_BAR)}
-<div class="navigationBar">
- {$NAV_BAR}
-</div>
-{/if}
-
+{if !empty($navbar) }{include file='navigation_bar.tpl'}{/if}
<table class="table2" id="detailedStats">
<tr class="throw">
@@ -139,9 +133,4 @@
{/if}
</table>
-
-{if !empty($NAV_BAR)}
-<div class="navigationBar">
- {$NAV_BAR}
-</div>
-{/if}
+{if !empty($navbar) }{include file='navigation_bar.tpl'}{/if}
diff --git a/admin/template/goto/navigation_bar.tpl b/admin/template/goto/navigation_bar.tpl
new file mode 100644
index 000000000..94c8ad05f
--- /dev/null
+++ b/admin/template/goto/navigation_bar.tpl
@@ -0,0 +1,39 @@
+{* $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>
+{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}
+ <span class="pageNumberSelected">{$page}</span>
+ {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}
+
+</div> \ No newline at end of file
diff --git a/admin/template/goto/rating.tpl b/admin/template/goto/rating.tpl
index c50a26602..0ff212bf5 100644
--- a/admin/template/goto/rating.tpl
+++ b/admin/template/goto/rating.tpl
@@ -32,7 +32,8 @@
</fieldset>
</form>
-<div class="navigationBar">{$NAVBAR}</div>
+{if !empty($navbar) }{include file='navigation_bar.tpl'}{/if}
+
<table width="99%">
<tr class="throw">
<td>{'File'|@translate}</td>
@@ -64,4 +65,4 @@
{/foreach} {*images*}
</table>
-<div class="navigationBar">{$NAVBAR}</div>
+{if !empty($navbar) }{include file='navigation_bar.tpl'}{/if}
diff --git a/admin/template/goto/user_list.tpl b/admin/template/goto/user_list.tpl
index aa4e369dc..e6c4373ac 100644
--- a/admin/template/goto/user_list.tpl
+++ b/admin/template/goto/user_list.tpl
@@ -91,7 +91,7 @@
{/foreach}
</table>
-<div class="navigationBar">{$NAVBAR}</div>
+{if !empty($navbar) }{include file='navigation_bar.tpl'}{/if}
{* delete the selected users ? *}
<fieldset>
diff --git a/admin/user_list.php b/admin/user_list.php
index 5011a2aea..abfc94742 100644
--- a/admin/user_list.php
+++ b/admin/user_list.php
@@ -589,7 +589,7 @@ $navbar = create_navigation_bar(
$conf['users_page']
);
-$template->assign('NAVBAR', $navbar);
+$template->assign('navbar', $navbar);
// +-----------------------------------------------------------------------+
// | user list |
diff --git a/comments.php b/comments.php
index 3b637e7f8..91fbc555c 100644
--- a/comments.php
+++ b/comments.php
@@ -265,7 +265,7 @@ $navbar = create_navigation_bar($url,
$page['items_number'],
'');
-$template->assign('NAVBAR', $navbar);
+$template->assign('navbar', $navbar);
// +-----------------------------------------------------------------------+
// | last comments display |
diff --git a/include/functions.inc.php b/include/functions.inc.php
index 83c9980de..3f43b943a 100644
--- a/include/functions.inc.php
+++ b/include/functions.inc.php
@@ -1493,4 +1493,73 @@ function get_comment_post_key($image_id)
)
);
}
+
+/**
+ * return an array which will be sent to template to display navigation bar
+ */
+function create_navigation_bar($url, $nb_element, $start, $nb_element_page, $clean_url = false)
+{
+ global $conf;
+
+ $pages_around = $conf['paginate_pages_around'];
+ $start_str = $clean_url ? '/start-' : (strpos($url, '?')===false ? '?':'&amp;').'start=';
+
+ if (!isset($start) or !is_numeric($start) or (is_numeric($start) and $start < 0))
+ {
+ $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);
+
+ $navbar['CURRENT_PAGE'] = $cur_page;
+
+ // link to first 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 ?
+ if ($cur_page != $maximum)
+ {
+ $temp_start = ($maximum - 1) * $nb_element_page;
+ $navbar['URL_LAST'] = $url.$start_str.$temp_start;
+ }
+
+ // pages to display
+ $navbar['pages'] = array();
+
+ $navbar['pages'][1] = $url;
+ $navbar['pages'][$maximum] = $url.$start_str. ($maximum - 1) * $nb_element_page;
+
+ for ($i = $cur_page - $pages_around, $stop = $cur_page + $pages_around + 1; $i < $stop; $i++)
+ {
+ if ($i < 2 or $i > $maximum - 1)
+ {
+ continue;
+ }
+ $navbar['pages'][$i] = $url.$start_str. ($i - 1) * $nb_element_page;
+ }
+ ksort($navbar['pages']);
+ }
+ return $navbar;
+}
?> \ No newline at end of file
diff --git a/include/functions_html.inc.php b/include/functions_html.inc.php
index 9b045bfcb..45e5e04eb 100644
--- a/include/functions_html.inc.php
+++ b/include/functions_html.inc.php
@@ -73,153 +73,6 @@ function get_icon($date, $is_child_date = false)
return $cache['get_icon']['_icons_'][$is_child_date];
}
-function create_navigation_bar(
- $url, $nb_element, $start, $nb_element_page, $clean_url = false
- )
-{
- global $conf;
-
- $pages_around = $conf['paginate_pages_around'];
- $start_str = $clean_url ? '/start-' :
- ( ( strpos($url, '?')===false ? '?':'&amp;') . 'start=' );
-
- $navbar = '';
-
- // current page detection
- if (!isset($start)
- or !is_numeric($start)
- or (is_numeric($start) and $start < 0))
- {
- $start = 0;
- }
-
- // 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);
-
- // link to first page ?
- if ($cur_page != 1)
- {
- $navbar.=
- '<a href="'.$url.'" rel="first">'
- .l10n('first_page')
- .'</a>';
- }
- else
- {
- $navbar.= l10n('first_page');
- }
- $navbar.= ' | ';
- // link on previous page ?
- if ($start != 0)
- {
- $previous = $start - $nb_element_page;
-
- $navbar.=
- '<a href="'
- .$url.($previous > 0 ? $start_str.$previous : '')
- .'" rel="prev">'
- .l10n('previous_page')
- .'</a>';
- }
- else
- {
- $navbar.= l10n('previous_page');
- }
- $navbar.= ' |';
-
- if ($cur_page > $pages_around + 1)
- {
- $navbar.= '&nbsp;<a href="'.$url.'">1</a>';
-
- if ($cur_page > $pages_around + 2)
- {
- $navbar.= ' ...';
- }
- }
-
- // inspired from punbb source code
- for ($i = $cur_page - $pages_around, $stop = $cur_page + $pages_around + 1;
- $i < $stop;
- $i++)
- {
- if ($i < 1 or $i > $maximum)
- {
- continue;
- }
- else if ($i != $cur_page)
- {
- $temp_start = ($i - 1) * $nb_element_page;
-
- $navbar.=
- '&nbsp;'
- .'<a href="'.$url
- .($temp_start > 0 ? $start_str.$temp_start : '')
- .'">'
- .$i
- .'</a>';
- }
- else
- {
- $navbar.=
- '&nbsp;'
- .'<span class="pageNumberSelected">'
- .$i
- .'</span>';
- }
- }
-
- if ($cur_page < ($maximum - $pages_around))
- {
- $temp_start = ($maximum - 1) * $nb_element_page;
-
- if ($cur_page < ($maximum - $pages_around - 1))
- {
- $navbar.= ' ...';
- }
-
- $navbar.= ' <a href="'.$url.$start_str.$temp_start.'">'.$maximum.'</a>';
- }
-
- $navbar.= ' | ';
- // link on next page ?
- if ($nb_element > $nb_element_page
- and $start + $nb_element_page < $nb_element)
- {
- $next = $start + $nb_element_page;
-
- $navbar.=
- '<a href="'.$url.$start_str.$next.'" rel="next">'
- .l10n('next_page')
- .'</a>';
- }
- else
- {
- $navbar.= l10n('next_page');
- }
-
- $navbar.= ' | ';
- // link to last page ?
- if ($cur_page != $maximum)
- {
- $temp_start = ($maximum - 1) * $nb_element_page;
-
- $navbar.=
- '<a href="'.$url.$start_str.$temp_start.'" rel="last">'
- .l10n('last_page')
- .'</a>';
- }
- else
- {
- $navbar.= l10n('last_page');
- }
- }
- return $navbar;
-}
-
/**
* returns the list of categories as a HTML string
*
diff --git a/include/picture_comment.inc.php b/include/picture_comment.inc.php
index 73b245b6b..2682d9dab 100644
--- a/include/picture_comment.inc.php
+++ b/include/picture_comment.inc.php
@@ -112,7 +112,7 @@ SELECT COUNT(*) AS nb_comments
$template->assign(
array(
'COMMENT_COUNT' => $row['nb_comments'],
- 'COMMENT_NAV_BAR' => $navigation_bar,
+ 'navbar' => $navigation_bar,
)
);
diff --git a/index.php b/index.php
index ac1835544..944b33a4d 100644
--- a/index.php
+++ b/index.php
@@ -64,6 +64,7 @@ if (isset($page['category']))
check_restrictions($page['category']['id']);
}
+$page['navigation_bar'] = array();
if (count($page['items']) > $user['nb_image_page'])
{
$page['navigation_bar'] = create_navigation_bar(
@@ -74,10 +75,6 @@ if (count($page['items']) > $user['nb_image_page'])
true
);
}
-else
-{
- $page['navigation_bar'] = '';
-}
// caddie filling :-)
if (isset($_GET['caddie']))
@@ -219,7 +216,7 @@ if ( $page['section']=='search' and $page['start']==0 and
}
// navigation bar
-$template->assign( 'NAV_BAR', $page['navigation_bar'] );
+$template->assign( 'navbar', $page['navigation_bar'] );
if ( count($page['items']) > 0
and $page['section'] != 'most_visited'
diff --git a/template/yoga/comments.tpl b/template/yoga/comments.tpl
index da3c2a165..1475b1810 100644
--- a/template/yoga/comments.tpl
+++ b/template/yoga/comments.tpl
@@ -65,7 +65,7 @@
</form>
-<div class="navigationBar">{$NAVBAR}</div>
+{if !empty($navbar) }{include file='navigation_bar.tpl'}{/if}
{if isset($comments)}
<div id="comments">
diff --git a/template/yoga/index.tpl b/template/yoga/index.tpl
index 4a87fc9c1..cc882d9d1 100644
--- a/template/yoga/index.tpl
+++ b/template/yoga/index.tpl
@@ -103,12 +103,7 @@
{if !empty($CATEGORIES) }{$CATEGORIES}{/if}
{if !empty($THUMBNAILS) }{$THUMBNAILS}{/if}
-
-{if !empty($NAV_BAR) }
-<div class="navigationBar">
- {$NAV_BAR}
-</div>
-{/if}
+{if !empty($navbar) }{include file='navigation_bar.tpl'}{/if}
{if !empty($CONTENT_DESCRIPTION) }
<div class="additional_info">
diff --git a/template/yoga/navigation_bar.tpl b/template/yoga/navigation_bar.tpl
new file mode 100644
index 000000000..94c8ad05f
--- /dev/null
+++ b/template/yoga/navigation_bar.tpl
@@ -0,0 +1,39 @@
+{* $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>
+{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}
+ <span class="pageNumberSelected">{$page}</span>
+ {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}
+
+</div> \ No newline at end of file
diff --git a/template/yoga/picture.tpl b/template/yoga/picture.tpl
index 26450a21c..a6c9eda06 100644
--- a/template/yoga/picture.tpl
+++ b/template/yoga/picture.tpl
@@ -255,9 +255,7 @@ y.callService(
{if $COMMENT_COUNT > 0}
<h3>{$pwg->l10n_dec('%d comment', '%d comments',$COMMENT_COUNT)}</h3>
{/if}
- {if !empty($COMMENT_NAV_BAR)}
- <div class="navigationBar">{$COMMENT_NAV_BAR}</div>
- {/if}
+ {if !empty($navbar) }{include file='navigation_bar.tpl'}{/if}
{if isset($comments)}
{include file='comment_list.tpl' comment_separator=true}