$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':
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'] != '') {
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 */
}
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
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()
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"))
} // _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 = "<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";
+ return $output;
-// $Year = new Calendar_Year();
-// $Month = new Calendar_Month();
-// $Day = new Calendar_Day();
+ } // get_calendar()
- $output = "<select name=\"year\">\n";
- for($year = 1990; $year <= date("Y"); $year++) {
- $output.= "<option value=\"". $year ."\">". $year ."</option>\n";
- }
- $output.= "</select>\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.= "<select name=\"month\">\n";
- for($month = 1; $month <= 12; $month++) {
- $output.= "<option value=\"". $month ."\">". $month ."</option>\n";
- }
- $output.= "</select>\n";
- $output.= "<select name=\"day\">\n";
- for($day = 1; $day <= 31; $day++) {
- $output.= "<option value=\"". $day ."\">". $day ."</option>\n";
+ // 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) .");";
+
+ $selectedDays = array (
+ new Calendar_Day($year,$month,$day),
+ new Calendar_Day($year,12,25),
+ );
+
+ // Build the days in the month
+ $month->build($selectedDays);
+
+ $this->tmpl->assign('current_month', date('F Y',$month->getTimeStamp()));
+ $this->tmpl->assign('prev_month', $prev);
+ $this->tmpl->assign('next_month', $next);
+
+ while ( $day = $month->fetch() ) {
+
+ if(!isset($matrix[$rows]))
+ $matrix[$rows] = Array();
+
+ $string = "";
+
+ $dayStamp = $day->thisDay(true);
+ $link = "javascript:setCalendarDate(". date('Y',$dayStamp) .", ". date('n',$dayStamp).", ". date('j',$dayStamp) .");";
+
+ // isFirst() to find start of week
+ if ( $day->isFirst() )
+ $string.= "<tr>\n";
+
+ if ( $day->isSelected() ) {
+ $string.= "<td class=\"selected\">".$day->thisDay()."</td>\n";
+ } else if ( $day->isEmpty() ) {
+ $string.= "<td> </td>\n";
+ } else {
+ $string.= "<td><a class=\"calendar\" href=\"".$link."\">".$day->thisDay()."</a></td>\n";
+ }
+
+ // isLast() to find end of week
+ if ( $day->isLast() )
+ $string.= "</tr>\n";
+
+ $matrix[$rows][$cols] = $string;
+
+ $cols++;
+
+ if($cols > 7) {
+ $cols = 1;
+ $rows++;
+ }
}
- $output.= "</select>\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)
{
// del the tag from users session
HTML_AJAX.grab(encodeURI('rpc.php?action=deltag&id=' + id));
}
- else if(mode == "reset") {
- HTML_AJAX.grab(encodeURI('rpc.php?action=reset'));
- clearSearch();
- }
else if(mode == "condition") {
setCheckedValue(id, id.value);
HTML_AJAX.grab(encodeURI('rpc.php?action=tagcondition&mode=' + id.value));
refreshAvailableTags();
refreshSelectedTags();
showPhotoIndex();
+}
+
+function startDateSearch()
+{
+ from_year = document.getElementById('fromyear').value;
+ from_month = document.getElementById('frommonth').value;
+ from_day = document.getElementById('fromday').value;
+ from = from_year +"-"+ from_month +"-"+ from_day;
+ to_year = document.getElementById('toyear').value;
+ to_month = document.getElementById('tomonth').value;
+ to_day = document.getElementById('today').value;
+ to = to_year +"-"+ to_month +"-"+ to_day;
+ HTML_AJAX.grab(encodeURI('rpc.php?action=date_search&from='+ from +'&to='+ to));
+
+ refreshAvailableTags();
+ refreshSelectedTags();
+ refreshPhotoIndex();
+ refreshPhotoIndex();
}
function setViewMode(mode)
return photo_to_show;
}
+function showCalendar(date_box, click_obj)
+{
+ var calendar = document.getElementById('calendar');
+ if(date_box == 'from') {
+ var xpos = document.getElementById('frompic').offsetLeft;
+ var ypos = document.getElementById('frompic').offsetTop;
+ calendar_mode = 'from';
+ }
+ if(date_box == 'to') {
+ var xpos = document.getElementById('topic').offsetLeft;
+ var ypos = document.getElementById('topic').offsetTop;
+ calendar_mode = 'to';
+ }
+ calendar.style.left = xpos + 60 + 'px';
+ calendar.style.top = ypos + 80 + 'px';
+
+ if(calendar.style.visibility == "" || calendar.style.visibility == 'hidden') {
+ calendar.style.visibility = 'visible';
+ calendar.innerHTML = "Loading...";
+ calendar.innerHTML = HTML_AJAX.grab(encodeURI('rpc.php?action=get_calendar_matrix'));
+ calendar_shown = 1;
+ }
+ else {
+ calendar.style.visibility = 'hidden';
+ calendar_shown = 0;
+ }
+}
+function setMonth(year, month, day)
+{
+ var calendar = document.getElementById('calendar');
+ calendar.innerHTML = "Loading...";
+ calendar.innerHTML = HTML_AJAX.grab(encodeURI('rpc.php?action=get_calendar_matrix&year='+ year +'&month='+ month +'&day='+ day));
+}
-var startup = 1;
+function setCalendarDate(year, month, day)
+{
+ document.getElementById(calendar_mode+'year').value = year;
+ document.getElementById(calendar_mode+'month').value = month;
+ document.getElementById(calendar_mode+'day').value = day;
+}
+
+function resetAll()
+{
+ HTML_AJAX.grab(encodeURI('rpc.php?action=reset'));
+ clearSearch();
+}
+var startup = 1;
+var calendar_shown = 0;
+var calendar_mode = '';