summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--phpfspot.class.php39
-rw-r--r--phpfspot.js7
-rw-r--r--phpfspot_cfg.php12
-rw-r--r--rpc.php1
-rw-r--r--templates/photo_index.tpl22
5 files changed, 72 insertions, 9 deletions
diff --git a/phpfspot.class.php b/phpfspot.class.php
index 0fa1740..525b5c1 100644
--- a/phpfspot.class.php
+++ b/phpfspot.class.php
@@ -280,7 +280,7 @@ class PHPFSPOT {
}
/* return according the selected tags */
- if(isset($_SESSION['selected_tags'])) {
+ if(isset($_SESSION['selected_tags']) && !empty($_SESSION['selected_tags'])) {
$selected = "";
foreach($_SESSION['selected_tags'] as $tag)
$selected.= $tag .",";
@@ -354,18 +354,41 @@ class PHPFSPOT {
$count = count($photos);
+ if(!$_SESSION['begin_with'] || $_SESSION['begin_with'] == 0)
+ $begin_with = 0;
+ else
+ $begin_with = $_SESSION['begin_with'];
+
+ if($this->cfg->rows_per_page == 0)
+ $end_with = $count;
+ else
+ $end_with = $begin_with + ($this->cfg->rows_per_page * $this->cfg->thumbs_per_row);
+
+
$rows = 0;
$cols = 0;
$images[$rows] = Array();
+ $img_height[$rows] = Array();
+ $img_width[$rows] = Array();
- for($i = 0; $i < $count; $i++) {
+ for($i = $begin_with; $i < $end_with; $i++) {
$images[$rows][$cols] = $photos[$i];
+ $thumb_path = $this->cfg->base_path ."/thumbs/". $this->cfg->thumb_width ."_". $this->getMD5($photos[$i]);
+
+ if(file_exists($thumb_path)) {
+ $info = getimagesize($thumb_path);
+ $img_width[$rows][$cols] = $info[0];
+ $img_height[$rows][$cols] = $info[1];
+ }
+
if($cols == $this->cfg->thumbs_per_row-1) {
$cols = 0;
$rows++;
$images[$rows] = Array();
+ $img_width[$rows] = Array();
+ $img_height[$rows] = Array();
}
else {
$cols++;
@@ -378,9 +401,21 @@ class PHPFSPOT {
if(isset($_SESSION['searchfor']) && $_SESSION['searchfor'] != '')
$this->tmpl->assign('searchfor', $_SESSION['searchfor']);
+ if($this->cfg->rows_per_page != 0) {
+ $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);
+
+ if($begin_with != 0)
+ $this->tmpl->assign("previous_url", "javascript:showPhotoIndex(". $previous_start .");");
+ if($end_with < $count)
+ $this->tmpl->assign("next_url", "javascript:showPhotoIndex(". $next_start .");");
+ }
+
$this->tmpl->assign('count', $count);
$this->tmpl->assign('width', $this->cfg->thumb_width);
$this->tmpl->assign('images', $images);
+ $this->tmpl->assign('img_width', $img_width);
+ $this->tmpl->assign('img_height', $img_height);
$this->tmpl->assign('rows', $rows);
$this->tmpl->assign('columns', $this->cfg->thumbs_per_row);
$this->tmpl->show("photo_index.tpl");
diff --git a/phpfspot.js b/phpfspot.js
index 4849295..fcc5766 100644
--- a/phpfspot.js
+++ b/phpfspot.js
@@ -48,9 +48,12 @@ function refreshSelectedTags()
selected_tags.innerHTML = HTML_AJAX.grab(encodeURI('rpc.php?action=show_selected_tags'));
}
-function showPhotoIndex()
+function showPhotoIndex(begin_with)
{
- HTML_AJAX.replace(document.getElementById("content"), encodeURI('rpc.php?action=show_photo_index'));
+ if(begin_with == undefined)
+ HTML_AJAX.replace(document.getElementById("content"), encodeURI('rpc.php?action=show_photo_index'));
+ else
+ HTML_AJAX.replace(document.getElementById("content"), encodeURI('rpc.php?action=show_photo_index&begin_with=' + begin_with));
}
function showBubbleDetails(object, id, direction)
diff --git a/phpfspot_cfg.php b/phpfspot_cfg.php
index a451544..ecb45ac 100644
--- a/phpfspot_cfg.php
+++ b/phpfspot_cfg.php
@@ -7,17 +7,17 @@ class PHPFSPOT_CFG {
var $product = "phpfspot";
var $version = "0.1";
- var $base_path = "/var/www/images.netshadow.at/htdocs/phpfspot";
+ var $base_path = "/var/www/images.netshadow.at/htdocs";
var $web_path = "/phpfspot";
/* it's enough if this database is readonly for the webserver */
- var $fspot_db = "/var/www/images.netshadow.at/htdocs/phpfspot/photos.db";
+ var $fspot_db = "/var/www/images.netshadow.at/f-spot-dbs/photos.db";
/* this database MUST be writeable for the webserver. Set the directory
permissions correctly so phpfspot can create this database for you!!
*/
- var $phpfspot_db = "/var/www/images.netshadow.at/htdocs/phpfspot/phpfspot.db";
+ var $phpfspot_db = "/var/www/images.netshadow.at/f-spot-dbs/phpfspot.db";
/* don't touch if you haven't changed the base templates */
var $thumb_width = "150";
@@ -27,12 +27,16 @@ class PHPFSPOT_CFG {
/* how many columns in the photo index view */
var $thumbs_per_row = 4;
+ /* how many rows should be displayed on the photo index view */
+ /* use 0 to display all matching photos on one page */
+ var $rows_per_page = 4;
+
/* Usually the photo directory differs between your local F-Spot installation
and your webserver. With this you can advice phpfspot to replace all paths
(they are stored in F-Spot's sqlite3 database
*/
var $path_replace_from = "/home/unki";
- var $path_replace_to = "/var/www/images.netshadow.at/htdocs/phpfspot";
+ var $path_replace_to = "/var/www/images.netshadow.at";
/* This is not really a security option - it only hides some present F-Spot
tags from the available-tags-list
diff --git a/rpc.php b/rpc.php
index 0bdccc9..6775647 100644
--- a/rpc.php
+++ b/rpc.php
@@ -80,6 +80,7 @@ class PHPFSPOT_RPC {
case 'show_photo_index':
+ $_SESSION['begin_with'] = $_GET['begin_with'];
$fspot->showPhotoIndex();
break;
diff --git a/templates/photo_index.tpl b/templates/photo_index.tpl
index 89d348e..36d0955 100644
--- a/templates/photo_index.tpl
+++ b/templates/photo_index.tpl
@@ -33,7 +33,7 @@
<div id="outter">
<div id="inner">
<a href="javascript:showImage({$images[row][col]});" id="{$images[row][col]}" class="bubble">
- <img class="thumb" id="{$images[row][col]}" src="phpfspot_img.php?idx={$images[row][col]}&amp;width={$width}" alt="thumb_{$images[row][col]}" />
+ <img class="thumb" id="{$images[row][col]}" src="phpfspot_img.php?idx={$images[row][col]}&amp;width={$width}" alt="thumb_{$images[row][col]}" width="{$img_width[row][col]}" height="{$img_height[row][col]}" />
</a>
</div>
</div>
@@ -48,6 +48,26 @@
</div>
</td>
</tr>
+ <tr>
+ <td style="text-align: left; width: 33%;">
+ { if $previous_url == "" }
+ &nbsp;
+ { else }
+ <a href="{$previous_url}">
+ <img src="resources/arrow_left.png" alt="previous photo" />
+ </a>
+ { /if }
+ </td>
+ <td style="text-align: right; width: 33%;">
+ { if $next_url == "" }
+ &nbsp;
+ { else }
+ <a href="{$next_url}">
+ <img src="resources/arrow_right.png" alt="next photo" />
+ </a>
+ { /if}
+ </td>
+ </tr>
</table>
<script type="text/javascript">
<!--