summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--phpfspot.class.php58
-rw-r--r--phpfspot.js23
-rw-r--r--rpc.php4
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 = "<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()
@@ -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();