summaryrefslogtreecommitdiff
path: root/modules/calendarview/views
diff options
context:
space:
mode:
authorTristan Zur <tzur@webserver.ccwn.org>2015-06-10 20:55:53 +0200
committerTristan Zur <tzur@webserver.ccwn.org>2015-06-10 20:55:53 +0200
commit406abd7c4df1ace2cd3e4e17159e8941a2e8c0c4 (patch)
treea324be16021f44f2fd6d55e609f47024e945b1db /modules/calendarview/views
Initial import
Diffstat (limited to 'modules/calendarview/views')
-rw-r--r--modules/calendarview/views/calendarview_sidebar.html.php9
-rw-r--r--modules/calendarview/views/calendarview_year.html.php95
-rw-r--r--modules/calendarview/views/user_profile_calendarview.html.php86
3 files changed, 190 insertions, 0 deletions
diff --git a/modules/calendarview/views/calendarview_sidebar.html.php b/modules/calendarview/views/calendarview_sidebar.html.php
new file mode 100644
index 0000000..b4f1f6f
--- /dev/null
+++ b/modules/calendarview/views/calendarview_sidebar.html.php
@@ -0,0 +1,9 @@
+<?php defined("SYSPATH") or die("No direct script access.") ?>
+<ul>
+ <? if ($day_count > 0): ?>
+ <li><a href="<?=url::site("calendarview/day/" . date("Y", $date) . "/-1/" . date("n", $date) . "/" . date("j", $date)); ?>"><?=t("More from"); ?> <?=date("F", $date); ?> <?=date("j", $date); ?><?=date("S", $date); ?></a></li>
+ <? endif ?>
+ <? if ($month_count > 0): ?>
+ <li><a href="<?=url::site("calendarview/month/" . date("Y", $date) . "/-1/" . date("n", $date)); ?>"><?=t("More from"); ?> <?=date("F", $date); ?></a></li>
+ <? endif ?>
+</ul> \ No newline at end of file
diff --git a/modules/calendarview/views/calendarview_year.html.php b/modules/calendarview/views/calendarview_year.html.php
new file mode 100644
index 0000000..b40d7d5
--- /dev/null
+++ b/modules/calendarview/views/calendarview_year.html.php
@@ -0,0 +1,95 @@
+<?php defined("SYSPATH") or die("No direct script access.") ?>
+<div id="g-album-header">
+ <div id="g-album-header-buttons">
+ <?= $theme->dynamic_top() ?>
+ </div>
+ <h1><?= html::clean($title) ?></h1>
+</div>
+
+<br/><?= $calendar_user_year_form ?><br /><br />
+
+<?
+ // Search the db for all photos that were taken during the selected year.
+ if ($calendar_user == "-1") {
+ $items_for_year = ORM::factory("item")
+ ->viewable()
+ ->where("type", "!=", "album")
+ ->where("captured", ">=", mktime(0, 0, 0, 1, 1, $calendar_year))
+ ->where("captured", "<", mktime(0, 0, 0, 1, 1, ($calendar_year + 1)))
+ ->order_by("captured")
+ ->find_all();
+ } else {
+ $items_for_year = ORM::factory("item")
+ ->viewable()
+ ->where("owner_id", "=", $calendar_user)
+ ->where("type", "!=", "album")
+ ->where("captured", ">=", mktime(0, 0, 0, 1, 1, $calendar_year))
+ ->where("captured", "<", mktime(0, 0, 0, 1, 1, ($calendar_year + 1)))
+ ->order_by("captured")
+ ->find_all();
+ }
+
+ // 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 ((count($items_for_year) > 0) && (date("n", $items_for_year[$counter]->captured) == 1)) {
+ $month_url = url::site("calendarview/month/" . $calendar_year . "/" . $calendar_user . "/" . $counter_months . "/");
+ } else {
+ $month_url = "";
+ }
+ $calendar = new PHPCalendar($counter_months, $calendar_year, $month_url);
+
+ // Loop through each photo taken during this year, and see what month and day they were taken on.
+ // Make the corresponding dates on the calendars into clickable links.
+ while ($counter < (count($items_for_year))) {
+
+ // Check and see if we've switched to a new month.
+ // If so, render the current calendar and set up a new one.
+ while (date("n", $items_for_year[$counter]->captured) > $counter_months) {
+ echo $calendar->render();
+ print "</div>";
+ $counter_months++;
+ $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 {
+ $month_url = "";
+ }
+ $calendar = new PHPCalendar($counter_months, $calendar_year, $month_url);
+ }
+
+ // 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++;
+ }
+
+ // Print out the last calendar to be generated.
+ echo $calendar->render();
+ 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++;
+ }
+?>
+<?= $theme->dynamic_bottom() ?>
diff --git a/modules/calendarview/views/user_profile_calendarview.html.php b/modules/calendarview/views/user_profile_calendarview.html.php
new file mode 100644
index 0000000..4d9d68a
--- /dev/null
+++ b/modules/calendarview/views/user_profile_calendarview.html.php
@@ -0,0 +1,86 @@
+<?php defined("SYSPATH") or die("No direct script access.") ?>
+<?
+ // Generate a list of items within the specified 3 month time-frame.
+ $items = ORM::factory("item")
+ ->viewable()
+ ->where("owner_id", "=", $user_id)
+ ->where("type", "!=", "album")
+ ->where("captured", ">=", mktime(0, 0, 0, $user_month-2, 1, $user_year))
+ ->where("captured", "<", mktime(0, 0, 0, $user_month+1, 1, ($user_year)))
+ ->order_by("captured")
+ ->find_all();
+
+ // Set up some initial variables.
+ $calendar_year = $user_year;
+ $counter_months = $user_month - 2;
+ if ($counter_months < 1) {
+ $counter_months += 12;
+ $calendar_year--;
+ }
+ $counter_days = 0;
+ $counter = 0;
+
+ // Print the first month.
+ print "<div id=\"g-calendar-profile-grid\">";
+ if ((count($items) > 0) && (date("n", $items[$counter]->captured) == $counter_months)) {
+ $month_url = url::site("calendarview/month/" . $calendar_year . "/" . $user_id . "/" . $counter_months . "/");
+ } else {
+ $month_url = "";
+ }
+ $calendar = new PHPCalendar($counter_months, $calendar_year, $month_url);
+
+ // Loop through each photo taken during the 3 month time frame, and see what month and day they were taken on.
+ // Make the corresponding dates on the calendars into clickable links.
+ while ($counter < (count($items))) {
+
+ // Check and see if we've switched to a new month.
+ // If so, render the current calendar and set up a new one.
+ // Continue printing empty months until we reach the next photo or the last month.
+ while (date("n", $items[$counter]->captured) != $counter_months) {
+ echo $calendar->render();
+ print "</div>";
+ $counter_months++;
+ if ($counter_months == 13) {
+ $counter_months = 1;
+ $calendar_year++;
+ }
+ $counter_days = 0;
+ print "<div id=\"g-calendar-profile-grid\">";
+ if (date("n", $items[$counter]->captured) == $counter_months) {
+ $month_url = url::site("calendarview/month/" . $calendar_year . "/" . $user_id . "/" . $counter_months . "/");
+ } else {
+ $month_url = "";
+ }
+ $calendar = new PHPCalendar($counter_months, $calendar_year, $month_url);
+ }
+
+ // 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[$counter]->captured) > $counter_days) {
+ $counter_days = date("j", $items[$counter]->captured);
+ $calendar->event($counter_days, url::site("calendarview/day/" . $calendar_year . "/" . $user_id . "/" . $counter_months . "/" . $counter_days));
+ }
+
+ // Move onto the next photo.
+ $counter++;
+ }
+
+ // Print out the last calendar to be generated.
+ echo $calendar->render();
+ print "</div>";
+ $counter_months++;
+
+ // If the calendar that was previously rendered was not the final month,
+ // then print out a few empty months to fill the remaining space.
+ while ($counter_months < $user_month + 1) {
+ print "<div id=\"g-calendar-profile-grid\">";
+ $month_url = "";
+ $calendar = new PHPCalendar($counter_months, $calendar_year, $month_url);
+ echo $calendar->render();
+ print "</div>";
+ $counter_months++;
+ }
+
+?>
+<br clear="all" /><br /><br />
+<div align="right"><a href="<?=url::site("calendarview/calendar/{$user_year}/{$user_id}"); ?>"><?=t("View full calendar"); ?> &gt;&gt;</a></div>