summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Unterkircher <unki@netshadow.at>2007-07-01 09:04:03 +0000
committerAndreas Unterkircher <unki@netshadow.at>2007-07-01 09:04:03 +0000
commit7258a4139baaaace3ce9bbeeeab8a20da1b12ff7 (patch)
tree8d4c1562f53368667b8b689b236e69e732ae179c
parentf02f5af73dc6dea8e56824edba0fa187a19ac54f (diff)
issue6, page selector - a first try
git-svn-id: file:///var/lib/svn/phpfspot/trunk@152 fa6a889d-dae6-447d-9e79-4ba9a3039384
-rw-r--r--phpfspot.class.php43
-rw-r--r--templates/photo_index.tpl57
2 files changed, 78 insertions, 22 deletions
diff --git a/phpfspot.class.php b/phpfspot.class.php
index 7b11595..c142742 100644
--- a/phpfspot.class.php
+++ b/phpfspot.class.php
@@ -437,6 +437,8 @@ class PHPFSPOT {
$this->tmpl->assign('searchfor', $_SESSION['searchfor']);
if($this->cfg->rows_per_page != 0) {
+
+ /* calculate the page switchers */
$previous_start = $begin_with - ($this->cfg->rows_per_page * $this->cfg->thumbs_per_row);
$next_start = $begin_with + ($this->cfg->rows_per_page * $this->cfg->thumbs_per_row);
@@ -444,6 +446,47 @@ class PHPFSPOT {
$this->tmpl->assign("previous_url", "javascript:showPhotoIndex(". $previous_start .");");
if($end_with < $count)
$this->tmpl->assign("next_url", "javascript:showPhotoIndex(". $next_start .");");
+
+ /* page selector */
+ $photo_per_page = $this->cfg->rows_per_page * $this->cfg->thumbs_per_row;
+
+ /* until 6 pages we show the selector from 1-6
+ everything large will be
+ 1 ... 2 3 4 (5) 6 7 ... 9
+ */
+ $last_page = ceil($count / $photo_per_page);
+
+ if($begin_with == 0) {
+ $current_page = 1;
+ }
+ else {
+ $current_page = 0;
+ for($i = $begin_with; $i >= 0; $i-=$photo_per_page) {
+ $current_page++;
+ }
+ }
+
+ for($i = 1; $i <= $last_page; $i++) {
+
+
+ if($current_page == $i)
+ $style = "style=\"font-size: 125%;\"";
+ elseif($current_page-1 == $i || $current_page+1 == $i)
+ $style = "style=\"font-size: 105%;\"";
+ elseif(($current_page-5 >= $i) && ($i != 1) ||
+ ($current_page+5 <= $i) && ($i != $last_page))
+ $style = "style=\"font-size: 75%;\"";
+ else
+ $style = "";
+
+ $page_select.= "<a href=\"javascript:showPhotoIndex(". (($i*$photo_per_page)-$photo_per_page) .");\"";
+ if($style != "")
+ $page_select.= $style;
+ $page_select.= ">". $i ."</a>&nbsp;";
+
+ }
+
+ $this->tmpl->assign('page_selector', $page_select);
}
$current_tags = "";
diff --git a/templates/photo_index.tpl b/templates/photo_index.tpl
index 61f54d4..28a933d 100644
--- a/templates/photo_index.tpl
+++ b/templates/photo_index.tpl
@@ -1,29 +1,35 @@
<!-- Image Matrix -->
<table>
<tr>
- <td class="index_header">
- <b>Photo Index,</b>
- {if ! $searchfor }
- {if $count == 1}
- {$count} image has been found for the selected tags
- {else}
- {$count} images have been found for the selected tags
- {/if}
- {else}
- {if $count == 1}
- {$count} image is the result for your search about "{$searchfor}"
- {else}
- {$count} images are the result for your search about "{$searchfor}"
- {/if}
- {/if}
- </td>
- <td class="index_header" style="text-align: right;">
- <a href="{$extern_link}">Extern</a>
- <img src="resources/photo_index.png" alt="photo index" />
+ <td colspan="3">
+ <table style="width: 100%;">
+ <tr>
+ <td class="index_header"style="width: 80%;">
+ <b>Photo Index,</b>
+ {if ! $searchfor }
+ {if $count == 1}
+ {$count} image has been found for the selected tags
+ {else}
+ {$count} images have been found for the selected tags
+ {/if}
+ {else}
+ {if $count == 1}
+ {$count} image is the result for your search about "{$searchfor}"
+ {else}
+ {$count} images are the result for your search about "{$searchfor}"
+ {/if}
+ {/if}
+ </td>
+ <td class="index_header" style="text-align: right;">
+ <a href="{$extern_link}">Extern</a>
+ <img src="resources/photo_index.png" alt="photo index" />
+ </td>
+ </tr>
+ </table>
</td>
</tr>
<tr>
- <td colspan="2">
+ <td colspan="3">
<div id="matrix">
<table>
{section name="row" loop=$rows step=1}
@@ -50,7 +56,7 @@
</td>
</tr>
<tr>
- <td style="text-align: left; width: 33%;">
+ <td style="text-align: left; width: 32px;">
{ if $previous_url == "" }
&nbsp;
{ else }
@@ -59,7 +65,14 @@
</a>
{ /if }
</td>
- <td style="text-align: right; width: 33%;">
+ <td style="text-align: center;">
+ { if $page_selector == "" }
+ &nbsp;
+ { else }
+ {$page_selector}
+ { /if}
+ </td>
+ <td style="text-align: right; width: 32px;">
{ if $next_url == "" }
&nbsp;
{ else }