class constructor, does the initial date calculation $GMTDiff: GMT Zone for current day calculation, do not set to use local server time ******************************************************************************** */ public function __construct($year=false,$month=false,$day=false,$GMTDiff="none") { $this->timetoday=time(); $this->selectedday=-2; $this->selectedyear=$year; $this->selectedmonth=$month; if (!$month) $month=1; if (!$day) $day=1; else $this->selectedday=$day; $h=$this->mkActiveGMDate("H"); $m=$this->mkActiveGMDate("i"); $s=$this->mkActiveGMDate("s"); $d=$this->mkActiveGMDate("j"); $mo=$this->mkActiveGMDate("n"); $y=$this->mkActiveGMDate("Y"); $is_dst=$this->mkActiveDate("I"); if ($GMTDiff!="none") $this->timetoday=$this->mkActiveTime($h,$m,$s,$mo,$d,$y)+(3600*($GMTDiff+$is_dst)); $this->unixtime=$this->mkActiveTime($h,$m,$s,$month,$day,$year); if ($this->unixtime==-1 || !$year) $this->unixtime=$this->timetoday; $this->daytoday=$this->mkActiveDate("j"); $this->monthtoday=$this->mkActiveDate("n"); $this->yeartoday=$this->mkActiveDate("Y"); if (!$day) $this->actday=$this->daytoday; else $this->actday=$this->mkActiveDate("j",$this->unixtime); if (!$month) $this->actmonth=$this->monthtoday; else $this->actmonth=$this->mkActiveDate("n",$this->unixtime); if (!$year) $this->actyear=$this->yeartoday; else $this->actyear=$this->mkActiveDate("Y",$this->unixtime); $this->has31days=checkdate($this->actmonth,31,$this->actyear); $this->isSchalt=checkdate(2,29,$this->actyear); if ($this->isSchalt==1 && $this->actmonth==2) $this->maxdays=29; elseif ($this->isSchalt!=1 && $this->actmonth==2) $this->maxdays=28; elseif ($this->has31days==1) $this->maxdays=31; else $this->maxdays=30; $this->firstday=$this->mkActiveDate("w", $this->mkActiveTime(0,0,1,$this->actmonth,1,$this->actyear)); $this->GMTDiff=$GMTDiff; /* ******************************************************************************** You can change below the default year's and month's view navigation controls ******************************************************************************** */ if (version_compare(JVERSION, '5.0.0', '>=')) { // Joomla 5 $this->yearNavBack=" "; // Previous year $this->yearNavForw=" "; // Next year $this->monthNavBack=" "; // Previous month $this->monthNavForw=" "; // Next month } elseif (version_compare(JVERSION, '4.0.0', '>=')) { // Joomla 4 $this->yearNavBack=" << "; // Previous year, this could be an image link $this->yearNavForw=" >> "; // Next year, this could be an image link $this->monthNavBack=" << "; // Previous month, this could be an image link $this->monthNavForw=" >> "; // Next month, this could be an image link } $this->selBtn="Go"; // value of the date picker button (if enabled) $this->monthYearDivider=" "; // the divider between month and year in the month`s title } /* ******************************************************************************** PUBLIC enableYearNav() -> enables the year's navigation controls ******************************************************************************** */ function enableYearNav($link=false,$arrowBack=false,$arrowForw=false) { if ($link) $this->urlNav=$link; if ($arrowBack) $this->yearNavBack=$arrowBack; if ($arrowForw) $this->yearNavForw=$arrowForw; $this->yearNav=true; } /* ******************************************************************************** PUBLIC enableMonthNav() -> enables the month's navigation controls ******************************************************************************** */ function enableMonthNav($link=false,$arrowBack=false,$arrowForw=false) { if ($link) $this->urlNav=$link; if ($arrowBack) $this->monthNavBack=$arrowBack; if ($arrowForw) $this->monthNavForw=$arrowForw; $this->monthNav=true; } /* ******************************************************************************** PUBLIC enableDayLinks() -> enables the day links param javaScript: sets a Javascript function on each day link ******************************************************************************** */ function enableDayLinks($link=false,$javaScript=false) { if ($link) $this->url=$link; if ($javaScript) $this->javaScriptDay=$javaScript; $this->dayLinks=true; } /* ******************************************************************************** PUBLIC enableNewEventLinks() -> enables links on each day to create new events param link: full html template with token "{date}" to get day's date ******************************************************************************** */ function enableNewEventLinks($link) { if ($link && (stripos($link, '{date}') !== false)) { $this->htmlNewEventLink = $link; $this->dayNewEventLinks = true; } else { $this->dayNewEventLinks = false; } return $this->dayNewEventLinks; } /* ******************************************************************************** PUBLIC enableDatePicker() -> enables the day picker control ******************************************************************************** */ function enableDatePicker($startYear=false,$endYear=false,$link=false,$button=false) { if ($link) $this->urlPicker=$link; if ($startYear && $endYear) { if ($startYear>=$this->startYear && $startYear<$this->endYear) $this->startYear=$startYear; if ($endYear>$this->startYear && $endYear<=$this->endYear) $this->endYear=$endYear; } if ($button) $this->selBtn=$button; $this->datePicker=true; } /* ******************************************************************************** PUBLIC enableWeekNum() -> enables a week number column ******************************************************************************** */ function enableWeekNum($title="",$link=false,$javaScript=false) { // checking before enabling, as week number calulation works only if php version > 4.1.0 [php function: date ("W")] if (is_integer($this->getWeekNum($this->actday))) { $this->weekNum=true; $this->weekNumTitle=$title; $this->monthSpan++; if (empty($link)) { $this->weekUrl=''; } else { $this->weekUrl=$link; } if (empty($javaScript)) { $this->javaScriptWeek=''; } else { $this->javaScriptWeek=$javaScript; } } } /* ******************************************************************************** PUBLIC setEvent() -> sets a calendar event, $id: the HTML class (css layout) ******************************************************************************** */ function setEvent($year,$month,$day,$id=false,$url=false) { $eventTime=$this->mkActiveTime(0,0,1,$month,$day,$year); if (!$id) $id=$this->cssEvent; $this->calEvents[$eventTime]=$id; $this->calEventsUrl[$eventTime]=$url; } /* ******************************************************************************** PUBLIC setEventContent() -> sets a calendar event content, $content: can be a string or an array, $id: the HTML class (css layout) ******************************************************************************** */ /** * set event content * * @param int $year * @param int $month * @param int $day * @param string or array $content * @param string $url * @param string $id the HTML class */ function setEventContent($year, $month, $day, $content, $url=false, $id=false) { // event time $eventTime = $this->mkActiveTime(0, 0, 1, $month, $day, $year); // add to eventcontent array $eventContent[$eventTime] = $content; $this->calEventContent[] = $eventContent; // add specific id if (!$id) $id = $this->cssEventContent; $this->calEventContentId[] = $id; // add url if ($url) $this->calEventContentUrl[] = $url; else $this->calEventContentUrl[] = $this->calInit++; } /* ******************************************************************************** PUBLIC setMonthNames() -> sets the month names, $namesArray must be an array of 12 months starting with January ******************************************************************************** */ function setMonthNames($namesArray) { if (!is_array($namesArray) || count($namesArray)!=12) return false; else $this->monthNames=$namesArray; } /* ******************************************************************************** PUBLIC setDayNames() -> sets the week day names, $namesArray must be an array of 7 days starting with Sunday ******************************************************************************** */ function setDayNames($namesArray) { if (!is_array($namesArray) || count($namesArray)!=7) return false; else $this->dayNames=$namesArray; } /* ******************************************************************************** PUBLIC setFirstWeekDay() -> sets the first day of the week, currently only Sunday and Monday supported, $daynum=0 -> Sunday ******************************************************************************** */ function setFirstWeekDay($daynum) { if ($daynum==0) $this->startOnSun=true; else $this->startOnSun=false; } /* ******************************************************************************** PUBLIC showYear() -> returns the year's view as html table string Each private method returns a tr tag of the table as a string. You can change the calendar structure by simply calling these private methods in another order ******************************************************************************** */ function showYear($rowCount=false,$startMonth=false) { if ($rowCount) $this->rowCount=$rowCount; $this->monthNav=false; // disables month navigation in yearview $out=$this->mkYearHead(); // this should remain first: opens table tag $out.=$this->mkYearTitle(); // tr tag: year title and navigation $out.=$this->mkDatePicker("yearonly"); // tr tag: year date picker (only year selection) $this->datePicker=false; // disables month date picker in yearview $out.=$this->mkYearBody($startMonth); // tr tag(s): year month (html tables) $out.=$this->mkYearFoot(); // this should remain last: closes table tag return $out; } /* ******************************************************************************** PUBLIC showMonth() -> returns the month's view as html table string Each private method returns a tr tag of the table as a string. You can change the calendar structure by simply calling these private methods in another order $showNoMonthDays = false: days, that do not belong to the current month, will not be displayed $showNoMonthDays = true: days, that do not belong to the current month, will be displayed (note: these 'noMonthDays' will not contain any events or eventcontents!) ******************************************************************************** */ function showMonth($showNoMonthDays=false) { $this->showNoMonthDays=$showNoMonthDays; $out=$this->mkMonthHead(); // this should remain first: opens table tag $out.=$this->mkMonthTitle(); // tr tag: month title and navigation $out.=$this->mkDatePicker(); // tr tag: month date picker (month and year selection) $out.=$this->mkWeekDays(); // tr tag: the weekday names if ($this->showNoMonthDays==false) $out.=$this->mkMonthBody(); // tr tags: the days of the month else $out.=$this->mkMonthBody(1); // tr tags: the days of the month $out.=$this->mkMonthFoot(); // this should remain last: closes table tag return $out; } /* ---------------------- @START PRIVATE METHODS ---------------------- */ /* ******************************************************************************** THE FOLLOWING METHODS AND VARIABLES ARE PRIVATE. PLEASE DO NOT CALL OR MODIFY THEM ******************************************************************************** */ var $version="1.2.0"; var $releaseDate="23 Feb 2006"; var $monthSpan=7; var $timezone=false; var $yearNav=false; var $monthNav=false; var $dayLinks=false; var $dayNewEventLinks=false; var $datePicker=false; var $url=false; var $urlNav=false; var $urlPicker=false; var $htmlNewEventLink=false; var $calEvents=false; var $calEventsUrl=false; var $eventUrl=false; var $javaScriptDay=false; var $monthNames=false; var $dayNames=false; var $calEventContent=[]; var $calEventContentUrl=[]; var $calEventContentId=[]; var $calInit=0; var $weekNum=false; var $WeekUrl=false; var $javaScriptWeek=false; /* ******************************************************************************** PRIVATE mkYearHead() -> creates the year table tag ******************************************************************************** */ function mkYearHead() { return "cssYearTable."\">\n"; } /* ******************************************************************************** PRIVATE mkYearTitle() -> creates the tile and navigation tr tag of the year table ******************************************************************************** */ function mkYearTitle() { if ($this->rowCount<1 || $this->rowCount>12) $this->rowCount=4; if (!$this->yearNav) { $out="\n"; } else { $out="\n"; } return $out; } /* ******************************************************************************** PRIVATE mkYearBody() -> creates the tr tags of the year table ******************************************************************************** */ function mkYearBody($stmonth=false) { if (!$stmonth || $stmonth>12) $stmonth=1; $TrMaker = $this->rowCount; $curyear = $this->actyear; $out="\n"; for ($x=1; $x<=12; $x++) { $this->activeCalendar($curyear,$stmonth,false,$this->GMTDiff); $out.="\n"; if ($x == $TrMaker && $x < 12) { $out.=""; $TrMaker = ($TrMaker+$this->rowCount); } if ($stmonth == 12) { $stmonth = 1; $curyear++; } else $stmonth++; } $out.="\n"; return $out; } /* ******************************************************************************** PRIVATE mkYearFoot() -> closes the year table tag ******************************************************************************** */ function mkYearFoot() { return "
rowCount."\" class=\"".$this->cssYearTitle."\">"; $out.=$this->actyear; $out.="
rowCount."\" align=\"center\">"; $out.=""; $out.=""; $out.="
cssYearNav."\">"; $out.=$this->mkUrl($this->actyear-1); $out.=$this->yearNavBack."cssYearTitle."\">".$this->actyear."cssYearNav."\">"; $out.=$this->mkUrl($this->actyear+1); $out.=$this->yearNavForw."
\n".$this->showMonth()."
\n"; } /* ******************************************************************************** PRIVATE mkMonthHead() -> creates the month table tag ******************************************************************************** */ function mkMonthHead() { return "cssMonthTable."\">\n"; } /* ******************************************************************************** PRIVATE mkMonthTitle() -> creates the tile and navigation tr tag of the month table ******************************************************************************** */ function mkMonthTitle() { if (!$this->monthNav) { $out="\n"; } else { $out = ""; $out .= ""; $out .= "\n"; } return $out; } /* ******************************************************************************** PRIVATE mkDatePicker() -> creates the tr tag for the date picker ******************************************************************************** */ function mkDatePicker($yearpicker=false) { if ($this->datePicker && !empty($this->urlPicker)) { if ($yearpicker) $pickerSpan=$this->rowCount; else $pickerSpan=$this->monthSpan; $out="\n"; } else $out=""; return $out; } /* ******************************************************************************** PRIVATE mkWeekDays() -> creates the tr tag of the month table for the weekdays ******************************************************************************** */ function mkWeekDays() { if ($this->startOnSun) { $out=''; if ($this->weekNum) $out.=""; for ($x=0;$x<=6;$x++) $out.=""; $out.="\n"; } else { $out=''; if ($this->weekNum) $out.=""; for ($x=1;$x<=6;$x++) $out.=""; $out.=""; $out.="\n"; $this->firstday=$this->firstday-1; if ($this->firstday<0) $this->firstday=6; } return $out; } /* ******************************************************************************** PRIVATE mkMonthBody() -> creates the tr tags of the month table ******************************************************************************** */ function mkMonthBody($showNoMonthDays=0) { if ($this->actmonth==1) { $pMonth=12; $pYear=$this->actyear-1; } else{ $pMonth=$this->actmonth-1; $pYear=$this->actyear; } $out=''; $cor=0; if ($this->startOnSun) { $cor=1; } if ($this->weekNum) { $out.=""; } $monthday=0; $nmonthday=1; for ($x=0; $x<=6; $x++) { if ($x>=$this->firstday) { $monthday++; $out.=$this->mkDay($monthday); } else { if ($showNoMonthDays==0) { $out.=""; } else { $out.=""; } } } $out.="\n"; $goon=$monthday+1; $stop=0; for ($x=0; $x<=6; $x++) { if ($goon>$this->maxdays) { break; } if ($stop==1) { break; } $out.=''; if ($this->weekNum) $out.=""; for ($i=$goon; $i<=$goon+6; $i++) { if ($i>$this->maxdays) { if ($showNoMonthDays==0) { $out.=""; } else { $out.=''; } $stop=1; } else { $out.=$this->mkDay($i); } } $goon=$goon+7; $out.="\n"; } $this->selectedday="-2"; return $out; } /* ******************************************************************************** PRIVATE mkDay() -> creates each td tag of the month body ******************************************************************************** */ function mkDay($var) { $eventContent = $this->mkEventContent($var); $linktext = $var; if ($this->dayLinks) { if ($eventContent) { if ($this->javaScriptDay) { $linktext="javaScriptDay."(".$this->actyear.",".$this->actmonth.",".$var.")\">".$var.""; } elseif (!empty($this->url)) { $dayurl= Route::_($this->url.(strpos($this->url,"?") === false ? '?' : '&').'id='.sprintf('%04d%02d%02d',$this->actyear,$this->actmonth,$var)); $linktext="".$var.""; } } } $htmlNewEventLink = ''; if ($this->dayNewEventLinks) { $htmlNewEventLink = preg_replace('/{date}/', sprintf('%04d-%02d-%02d', $this->actyear, $this->actmonth, $var), $this->htmlNewEventLink); } if ($this->isEvent($var)) { if ($this->eventUrl) { $out=""; $this->eventUrl=false; } else { $out=""; } } else { /* allow styling of multiple things like "today is Sunday" */ $cssClass = array($this->cssMonthDay); if (($var == $this->selectedday) && ($this->actmonth == $this->selectedmonth) && ($this->actyear == $this->selectedyear)) { $cssClass[] = $this->cssSelecDay; } if (($var == $this->daytoday) && ($this->actmonth == $this->monthtoday) && ($this->actyear == $this->yeartoday)) { $cssClass[] = $this->cssToday; } if (($this->getWeekday($var) == 0) && $this->crSunClass) { $cssClass[] = $this->cssSunday; } if (($this->getWeekday($var) == 6) && $this->crSatClass) { $cssClass[] = $this->cssSaturday; } $out = ""; } return $out; } /* ******************************************************************************** PRIVATE mkMonthFoot() -> closes the month table ******************************************************************************** */ function mkMonthFoot() { return "
cssMonthTitle."\" colspan=\"".$this->monthSpan."\">"; $out.=$this->getMonthName().$this->monthYearDivider.$this->actyear; $out.="
cssMonthNav."\" colspan=\"2\" style=\"text-align:right;\">"; if ($this->actmonth==1) { // january $out.=$this->mkUrl($this->actyear-1,"12"); } else { $out.=$this->mkUrl($this->actyear,$this->actmonth-1); } $out .= $this->monthNavBack."cssMonthTitle."\" colspan=\"".($this->monthSpan-4)."\">"; $out .= $this->getMonthName().$this->monthYearDivider.$this->actyear."cssMonthNav."\" colspan=\"2\" style=\"text-align:left;\">"; if ($this->actmonth==12) { //december $out.=$this->mkUrl($this->actyear+1,"1"); } else { $out.=$this->mkUrl($this->actyear,$this->actmonth+1); } $out.=$this->monthNavForw."
cssPicker."\" colspan=\"".$pickerSpan."\">\n"; $out.="
cssPickerForm."\" class=\"".$this->cssPickerForm."\" action=\"".$this->urlPicker."\" method=\"get\">\n"; if (!$yearpicker) { $out.="\n"; } $out.="\n"; $out.="selBtn."\" class=\"".$this->cssPickerButton."\">\n"; $out.="
\n"; $out.="
cssWeekNumTitle."\">".$this->weekNumTitle."cssWeekDay."\">".$this->getDayName($x)."
cssWeekNumTitle."\">".$this->weekNumTitle."cssWeekDay."\">".$this->getDayName($x)."cssWeekDay."\">".$this->getDayName(0)."
cssWeekNum."\">".$this->mkWeekNum(1+$cor)."cssNoMonthDay."\">cssNoMonthDay."\">".($this->getMonthDays($pMonth,$pYear)-($this->firstday-1)+$x)."
cssWeekNum."\">".$this->mkWeekNum($goon+$cor)."cssNoMonthDay."\">
'.$nmonthday++.'
eventID."\">
".$htmlNewEventLink."eventUrl."\">".$var."
".$eventContent."
eventID."\">
".$htmlNewEventLink.$linktext.'
'.$eventContent."
getMonthName()."\" jem-dayname=\"".$this->getDayName($this->getWeekday($var))."\">".$htmlNewEventLink.$linktext.'
'.$eventContent."
\n"; } /* ******************************************************************************** PRIVATE mkUrl() -> creates the day and navigation link structure ******************************************************************************** */ function mkUrl($year, $month=false, $day=false) { if (strpos($this->url,"?") === false) { $glue="?"; } else { $glue="&"; } if (strpos($this->urlNav,"?") === false) { $glueNav="?"; } else { $glueNav="&"; } $yearNavLink = empty($this->urlNav) ? '' : "urlNav.$glueNav.$this->yearID."=".$year)."\" rel=\"noindex, nofollow\">"; $monthNavLink = empty($this->urlNav) ? '' : "urlNav.$glueNav.$this->yearID."=".$year."&".$this->monthID."=".$month)."\" rel=\"noindex, nofollow\">"; $dayLink = empty($this->url) ? $day : "url.$glue.$this->yearID."=".$year."&".$this->monthID."=".$month."&".$this->dayID."=".$day)."\">".$day.""; if ($year && $month && $day) return $dayLink; if ($year && !$month && !$day) return $yearNavLink; if ($year && $month && !$day) return $monthNavLink; } /* ******************************************************************************** PRIVATE mkEventContent() -> creates the table for the event content ******************************************************************************** */ /* see below function mkEventContent_old($var) { $hasContent=$this->hasEventContent($var); $out=""; if ($hasContent) { for ($x=0;$x $eventContentData) { foreach($eventContentData as $eventContentUrl => $eventContent) { $out.=""; if (is_string($eventContent)) { if (is_int($eventContentUrl)) { $out.="
".$eventContent."
"; } else { $out.="".$eventContent.""; } } else if (is_array($eventContent)) { foreach($eventContent as $arrayContent) { if (is_int($eventContentUrl)) { $out.="".$arrayContent.""; } else { $out.="".$arrayContent.""; } } $out.=""; } else $out=""; } } } } return $out; } */ /** * creates the div for the event content * * @param int $var the day * @return string */ function mkEventContent($var) { $hasContent=$this->hasEventContent($var); $out=""; if ($hasContent) { $n = is_array($hasContent) ? count($hasContent) : 0; for ($x = 0; $x < $n; $x++) { foreach ($hasContent[$x] as $eventContentid => $eventContentData) { foreach ($eventContentData as $eventContentUrl => $eventContent) { if (is_string($eventContent)) { $eventContent = array($eventContent); } foreach($eventContent as $arrayContent) { $out .= '
'; if (is_int($eventContentUrl)) { $out.= $arrayContent; } else { $out.=''.$arrayContent.''; } $out.='
'; } } } } } return $out; } /* ******************************************************************************** PRIVATE mkWeekNum() -> returns the week number and optionally creates a link ******************************************************************************** */ function mkWeekNum($var) { $year=$this->actyear; $week=$this->getWeekNum($var); if ($week>50 && $this->actmonth==1) $year=$this->actyear-1; $out=""; if ($this->weekUrl) { if (strpos($this->weekUrl,"?") === false) $glue="?"; else $glue="&"; $out.="weekUrl.$glue.$this->yearID."=".$year."&".$this->weekID."=".$week."\">".$week.""; } elseif ($this->javaScriptWeek) $out.="javaScriptWeek."(".$year.",".$week.")\">".$week.""; else $out.=$week; return $out; } /* ******************************************************************************** PRIVATE getMonthName() -> returns the month's name, according to the configuration ******************************************************************************** */ function getMonthName($var=false) { if (!$var) $var=@$this->actmonth; if ($this->monthNames) return $this->monthNames[$var-1]; switch($var) { case 1: return Text::_($this->jan); case 2: return Text::_($this->feb); case 3: return Text::_($this->mar); case 4: return Text::_($this->apr); case 5: return Text::_($this->may); case 6: return Text::_($this->jun); case 7: return Text::_($this->jul); case 8: return Text::_($this->aug); case 9: return Text::_($this->sep); case 10: return Text::_($this->oct); case 11: return Text::_($this->nov); case 12: return Text::_($this->dec); } } /* ******************************************************************************** PRIVATE getDayName() -> returns the day's name, according to the configuration ******************************************************************************** */ function getDayName($var=false) { if ($this->dayNames) return $this->dayNames[$var]; switch($var) { case 0: return Text::_($this->sun); case 1: return Text::_($this->mon); case 2: return Text::_($this->tue); case 3: return Text::_($this->wed); case 4: return Text::_($this->thu); case 5: return Text::_($this->fri); case 6: return Text::_($this->sat); } } /* ******************************************************************************** PRIVATE getMonthDays() -> returns the number of days of the month specified ******************************************************************************** */ function getMonthDays($month,$year) { $has31days=checkdate($month,31,$year); $isSchalt=checkdate(2,29,$year); if ($isSchalt==1 && $month==2) $maxdays=29; elseif ($isSchalt!=1 && $month==2) $maxdays=28; elseif ($has31days==1) $maxdays=31; else $maxdays=30; return $maxdays; } /* ******************************************************************************** PRIVATE getWeekday() -> returns the weekday's number, 0 = Sunday ... 6 = Saturday ******************************************************************************** */ function getWeekday($var) { return $this->mkActiveDate("w", $this->mkActiveTime(0,0,1,$this->actmonth,$var,$this->actyear)); } /* ******************************************************************************** PRIVATE getWeekNum() -> returns the week number, php version > 4.1.0, unsupported by the ADOdb Date Library ******************************************************************************** */ function getWeekNum($var) { return date("W", $this->mkActiveTime(0,0,1,$this->actmonth,$var,$this->actyear))+0; } /* ******************************************************************************** PRIVATE isEvent() -> checks if a date was set as an event and creates the eventID (css layout) and eventUrl ******************************************************************************** */ function isEvent($var) { if ($this->calEvents) { $checkTime=$this->mkActiveTime(0,0,1,$this->actmonth,$var,$this->actyear); $selectedTime=$this->mkActiveTime(0,0,1,$this->selectedmonth,$this->selectedday,$this->selectedyear); $todayTime=$this->mkActiveTime(0,0,1,$this->monthtoday,$this->daytoday,$this->yeartoday); foreach($this->calEvents as $eventTime => $eventID) { if ($eventTime==$checkTime) { if ($eventTime==$selectedTime) $this->eventID=$this->cssPrefixSelecEvent.$eventID; elseif ($eventTime==$todayTime) $this->eventID=$this->cssPrefixTodayEvent.$eventID; else $this->eventID=$eventID; if ($this->calEventsUrl[$eventTime]) $this->eventUrl=$this->calEventsUrl[$eventTime]; return true; } } return false; } } /* ******************************************************************************** PRIVATE hasEventContent() -> checks if an event content was set ******************************************************************************** */ /** * checks if an event content was set for the day * * @param int $var day of the month * @return array */ function hasEventContent($var) { $hasContent = []; if ($this->calEventContent) { $checkTime = $this->mkActiveTime(0, 0, 1, $this->actmonth, $var, $this->actyear); $n = is_array($this->calEventContent) ? count($this->calEventContent) : 0; for ($x = 0; $x < $n; $x++) { $eventContent = $this->calEventContent[$x]; $eventContentUrl = $this->calEventContentUrl[$x]; $eventContentId = $this->calEventContentId[$x]; foreach ($eventContent as $eventTime => $eventContent) { if ($eventTime == $checkTime) $hasContent[][$eventContentId][$eventContentUrl] = $eventContent; } } } return $hasContent; } /* ******************************************************************************** PRIVATE mkActiveDate() -> checks if ADOdb Date Library is loaded and calls the date function ******************************************************************************** */ function mkActiveDate($param,$acttime=false) { if (!$acttime) $acttime=$this->timetoday; if (function_exists("adodb_date")) return adodb_date($param,$acttime); else return date($param,$acttime); } /* ******************************************************************************** PRIVATE mkActiveGMDate() -> checks if ADOdb Date Library is loaded and calls the gmdate function ******************************************************************************** */ function mkActiveGMDate($param,$acttime=false) { if (!$acttime) $acttime=time(); if (function_exists("adodb_gmdate")) return adodb_gmdate($param,$acttime); else return gmdate($param,$acttime); } /* ******************************************************************************** PRIVATE mkActiveTime() -> checks if ADOdb Date Library is loaded and calls the mktime function ******************************************************************************** */ /** * checks if ADOdb Date Library is loaded and calls the mktime function * * @param int $hr * @param int $min * @param int $sec * @param int $month [optional] * @param int $day [optional] * @param int $year [optional] * @return int */ function mkActiveTime($hr,$min,$sec,$month=false,$day=false,$year=false) { if (function_exists("adodb_mktime")) return adodb_mktime($hr,$min,$sec,$month,$day,$year); else return mktime($hr,$min,$sec,$month,$day,$year); } } ?>