Beispiel #1
0
        $cellId++;
    }
    $cellId = 0;
    $rowId++;
}
// Assigning events to the template
$xoopsTpl->assign('tableRows', $tableRows);
// Retriving categories
$cats = $catHandler->objectToArray($catHandler->getAllCat($xoopsUser));
// Assigning categories to the template
$xoopsTpl->assign('cats', $cats);
// Retriving weekdayNames
$weekdayNames = Calendar_Util_Textual::weekdayNames();
for ($i = 0; $i < $xoopsModuleConfig['week_start_day']; $i++) {
    $weekdayName = array_shift($weekdayNames);
    $weekdayNames[] = $weekdayName;
}
// Assigning weekdayNames to the template
$xoopsTpl->assign('weekdayNames', $weekdayNames);
// Retriving monthNames
$monthNames = Calendar_Util_Textual::monthNames();
// Making navig data
$navig = array('prev' => array('uri' => 'year=' . $pMonthCalObj->thisYear() . '&amp;month=' . $pMonthCalObj->thisMonth(), 'name' => $extcalTimeHandler->getFormatedDate($xoopsModuleConfig['nav_date_month'], $pMonthCalObj->getTimestamp())), 'this' => array('uri' => 'year=' . $monthCalObj->thisYear() . '&amp;month=' . $monthCalObj->thisMonth(), 'name' => $extcalTimeHandler->getFormatedDate($xoopsModuleConfig['nav_date_month'], $monthCalObj->getTimestamp())), 'next' => array('uri' => 'year=' . $nMonthCalObj->thisYear() . '&amp;month=' . $nMonthCalObj->thisMonth(), 'name' => $extcalTimeHandler->getFormatedDate($xoopsModuleConfig['nav_date_month'], $nMonthCalObj->getTimestamp())));
// Assigning navig data to the template
$xoopsTpl->assign('navig', $navig);
// Assigning current form navig data to the template
$xoopsTpl->assign('selectedCat', $cat);
$xoopsTpl->assign('year', $year);
$xoopsTpl->assign('month', $month);
$xoopsTpl->assign('view', "calmonth");
include XOOPS_ROOT_PATH . '/footer.php';
Beispiel #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;
}