X-Git-Url: https://git.nubati.net/cgi-bin/gitweb.cgi?p=phpfspot.git;a=blobdiff_plain;f=phpfspot.class.php;h=4cdf3039541794ee1a4fe9550df2a7c440722321;hp=5e25f21b81d446d3c1097b630a44b40ba7ae978c;hb=2b68f1944dc095b4252a66b3a0dd64b5650d9d7a;hpb=99b313d1ae233bc46374a6ba435447b5f7b669af diff --git a/phpfspot.class.php b/phpfspot.class.php index 5e25f21..4cdf303 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()); - $this->tmpl->assign('to_date', $this->get_calendar()); + + $_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(); @@ -339,25 +361,37 @@ class PHPFSPOT { public function resetTags() { - unset($_SESSION['selected_tags']); + if(isset($_SESSION['selected_tags'])) + unset($_SESSION['selected_tags']); } // resetTags() public function resetPhotoView() { - unset($_SESSION['current_photo']); + if(isset($_SESSION['current_photo'])) + unset($_SESSION['current_photo']); } // resetPhotoView(); public function resetTagSearch() { - unset($_SESSION['searchfor']); + if(isset($_SESSION['searchfor'])) + unset($_SESSION['searchfor']); } // resetTagSearch() + public function resetDateSearch() + { + if(isset($_SESSION['from_date'])) + unset($_SESSION['from_date']); + if(isset($_SESSION['to_date'])) + unset($_SESSION['to_date']); + + } // resetDateSearch(); + public function getPhotoSelection() { - $tagged_photos = Array(); + $matched_photos = Array(); /* return a search result */ if(isset($_SESSION['searchfor']) && $_SESSION['searchfor'] != '') { @@ -372,9 +406,9 @@ class PHPFSPOT { ORDER BY p.time ASC "); while($row = $this->db->db_fetch_object($result)) { - array_push($tagged_photos, $row['photo_id']); + array_push($matched_photos, $row['photo_id']); } - return $tagged_photos; + return $matched_photos; } /* return according the selected tags */ @@ -432,11 +466,31 @@ class PHPFSPOT { } while($row = $this->db->db_fetch_object($result)) { - array_push($tagged_photos, $row['photo_id']); + array_push($matched_photos, $row['photo_id']); } - return $tagged_photos; + return $matched_photos; } + if(isset($_SESSION['from_date']) && isset($_SESSION['to_date'])) { + $from_date = strtotime($_SESSION['from_date']); + $to_date = strtotime($_SESSION['to_date']); + $result = $this->db->db_query(" + SELECT DISTINCT photo_id + FROM photo_tags pt + INNER JOIN photos p + ON p.id=pt.photo_id + WHERE + time>='". $from_date ."' + AND + time<='". $to_date ."' + ORDER BY p.time ASC + "); + while($row = $this->db->db_fetch_object($result)) { + array_push($matched_photos, $row['photo_id']); + } + return $matched_photos; + } + /* return all available photos */ $result = $this->db->db_query(" SELECT DISTINCT photo_id @@ -446,9 +500,9 @@ class PHPFSPOT { ORDER BY p.time ASC "); while($row = $this->db->db_fetch_object($result)) { - array_push($tagged_photos, $row['photo_id']); + array_push($matched_photos, $row['photo_id']); } - return $tagged_photos; + return $matched_photos; } // getPhotoSelection() @@ -612,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"; @@ -635,43 +692,6 @@ class PHPFSPOT { } // showPhotoIndex() - public function showBubbleDetails($photo, $direction) - { - if($direction == "up") - $direction = "bubbleimg_up"; - else - $direction = "bubbleimg_down"; - - $details = $this->get_photo_details($photo); - $orig_path = $this->translate_path($details['directory_path']) ."/". $details['name']; - - $image_url = "phpfspot_img.php?idx=". $photo ."&width=". $this->cfg->bubble_width; - - $filesize = filesize($orig_path); - $filesize = rand($filesize/1024, 2); - - if(!file_exists($orig_path)) { - $this->_warning("Photo ". $orig_path ." does not exist!
\n"); - return; - } - - if(!is_readable($orig_path)) { - $this->_warning("Photo ". $orig_path ." is not readable for user ". get_current_user() ."
\n"); - return; - } - - $img = getimagesize($orig_path); - - $this->tmpl->assign('file_size', $filesize); - $this->tmpl->assign('width', $img[0]); - $this->tmpl->assign('height', $img[1]); - $this->tmpl->assign('file_name', $details['name']); - $this->tmpl->assign('image_id', $direction); - $this->tmpl->assign('image_url', $image_url); - $this->tmpl->show("bubble_details.tpl"); - - } // showBubbleDetails() - public function showCredits() { $this->tmpl->assign('version', $this->cfg->version); @@ -849,7 +869,6 @@ class PHPFSPOT { $resolutions = Array( $this->cfg->thumb_width, - $this->cfg->bubble_width, $this->cfg->photo_width, $this->cfg->mini_width, ); @@ -946,8 +965,16 @@ class PHPFSPOT { array_push($_SESSION['selected_tags'], $tag); } + $this->resetDateSearch(); + } // startTagSearch() + public function startDateSearch($from, $to) + { + $_SESSION['from_date'] = $from; + $_SESSION['to_date'] = $to; + } + private function rotateImage($img, $degrees) { if(function_exists("imagerotate")) @@ -1120,37 +1147,94 @@ class PHPFSPOT { } // _warning() - private function get_calendar() + private function get_calendar($mode) { -// require_once CALENDAR_ROOT.'Year.php'; -// require_once CALENDAR_ROOT.'Month.php'; -// require_once CALENDAR_ROOT.'Day.php'; + $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"); -// $Year = new Calendar_Year(); -// $Month = new Calendar_Month(); -// $Day = new Calendar_Day(); + $output = "\n"; + $output.= "\n"; + $output.= "\n"; + return $output; - $output = "\n"; + } // get_calendar() - $output.= "\n"; + public function get_calendar_matrix($year = 0, $month = 0, $day = 0) + { + if (!isset($year)) $year = date('Y'); + if (!isset($month)) $month = date('m'); + if (!isset($day)) $day = date('d'); + $rows = 1; + $cols = 1; + $matrix = Array(); + + require_once CALENDAR_ROOT.'Month/Weekdays.php'; + require_once CALENDAR_ROOT.'Day.php'; + + + // Build the month + $month = new Calendar_Month_Weekdays($year,$month); + + // Create links + $prevStamp = $month->prevMonth(true); + $prev = "javascript:setMonth(". date('Y',$prevStamp) .", ". date('n',$prevStamp) .", ". date('j',$prevStamp) .");"; + $nextStamp = $month->nextMonth(true); + $next = "javascript:setMonth(". date('Y',$nextStamp) .", ". date('n',$nextStamp) .", ". date('j',$nextStamp) .");"; - $output.= "\n"; - return $output; + $this->tmpl->assign('matrix', $matrix); + $this->tmpl->assign('rows', $rows); + $this->tmpl->show("calendar.tpl"); - } // get_calendar() + } // get_calendar_matrix() public function getExport($mode) { @@ -1168,6 +1252,9 @@ class PHPFSPOT { if($current_tags != "") { $orig_url.= "&tags=". $current_tags; } + if(isset($_SESSION['from_date']) && isset($_SESSION['to_date'])) { + $orig_url.= "&from_date=". $_SESSION['from_date'] ."&to_date=". $_SESSION['to_date']; + } $thumb_url = $protocol ."://". $server_name . $this->cfg->web_path ."phpfspot_img.php?idx=". $picture ."&width=". $this->cfg->thumb_width; @@ -1207,6 +1294,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() + } ?>