2009-11-12 04:04:01 +00:00
|
|
|
<?php defined("SYSPATH") or die("No direct script access.") ?>
|
2010-03-03 23:47:52 +00:00
|
|
|
<div id="g-album-header">
|
|
|
|
<div id="g-album-header-buttons">
|
|
|
|
<?= $theme->dynamic_top() ?>
|
|
|
|
</div>
|
|
|
|
<h1><?= html::clean($title) ?></h1>
|
|
|
|
</div>
|
2009-11-12 04:04:01 +00:00
|
|
|
|
2010-03-04 01:51:33 +00:00
|
|
|
<br/><?= $calendar_user_year_form ?><br /><br />
|
2009-11-12 04:04:01 +00:00
|
|
|
|
|
|
|
<?
|
|
|
|
$counter_months = 1;
|
2010-02-08 04:37:54 +00:00
|
|
|
// Loop through January to November in the current year.
|
2009-11-12 04:04:01 +00:00
|
|
|
while ($counter_months <12) {
|
2010-03-03 07:07:42 +00:00
|
|
|
print "<div id=\"g-calendar-grid\">";
|
2009-11-12 04:04:01 +00:00
|
|
|
|
|
|
|
// Figure out if any photos were taken for the current month.
|
|
|
|
if ($calendar_user == "-1") {
|
|
|
|
$month_count = ORM::factory("item")
|
|
|
|
->viewable()
|
2009-12-23 05:31:03 +00:00
|
|
|
->where("type", "!=", "album")
|
|
|
|
->where("captured", ">=", mktime(0, 0, 0, $counter_months, 1, $calendar_year))
|
|
|
|
->where("captured", "<", mktime(0, 0, 0, $counter_months+1, 1, $calendar_year))
|
2009-11-12 04:04:01 +00:00
|
|
|
->find_all()
|
|
|
|
->count();
|
|
|
|
} else {
|
|
|
|
$month_count = ORM::factory("item")
|
|
|
|
->viewable()
|
2010-03-04 21:24:04 +00:00
|
|
|
->where("owner_id", "=", $calendar_user)
|
2009-12-23 05:31:03 +00:00
|
|
|
->where("type", "!=", "album")
|
|
|
|
->where("captured", ">=", mktime(0, 0, 0, $counter_months, 1, $calendar_year))
|
|
|
|
->where("captured", "<", mktime(0, 0, 0, $counter_months+1, 1, $calendar_year))
|
2009-11-12 04:04:01 +00:00
|
|
|
->find_all()
|
|
|
|
->count();
|
|
|
|
}
|
2010-03-03 23:34:16 +00:00
|
|
|
if ($month_count > 0) {
|
|
|
|
$month_url = url::site("calendarview/month/" . $calendar_year . "/" . $calendar_user . "/" . $counter_months . "/");
|
|
|
|
} else {
|
|
|
|
$month_url = "";
|
|
|
|
}
|
|
|
|
$calendar = new PHPCalendar($counter_months, $calendar_year, $month_url);
|
2009-11-12 04:04:01 +00:00
|
|
|
|
|
|
|
// If there are photos, loop through each day in the month and display links on the correct dates.
|
|
|
|
if ($month_count > 0) {
|
|
|
|
$curr_day = 1;
|
|
|
|
$MAX_DAYS = date('t', mktime(00, 00, 00, $counter_months, 1, $calendar_year));
|
|
|
|
while ($curr_day < $MAX_DAYS) {
|
|
|
|
if ($calendar_user == "-1") {
|
|
|
|
$day_count = ORM::factory("item")
|
|
|
|
->viewable()
|
2009-12-23 05:31:03 +00:00
|
|
|
->where("type", "!=", "album")
|
|
|
|
->where("captured", ">=", mktime(0, 0, 0, $counter_months, $curr_day, $calendar_year))
|
|
|
|
->where("captured", "<", mktime(0, 0, 0, $counter_months, ($curr_day + 1), $calendar_year))
|
2009-11-12 04:04:01 +00:00
|
|
|
->find_all()
|
|
|
|
->count();
|
|
|
|
} else {
|
|
|
|
$day_count = ORM::factory("item")
|
|
|
|
->viewable()
|
2010-03-04 21:24:04 +00:00
|
|
|
->where("owner_id", "=", $calendar_user)
|
2009-12-23 05:31:03 +00:00
|
|
|
->where("type", "!=", "album")
|
|
|
|
->where("captured", ">=", mktime(0, 0, 0, $counter_months, $curr_day, $calendar_year))
|
|
|
|
->where("captured", "<", mktime(0, 0, 0, $counter_months, ($curr_day + 1), $calendar_year))
|
2009-11-12 04:04:01 +00:00
|
|
|
->find_all()
|
|
|
|
->count();
|
|
|
|
}
|
|
|
|
if ($day_count > 0) {
|
2010-02-24 22:24:54 +00:00
|
|
|
$calendar->event($curr_day, url::site("calendarview/day/" . $calendar_year . "/" . $calendar_user . "/" . $counter_months . "/" . $curr_day));
|
2009-11-12 04:04:01 +00:00
|
|
|
}
|
|
|
|
$curr_day++;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Do the last day of the month seperately, because the mktime code is different.
|
|
|
|
if ($calendar_user == "-1") {
|
|
|
|
$day_count = ORM::factory("item")
|
|
|
|
->viewable()
|
2009-12-23 05:31:03 +00:00
|
|
|
->where("type", "!=", "album")
|
|
|
|
->where("captured", ">=", mktime(0, 0, 0, $counter_months, $MAX_DAYS, $calendar_year))
|
|
|
|
->where("captured", "<",mktime(0, 0, 0, ($counter_months + 1), 1, $calendar_year))
|
2009-11-12 04:04:01 +00:00
|
|
|
->find_all()
|
|
|
|
->count();
|
|
|
|
} else {
|
|
|
|
$day_count = ORM::factory("item")
|
|
|
|
->viewable()
|
2009-12-23 05:31:03 +00:00
|
|
|
->where("owner_id", "=", $calendar_user)
|
|
|
|
->where("type", "!=", "album")
|
|
|
|
->where("captured", ">=", mktime(0, 0, 0, $counter_months, $MAX_DAYS, $calendar_year))
|
|
|
|
->where("captured", "<", mktime(0, 0, 0, ($counter_months + 1), 1, $calendar_year))
|
2009-11-12 04:04:01 +00:00
|
|
|
->find_all()
|
|
|
|
->count();
|
|
|
|
}
|
|
|
|
if ($day_count > 0) {
|
2010-02-08 04:37:54 +00:00
|
|
|
$calendar->event($MAX_DAYS, url::site("calendarview/day/" . $calendar_year . "/" . $calendar_user . "/" . $counter_months . "/" . $MAX_DAYS));
|
2009-11-12 04:04:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
echo $calendar->render();
|
2010-03-03 07:07:42 +00:00
|
|
|
print "</div>";
|
2009-11-12 04:04:01 +00:00
|
|
|
$counter_months++;
|
|
|
|
}
|
2009-12-23 05:31:03 +00:00
|
|
|
|
2009-11-12 04:04:01 +00:00
|
|
|
// Do December seperately, because the mktime code is different.
|
2010-03-03 07:07:42 +00:00
|
|
|
print "<div id=\"g-calendar-grid\">";
|
2009-11-12 04:04:01 +00:00
|
|
|
if ($calendar_user == "-1") {
|
|
|
|
$month_count = ORM::factory("item")
|
|
|
|
->viewable()
|
2009-12-23 05:31:03 +00:00
|
|
|
->where("type", "!=", "album")
|
|
|
|
->where("captured", ">=", mktime(0, 0, 0, $counter_months, 1, $calendar_year))
|
|
|
|
->where("captured", "<", mktime(0, 0, 0, 1, 1, ($calendar_year + 1)))
|
2009-11-12 04:04:01 +00:00
|
|
|
->find_all()
|
|
|
|
->count();
|
|
|
|
} else {
|
|
|
|
$month_count = ORM::factory("item")
|
|
|
|
->viewable()
|
2009-12-23 05:31:03 +00:00
|
|
|
->where("owner_id", "=", $calendar_user)
|
|
|
|
->where("type", "!=", "album")
|
|
|
|
->where("captured", ">=", mktime(0, 0, 0, $counter_months, 1, $calendar_year))
|
|
|
|
->where("captured", "<", mktime(0, 0, 0, 1, 1, ($calendar_year + 1)))
|
2009-11-12 04:04:01 +00:00
|
|
|
->find_all()
|
2009-12-23 05:31:03 +00:00
|
|
|
->count();
|
2009-11-12 04:04:01 +00:00
|
|
|
}
|
2010-03-03 23:34:16 +00:00
|
|
|
if ($month_count > 0) {
|
|
|
|
$month_url = url::site("calendarview/month/" . $calendar_year . "/" . $calendar_user . "/" . $counter_months . "/");
|
|
|
|
} else {
|
|
|
|
$month_url = "";
|
|
|
|
}
|
|
|
|
$calendar = new PHPCalendar($counter_months, $calendar_year, $month_url);
|
2009-11-12 04:04:01 +00:00
|
|
|
if ($month_count > 0) {
|
|
|
|
$curr_day = 1;
|
|
|
|
$MAX_DAYS = date('t', mktime(00, 00, 00, $counter_months, 1, $calendar_year));
|
|
|
|
while ($curr_day < $MAX_DAYS) {
|
|
|
|
if ($calendar_user == "-1") {
|
|
|
|
$day_count = ORM::factory("item")
|
|
|
|
->viewable()
|
2009-12-23 05:31:03 +00:00
|
|
|
->where("type", "!=", "album")
|
|
|
|
->where("captured", ">=", mktime(0, 0, 0, $counter_months, $curr_day, $calendar_year))
|
|
|
|
->where("captured", "<", mktime(0, 0, 0, $counter_months, ($curr_day + 1), $calendar_year))
|
2009-11-12 04:04:01 +00:00
|
|
|
->find_all()
|
|
|
|
->count();
|
|
|
|
} else {
|
|
|
|
$day_count = ORM::factory("item")
|
|
|
|
->viewable()
|
2009-12-23 05:31:03 +00:00
|
|
|
->where("owner_id", "=", $calendar_user)
|
|
|
|
->where("type", "!=", "album")
|
|
|
|
->where("captured", ">=", mktime(0, 0, 0, $counter_months, $curr_day, $calendar_year))
|
|
|
|
->where("captured", "<", mktime(0, 0, 0, $counter_months, ($curr_day + 1), $calendar_year))
|
2009-11-12 04:04:01 +00:00
|
|
|
->find_all()
|
|
|
|
->count();
|
|
|
|
}
|
|
|
|
if ($day_count > 0) {
|
2010-02-24 22:24:54 +00:00
|
|
|
$calendar->event($curr_day, url::site("calendarview/day/" . $calendar_year . "/" . $calendar_user . "/" . $counter_months . "/" . $curr_day));
|
2009-11-12 04:04:01 +00:00
|
|
|
}
|
|
|
|
$curr_day++;
|
|
|
|
}
|
|
|
|
if ($calendar_user == "-1") {
|
|
|
|
$day_count = ORM::factory("item")
|
|
|
|
->viewable()
|
2009-12-23 05:31:03 +00:00
|
|
|
->where("type", "!=", "album")
|
|
|
|
->where("captured", ">=", mktime(0, 0, 0, $counter_months, $MAX_DAYS, $calendar_year))
|
|
|
|
->where("captured", "<", mktime(0, 0, 0, 1, 1, $calendar_year+1))
|
2009-11-12 04:04:01 +00:00
|
|
|
->find_all()
|
|
|
|
->count();
|
|
|
|
} else {
|
|
|
|
$day_count = ORM::factory("item")
|
|
|
|
->viewable()
|
2009-12-23 05:31:03 +00:00
|
|
|
->where("owner_id", "=", $calendar_user)
|
|
|
|
->where("type", "!=", "album")
|
|
|
|
->where("captured", ">=", mktime(0, 0, 0, $counter_months, $MAX_DAYS, $calendar_year))
|
|
|
|
->where("captured", "<", mktime(0, 0, 0, 1, 1, $calendar_year+1))
|
2009-11-12 04:04:01 +00:00
|
|
|
->find_all()
|
2009-12-23 05:31:03 +00:00
|
|
|
->count();
|
2009-11-12 04:04:01 +00:00
|
|
|
}
|
|
|
|
if ($day_count > 0) {
|
2010-02-24 22:24:54 +00:00
|
|
|
$calendar->event($MAX_DAYS, url::site("calendarview/day/" . $calendar_year . "/" . $calendar_user . "/" . $counter_months . "/" . $MAX_DAYS));
|
2009-11-12 04:04:01 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
$counter_months++;
|
|
|
|
echo $calendar->render();
|
2010-03-03 07:07:42 +00:00
|
|
|
print "</div>";
|
2010-02-08 04:37:54 +00:00
|
|
|
?>
|