From ca33ffdcbb65a0b344e450966c2fcff1d9e9212b Mon Sep 17 00:00:00 2001 From: Andreas Unterkircher Date: Wed, 6 Jun 2007 19:41:44 +0000 Subject: display photo index as matrix show a larger pic when user clicks on it git-svn-id: file:///var/lib/svn/phpfspot/trunk@25 fa6a889d-dae6-447d-9e79-4ba9a3039384 --- phpfspot.class.php | 47 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 36 insertions(+), 11 deletions(-) (limited to 'phpfspot.class.php') diff --git a/phpfspot.class.php b/phpfspot.class.php index 628cfea..dbefee8 100644 --- a/phpfspot.class.php +++ b/phpfspot.class.php @@ -39,7 +39,6 @@ class PHPFSPOT { public function show() { - $this->prepare_single_photo($this->current_photo); $this->tmpl->assign('tags', $this->tags); $this->tmpl->show("index.tpl"); @@ -117,21 +116,23 @@ class PHPFSPOT { } // translate_path - public function prepare_single_photo($photo) + public function showPhoto($photo) { if(isset($photo)) { - $this->tmpl->assign('image_url', 'phpfspot_img.php?idx='. $this->avail_photos[$photo] ."&width=". $this->cfg->photo_width); + $this->tmpl->assign('image_url', 'phpfspot_img.php?idx='. $photo ."&width=". $this->cfg->photo_width); } if($photo > 0) { $this->tmpl->assign('previous_url', "javascript:showImage(". ($photo-1) .");"); } - if($photo < count($this->avail_photos)) { + if($photo < count($this->photos)) { $this->tmpl->assign('next_url', "javascript:showImage(". ($photo+1) .");"); } - } // prepare_single_photo() + $this->tmpl->show("single_photo.tpl"); + + } // showPhoto() public function getAvailableTags() { @@ -212,19 +213,43 @@ class PHPFSPOT { array_push($tagged_photos, $row['photo_id']); } - return $tagged_photos; } // getAllTagPhotos() public function showPhotoIndex() { - foreach($this->getAllTagPhotos() as $photo) - { - $images.= "
\n"; - } + $photos = $this->getAllTagPhotos(); + $count = count($photos); + + $rows = 0; + $cols = 0; + $images[$rows] = Array(); + + for($i = 0; $i < $count; $i++) { + + $images[$rows][$cols] = $photos[$i]; + + if($cols == $this->cfg->thumbs_per_row-1) { + $cols = 0; + $rows++; + $images[$rows] = Array(); + } + else { + $cols++; + } + } + + // +1 for for smarty's selection iteration + $rows++; + + //$images.= "
\n"; - $this->tmpl->assign('image_matrix', $images); + $this->tmpl->assign('count', $count); + $this->tmpl->assign('width', $this->cfg->thumb_width); + $this->tmpl->assign('images', $images); + $this->tmpl->assign('rows', $rows); + $this->tmpl->assign('columns', $this->cfg->thumbs_per_row); $this->tmpl->show("photo_index.tpl"); -- cgit v1.2.3-18-g5258