/** * 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(); }
$yearID = false; // GET variable for the year (set in Active Calendar Class), init false to display current year $monthID = false; // GET variable for the month (set in Active Calendar Class), init false to display current month $dayID = false; // GET variable for the day (set in Active Calendar Class), init false to display current day extract($_GET); $cal = new activeCalendar($yearID, $monthID, $dayID); echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; ?> <!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 Month View Example</title> <link rel="stylesheet" type="text/css" href="activecalendar.css" /> </head> <body> <center> <?php $cal->enableMonthNav(); // this enables the month's navigation controls $cal->enableDatePicker(2002, 2006, $myurl); // this enables the date picker controls $cal->enableDayLinks($myurl); // this enables the day links echo $cal->showMonth(); // this displays the month's view ?> </center> </body> </html>
/** * 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 . "&yearID={$eventYear}&monthID={$month}&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 . "&yearID={$eventYear}&monthID={$month}&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 . "&yearID={$eventYear}&monthID={$month}&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 . "&yearID={$eventYear}&monthID={$month}&dayID={$curday}" . $url_cat; $cal->setEvent("{$eventYear}", "{$month}", "{$curday}", false, $eventurl); } } } else { $eventurl = $url . "&yearID={$eventYear}&monthID={$month}&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; }
} if ($showcal == 1) { $out = "<a href=\"" . $suiteurl . "\">Check another function</a>"; $out .= "<table><tr><td bgcolor=\"#ffff99\" class=\"code\">"; $out .= "Function <b>showMonth()</b> generates the following calendar:"; $out .= "</td></tr></table><br />"; $out .= $cal->showMonth(); $out .= "<br /><a href=\"http://validator.w3.org/check?uri=referer\" target=\"_blank\">Validate this XHTML <span class=\"small\">(results in a new window)</span></a>"; echo $out; } if ($showcal == 2 || !$showcal && $yearID && $monthID && !$dayID) { $out = "<a href=\"" . $suiteurl . "\">Check another function</a>"; $out .= "<table><tr><td bgcolor=\"#ffff99\" class=\"code\">"; $out .= "Functions <b>enableMonthNav()</b>, <b>enableDatePicker(2000,2010)</b> and <b>showMonth()</b> generate the following calendar(s):"; $out .= "</td></tr></table><br />"; $cal->enableMonthNav($suiteurl); $cal->enableDatePicker(2000, 2010); $out .= $cal->showMonth(); $out .= "<br /><a href=\"http://validator.w3.org/check?uri=referer\" target=\"_blank\">Validate this XHTML <span class=\"small\">(results in a new window)</span></a>"; echo $out; } if ($showcal == 3 || !$showcal && $yearID && $monthID && $dayID) { $out = "<a href=\"" . $suiteurl . "\">Check another function</a>"; $out .= "<table><tr><td bgcolor=\"#ffff99\" class=\"code\">"; $out .= "Functions <b>enableDayLinks()</b> and <b>showMonth()</b> generate the following calendar:"; $out .= "</td></tr></table><br />"; $cal->enableDayLinks($suiteurl); $out .= $cal->showMonth(); $out .= "<br /><a href=\"http://validator.w3.org/check?uri=referer\" target=\"_blank\">Validate this XHTML <span class=\"small\">(results in a new window)</span></a>"; echo $out; }
/** * 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(); } }
$cal->setEvent($mysqlYear, $mysqlMonth, $mysqlDay, $eventID); // set the event, if you want the whole day to be an event $cal->setEventContent($mysqlYear, $mysqlMonth, $mysqlDay, $mysqlContent, $mysqlLink); // set the event content and link } echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; ?> <!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 with MySQL Events</title> <link rel="stylesheet" type="text/css" href="<?php print @$_GET['css']; ?> " /> </head> <body> <center> <?php $cal->enableDatePicker(2002, 2010); // this enables the month's datepicker (year range 2002 - 2010) $cal->enableMonthNav($myurl); // this enables the month's navigation controls echo $cal->showMonth(); // this displays the month's view ?> <br /> <a href="../examples.php">Back to examples.php</a> </center> </body> </html>
$arrowBack = "<img src=\"img/back.png\" border=\"0\" alt=\"<<\" />"; // use png arrow back $arrowForw = "<img src=\"img/forward.png\" border=\"0\" alt=\">>\" />"; // use png arrow forward $cal = new activeCalendar($yearID, $monthID, $dayID); if (@$_GET['calmode'] == "start") { $cal->enableDayLinks(false, "getStartDate"); } elseif (@$_GET['calmode'] == "end") { $cal->enableDayLinks(false, "getEndDate"); } elseif (@$_GET['calmode'] == "eu") { $cal->enableDayLinks(false, "getEUDate"); } elseif (@$_GET['calmode'] == "us") { $cal->enableDayLinks(false, "getUSDate"); } // enables day links with javascript function getUSDate $cal->enableMonthNav($myurl, $arrowBack, $arrowForw); // enables navigation controls $cal->setFirstWeekDay(1); // '0' -> Sunday , '1' -> Monday ?> <?php print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; ?> <!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 :: Example</title> <link rel="stylesheet" type="text/css" href="<?php print @$_GET['css']; ?> " />