function display_days($day_count, $week_of_month, $month, $year) { global $db, $phpc_script, $config, $first_day_of_week; if ($day_count > 7) { return array(); } $day_of_month = ($week_of_month - 1) * 7 + $day_count - (7 + day_of_first($month, $year) - $first_day_of_week) % 7; if ($day_of_month <= 0 || $day_of_month > days_in_month($month, $year)) { $html_day = tag('td', attributes('class="none"')); } else { $currentday = date('j'); $currentmonth = date('n'); $currentyear = date('Y'); // set whether the date is in the past or future/present if ($currentyear > $year || $currentyear == $year && ($currentmonth > $month || $currentmonth == $month && $currentday > $day_of_month)) { $current_era = 'past'; } else { $current_era = 'future'; } if (can_add_event()) { $html_day = tag('td', attributes('valign="top"', "class=\"{$current_era}\""), create_date_link('+', 'event_form', $year, $month, $day_of_month, array('class="phpc-add"')), create_date_link($day_of_month, 'display', $year, $month, $day_of_month, array('class="date"'))); } else { $html_day = tag('td', attributes('valign="top"', "class=\"{$current_era}\""), create_date_link($day_of_month, 'display', $year, $month, $day_of_month, array('class="date"'))); } $result = get_events_by_date($day_of_month, $month, $year); /* Start off knowing we don't need to close the event * list. loop through each event for the day */ $have_events = false; $html_events = tag('ul'); while ($row = $result->FetchRow($result)) { $subject = htmlspecialchars(strip_tags(stripslashes($row['subject']))); $event_time = formatted_time_string($row['starttime'], $row['eventtype']); $event = tag('li', tag('a', attributes("href=\"{$phpc_script}" . "?action=display&" . "id={$row['id']}\""), ($event_time ? "{$event_time} - " : '') . $subject)); $html_events->add($event); $have_events = true; } if ($have_events) { $html_day->add($html_events); } } return array_merge(array($html_day), display_days($day_count + 1, $week_of_month, $month, $year)); }
function navbar() { global $vars, $action, $config, $year, $month, $day; $html = tag('div', attributes('class="phpc-navbar"')); if (can_add_event() && $action != 'add') { menu_item_append($html, _('Add Event'), 'event_form', $year, $month, $day); } if ($action != 'search') { menu_item_append($html, _('Search'), 'search', $year, $month, $day); } if (!empty($vars['day']) || !empty($vars['id']) || $action != 'display') { menu_item_append($html, _('Back to Calendar'), 'display', $year, $month); } if ($action != 'display' || !empty($vars['id'])) { menu_item_append($html, _('View date'), 'display', $year, $month, $day); } if (is_user()) { menu_item_append($html, _('Log out'), 'logout', empty($vars['year']) ? false : $year, empty($vars['month']) ? false : $month, empty($vars['day']) ? false : $day, $action); } else { menu_item_append($html, _('Log in'), 'login', empty($vars['year']) ? false : $year, empty($vars['month']) ? false : $month, empty($vars['day']) ? false : $day, $action); } if (is_admin() && $action != 'admin') { menu_item_append($html, _('Admin'), 'admin'); } if (isset($var['display']) && $var['display'] == 'day') { $monthname = month_name($month); $lasttime = mktime(0, 0, 0, $month, $day - 1, $year); $lastday = date('j', $lasttime); $lastmonth = date('n', $lasttime); $lastyear = date('Y', $lasttime); $lastmonthname = month_name($lastmonth); $nexttime = mktime(0, 0, 0, $month, $day + 1, $year); $nextday = date('j', $nexttime); $nextmonth = date('n', $nexttime); $nextyear = date('Y', $nexttime); $nextmonthname = month_name($nextmonth); menu_item_prepend($html, "{$lastmonthname} {$lastday}", 'display', $lastyear, $lastmonth, $lastday); menu_item_append($html, "{$nextmonthname} {$nextday}", 'display', $nextyear, $nextmonth, $nextday); } return $html; }