issue13, added first try of external link to directly jump to a photo
authorAndreas Unterkircher <unki@netshadow.at>
Thu, 12 Jul 2007 17:36:34 +0000 (17:36 +0000)
committerAndreas Unterkircher <unki@netshadow.at>
Thu, 12 Jul 2007 17:36:34 +0000 (17:36 +0000)
git-svn-id: file:///var/lib/svn/phpfspot/trunk@192 fa6a889d-dae6-447d-9e79-4ba9a3039384

phpfspot.class.php
phpfspot.js
rpc.php
templates/single_photo.tpl

index 33d4e24ffe0a5b99469ecb75a62f23b8cf048d9a..dd634dbe70a8b8cc5cb974de880482dabf72030d 100644 (file)
@@ -12,7 +12,6 @@ class PHPFSPOT {
    var $tmpl;
    var $tags;
    var $avail_tags;
-   var $current_tags;
 
    public function __construct()
    {
@@ -64,6 +63,14 @@ class PHPFSPOT {
                $_SESSION['selected_tags'] = split(',', $_GET['tags']);
             }
             break;
+         case 'showp':
+            if(isset($_GET['tags'])) {
+               $_SESSION['selected_tags'] = split(',', $_GET['tags']);
+            }
+            if(isset($_GET['id'])) {
+               $_SESSION['current_photo'] = $_GET['id'];
+            }
+            break;
          case 'export':
             $this->tmpl->show("export.tpl");
             return;
@@ -192,6 +199,14 @@ class PHPFSPOT {
       $meta_make = isset($meta['Make']) ? $meta['Make'] ." ". $meta['Model'] : "n/a";
       $meta_size = isset($meta['FileSize']) ? round($meta['FileSize']/1024, 1) ."kbyte" : "n/a";
 
+      $current_tags = $this->getCurrentTags();
+      $extern_link = "index.php?mode=showp&id=". $photo;
+      if($current_tags != "") {
+         $extern_link.= "&tags=". $current_tags;
+      }
+
+      $this->tmpl->assign('extern_link', $extern_link);
+
       if(file_exists($thumb_path)) {
 
          $info = getimagesize($thumb_path);
@@ -328,6 +343,12 @@ class PHPFSPOT {
 
    } // resetTags()
 
+   public function resetPhotoView()
+   {
+      unset($_SESSION['current_photo']);
+
+   } // resetPhotoView();
+
    public function resetTagSearch()
    {
       unset($_SESSION['searchfor']);
@@ -585,13 +606,8 @@ class PHPFSPOT {
             $this->tmpl->assign('page_selector', $page_select);
       }
 
-      $current_tags = "";
-      if($_SESSION['selected_tags'] != "") {
-         foreach($_SESSION['selected_tags'] as $tag)
-            $current_tags.= $tag .",";
-         $current_tags = substr($current_tags, 0, strlen($current_tags)-1);
-      }
-
+      
+      $current_tags = $this->getCurrentTags();
       $extern_link = "index.php?mode=showpi";
       if($current_tags != "") {
          $extern_link.= "&tags=". $current_tags;
@@ -1167,6 +1183,25 @@ class PHPFSPOT {
 
    } // getExport()
 
+   private function getCurrentTags()
+   {
+      $current_tags = "";
+      if($_SESSION['selected_tags'] != "") {
+         foreach($_SESSION['selected_tags'] as $tag)
+            $current_tags.= $tag .",";
+         $current_tags = substr($current_tags, 0, strlen($current_tags)-1);
+      }
+      return $current_tags;
+
+   } // getCurrentTags()
+
+   public function getCurrentPhoto()
+   {
+      if(isset($_SESSION['current_photo'])) {
+         print $_SESSION['current_photo'];
+      }
+   } // getCurrentPhoto()
+
 }
 
 ?>
index ce66cf6a35a924ec5f5a5e979575f5c06fb791ac..9204f3251c971c9f3a5462ee623e7b1cc1b32c73 100644 (file)
@@ -131,8 +131,14 @@ function init_phpfspot()
 {
    refreshAvailableTags();
 
-   if(refreshSelectedTags()) {
-      showPhotoIndex();
+   if(photo = getPhotoToShow()) {
+      showImage(photo)
+      refreshSelectedTags();
+   }
+   else {
+      if(refreshSelectedTags()) {
+         showPhotoIndex();
+      }
    }
 }
 
@@ -146,5 +152,19 @@ function setBackGrdColor(item, color)
       item.style.backgroundColor='#93A8CA';
 }
 
+function getPhotoToShow()
+{
+   // update selected tags
+   var photo_to_show = HTML_AJAX.grab(encodeURI('rpc.php?action=get_photo_to_show'));
+
+   // if no image needs to be shown, return false from here
+   if(photo_to_show == "")
+      return false;
+   
+   return photo_to_show;
+}
+
+
+
 var startup = 1;
 
diff --git a/rpc.php b/rpc.php
index 704c921a63f9d9da033adbde9a25d9e9ab81e069..4bbf4d50b1cbd84314a4be38be0062048c00efb8 100644 (file)
--- a/rpc.php
+++ b/rpc.php
@@ -70,6 +70,7 @@ class PHPFSPOT_RPC {
 
             $fspot->resetTagSearch();
             $fspot->resetTags();
+            $fspot->resetPhotoView();
             break;
 
          case 'tagcondition':
@@ -103,6 +104,10 @@ class PHPFSPOT_RPC {
             $fspot->getExport($_GET['mode']);
             break;
 
+         case 'get_photo_to_show':
+            $fspot->getCurrentPhoto();
+            break;
+
       }
 
    } // process_ajax_request();
index e83d9145e77558edb5e3a4f0afc961916279a577..9f9269367307b3a44a6285bec57af842385bb43f 100644 (file)
@@ -6,6 +6,9 @@
    &nbsp;{$description}<br />
   </td>
   <td class="index_header" style="text-align: right;">
+   {if $extern_link }
+    <a href="{$extern_link}" title="Use this link to return to the current view"><img src="resources/link.png" /></a>
+   {/if}
    <a href="{$image_url_full}" target="_blank" onclick="click(this);">
     <img src="resources/original.png" alt="original resolution" />
    </a>