Example #1
0
    define('CALENDAR_ROOT', '../../');
}
require_once CALENDAR_ROOT . 'Month/Weeks.php';
require_once CALENDAR_ROOT . 'Day.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']);
// 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>
Example #2
0
function bExtcalMinicalShow($options)
{
    define('CALENDAR_ROOT', XOOPS_ROOT_PATH . '/modules/extcal/class/pear/Calendar/');
    include_once XOOPS_ROOT_PATH . '/modules/extcal/class/config.php';
    require_once CALENDAR_ROOT . 'Util/Textual.php';
    require_once CALENDAR_ROOT . 'Month/Weeks.php';
    require_once CALENDAR_ROOT . 'Day.php';
    // Retriving Image for block if enabled
    if ($options[0] == 1) {
        $imageHandler =& xoops_gethandler('image');
        $criteria = new Criteria('imgcat_id', $options[1]);
        $criteria->setSort('image_id');
        $criteria->setOrder('RAND()');
        $criteria->setLimit(1);
        $image = $imageHandler->getObjects($criteria);
        if (isset($image[0])) {
            $imageArray = array('displayImage' => true, 'image_name' => $image[0]->getVar('image_name'), 'image_nicename' => $image[0]->getVar('image_nicename'));
        } else {
            $imageArray = array('displayImage' => false);
        }
    } else {
        $imageArray = array('displayImage' => false);
    }
    // Retriving module config
    $extcalConfig = ExtcalConfig::getHandler();
    $xoopsModuleConfig = $extcalConfig->getModuleConfig();
    // Getting eXtCal object's handler
    $catHandler = xoops_getmodulehandler('cat', 'extcal');
    $eventHandler = xoops_getmodulehandler('event', 'extcal');
    $extcalTimeHandler = ExtcalTime::getHandler();
    // Retriving month and year value according to block options
    $month = date('n');
    $year = date('Y');
    if ($options[2] == -1) {
        $month--;
        if ($month == 0) {
            $month = 12;
            $year--;
        }
    } else {
        if ($options[2] == 1) {
            $month++;
            if ($month == 13) {
                $month = 1;
                $year++;
            }
        }
    }
    // Saving display link preference
    $displayLink = $options[3];
    // Delete options to keep only categorie data
    array_shift($options);
    array_shift($options);
    array_shift($options);
    array_shift($options);
    // Retriving events and formatting them
    $events = $eventHandler->objectToArray($eventHandler->getEventCalendarMonth($month, $year, $options));
    //$eventHandler->formatEventDate($events, "l dS \of F Y h:i:s A");
    // Calculating timestamp for the begin and the end of the month
    $startMonth = mktime(0, 0, 0, $month, 1, $year);
    $endMonth = mktime(23, 59, 59, $month + 1, 0, $year);
    /*
     *  Adding all event occuring during this month to an array indexed by day number
     */
    $eventsArray = array();
    foreach ($events as $event) {
        if (!$event['event_isrecur']) {
            bExtcalMinicalAddEventToArray($event, $eventsArray, $extcalTimeHandler, $startMonth, $endMonth);
        } else {
            $recurEvents = $eventHandler->getRecurEventToDisplay($event, $startMonth, $endMonth);
            foreach ($recurEvents as $recurEvent) {
                bExtcalMinicalAddEventToArray($recurEvent, $eventsArray, $extcalTimeHandler, $startMonth, $endMonth);
            }
        }
    }
    /*
     *  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($GLOBALS['xoopsUser']))), date('n', xoops_getUserTimestamp(time(), $extcalTimeHandler->_getUserTimeZone($GLOBALS['xoopsUser']))), date('j', xoops_getUserTimestamp(time(), $extcalTimeHandler->_getUserTimeZone($GLOBALS['xoopsUser'])))));
    // Build calendar object
    $monthCalObj = new Calendar_Month_Weeks($year, $month, $xoopsModuleConfig['week_start_day']);
    $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 (isset($eventsArray[$dayCalObj->thisDay()]) && !$dayCalObj->isEmpty()) {
                $tableRows[$rowId]['week'][$cellId]['haveEvents'] = true;
            } else {
                $tableRows[$rowId]['week'][$cellId]['haveEvents'] = false;
            }
            $cellId++;
        }
        $cellId = 0;
        $rowId++;
    }
    // Retriving weekdayNames
    $weekdayNames = Calendar_Util_Textual::weekdayNames('one');
    for ($i = 0; $i < $xoopsModuleConfig['week_start_day']; $i++) {
        $weekdayName = array_shift($weekdayNames);
        $weekdayNames[] = $weekdayName;
    }
    // Making navig data
    $navig = array('uri' => 'year=' . $monthCalObj->thisYear() . '&amp;month=' . $monthCalObj->thisMonth(), 'name' => $extcalTimeHandler->getFormatedDate($xoopsModuleConfig['nav_date_month'], $monthCalObj->getTimestamp()));
    $ret = array('image' => $imageArray, 'displayLink' => $displayLink, 'submitText' => _MB_EXTCAL_SUBMIT_LINK_TEXT, 'tableRows' => $tableRows, 'weekdayNames' => $weekdayNames, 'navig' => $navig);
    return $ret;
}
Example #3
0
        addEventToArray($event, $eventsArray);
    } else {
        $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'] = '';
    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;
    }