示例#1
0
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&amp;" . "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));
}
示例#2
0
function weeks_in_month($month, $year)
{
    global $first_day_of_week;
    return ceil((days_in_month($month, $year) + (7 + day_of_first($month, $year) - $first_day_of_week) % 7) / 7);
}