/**
  * Returns the source-code for a calendar in the "month"-view.
  *
  * @param   integer     $intYear: This year will be selected. If empty it will be used the current year.
  * @param   integer     $intMonth: This month will be selected. If empty it will be used the current month.
  * @param   integer     $intDay: This day will be selected. If empty it will be used the current day.
  * @return  strign      html-source for the calendar.
  */
 function getCalendar($intYear = 0, $intMonth = 0, $intDay = 0)
 {
     global $_ARRAYLANG;
     $intYear = intval($intYear);
     $intMonth = intval($intMonth);
     $intDay = intval($intDay);
     $objCalendar = new \activeCalendar($intYear, $intMonth, $intDay);
     $objCalendar->setMonthNames(explode(',', $_ARRAYLANG['TXT_BLOG_LIB_CALENDAR_MONTHS']));
     $objCalendar->setDayNames(explode(',', $_ARRAYLANG['TXT_BLOG_LIB_CALENDAR_WEEKDAYS']));
     $objCalendar->setFirstWeekDay(1);
     $objCalendar->enableMonthNav('index.php?section=Blog&cmd=search&mode=date');
     $arrEntriesInPeriod = $this->getEntriesInPeriod(mktime(0, 0, 0, $intMonth, 1, $intYear), mktime(0, 0, 0, $intMonth, 31, $intYear));
     if (count($arrEntriesInPeriod) > 0) {
         foreach ($arrEntriesInPeriod as $intTimeStamp) {
             $objCalendar->setEvent($intYear, $intMonth, date('d', $intTimeStamp), null, 'index.php?section=Blog&cmd=search&mode=date&yearID=' . $intYear . '&monthID=' . $intMonth . '&dayID=' . date('d', $intTimeStamp));
         }
     }
     return $objCalendar->showMonth();
 }
 /**
  * Loads datepicker
  *      
  * @param object  &$datePicker
  * @param integer $cat
  * 
  * @return null
  */
 function loadDatePicker(&$datePicker, $cat = null)
 {
     global $_CORELANG;
     if ($this->_objTpl->placeholderExists($this->moduleLangVar . '_DATEPICKER')) {
         $timestamp = time();
         $datePickerYear = $_REQUEST["yearID"] ? $_REQUEST["yearID"] : date('Y', $timestamp);
         $datePickerMonth = $_REQUEST["monthID"] ? $_REQUEST["monthID"] : date('m', $timestamp);
         $datePickerDay = $_REQUEST["dayID"] ? $_REQUEST["dayID"] : date('d', $timestamp);
         $datePicker = new \activeCalendar($datePickerYear, $datePickerMonth, $datePickerDay);
         $datePicker->enableMonthNav("?section=Calendar");
         $datePicker->enableDayLinks("?section=Calendar");
         $datePicker->setDayNames(explode(',', $_CORELANG['TXT_DAY_ARRAY']));
         $datePicker->setMonthNames(explode(',', $_CORELANG['TXT_MONTH_ARRAY']));
         $eventManagerAllEvents = new \Cx\Modules\Calendar\Controller\CalendarEventManager(null, null, $cat, null, true, false, true);
         $eventManagerAllEvents->getEventList();
         $events = $eventManagerAllEvents->getEventsWithDate();
         foreach ($events as $event) {
             $datePicker->setEvent($event["year"], $event["month"], $event["day"], " withEvent");
         }
         $datePicker = $datePicker->showMonth();
     }
 }
 /**
  * Returns the calendar boxes
  *      
  * @param  integer $boxes  Number of boxes
  * @param  year    $year   Year
  * @param  integer $month  month
  * @param  integer $day    day
  * @param  integer $catid  category id
  * 
  * @return string  calendar boxes
  */
 function getBoxes($boxes, $year, $month = 0, $day = 0, $catid = 0)
 {
     global $_ARRAYLANG, $objInit;
     if ($catid != 0 && !empty($catid)) {
         $url_cat = "&catid={$catid}";
     } else {
         $url_cat = "";
     }
     $url = htmlentities($this->calendarBoxUrl, ENT_QUOTES, CONTREXX_CHARSET) . $url_cat;
     $firstblock = true;
     $month = intval($month);
     $year = intval($year);
     $day = intval($day);
     $monthnames = explode(",", $_ARRAYLANG['TXT_CALENDAR_MONTH_ARRAY']);
     $daynames = explode(',', $_ARRAYLANG['TXT_CALENDAR_DAY_ARRAY']);
     $calenderBoxes = '';
     for ($i = 0; $i < $boxes; $i++) {
         $cal = new \activeCalendar($year, $month, $day);
         $cal->setMonthNames($monthnames);
         $cal->setDayNames($daynames);
         if ($firstblock) {
             $cal->enableMonthNav($url);
         } else {
             // This is necessary for the modification of the linkname
             // The modification makes a link on the monthname
             $cal->urlNav = $url;
         }
         // for seperate variable for the month links
         if (!empty($this->calendarBoxMonthNavUrl)) {
             $cal->urlMonthNav = htmlentities($this->calendarBoxMonthNavUrl, ENT_QUOTES, CONTREXX_CHARSET);
         }
         //load events
         foreach ($this->eventList as $objEvent) {
             if ($objEvent->access && $objInit->mode == 'frontend' && !\Permission::checkAccess(116, 'static', true)) {
                 continue;
             }
             $startdate = $objEvent->startDate;
             $enddate = $objEvent->endDate;
             $eventYear = date("Y", $startdate);
             $eventMonth = date("m", $startdate);
             $eventDay = date("d", $startdate);
             $eventEndDay = date("d", $enddate);
             $eventEndMonth = date("m", $enddate);
             // do only something when the event is in the current month
             if ($eventMonth <= $month && $eventEndMonth >= $month) {
                 // if the event is longer than one day but every day is in the same month
                 if ($eventEndDay > $eventDay && $eventMonth == $eventEndMonth) {
                     $curday = $eventDay;
                     while ($curday <= $eventEndDay) {
                         $eventurl = $url . "&amp;yearID={$eventYear}&amp;monthID={$month}&amp;dayID={$curday}" . $url_cat;
                         $cal->setEvent("{$eventYear}", "{$eventMonth}", "{$curday}", false, $eventurl);
                         $curday++;
                     }
                 } elseif ($eventEndMonth > $eventMonth) {
                     if ($eventMonth == $month) {
                         // Show the part of the event in the starting month
                         $curday = $eventDay;
                         while ($curday <= 31) {
                             $eventurl = $url . "&amp;yearID={$eventYear}&amp;monthID={$month}&amp;dayID={$curday}" . $url_cat;
                             $cal->setEvent("{$eventYear}", "{$eventMonth}", "{$curday}", false, $eventurl);
                             $curday++;
                         }
                     } elseif ($eventEndMonth == $month) {
                         // show the part of the event in the ending month
                         $curday = $eventEndDay;
                         while ($curday > 0) {
                             $eventurl = $url . "&amp;yearID={$eventYear}&amp;monthID={$month}&amp;dayID={$curday}" . $url_cat;
                             $cal->setEvent("{$eventYear}", "{$eventEndMonth}", "{$curday}", false, $eventurl);
                             $curday--;
                         }
                     } elseif ($eventMonth < $month && $eventEndMonth > $month) {
                         foreach (range(0, 31, 1) as $curday) {
                             $eventurl = $url . "&amp;yearID={$eventYear}&amp;monthID={$month}&amp;dayID={$curday}" . $url_cat;
                             $cal->setEvent("{$eventYear}", "{$month}", "{$curday}", false, $eventurl);
                         }
                     }
                 } else {
                     $eventurl = $url . "&amp;yearID={$eventYear}&amp;monthID={$month}&amp;dayID={$eventDay}" . $url_cat;
                     $cal->setEvent("{$eventYear}", "{$eventMonth}", "{$eventDay}", false, $eventurl);
                 }
             }
         }
         $calenderBoxes .= $cal->showMonth(false, true);
         if ($month == 12) {
             $year++;
             $month = 1;
         } else {
             $month++;
         }
         $day = 0;
         $firstblock = false;
     }
     return $calenderBoxes;
 }
Exemple #4
0
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head><title>Active Calendar Class Year View with Events Example</title>
<link rel="stylesheet" type="text/css" href="activecalendar1.css" />
</head>
<body>
<center>
<?php 
$monthName = array("1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12");
// The months will not have a name, just a number
$dayName = array("So", "Mo", "Di", "Mi", "Do", "Fr", "Sa");
// The days will be in german language
$cal->monthYearDivider = " / ";
// this creates a different divider between month and year in the month`s title
$cal->setMonthNames($monthName);
$cal->setDayNames($dayName);
$cal->enableYearNav($myurl);
// this enables the year's navigation controls
$cal->enableDatePicker(2003, 2008);
// this enables the date picker (year range 2003 - 2008)
$cal->enableDayLinks($myurl);
// this enables the day links
$cal->setEvent(2005, 5, 7);
// this sets an event on 7 May 2004
$cal->setEvent(2005, 12, 20);
// this sets an event on 20 December 2004
if (!$yearID) {
    $yearID = date("Y");
}
// make sure there is an $yearID (for the following functions)