Only run 1 db query instead of 367 queries.
This commit is contained in:
parent
4cfaa3dd4e
commit
753cc5809d
|
@ -9,170 +9,86 @@
|
||||||
<br/><?= $calendar_user_year_form ?><br /><br />
|
<br/><?= $calendar_user_year_form ?><br /><br />
|
||||||
|
|
||||||
<?
|
<?
|
||||||
$counter_months = 1;
|
// Search the db for all photos that were taken during the selected year.
|
||||||
// Loop through January to November in the current year.
|
|
||||||
while ($counter_months <12) {
|
|
||||||
print "<div id=\"g-calendar-grid\">";
|
|
||||||
|
|
||||||
// Figure out if any photos were taken for the current month.
|
|
||||||
if ($calendar_user == "-1") {
|
|
||||||
$month_count = ORM::factory("item")
|
|
||||||
->viewable()
|
|
||||||
->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))
|
|
||||||
->find_all()
|
|
||||||
->count();
|
|
||||||
} else {
|
|
||||||
$month_count = ORM::factory("item")
|
|
||||||
->viewable()
|
|
||||||
->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, $counter_months+1, 1, $calendar_year))
|
|
||||||
->find_all()
|
|
||||||
->count();
|
|
||||||
}
|
|
||||||
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);
|
|
||||||
|
|
||||||
// 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()
|
|
||||||
->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))
|
|
||||||
->find_all()
|
|
||||||
->count();
|
|
||||||
} else {
|
|
||||||
$day_count = ORM::factory("item")
|
|
||||||
->viewable()
|
|
||||||
->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))
|
|
||||||
->find_all()
|
|
||||||
->count();
|
|
||||||
}
|
|
||||||
if ($day_count > 0) {
|
|
||||||
$calendar->event($curr_day, url::site("calendarview/day/" . $calendar_year . "/" . $calendar_user . "/" . $counter_months . "/" . $curr_day));
|
|
||||||
}
|
|
||||||
$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()
|
|
||||||
->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))
|
|
||||||
->find_all()
|
|
||||||
->count();
|
|
||||||
} else {
|
|
||||||
$day_count = ORM::factory("item")
|
|
||||||
->viewable()
|
|
||||||
->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))
|
|
||||||
->find_all()
|
|
||||||
->count();
|
|
||||||
}
|
|
||||||
if ($day_count > 0) {
|
|
||||||
$calendar->event($MAX_DAYS, url::site("calendarview/day/" . $calendar_year . "/" . $calendar_user . "/" . $counter_months . "/" . $MAX_DAYS));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
echo $calendar->render();
|
|
||||||
print "</div>";
|
|
||||||
$counter_months++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Do December seperately, because the mktime code is different.
|
|
||||||
print "<div id=\"g-calendar-grid\">";
|
|
||||||
if ($calendar_user == "-1") {
|
if ($calendar_user == "-1") {
|
||||||
$month_count = ORM::factory("item")
|
$items_for_year = ORM::factory("item")
|
||||||
->viewable()
|
->viewable()
|
||||||
->where("type", "!=", "album")
|
->where("type", "!=", "album")
|
||||||
->where("captured", ">=", mktime(0, 0, 0, $counter_months, 1, $calendar_year))
|
->where("captured", ">=", mktime(0, 0, 0, 1, 1, $calendar_year))
|
||||||
->where("captured", "<", mktime(0, 0, 0, 1, 1, ($calendar_year + 1)))
|
->where("captured", "<", mktime(0, 0, 0, 1, 1, ($calendar_year + 1)))
|
||||||
->find_all()
|
->order_by("captured")
|
||||||
->count();
|
->find_all();
|
||||||
} else {
|
} else {
|
||||||
$month_count = ORM::factory("item")
|
$items_for_year = ORM::factory("item")
|
||||||
->viewable()
|
->viewable()
|
||||||
->where("owner_id", "=", $calendar_user)
|
->where("owner_id", "=", $calendar_user)
|
||||||
->where("type", "!=", "album")
|
->where("type", "!=", "album")
|
||||||
->where("captured", ">=", mktime(0, 0, 0, $counter_months, 1, $calendar_year))
|
->where("captured", ">=", mktime(0, 0, 0, 1, 1, $calendar_year))
|
||||||
->where("captured", "<", mktime(0, 0, 0, 1, 1, ($calendar_year + 1)))
|
->where("captured", "<", mktime(0, 0, 0, 1, 1, ($calendar_year + 1)))
|
||||||
->find_all()
|
->order_by("captured")
|
||||||
->count();
|
->find_all();
|
||||||
}
|
}
|
||||||
if ($month_count > 0) {
|
|
||||||
|
// Set up some initial variables.
|
||||||
|
$counter_months = 1;
|
||||||
|
$counter_days = 0;
|
||||||
|
$counter = 0;
|
||||||
|
|
||||||
|
// Set up the January Calendar.
|
||||||
|
// Check and see if any photos were taken in January,
|
||||||
|
// If so, make the month title into a clickable link.
|
||||||
|
print "<div id=\"g-calendar-grid\">";
|
||||||
|
if (date("n", $items_for_year[$counter]->captured) == 1) {
|
||||||
$month_url = url::site("calendarview/month/" . $calendar_year . "/" . $calendar_user . "/" . $counter_months . "/");
|
$month_url = url::site("calendarview/month/" . $calendar_year . "/" . $calendar_user . "/" . $counter_months . "/");
|
||||||
} else {
|
} else {
|
||||||
$month_url = "";
|
$month_url = "";
|
||||||
}
|
}
|
||||||
$calendar = new PHPCalendar($counter_months, $calendar_year, $month_url);
|
$calendar = new PHPCalendar($counter_months, $calendar_year, $month_url);
|
||||||
if ($month_count > 0) {
|
|
||||||
$curr_day = 1;
|
// Loop through each photo taken during this year, and see what month and day they were taken on.
|
||||||
$MAX_DAYS = date('t', mktime(00, 00, 00, $counter_months, 1, $calendar_year));
|
// Make the corresponding dates on the calendars into clickable links.
|
||||||
while ($curr_day < $MAX_DAYS) {
|
while ($counter < (count($items_for_year))) {
|
||||||
if ($calendar_user == "-1") {
|
|
||||||
$day_count = ORM::factory("item")
|
// Check and see if we've switched to a new month.
|
||||||
->viewable()
|
// If so, render the current calendar and set up a new one.
|
||||||
->where("type", "!=", "album")
|
while (date("n", $items_for_year[$counter]->captured) > $counter_months) {
|
||||||
->where("captured", ">=", mktime(0, 0, 0, $counter_months, $curr_day, $calendar_year))
|
echo $calendar->render();
|
||||||
->where("captured", "<", mktime(0, 0, 0, $counter_months, ($curr_day + 1), $calendar_year))
|
print "</div>";
|
||||||
->find_all()
|
$counter_months++;
|
||||||
->count();
|
$counter_days = 0;
|
||||||
|
print "<div id=\"g-calendar-grid\">";
|
||||||
|
if (date("n", $items_for_year[$counter]->captured) == $counter_months) {
|
||||||
|
$month_url = url::site("calendarview/month/" . $calendar_year . "/" . $calendar_user . "/" . $counter_months . "/");
|
||||||
} else {
|
} else {
|
||||||
$day_count = ORM::factory("item")
|
$month_url = "";
|
||||||
->viewable()
|
|
||||||
->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))
|
|
||||||
->find_all()
|
|
||||||
->count();
|
|
||||||
}
|
}
|
||||||
if ($day_count > 0) {
|
$calendar = new PHPCalendar($counter_months, $calendar_year, $month_url);
|
||||||
$calendar->event($curr_day, url::site("calendarview/day/" . $calendar_year . "/" . $calendar_user . "/" . $counter_months . "/" . $curr_day));
|
|
||||||
}
|
|
||||||
$curr_day++;
|
|
||||||
}
|
|
||||||
if ($calendar_user == "-1") {
|
|
||||||
$day_count = ORM::factory("item")
|
|
||||||
->viewable()
|
|
||||||
->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))
|
|
||||||
->find_all()
|
|
||||||
->count();
|
|
||||||
} else {
|
|
||||||
$day_count = ORM::factory("item")
|
|
||||||
->viewable()
|
|
||||||
->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))
|
|
||||||
->find_all()
|
|
||||||
->count();
|
|
||||||
}
|
|
||||||
if ($day_count > 0) {
|
|
||||||
$calendar->event($MAX_DAYS, url::site("calendarview/day/" . $calendar_year . "/" . $calendar_user . "/" . $counter_months . "/" . $MAX_DAYS));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the day of the current photo is different then the day of the previous photo,
|
||||||
|
// then add a link to the calendar for this date and set the current day to this day.
|
||||||
|
if (date("j", $items_for_year[$counter]->captured) > $counter_days) {
|
||||||
|
$counter_days = date("j", $items_for_year[$counter]->captured);
|
||||||
|
$calendar->event($counter_days, url::site("calendarview/day/" . $calendar_year . "/" . $calendar_user . "/" . $counter_months . "/" . $counter_days));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Move onto the next photo.
|
||||||
|
$counter++;
|
||||||
}
|
}
|
||||||
$counter_months++;
|
|
||||||
|
// Print out the last calendar to be generated.
|
||||||
echo $calendar->render();
|
echo $calendar->render();
|
||||||
print "</div>";
|
print "</div>";
|
||||||
?>
|
$counter_months++;
|
||||||
|
|
||||||
|
// If the calendar that was previously rendered was not December,
|
||||||
|
// then print out a few empty months for the rest of the year.
|
||||||
|
while ($counter_months < 13) {
|
||||||
|
print "<div id=\"g-calendar-grid\">";
|
||||||
|
$month_url = "";
|
||||||
|
$calendar = new PHPCalendar($counter_months, $calendar_year, $month_url);
|
||||||
|
echo $calendar->render();
|
||||||
|
print "</div>";
|
||||||
|
$counter_months++;
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
|
@ -9,170 +9,86 @@
|
||||||
<br/><?= $calendar_user_year_form ?><br /><br />
|
<br/><?= $calendar_user_year_form ?><br /><br />
|
||||||
|
|
||||||
<?
|
<?
|
||||||
$counter_months = 1;
|
// Search the db for all photos that were taken during the selected year.
|
||||||
// Loop through January to November in the current year.
|
|
||||||
while ($counter_months <12) {
|
|
||||||
print "<div id=\"g-calendar-grid\">";
|
|
||||||
|
|
||||||
// Figure out if any photos were taken for the current month.
|
|
||||||
if ($calendar_user == "-1") {
|
|
||||||
$month_count = ORM::factory("item")
|
|
||||||
->viewable()
|
|
||||||
->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))
|
|
||||||
->find_all()
|
|
||||||
->count();
|
|
||||||
} else {
|
|
||||||
$month_count = ORM::factory("item")
|
|
||||||
->viewable()
|
|
||||||
->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, $counter_months+1, 1, $calendar_year))
|
|
||||||
->find_all()
|
|
||||||
->count();
|
|
||||||
}
|
|
||||||
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);
|
|
||||||
|
|
||||||
// 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()
|
|
||||||
->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))
|
|
||||||
->find_all()
|
|
||||||
->count();
|
|
||||||
} else {
|
|
||||||
$day_count = ORM::factory("item")
|
|
||||||
->viewable()
|
|
||||||
->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))
|
|
||||||
->find_all()
|
|
||||||
->count();
|
|
||||||
}
|
|
||||||
if ($day_count > 0) {
|
|
||||||
$calendar->event($curr_day, url::site("calendarview/day/" . $calendar_year . "/" . $calendar_user . "/" . $counter_months . "/" . $curr_day));
|
|
||||||
}
|
|
||||||
$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()
|
|
||||||
->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))
|
|
||||||
->find_all()
|
|
||||||
->count();
|
|
||||||
} else {
|
|
||||||
$day_count = ORM::factory("item")
|
|
||||||
->viewable()
|
|
||||||
->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))
|
|
||||||
->find_all()
|
|
||||||
->count();
|
|
||||||
}
|
|
||||||
if ($day_count > 0) {
|
|
||||||
$calendar->event($MAX_DAYS, url::site("calendarview/day/" . $calendar_year . "/" . $calendar_user . "/" . $counter_months . "/" . $MAX_DAYS));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
echo $calendar->render();
|
|
||||||
print "</div>";
|
|
||||||
$counter_months++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Do December seperately, because the mktime code is different.
|
|
||||||
print "<div id=\"g-calendar-grid\">";
|
|
||||||
if ($calendar_user == "-1") {
|
if ($calendar_user == "-1") {
|
||||||
$month_count = ORM::factory("item")
|
$items_for_year = ORM::factory("item")
|
||||||
->viewable()
|
->viewable()
|
||||||
->where("type", "!=", "album")
|
->where("type", "!=", "album")
|
||||||
->where("captured", ">=", mktime(0, 0, 0, $counter_months, 1, $calendar_year))
|
->where("captured", ">=", mktime(0, 0, 0, 1, 1, $calendar_year))
|
||||||
->where("captured", "<", mktime(0, 0, 0, 1, 1, ($calendar_year + 1)))
|
->where("captured", "<", mktime(0, 0, 0, 1, 1, ($calendar_year + 1)))
|
||||||
->find_all()
|
->order_by("captured")
|
||||||
->count();
|
->find_all();
|
||||||
} else {
|
} else {
|
||||||
$month_count = ORM::factory("item")
|
$items_for_year = ORM::factory("item")
|
||||||
->viewable()
|
->viewable()
|
||||||
->where("owner_id", "=", $calendar_user)
|
->where("owner_id", "=", $calendar_user)
|
||||||
->where("type", "!=", "album")
|
->where("type", "!=", "album")
|
||||||
->where("captured", ">=", mktime(0, 0, 0, $counter_months, 1, $calendar_year))
|
->where("captured", ">=", mktime(0, 0, 0, 1, 1, $calendar_year))
|
||||||
->where("captured", "<", mktime(0, 0, 0, 1, 1, ($calendar_year + 1)))
|
->where("captured", "<", mktime(0, 0, 0, 1, 1, ($calendar_year + 1)))
|
||||||
->find_all()
|
->order_by("captured")
|
||||||
->count();
|
->find_all();
|
||||||
}
|
}
|
||||||
if ($month_count > 0) {
|
|
||||||
|
// Set up some initial variables.
|
||||||
|
$counter_months = 1;
|
||||||
|
$counter_days = 0;
|
||||||
|
$counter = 0;
|
||||||
|
|
||||||
|
// Set up the January Calendar.
|
||||||
|
// Check and see if any photos were taken in January,
|
||||||
|
// If so, make the month title into a clickable link.
|
||||||
|
print "<div id=\"g-calendar-grid\">";
|
||||||
|
if (date("n", $items_for_year[$counter]->captured) == 1) {
|
||||||
$month_url = url::site("calendarview/month/" . $calendar_year . "/" . $calendar_user . "/" . $counter_months . "/");
|
$month_url = url::site("calendarview/month/" . $calendar_year . "/" . $calendar_user . "/" . $counter_months . "/");
|
||||||
} else {
|
} else {
|
||||||
$month_url = "";
|
$month_url = "";
|
||||||
}
|
}
|
||||||
$calendar = new PHPCalendar($counter_months, $calendar_year, $month_url);
|
$calendar = new PHPCalendar($counter_months, $calendar_year, $month_url);
|
||||||
if ($month_count > 0) {
|
|
||||||
$curr_day = 1;
|
// Loop through each photo taken during this year, and see what month and day they were taken on.
|
||||||
$MAX_DAYS = date('t', mktime(00, 00, 00, $counter_months, 1, $calendar_year));
|
// Make the corresponding dates on the calendars into clickable links.
|
||||||
while ($curr_day < $MAX_DAYS) {
|
while ($counter < (count($items_for_year))) {
|
||||||
if ($calendar_user == "-1") {
|
|
||||||
$day_count = ORM::factory("item")
|
// Check and see if we've switched to a new month.
|
||||||
->viewable()
|
// If so, render the current calendar and set up a new one.
|
||||||
->where("type", "!=", "album")
|
while (date("n", $items_for_year[$counter]->captured) > $counter_months) {
|
||||||
->where("captured", ">=", mktime(0, 0, 0, $counter_months, $curr_day, $calendar_year))
|
echo $calendar->render();
|
||||||
->where("captured", "<", mktime(0, 0, 0, $counter_months, ($curr_day + 1), $calendar_year))
|
print "</div>";
|
||||||
->find_all()
|
$counter_months++;
|
||||||
->count();
|
$counter_days = 0;
|
||||||
|
print "<div id=\"g-calendar-grid\">";
|
||||||
|
if (date("n", $items_for_year[$counter]->captured) == $counter_months) {
|
||||||
|
$month_url = url::site("calendarview/month/" . $calendar_year . "/" . $calendar_user . "/" . $counter_months . "/");
|
||||||
} else {
|
} else {
|
||||||
$day_count = ORM::factory("item")
|
$month_url = "";
|
||||||
->viewable()
|
|
||||||
->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))
|
|
||||||
->find_all()
|
|
||||||
->count();
|
|
||||||
}
|
}
|
||||||
if ($day_count > 0) {
|
$calendar = new PHPCalendar($counter_months, $calendar_year, $month_url);
|
||||||
$calendar->event($curr_day, url::site("calendarview/day/" . $calendar_year . "/" . $calendar_user . "/" . $counter_months . "/" . $curr_day));
|
|
||||||
}
|
|
||||||
$curr_day++;
|
|
||||||
}
|
|
||||||
if ($calendar_user == "-1") {
|
|
||||||
$day_count = ORM::factory("item")
|
|
||||||
->viewable()
|
|
||||||
->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))
|
|
||||||
->find_all()
|
|
||||||
->count();
|
|
||||||
} else {
|
|
||||||
$day_count = ORM::factory("item")
|
|
||||||
->viewable()
|
|
||||||
->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))
|
|
||||||
->find_all()
|
|
||||||
->count();
|
|
||||||
}
|
|
||||||
if ($day_count > 0) {
|
|
||||||
$calendar->event($MAX_DAYS, url::site("calendarview/day/" . $calendar_year . "/" . $calendar_user . "/" . $counter_months . "/" . $MAX_DAYS));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If the day of the current photo is different then the day of the previous photo,
|
||||||
|
// then add a link to the calendar for this date and set the current day to this day.
|
||||||
|
if (date("j", $items_for_year[$counter]->captured) > $counter_days) {
|
||||||
|
$counter_days = date("j", $items_for_year[$counter]->captured);
|
||||||
|
$calendar->event($counter_days, url::site("calendarview/day/" . $calendar_year . "/" . $calendar_user . "/" . $counter_months . "/" . $counter_days));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Move onto the next photo.
|
||||||
|
$counter++;
|
||||||
}
|
}
|
||||||
$counter_months++;
|
|
||||||
|
// Print out the last calendar to be generated.
|
||||||
echo $calendar->render();
|
echo $calendar->render();
|
||||||
print "</div>";
|
print "</div>";
|
||||||
?>
|
$counter_months++;
|
||||||
|
|
||||||
|
// If the calendar that was previously rendered was not December,
|
||||||
|
// then print out a few empty months for the rest of the year.
|
||||||
|
while ($counter_months < 13) {
|
||||||
|
print "<div id=\"g-calendar-grid\">";
|
||||||
|
$month_url = "";
|
||||||
|
$calendar = new PHPCalendar($counter_months, $calendar_year, $month_url);
|
||||||
|
echo $calendar->render();
|
||||||
|
print "</div>";
|
||||||
|
$counter_months++;
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
Reference in New Issue
Block a user