summaryrefslogtreecommitdiffstats
path: root/phpfspot.class.php
diff options
context:
space:
mode:
authorAndreas Unterkircher <unki@netshadow.at>2009-05-23 09:45:29 +0200
committerAndreas Unterkircher <unki@netshadow.at>2009-05-23 09:45:29 +0200
commitea36e81b91c8689ae44d413eca4697d1993ac30b (patch)
tree22630855ca7bf23fb0b8652f90d9e5b8e4f2c704 /phpfspot.class.php
parent6216473e5065117651a08931182e7ca9f0cb41a2 (diff)
avoid notice messages about undefined variables, resolves #179
Signed-off-by: Andreas Unterkircher <unki@netshadow.at>
Diffstat (limited to 'phpfspot.class.php')
-rw-r--r--phpfspot.class.php74
1 files changed, 42 insertions, 32 deletions
diff --git a/phpfspot.class.php b/phpfspot.class.php
index b82efa5..1423f98 100644
--- a/phpfspot.class.php
+++ b/phpfspot.class.php
@@ -213,6 +213,7 @@ class PHPFSPOT {
require_once "phpfspot_tmpl.php";
$this->tmpl = new PHPFSPOT_TMPL();
+ /* pre-set some template variables */
$this->tmpl->assign('web_path', $this->cfg->web_path);
/* Starting with F-Spot 0.4.2, the rating-feature was available */
@@ -1471,40 +1472,45 @@ class PHPFSPOT {
}
$thumbs = 0;
- $images[$thumbs] = Array();
- $img_height[$thumbs] = Array();
- $img_width[$thumbs] = Array();
- $img_id[$thumbs] = Array();
- $img_name[$thumbs] = Array();
- $img_fullname[$thumbs] = Array();
- $img_title = Array();
- $img_rating = Array();
for($i = $begin_with; $i < $end_with; $i++) {
- if(isset($photos[$i])) {
+ if(!isset($photos[$i]))
+ continue;
+
+ /* on first run, initalize all used variables */
+ if($thumbs == 0) {
+ $images = Array();
+ $images[$thumbs] = Array();
+ $img_height[$thumbs] = Array();
+ $img_width[$thumbs] = Array();
+ $img_id[$thumbs] = Array();
+ $img_name[$thumbs] = Array();
+ $img_fullname[$thumbs] = Array();
+ $img_title = Array();
+ $img_rating = Array();
+ }
- $images[$thumbs] = $photos[$i];
- $img_id[$thumbs] = $i;
- $img_name[$thumbs] = htmlspecialchars($this->getPhotoName($photos[$i], 15));
- $img_fullname[$thumbs] = htmlspecialchars($this->getPhotoName($photos[$i], 0));
- $img_title[$thumbs] = "Click to view photo ". htmlspecialchars($this->getPhotoName($photos[$i], 0));
- $img_rating[$thumbs] = $this->get_photo_rating($photos[$i]);
+ $images[$thumbs] = $photos[$i];
+ $img_id[$thumbs] = $i;
+ $img_name[$thumbs] = htmlspecialchars($this->getPhotoName($photos[$i], 15));
+ $img_fullname[$thumbs] = htmlspecialchars($this->getPhotoName($photos[$i], 0));
+ $img_title[$thumbs] = "Click to view photo ". htmlspecialchars($this->getPhotoName($photos[$i], 0));
+ $img_rating[$thumbs] = $this->get_photo_rating($photos[$i]);
- $thumb_path = $this->get_thumb_path($this->cfg->thumb_width, $photos[$i], $this->get_latest_version($photos[$i]));
+ /* get local path of the thumbnail image to be displayed */
+ $thumb_path = $this->get_thumb_path($this->cfg->thumb_width, $photos[$i], $this->get_latest_version($photos[$i]));
- if(file_exists($thumb_path)) {
- $info = getimagesize($thumb_path);
+ /* if the image exist and is readable, extract some details */
+ if(file_exists($thumb_path) && is_readable($thumb_path)) {
+ if($info = getimagesize($thumb_path) !== false) {
$img_width[$thumbs] = $info[0];
$img_height[$thumbs] = $info[1];
}
- $thumbs++;
- }
+ }
+ $thumbs++;
}
- // +1 for for smarty's selection iteration
- $thumbs++;
-
if(isset($_SESSION['searchfor_tag']) && $_SESSION['searchfor_tag'] != '')
$this->tmpl->assign('searchfor_tag', $_SESSION['searchfor_tag']);
@@ -1629,16 +1635,20 @@ class PHPFSPOT {
$this->tmpl->assign('preview_width', $this->cfg->photo_width);
$this->tmpl->assign('thumb_container_width', $this->cfg->thumb_width);
$this->tmpl->assign('thumb_container_height', $this->cfg->thumb_height+20);
- $this->tmpl->assign('images', $images);
- $this->tmpl->assign('img_width', $img_width);
- $this->tmpl->assign('img_height', $img_height);
- $this->tmpl->assign('img_id', $img_id);
- $this->tmpl->assign('img_name', $img_name);
- $this->tmpl->assign('img_fullname', $img_fullname);
- $this->tmpl->assign('img_title', $img_title);
- $this->tmpl->assign('img_rating', $img_rating);
- $this->tmpl->assign('thumbs', $thumbs);
$this->tmpl->assign('selected_tags', $this->getSelectedTags('img'));
+ // +1 for for smarty's selection iteration
+ $this->tmpl->assign('thumbs', $thumbs+1);
+
+ if($thumbs > 0) {
+ $this->tmpl->assign('images', $images);
+ $this->tmpl->assign('img_width', $img_width);
+ $this->tmpl->assign('img_height', $img_height);
+ $this->tmpl->assign('img_id', $img_id);
+ $this->tmpl->assign('img_name', $img_name);
+ $this->tmpl->assign('img_fullname', $img_fullname);
+ $this->tmpl->assign('img_title', $img_title);
+ $this->tmpl->assign('img_rating', $img_rating);
+ }
$result = $this->tmpl->fetch("photo_index.tpl");