From 3d567f23a4e45ed8b082fbcd160bd0463b643529 Mon Sep 17 00:00:00 2001 From: Andreas Unterkircher Date: Sat, 14 Jul 2007 13:47:10 +0000 Subject: issue13, all external links have been tested again, single photo, with tag- or date-search are now possible git-svn-id: file:///var/lib/svn/phpfspot/trunk@202 fa6a889d-dae6-447d-9e79-4ba9a3039384 --- phpfspot.class.php | 58 +++++++++++++++++++++++++++++++++++++++++++++++++----- phpfspot.js | 23 ++++++++++++++++++---- rpc.php | 4 ++++ 3 files changed, 76 insertions(+), 9 deletions(-) diff --git a/phpfspot.class.php b/phpfspot.class.php index 31a3952..860b5de 100644 --- a/phpfspot.class.php +++ b/phpfspot.class.php @@ -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('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']); } + 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']); + $_SESSION['start_action'] = 'showp'; } 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': @@ -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"); @@ -204,6 +220,9 @@ class PHPFSPOT { 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); @@ -319,6 +338,9 @@ class PHPFSPOT { 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(); @@ -644,6 +666,9 @@ class PHPFSPOT { 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"; @@ -1124,9 +1149,13 @@ class PHPFSPOT { private function get_calendar($mode) { - $output = "\n"; - $output.= "\n"; - $output.= "\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 = "\n"; + $output.= "\n"; + $output.= "\n"; return $output; } // get_calendar() @@ -1262,6 +1291,25 @@ class PHPFSPOT { } } // 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() + } ?> diff --git a/phpfspot.js b/phpfspot.js index bd2baf3..d54f8b5 100644 --- a/phpfspot.js +++ b/phpfspot.js @@ -137,19 +137,34 @@ function clearSearch() document.getElementsByName('searchfor')[0].value = ''; } +function AskServerWhatToDo() +{ + return HTML_AJAX.grab(encodeURI('rpc.php?action=what_to_do')); +} + 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(whattodo == 'showpi_date') { + showPhotoIndex(); + } + if(whattodo == 'show_photo') { + if(photo = getPhotoToShow()) { + showImage(photo) + refreshSelectedTags(); + } + } } function setBackGrdColor(item, color) diff --git a/rpc.php b/rpc.php index 891f395..078fafd 100644 --- a/rpc.php +++ b/rpc.php @@ -116,6 +116,10 @@ class PHPFSPOT_RPC { $fspot->get_calendar_matrix($_GET['year'], $_GET['month'], $_GET['day']); break; + case 'what_to_do': + print $fspot->whatToDo(); + break; + } } // process_ajax_request(); -- cgit v1.2.3-18-g5258