issue13, all external links have been tested again, single photo, with tag- or date...
authorAndreas Unterkircher <unki@netshadow.at>
Sat, 14 Jul 2007 13:47:10 +0000 (13:47 +0000)
committerAndreas Unterkircher <unki@netshadow.at>
Sat, 14 Jul 2007 13:47:10 +0000 (13:47 +0000)
git-svn-id: file:///var/lib/svn/phpfspot/trunk@202 fa6a889d-dae6-447d-9e79-4ba9a3039384

phpfspot.class.php
phpfspot.js
rpc.php

index 31a39529776df42465141c2e718b2f8fa3a13fae..860b5de0d97d73e5811d2d0270a283e1184afa22 100644 (file)
@@ -54,21 +54,35 @@ class PHPFSPOT {
       $this->tmpl->assign('searchfor', $_SESSION['searchfor']);
       $this->tmpl->assign('page_title', $this->cfg->page_title);
       $this->tmpl->assign('current_condition', $_SESSION['tag_condition']);
       $this->tmpl->assign('searchfor', $_SESSION['searchfor']);
       $this->tmpl->assign('page_title', $this->cfg->page_title);
       $this->tmpl->assign('current_condition', $_SESSION['tag_condition']);
-      $this->tmpl->assign('from_date', $this->get_calendar('from'));
-      $this->tmpl->assign('to_date', $this->get_calendar('to'));
+
+      $_SESSION['start_action'] = $_GET['mode'];
 
       switch($_GET['mode']) {
          case 'showpi':
             if(isset($_GET['tags'])) {
                $_SESSION['selected_tags'] = split(',', $_GET['tags']);
             }
 
       switch($_GET['mode']) {
          case 'showpi':
             if(isset($_GET['tags'])) {
                $_SESSION['selected_tags'] = split(',', $_GET['tags']);
             }
+            if(isset($_GET['from_date'])) {
+               $_SESSION['from_date'] = $_GET['from_date'];
+            }
+            if(isset($_GET['to_date'])) {
+               $_SESSION['to_date'] = $_GET['to_date'];
+            }
             break;
          case 'showp':
             if(isset($_GET['tags'])) {
                $_SESSION['selected_tags'] = split(',', $_GET['tags']);
             break;
          case 'showp':
             if(isset($_GET['tags'])) {
                $_SESSION['selected_tags'] = split(',', $_GET['tags']);
+               $_SESSION['start_action'] = 'showp';
             }
             if(isset($_GET['id'])) {
                $_SESSION['current_photo'] = $_GET['id'];
             }
             if(isset($_GET['id'])) {
                $_SESSION['current_photo'] = $_GET['id'];
+               $_SESSION['start_action'] = 'showp';
+            }
+            if(isset($_GET['from_date'])) {
+               $_SESSION['from_date'] = $_GET['from_date'];
+            }
+            if(isset($_GET['to_date'])) {
+               $_SESSION['to_date'] = $_GET['to_date'];
             }
             break;
          case 'export':
             }
             break;
          case 'export':
@@ -78,6 +92,8 @@ class PHPFSPOT {
 
       }
 
 
       }
 
+      $this->tmpl->assign('from_date', $this->get_calendar('from'));
+      $this->tmpl->assign('to_date', $this->get_calendar('to'));
       $this->tmpl->assign('content_page', 'welcome.tpl');
       $this->tmpl->show("index.tpl");
 
       $this->tmpl->assign('content_page', 'welcome.tpl');
       $this->tmpl->show("index.tpl");
 
@@ -204,6 +220,9 @@ class PHPFSPOT {
       if($current_tags != "") {
          $extern_link.= "&tags=". $current_tags;
       }
       if($current_tags != "") {
          $extern_link.= "&tags=". $current_tags;
       }
+      if(isset($_SESSION['from_date']) && isset($_SESSION['to_date'])) {
+         $extern_link.= "&from_date=". $_SESSION['from_date'] ."&to_date=". $_SESSION['to_date'];
+      }
 
       $this->tmpl->assign('extern_link', $extern_link);
 
 
       $this->tmpl->assign('extern_link', $extern_link);
 
@@ -319,6 +338,9 @@ class PHPFSPOT {
 
    public function addTag($tag)
    {
 
    public function addTag($tag)
    {
+      // if the result of a date search are displayed, reset them
+      $this->resetDateSearch();
+
       if(!isset($_SESSION['selected_tags']))
          $_SESSION['selected_tags'] = Array();
 
       if(!isset($_SESSION['selected_tags']))
          $_SESSION['selected_tags'] = Array();
 
@@ -644,6 +666,9 @@ class PHPFSPOT {
       if($current_tags != "") {
          $extern_link.= "&tags=". $current_tags;
       }
       if($current_tags != "") {
          $extern_link.= "&tags=". $current_tags;
       }
+      if(isset($_SESSION['from_date']) && isset($_SESSION['to_date'])) {
+         $extern_link.= "&from_date=". $_SESSION['from_date'] ."&to_date=". $_SESSION['to_date'];
+      }
 
       $export_link = "index.php?mode=export";
 
 
       $export_link = "index.php?mode=export";
 
@@ -1124,9 +1149,13 @@ class PHPFSPOT {
 
    private function get_calendar($mode)
    {
 
    private function get_calendar($mode)
    {
-      $output = "<input type=\"text\" size=\"3\" id=\"". $mode ."year\" value=\"". date("Y") ."\" />\n";
-      $output.= "<input type=\"text\" size=\"1\" id=\"". $mode ."month\" value=\"". date("m") ."\" />\n";
-      $output.= "<input type=\"text\" size=\"1\" id=\"". $mode ."day\" value=\"". date("d") ."\" />\n";
+      $year = $_SESSION[$mode .'_date'] ? date("Y", strtotime($_SESSION[$mode .'_date'])) : date("Y");
+      $month = $_SESSION[$mode .'_date'] ? date("m", strtotime($_SESSION[$mode .'_date'])) : date("m");
+      $day = $_SESSION[$mode .'_date'] ? date("d", strtotime($_SESSION[$mode .'_date'])) : date("d");
+
+      $output = "<input type=\"text\" size=\"3\" id=\"". $mode ."year\" value=\"". $year ."\" />\n";
+      $output.= "<input type=\"text\" size=\"1\" id=\"". $mode ."month\" value=\"". $month ."\" />\n";
+      $output.= "<input type=\"text\" size=\"1\" id=\"". $mode ."day\" value=\"". $day ."\" />\n";
       return $output;
 
    } // get_calendar()
       return $output;
 
    } // get_calendar()
@@ -1262,6 +1291,25 @@ class PHPFSPOT {
       }
    } // getCurrentPhoto()
 
       }
    } // getCurrentPhoto()
 
+   public function whatToDo()
+   {
+      if(isset($_SESSION['selected_tags']) && !empty($_SESSION['selected_tags'])) {
+         return "showpi_tags";
+      }
+      elseif(isset($_SESSION['from_date']) && isset($_SESSION['to_date'])) {
+         return "showpi_date";
+      }
+      elseif(isset($_SESSION['current_photo'])) {
+         return "show_photo";
+      }
+      elseif(isset($_SESSION['start_action']) && $_SESSION['start_action'] == 'showpi') {
+         return "showpi";
+      }
+
+      return "nothing special";
+
+   } // whatToDo()
+
 }
 
 ?>
 }
 
 ?>
index bd2baf304a8f216aa56ad714319ec10916ad2cd0..d54f8b5403519a997419d21f2fab0a236d9dbd30 100644 (file)
@@ -137,19 +137,34 @@ function clearSearch()
    document.getElementsByName('searchfor')[0].value = '';
 }
 
    document.getElementsByName('searchfor')[0].value = '';
 }
 
+function AskServerWhatToDo()
+{
+   return HTML_AJAX.grab(encodeURI('rpc.php?action=what_to_do'));
+}
+
 function init_phpfspot()
 {
    refreshAvailableTags();
 
 function init_phpfspot()
 {
    refreshAvailableTags();
 
-   if(photo = getPhotoToShow()) {
-      showImage(photo)
-      refreshSelectedTags();
+   whattodo = AskServerWhatToDo();
+
+   if(whattodo == 'showpi') {
+      showPhotoIndex();
    }
    }
-   else {
+   if(whattodo == 'showpi_tags') {
       if(refreshSelectedTags()) {
          showPhotoIndex();
       }
    }
       if(refreshSelectedTags()) {
          showPhotoIndex();
       }
    }
+   if(whattodo == 'showpi_date') {
+      showPhotoIndex();
+   }
+   if(whattodo == 'show_photo') {
+      if(photo = getPhotoToShow()) {
+         showImage(photo)
+         refreshSelectedTags();
+      }
+   }
 }
 
 function setBackGrdColor(item, color)
 }
 
 function setBackGrdColor(item, color)
diff --git a/rpc.php b/rpc.php
index 891f395d77bbc89a9fc2ea022a7444b7bf857ade..078fafd4cba587a1cf6290f54ae267534f8cb116 100644 (file)
--- a/rpc.php
+++ b/rpc.php
@@ -116,6 +116,10 @@ class PHPFSPOT_RPC {
             $fspot->get_calendar_matrix($_GET['year'], $_GET['month'], $_GET['day']);
             break;
 
             $fspot->get_calendar_matrix($_GET['year'], $_GET['month'], $_GET['day']);
             break;
 
+         case 'what_to_do':
+            print $fspot->whatToDo();
+            break;
+
       }
 
    } // process_ajax_request();
       }
 
    } // process_ajax_request();