avoid notice messages about undefined variables, resolves #179
authorAndreas Unterkircher <unki@netshadow.at>
Sat, 23 May 2009 07:45:29 +0000 (09:45 +0200)
committerAndreas Unterkircher <unki@netshadow.at>
Sat, 23 May 2009 07:45:29 +0000 (09:45 +0200)
Signed-off-by: Andreas Unterkircher <unki@netshadow.at>
phpfspot.class.php
themes/default/templates/calendar.tpl
themes/default/templates/header.tpl
themes/default/templates/photo_index.tpl
themes/default/templates/search.tpl
themes/default/templates/single_photo.tpl
themes/default/templates/tags.tpl

index b82efa5..1423f98 100644 (file)
@@ -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");
 
index 1f52732..8c1d27e 100644 (file)
@@ -18,7 +18,7 @@
  <!-- matrix -->
  {section name="row" loop=$rows step=1}
   {section name="col" loop=8 step=1}
-   {if $matrix[row][col] }
+   {if isset($matrix[row][col]) }
     {$matrix[row][col]}
    {/if}
   {/section}
index c1d7a0c..d592ebf 100644 (file)
@@ -8,13 +8,13 @@
   <script type="text/javascript" src="{$web_path}/phpfspot.js"></script>
   <link rel="shortcut icon" href="{$web_path}/resources/gpl_16.png" type="image/png" />
   <link rel="icon" href="{$web_path}/resources/gpl_16.png" type="image/png" />
-  { if $use_lightbox }
+  { if isset($use_lightbox) }
   <script type="text/javascript" src="{$web_path}/lightbox2/js/prototype.js"></script>
   <script type="text/javascript" src="{$web_path}/lightbox2/js/scriptaculous.js?load=effects,builder"></script>
   <script type="text/javascript" src="{$web_path}/lightbox2/js/lightbox.js"></script>
   <link rel="stylesheet" href="{$web_path}/lightbox2/css/lightbox.css" type="text/css" media="screen" />
   { /if }
-  { if $use_autocomplete }
+  { if isset($use_autocomplete) }
   <script type="text/javascript" src="{$web_path}/autosuggest/js/bsn.AutoSuggest_2.1.3_comp.js"></script>
   <link rel="stylesheet" href="{$web_path}/autosuggest/css/autosuggest_inquisitor.css" type="text/css" media="screen" charset="utf-8" />
   { /if }
index fa63b31..ddc3229 100644 (file)
@@ -5,13 +5,13 @@
 <div class="header">
  <div class="header_title">
   <b>Photo Index</b>
-  {if $searchfor }
+  {if isset($searchfor) }
    {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}
-  {elseif $tag_result}
+  {elseif isset($tag_result)}
    {if $count == 1}
     {$count} image has been found for the selected tags.
    {else}
     {$count} images have been found.
    {/if}
   {/if}
-  {if $from_date && $to_date }
+  {if isset($from_date) && isset($to_date) }
    <br />
    Results are limited to a date within {$from_date} to {$to_date}.
   {/if}
  </div>
  <div class="header_menu">
-  {if $slideshow_link }
+  {if isset($slideshow_link) }
    <a href="{$slideshow_link}" title="Slideshow" target="_blank"><img src="{$web_path}/resources/slideshow.png" />&nbsp;Slideshow</a>
   {/if}
-  {if $extern_link }
+  {if isset($extern_link) }
    <a href="{$extern_link}" title="Use this link to return to the current view"><img src="{$web_path}/resources/link.png" />&nbsp;External Link</a>
   {/if} 
-  {if $export_link }
+  {if isset($export_link) }
    <a href="{$export_link}" target="_blank" title="this will open a new browser window where you can export this page in several formats"><img src="{$web_path}/resources/export.png" />&nbsp;Export</a>
   {/if}
-  {if $rss_link }
+  {if isset($rss_link) }
    <a href="{$rss_link}" target="_blank" title="RSS feed"><img src="{$web_path}/resources/rss.png" />&nbsp;RSS-Feed</a>
   {/if}
  </div>
@@ -48,7 +48,7 @@
 <!-- if result of a tag-search is displayed, show the selected tags
      with some small pictures in a bar. -->
 
-{ if $tag_result }
+{ if isset($tag_result) }
 <!-- seperator -->
  <div class="tagresult"></div>
  <!-- /seperator -->
 
  {section name="thumb" loop=$thumbs step=1}
 
-  {if $images[thumb] }
+  {if isset($images[thumb]) }
 
    <div class="thumb" onmouseover="setBackGrdColor(this, 'mouseover');" onmouseout="setBackGrdColor(this, 'mouseout');" style="width: { $thumb_container_width }px; height: { $thumb_container_height }px;">
-    { if $user_friendly_url }
+    { if isset($user_friendly_url) }
     <a href="{$web_path}/photoview/{$images[thumb]}" onclick="showPhoto({$images[thumb]}, 'scrollup'); return false;" id="thumblink{$images[thumb]}" name="image{$img_id[thumb]}" class="thumblink" onfocus="click(this);" title="{$img_title[thumb]}">
     { else }
     <a href="{$web_path}/index.php?mode=showp&amp;id={$images[thumb]}" onclick="showPhoto({$images[thumb]}, 'scrollup'); return false;" id="thumblink{$images[thumb]}" name="image{$img_id[thumb]}" class="thumblink" onfocus="click(this);" title="{$img_title[thumb]}">
     {$img_name[thumb]}
     </a>
     <!-- show lightbox eyes, if enabled -->
-    { if $use_lightbox }
+    { if isset($use_lightbox) }
     <a href="{$web_path}/phpfspot_img.php?idx={$images[thumb]}&amp;width={$preview_width}" alt="thumb_{$images[thumb]}" rel="lightbox[photoidx]" title="Preview of {$img_fullname[thumb]}"><img src="{$web_path}/resources/eyes.png" /></a>
     { /if }
     <!-- show F-Spot photo rating value, if available -->
-    { if $img_rating[thumb] }
+    { if isset($img_rating[thumb]) }
      <br />
      {section name="rating" loop=$img_rating[thumb] step=1}
       <img src="{$web_path}/resources/star.png" />
 
  <!-- the right nav arrow -->
  <div class="indexnavigationright">
- { if $next_url == "" }
+ { if !isset($next_url) || $next_url == "" }
   { if $count != 0 }
    <img src="{$web_path}/resources/arrow_right_gray.png" alt="last page reached" />
   { /if }
 
  <!-- the left nav arrow -->
  <div class="indexnavigationleft">
- { if $previous_url == "" }
+ { if !isset($previous_url) || $previous_url == "" }
   { if $count != 0 }
    <img src="{$web_path}/resources/arrow_left_gray.png" alt="first page reached" />
   { /if }
 
  <!-- the middle page selector -->
  <div class="indexnavigationcenter">
- { if $page_selector != "" }
+ { if isset($page_selector) && $page_selector != "" }
   {$page_selector}
  { /if}
  </div>
    var last_thumb;
 
    {section name="thumb" loop=$thumbs step=1}
-      {if $images[thumb] }
+      {if isset($images[thumb]) }
          image_urls[{counter}] = '{$web_path}/phpfspot_img.php?idx={$images[thumb]}&width={$width}';
          last_thumb = {$images[thumb]};
       {/if}
index 672bb35..69de0a1 100644 (file)
@@ -7,7 +7,7 @@
  <tr>
   <td>Tag:</td>
   <td>
-   { if $use_autocomplete }
+   { if isset($use_autocomplete) }
    <input type="text" name="searchfor_tag" id="searchfor_tag" value="{$searchfor_tag}" size="15" acdropdown="true" autocomplete_list="url:rpc.php?action=getxmltaglist&search=[S]&length=10" />
    { literal }
    <script type="text/javascript">
@@ -21,7 +21,7 @@
    </script>
    { /literal }
    { else }
-   <input type="text" name="searchfor_tag" value="{$searchfor_tag}" size="15" />
+   <input type="text" name="searchfor_tag" value="{ if isset($searchfor_tag) }{$searchfor_tag}{ /if }" size="15" />
    { /if }
   </td>
   <td>
@@ -31,7 +31,7 @@
  <tr>
   <td>Name:</td>
   <td>
-   <input type="text" name="searchfor_name" value="{$searchfor_name}" size="15" />
+   <input type="text" name="searchfor_name" value="{ if isset($searchfor_name) }{$searchfor_name}{ /if }" size="15" />
   </td>
   <td>
    <input type="image" class="submit" src="{$web_path}/resources/doit.png" alt="start search" title="start search" onclick="click(this);" />
@@ -40,7 +40,7 @@
  <tr>
   <td>Date:</td>
   <td class="nowarp">
-   { if ! $date_search_enabled }
+   { if ! isset($date_search_enabled) }
     <input type="checkbox" class="checkbox" name="consider_date" value="Y" onclick="datesearch();" />
    { else }
     <input type="checkbox" class="checkbox" name="consider_date" value="Y" onclick="datesearch();" checked="checked" />
    <input type="image" class="submit" src="{$web_path}/resources/doit.png" alt="start search" title="start search" onclick="click(this);" />
   </td>
  </tr>
- { if $has_rating }
+ { if isset($has_rating) }
  <tr>
   <td>Rating:</td>
   <td class="nowarp">
-   { if ! $rate_search_enabled }
+   { if ! isset($rate_search_enabled) }
     <input type="checkbox" class="checkbox" name="consider_rate" value="Y" />
    { else }
     <input type="checkbox" class="checkbox" name="consider_rate" value="Y" checked="checked" />
index 572bef7..f74b34c 100644 (file)
@@ -9,7 +9,7 @@
    {else}
     Photos
    {/if}
-   {if $description}
+   {if isset($description) }
     -&nbsp;{$description}<br />
    {/if}
   {/if}
@@ -19,7 +19,7 @@
   <a href="javascript:zoom(0);" title="zoom_100" onclick="click(this);"><img src="{$web_path}/resources/zoom-100.png" /></a>
   <a href="javascript:zoom(10);" title="zoom_in" onclick="click(this);"><img src="{$web_path}/resources/zoom-in.png" /></a>
   <a href="javascript:startAutoBrowse();" title="auto browsing"><img id="autobrowse_ico" src="{$web_path}/resources/16_play.png" />&nbsp;Auto-Browse</a>
-  {if $extern_link }
+  {if isset($extern_link) }
    <a href="{$extern_link}" title="Use this link to return to the current view"><img src="{$web_path}/resources/link.png" />&nbsp;External Link</a>
   {/if}
   <a href="{$image_url_full}" title="orig_image" target="_blank" onclick="click(this);"><img src="{$web_path}/resources/original.png" alt="original resolution" />&nbsp;Fullsize</a>
 <p class="cb">
 
  <div id="photo_details">
-   { if $ExifMadeWith }
+   { if isset($ExifMadeWith) }
    <u><img src="{$web_path}/resources/camera.png" alt="camera icon" />&nbsp;Image taken with:</u><br />
    {$ExifMadeWith}<br />
    { /if }
-   { if $ExifMadeOn }
+   { if isset($ExifMadeOn) }
    <u><img src="{$web_path}/resources/date.png" alt="calendar icon" />&nbsp;Image made on:</u><br />
    {$ExifMadeOn}<br />
    { /if }
-   { if $ExifOrigResolution }
+   { if isset($ExifOrigResolution) }
    <u><img src="{$web_path}/resources/image.png" alt="resolution icon" />&nbsp;Original resolution:</u><br />
    {$ExifOrigResolution}px<br />
    { /if }
    <u>Size:</u>&nbsp;{$ExifFileSize}<br />
-   { if $image_rating }
+   { if isset($image_rating) && $image_rating > 0 }
     <u><img src="{$web_path}/resources/rating.png" alt="rating" />&nbsp;Rating:</u><br />
     {section name="rating" loop=$image_rating step=1}
      <img src="{$web_path}/resources/star.png" />
     {/section}
     <br />
    { /if }
-   { if $has_versions }
+   { if isset($has_versions) }
     <br />
     Versions:<br />
     <select onchange="update_photo_version(this, {$photo});">
@@ -57,7 +57,7 @@
     </select>
     <br />
    { /if }
-   { if $tags }
+   { if isset($tags) }
     <br />
     <u><img src="{$web_path}/resources/small_available_tags.png" alt="available tags" />&nbsp;Tagged with:</u><br />
     { foreach from=$tags key=id item=name }
     { /foreach }
    { /if }
    <hr>
-   { if $prev_img }
+   { if isset($prev_img) && isset($previous_url) }
     <u><img src="{$web_path}/resources/photo.png" alt="photo icon" />&nbsp;Previous:</u><br />
     <a href="{$previous_url}" onfocus="click(this);" id="prev_link">
      <img src="{$web_path}/phpfspot_img.php?idx={$prev_img}&amp;width={$mini_width}" /><br />
     </a>
    { /if}
-   { if $next_img }
+   { if isset($next_img) && isset($next_url) }
     <u><img src="{$web_path}/resources/photo.png" alt="photo icon" />&nbsp;Next:</u><br />
     <a href="{$next_url}" onfocus="click(this);" id="next_link">
      <img src="{$web_path}/phpfspot_img.php?idx={$next_img}&amp;width={$mini_width}" /><br />
@@ -82,7 +82,7 @@
  <!-- the photo itself -->
 
  <div class="photo">
- { if $next_url == "" }
+ { if !isset($next_url) || $next_url == "" }
   <a href="{$image_url}" onclick="showPhotoIndex(); return false;" onfocus="click(this);" name="photo">
  { else }
   <a href="{$image_url}" onclick="{$next_url}; return false;" onfocus="click(this);" title="click for the next photo" name="photo">
  <!-- navigation arrows -->
 
  <div class="photonavigation">
-  { if $previous_url == "" }
+
+  <!-- previous -->
+  { if !isset($previous_url) || $previous_url == "" }
    <img src="{$web_path}/resources/arrow_left_gray.png" alt="first photo reached" />
   { else }
    <a href="{$previous_url}" onfocus="click(this);" title="click for the previous photo (left cursor)">
     <img src="{$web_path}/resources/arrow_left.png" alt="previous photo" />
    </a>
   { /if }
+
+  <!-- back to index -->
    <a href="javascript:showPhotoIndex({$current_page}, {$current_img});" onfocus="click(this);" title="click to go back to the index">
     <img src="{$web_path}/resources/arrow_up.png" alt="photo index" />
    </a>
-  { if $next_url == "" }
+
+  <!-- next -->
+  { if !isset($next_url) || $next_url == "" }
    <img src="{$web_path}/resources/arrow_right_gray.png" alt="last photo reached" />
   { else }
    <a href="{$next_url}" onfocus="click(this);" title="click for the next photo (right cursor)">
index 817cfbc..8a9521e 100644 (file)
@@ -8,7 +8,7 @@
  &nbsp;
  <input type="radio" name="condition" value="or" onclick="Tags('condition', this);" {if $current_condition == "or" } checked="checked" { /if } title="OR condition" />||
  <input type="radio" name="condition" value="and" onclick="Tags('condition', this);" {if $current_condition == "and" } checked="checked" { /if } title="AND condition" />&amp;&amp;
-{ if $preset_selected_tags }
+{ if isset($preset_selected_tags) }
  <div id="selected_tags">{ $preset_selected_tags }</div>
 { else }
  <div id="selected_tags">no tags selected</div>