Beispiel #1
0
        $recurEvents = $eventHandler->getRecurEventToDisplay($event, $startMonth, $endMonth);
        foreach ($recurEvents as $recurEvent) {
            addEventToArray($recurEvent, $eventsArray);
        }
    }
}
//echo "<pre>";print_r($eventsArray);echo "</pre>";
/*
*  Making an array to create tabbed output on the template
*/
// Flag current day
$selectedDays = array(new Calendar_Day(date('Y', xoops_getUserTimestamp(time(), $extcalTimeHandler->_getUserTimeZone($xoopsUser))), date('n', xoops_getUserTimestamp(time(), $extcalTimeHandler->_getUserTimeZone($xoopsUser))), date('j', xoops_getUserTimestamp(time(), $extcalTimeHandler->_getUserTimeZone($xoopsUser)))));
// Build calendar object
$monthCalObj = new Calendar_Month_Weeks($year, $month, $xoopsModuleConfig['week_start_day']);
$pMonthCalObj = $monthCalObj->prevMonth('object');
$nMonthCalObj = $monthCalObj->nextMonth('object');
$monthCalObj->build();
$tableRows = array();
$rowId = 0;
$cellId = 0;
while ($weekCalObj = $monthCalObj->fetch()) {
    $weekCalObj->build($selectedDays);
    $tableRows[$rowId]['weekInfo'] = array('week' => $weekCalObj->thisWeek('n_in_year'), 'day' => $weekCalObj->thisDay(), 'month' => $weekCalObj->thisMonth(), 'year' => $weekCalObj->thisYear());
    while ($dayCalObj = $weekCalObj->fetch()) {
        $tableRows[$rowId]['week'][$cellId] = array('isEmpty' => $dayCalObj->isEmpty(), 'number' => $dayCalObj->thisDay(), 'isSelected' => $dayCalObj->isSelected());
        if (@count($eventsArray[$dayCalObj->thisDay()]) > 0 && !$dayCalObj->isEmpty()) {
            $tableRows[$rowId]['week'][$cellId]['events'] = $eventsArray[$dayCalObj->thisDay()];
        } else {
            $tableRows[$rowId]['week'][$cellId]['events'] = '';
        }
        $cellId++;
Beispiel #2
0
}
if (!isset($_GET['d'])) {
    $_GET['d'] = date('d');
}
// Build a month object
$Month = new Calendar_Month_Weeks($_GET['y'], $_GET['m']);
// Create an array of days which are "selected"
// Used for Week::build() below
$selectedDays = array(new Calendar_Day($_GET['y'], $_GET['m'], $_GET['d']), new Calendar_Day($_GET['y'], 12, 25), new Calendar_Day(date('Y'), date('m'), date('d')));
// Instruct month to build Week objects
$Month->build();
// Construct strings for next/previous links
$PMonth = $Month->prevMonth('object');
// Get previous month as object
$prev = $_SERVER['PHP_SELF'] . '?y=' . $PMonth->thisYear() . '&m=' . $PMonth->thisMonth() . '&d=' . $PMonth->thisDay();
$NMonth = $Month->nextMonth('object');
$next = $_SERVER['PHP_SELF'] . '?y=' . $NMonth->thisYear() . '&m=' . $NMonth->thisMonth() . '&d=' . $NMonth->thisDay();
?>
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title> Calendar </title>
<style text="text/css">
table {
    background-color: silver;
}
caption {
    font-family: verdana;
    font-size: 12px;
    background-color: while;
}
    function renderMonthView()
    {
        global $TemplateDir, $ClassDir, $WebBaseDir, $WebTemplateDir, $i18n, $userid;
        require_once 'Calendar' . DIRECTORY_SEPARATOR . 'Month/Weeks.php';
        require_once 'Calendar' . DIRECTORY_SEPARATOR . 'Util' . DIRECTORY_SEPARATOR . 'Textual.php';
        include_once $ClassDir . "URLHelper.class.php";
        // Initialize GET variables if not set
        if (!isset($_GET['y'])) {
            $_GET['y'] = date('Y');
        }
        if (!isset($_GET['m'])) {
            $_GET['m'] = date('m');
        }
        if (!isset($_GET['d'])) {
            $_GET['d'] = date('d');
        }
        // Build a month object
        $Month = new Calendar_Month_Weeks($_GET['y'], $_GET['m'], 0);
        // count select month webcasts
        $apf_schedule = DB_DataObject::factory('ApfSchedule');
        $apf_schedule->selectAdd('publish_date , COUNT(*) AS NUM');
        $apf_schedule->whereAdd(" DATE_FORMAT(publish_date,'%Y-%m') = '{$_GET['y']}-{$_GET['m']}' ");
        //		$apf_schedule->whereAdd("userid='{$userid}'");
        $apf_schedule->setUserid($userid);
        $apf_schedule->groupBy('publish_date');
        //		$apf_schedule->debugLevel(4);
        $apf_schedule->find();
        $month_webcast = array();
        while ($apf_schedule->fetch()) {
            $month_webcast[date("Y-m-j", strtotime($apf_schedule->getPublishDate()))] = $apf_schedule->NUM;
        }
        //		Var_Dump::display($month_webcast);
        // Used for Week::build() below
        $selectedDays = array(new Calendar_Day(date('Y'), date('m'), date('d')));
        // Instruct month to build Week objects
        $Month->build();
        // Construct strings for next/previous links
        $PMonth = $Month->prevMonth('object');
        // Get previous month as object
        $base_url = $WebBaseDir . "/schedule/apf_schedule/list/";
        $prev = $base_url . '?y=' . $PMonth->thisYear() . '&m=' . $PMonth->thisMonth() . '&d=' . $PMonth->thisDay();
        $NMonth = $Month->nextMonth('object');
        $next = $base_url . '?y=' . $NMonth->thisYear() . '&m=' . $NMonth->thisMonth() . '&d=' . $NMonth->thisDay();
        $today_link = $base_url . '?y=' . date("Y") . '&m=' . date("m") . '&d=' . date("d");
        $calendar_title = date('F Y', $Month->getTimeStamp());
        $main_calendar = "";
        while ($Week = $Month->fetch()) {
            $main_calendar .= "<tr valign='top'>\n";
            // Build the days in the week, passing the selected days
            $Week->build($selectedDays);
            $i = 0;
            $temp_week_string = "";
            $week_days = array();
            while ($Day = $Week->fetch()) {
                // Build a link string for each day
                $link = $base_url . '?y=' . $Day->thisYear() . '&m=' . $Day->thisMonth() . '&d=' . $Day->thisDay();
                $data_string = $Day->thisYear() . "-" . $Day->thisMonth() . "-" . $Day->thisDay();
                $apf_schedule_num = $month_webcast["{$data_string}"] ? $month_webcast["{$data_string}"] : 0;
                $week_days[] = $data_string;
                // Check to see if day is selected
                if ($Day->isSelected()) {
                    $temp_week_string .= '<td class="calCellBusy"><div class="dayNumber"><a href="' . $link . '">' . $Day->thisDay() . '</a></div><div class="dayContents">' . $apf_schedule_num . '</div></td>' . "\n";
                    // Check to see if day is empty
                } else {
                    if ($Day->isEmpty()) {
                        $temp_week_string .= '<td class="calCellEmpty"><div class="dayNumber">' . $Day->thisDay() . '</div></td>' . "\n";
                    } else {
                        $temp_week_string .= '<td class="calCell" ><div class="dayNumber"><a href="' . $link . '" >' . $Day->thisDay() . '</a></div><div class="dayContents">' . $apf_schedule_num . '</div></td>' . "\n";
                    }
                }
                $i++;
            }
            $WeekNum = date('W', strtotime($week_days[0]));
            $main_calendar .= '<td class="week"><a href="###" onclick="document.admin_left_cal.act.value=\'ExportWeek\';document.admin_left_cal.weekdays.value=\'' . implode(",", $week_days) . '\';document.admin_left_cal.week.value=\'' . $WeekNum . '\';document.admin_left_cal.submit();" ><img src="' . URLHelper::getWebBaseURL() . $WebTemplateDir . '/images/xls_image_inline.gif" border="0" valign="middle" />' . $WeekNum . '</a></td>' . "\n";
            //"-".$Week->thisDay().
            $main_calendar .= $temp_week_string;
            $main_calendar .= '</tr>' . "\n";
        }
        $cal_header_string = "";
        $cal_header_string .= '<th class="week">' . $i18n->_("wk") . '</th>';
        $week_day_string = array('0' => $i18n->_("Sun"), '1' => $i18n->_("Mon"), '2' => $i18n->_("Tue"), '3' => $i18n->_("Wed"), '4' => $i18n->_("Thu"), '5' => $i18n->_("Fri"), '6' => $i18n->_("Sat"));
        for ($i = 0; $i <= 6; $i++) {
            if ($i == 0 || $i == 6) {
                $head_class = "class=\"calholiday\"";
            } else {
                $head_class = "";
            }
            $cal_header_string .= '<th ' . $head_class . '>' . $week_day_string[$i] . '</th>';
        }
        $header_today = $i18n->_("Today");
        $calendar_str = <<<EOD
<table class="month" cellspacing="0" cellpadding="0">
<caption>
<a href="{$prev}" > << </a> <b>{$calendar_title} <A href="{$today_link}" class="calholiday">{$header_today}</a> </b> <a href="{$next}"> >> </a>
</caption>
<tr class="calheader">
{$cal_header_string}
</tr>
{$main_calendar}
</table>
EOD;
        return $calendar_str;
    }