public function action_calendar() { $view = View::factory('calendar/calendar')->bind('calendar', $calendar_markup); $month = Arr::get($_GET, 'month', date('m')); $year = Arr::get($_GET, 'year', date('Y')); $event_type = Arr::get($_GET, 'event_type'); $calendar = new Calendar($month, $year); $calendar->standard('prev-next'); $event = Model_Event::monthly_events($month, $year, $event_type); $day_events = array(); // loop though events and group events by day and event types foreach ($event as $e) { $day = date('j-m', $e->eventstart); if (!isset($day_events[$day][$e->eventtype])) { $day_events[$day][$e->eventtype] = array(); } $day_events[$day][$e->eventtype][] = array('id' => $e->id); } if ($day_events) { foreach ($day_events as $daymonth => $types) { list($day, $month) = explode("-", $daymonth); $timestamp = mktime(0, 0, 0, $month, (int) $day, $year); foreach ($types as $type => $events) { $count = count($events); $type = $count > 1 ? Inflector::plural($type) : $type; $calendar->attach($calendar->event()->condition('timestamp', (int) $timestamp)->output($count . ' ' . $type)); } } } $calendar->attach($calendar->event()->condition('timestamp', time())->add_class('today')); $calendar_markup = $calendar->render(); $this->content = $view; }
public function action_index() { $calendar = new Calendar(Arr::get($_GET, 'month', date('m')), Arr::get($_GET, 'year', date('Y'))); $calendar->attach($calendar->event()->condition('timestamp', time())->output(html::anchor('http://google.de', 'google'))); $data = array('content' => $calendar->render()); $this->request->response = new View('index', $data); }
function calendar() { $profiler = new Profiler(); $calendar = new Calendar($this->input->get('month', date('m')), $this->input->get('year', date('Y'))); $calendar->attach($calendar->event()->condition('year', 2008)->condition('month', 8)->condition('day', 8)->output(html::anchor('http://forum.kohanaphp.com/comments.php?DiscussionID=275', 'Learning about Kohana Calendar'))); echo $calendar->render(); }
function calendar() { $profiler = new Profiler(); $cal = new Calendar(5, 2007); echo $cal->render(); }
if ($month == 1) { $prev_month = 12; $prev_year = $year - 1; $next_month = 2; $next_year = $year; } elseif ($month == 12) { $prev_month = 11; $prev_year = $year; $next_month = 1; $next_year = $year + 1; } else { $prev_month = $month - 1; $prev_year = $year; $next_month = $month + 1; $next_year = $year; } $page->content .= '<div class="graybg small">' . "\n"; $page->content .= ' <div class="left"><a href="?year=' . $prev_year . '&month=' . $prev_month . '">[Previous]</a></div>' . "\n"; $page->content .= ' <div class="right"><a href="?year=' . $next_year . '&month=' . $next_month . '">[Next]</a></div>' . "\n"; $page->content .= '</div>' . "\n"; $page->content .= $c->render($c->year, $c->month); $page->content .= '<div class="graybg small">' . "\n"; $page->content .= ' <div class="left"><a href="?year=' . $prev_year . '&month=' . $prev_month . '">[Previous]</a></div>' . "\n"; $page->content .= ' <div class="right"><a href="?year=' . $next_year . '&month=' . $next_month . '">[Next]</a></div>' . "\n"; $page->content .= '</div>' . "\n"; if ($_SESSION['login']) { $page->content .= "<div class=\"graybg small\">\n"; $page->content .= "[<a href=\"event/index.php?action=add\">Add an Event</a>]\n"; $page->content .= "</div>\n"; } $page->display();
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, 1, 1, $calendar_year + 1))->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, 1, 1, $calendar_year + 1))->find_all()->count(); } 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->attach($calendar->event()->condition('year', $calendar_year)->condition('month', $counter_months)->condition('day', $curr_day)->output(html::anchor(url::site("calendarview/day/" . $calendar_year . "/" . $calendar_user . "/" . $counter_months . "/" . $curr_day), $day_count))); } $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->attach($calendar->event()->condition('year', $calendar_year)->condition('month', $counter_months)->condition('day', $MAX_DAYS)->output(html::anchor(url::site("calendarview/day/" . $calendar_year . "/" . $calendar_user . "/" . $counter_months . "/" . $MAX_DAYS), $day_count))); } } $counter_months++; echo $calendar->render(); print "</td></tr></table>";
function calendar() { $profiler = new Profiler(); $calendar = new Calendar($this->input->get('month', date('m')), $this->input->get('year', date('Y'))); $calendar->attach($calendar->event()->condition('year', 2008)->condition('month', 8)->condition('day', 8)->output()); echo $calendar->render(); }