From 4a0b6f6114f19cebd796b3b1c6e5253edc3267c3 Mon Sep 17 00:00:00 2001 From: Andreas Unterkircher Date: Sat, 14 Jul 2007 12:06:42 +0000 Subject: issue24, first trial of date search is now included git-svn-id: file:///var/lib/svn/phpfspot/trunk@198 fa6a889d-dae6-447d-9e79-4ba9a3039384 --- phpfspot.class.php | 163 +++++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 128 insertions(+), 35 deletions(-) (limited to 'phpfspot.class.php') diff --git a/phpfspot.class.php b/phpfspot.class.php index 8fe0f77..31a3952 100644 --- a/phpfspot.class.php +++ b/phpfspot.class.php @@ -54,8 +54,8 @@ 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()); + $this->tmpl->assign('from_date', $this->get_calendar('from')); + $this->tmpl->assign('to_date', $this->get_calendar('to')); switch($_GET['mode']) { case 'showpi': @@ -339,25 +339,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 +384,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 +444,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 +478,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() @@ -908,8 +940,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")) @@ -1082,37 +1122,90 @@ 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'; + $output = "\n"; + $output.= "\n"; + $output.= "\n"; + return $output; -// $Year = new Calendar_Year(); -// $Month = new Calendar_Month(); -// $Day = new Calendar_Day(); + } // 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'; - $output.= "\n"; - $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) { -- cgit v1.2.3-18-g5258