diff --git a/3.0/modules/calendarview/css/calendarview_calendar.css b/3.0/modules/calendarview/css/calendarview_calendar.css index 53807042..4ea862a1 100644 --- a/3.0/modules/calendarview/css/calendarview_calendar.css +++ b/3.0/modules/calendarview/css/calendarview_calendar.css @@ -8,6 +8,15 @@ margin: 10px 10px 10px 10px; } +#g-calendar-profile-grid { + position: relative; + align: center; + float: left; + width: 200px; + height: 140px; + margin: 10px 10px 10px 10px; +} + /* Search form ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */ #cal_user { top: 0px; diff --git a/3.0/modules/calendarview/helpers/calendarview_event.php b/3.0/modules/calendarview/helpers/calendarview_event.php index 4ce60598..cb410b01 100644 --- a/3.0/modules/calendarview/helpers/calendarview_event.php +++ b/3.0/modules/calendarview/helpers/calendarview_event.php @@ -69,4 +69,31 @@ class calendarview_event_Core { site_status::clear("calendarview_needs_exif"); } } -} \ No newline at end of file + + static function show_user_profile($data) { + // Display a few months on the user profile screen. + $v = new View("user_profile_calendarview.html"); + $v->user_id = $data->user->id; + + // Figure out what month the users newest photo was taken it. + // Make that the last month to display. + // If a user hasn't uploaded anything, make the current month + // the last to be displayed. + $latest_photo = ORM::factory("item") + ->viewable() + ->where("type", "!=", "album") + ->where("captured", "!=", "") + ->where("owner_id", "=", $data->user->id) + ->order_by("captured", "DESC") + ->find_all(1); + if (count($latest_photo) > 0) { + $v->user_year = date('Y', $latest_photo[0]->captured); + $v->user_month = date('n', $latest_photo[0]->captured); + } else { + $v->user_year = date('Y'); + $v->user_month = date('n'); + } + + $data->content[] = (object) array("title" => t("User calendar"), "view" => $v); + } +} diff --git a/3.0/modules/calendarview/views/user_profile_calendarview.html.php b/3.0/modules/calendarview/views/user_profile_calendarview.html.php new file mode 100644 index 00000000..a98cd528 --- /dev/null +++ b/3.0/modules/calendarview/views/user_profile_calendarview.html.php @@ -0,0 +1,86 @@ + +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 "
"; + 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 "
"; + $counter_months++; + if ($counter_months == 13) { + $counter_months = 1; + $calendar_year++; + } + $counter_days = 0; + print "
"; + 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 "
"; + $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 "
"; + $month_url = ""; + $calendar = new PHPCalendar($counter_months, $calendar_year, $month_url); + echo $calendar->render(); + print "
"; + $counter_months++; + } + +?> +

+
"> >>